gnome-games r7781 - trunk/glchess/src/lib/scene/opengl
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7781 - trunk/glchess/src/lib/scene/opengl
- Date: Sun, 20 Jul 2008 02:58:30 +0000 (UTC)
Author: rancell
Date: Sun Jul 20 02:58:30 2008
New Revision: 7781
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7781&view=rev
Log:
Simplified selection code
Modified:
trunk/glchess/src/lib/scene/opengl/opengl.py
Modified: trunk/glchess/src/lib/scene/opengl/opengl.py
==============================================================================
--- trunk/glchess/src/lib/scene/opengl/opengl.py (original)
+++ trunk/glchess/src/lib/scene/opengl/opengl.py Sun Jul 20 02:58:30 2008
@@ -359,7 +359,6 @@
glRenderMode(GL_SELECT)
glInitNames()
- glPushName(0)
# Create pixel picking region near cursor location
glMatrixMode(GL_PROJECTION)
@@ -382,14 +381,13 @@
try:
records = glRenderMode(GL_RENDER)
except GLerror:
- records = None
-
- # Get the first record and use this as the selected square
- coord = None
- if records is not None:
- for record in records:
- coord = record[2]
- break
+ coord = None
+ else:
+ # Get the first record and use this as the selected square
+ if len(records) > 0:
+ (_, _, coord) = records[0]
+ else:
+ coord = None
# Reset projection matrix
glMatrixMode(GL_PROJECTION)
@@ -812,10 +810,10 @@
def drawSquares(self):
"""Draw the board squares for picking"""
-
+
# draw the floor squares
for u in [0, 1, 2, 3, 4, 5, 6, 7]:
- glLoadName(u)
+ glPushName(u)
for v in [0, 1, 2, 3, 4, 5, 6, 7]:
glPushName(v)
@@ -834,6 +832,7 @@
glEnd()
glPopName()
+ glPopName()
def drawPieces(self):
"""Draw the pieces in the scene"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]