[gnome-games] Use standard GTK+ background behind chess board. Make 3D view use more of the available area
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Use standard GTK+ background behind chess board. Make 3D view use more of the available area
- Date: Mon, 26 Apr 2010 05:08:44 +0000 (UTC)
commit c858209f812a9502d7899fd2bf9ec59446c03932
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Apr 26 15:07:07 2010 +1000
Use standard GTK+ background behind chess board. Make 3D view use more of the available area
glchess/src/lib/display.py | 16 ++++++++--------
glchess/src/lib/gtkui/chessview.py | 8 ++++++--
glchess/src/lib/scene/cairo/__init__.py | 10 ++--------
glchess/src/lib/scene/opengl/opengl.py | 7 +++----
glchess/src/lib/ui/ui.py | 4 ++--
5 files changed, 21 insertions(+), 24 deletions(-)
---
diff --git a/glchess/src/lib/display.py b/glchess/src/lib/display.py
index 4db94f1..6bfede1 100644
--- a/glchess/src/lib/display.py
+++ b/glchess/src/lib/display.py
@@ -266,13 +266,13 @@ class Splashscreen(ui.ViewFeedback):
"""Called by ui.ViewFeedback"""
pass
- def renderGL(self):
+ def renderGL(self, background_colour = (0, 0, 0)):
"""Called by ui.ViewFeedback"""
- self.scene.render()
+ self.scene.render(background_colour)
- def renderCairoStatic(self, context):
+ def renderCairoStatic(self, context, background_color = (0, 0, 0)):
"""Called by ui.ViewFeedback"""
- return self.cairoScene.renderStatic(context)
+ return self.cairoScene.renderStatic(context, background_color)
def renderCairoDynamic(self, context):
"""Called by ui.ViewFeedback"""
@@ -470,15 +470,15 @@ class View(ui.ViewFeedback):
self.showSmooth(self.doSmooth)
self.updateRotation(animate = False)
- def renderGL(self):
+ def renderGL(self, background_colour = (0, 0, 0)):
"""Called by ui.ViewFeedback"""
self.updateScene(SceneOpenGL)
- self.scene.controller.render()
+ self.scene.controller.render(background_colour)
- def renderCairoStatic(self, context):
+ def renderCairoStatic(self, context, background_color = (0, 0, 0)):
"""Called by ui.ViewFeedback"""
self.updateScene(SceneCairo)
- return self.scene.controller.renderStatic(context)
+ return self.scene.controller.renderStatic(context, background_color)
def renderCairoDynamic(self, context):
"""Called by ui.ViewFeedback"""
diff --git a/glchess/src/lib/gtkui/chessview.py b/glchess/src/lib/gtkui/chessview.py
index 7768728..35efb56 100644
--- a/glchess/src/lib/gtkui/chessview.py
+++ b/glchess/src/lib/gtkui/chessview.py
@@ -156,6 +156,10 @@ class GtkViewArea(gtk.DrawingArea):
def __expose(self, widget, event):
"""Gtk+ signal"""
+ gc = self.style.bg_gc[self.state]
+ c = gc.get_colormap().query_color(gc.foreground.pixel)
+ color = (c.red_float, c.green_float, c.blue_float)
+
if self.renderGL:
try:
self.__startGL()
@@ -165,7 +169,7 @@ class GtkViewArea(gtk.DrawingArea):
# Get the scene rendered
try:
if self.view.feedback is not None:
- self.view.feedback.renderGL()
+ self.view.feedback.renderGL(color)
except OpenGL.GL.GLerror, e:
print 'Rendering Error: ' + str(e)
traceback.print_exc(file = sys.stdout)
@@ -184,7 +188,7 @@ class GtkViewArea(gtk.DrawingArea):
else:
context = self.pixmap.cairo_create()
if self.view.feedback is not None:
- self.view.feedback.renderCairoStatic(context)
+ self.view.feedback.renderCairoStatic(context, color)
# Copy the background to render the dynamic elements on top
self.dynamicPixmap.draw_drawable(widget.get_style().white_gc, self.pixmap, 0, 0, 0, 0, -1, -1)
diff --git a/glchess/src/lib/scene/cairo/__init__.py b/glchess/src/lib/scene/cairo/__init__.py
index a248f38..7e12c4d 100644
--- a/glchess/src/lib/scene/cairo/__init__.py
+++ b/glchess/src/lib/scene/cairo/__init__.py
@@ -27,7 +27,6 @@ def blend_colour(colour_a, colour_b, alpha):
b = a[2] * alpha + b[2] * (1 - alpha)
return (r, g, b)
-BACKGROUND_COLOUR = parse_colour('#0b782f') # Fallback only
BORDER_COLOUR = parse_colour('#2e3436')
NUMBERING_COLOUR = parse_colour('#888a85')
BLACK_SQUARE_COLOURS = {None: parse_colour('#babdb6'),
@@ -385,19 +384,14 @@ class Scene(glchess.scene.Scene):
context.rotate(self.angle);
- def renderStatic(self, context):
+ def renderStatic(self, context, background_color):
"""Render the static elements in a scene.
"""
if self.redrawStatic is False:
return False
self.redrawStatic = False
- # Clear background
- if self.background_pixmap:
- context.set_source_pixmap(self.background_pixmap, 0, 0)
- context.get_source().set_extend(cairo.EXTEND_REPEAT)
- else:
- context.set_source_rgb(*BACKGROUND_COLOUR)
+ context.set_source_rgb(*background_color)
context.paint()
# Rotate board
diff --git a/glchess/src/lib/scene/opengl/opengl.py b/glchess/src/lib/scene/opengl/opengl.py
index e488167..e78ca8f 100644
--- a/glchess/src/lib/scene/opengl/opengl.py
+++ b/glchess/src/lib/scene/opengl/opengl.py
@@ -49,7 +49,6 @@ BOARD_DIFFUSE = (0.8, 0.8, 0.8, 1.0)
BOARD_SPECULAR = (1.0, 1.0, 1.0, 1.0)
BOARD_SHININESS = 128.0
-BACKGROUND_COLOUR = parse_colour('#0b782f') # Fallback only
BORDER_COLOUR = parse_colour('#2e3436')
NUMBERING_COLOUR = parse_colour('#888a85')
BLACK_SQUARE_COLOURS = {None: parse_colour('#babdb6'),
@@ -325,12 +324,12 @@ class Scene(glchess.scene.Scene):
self.animating = False
return self.animating
- def render(self):
+ def render(self, background_colour):
"""Render the scene.
This requires an OpenGL context.
"""
- glClearColor(BACKGROUND_COLOUR[0], BACKGROUND_COLOUR[1], BACKGROUND_COLOUR[2], 1.0)
+ glClearColor(background_colour[0], background_colour[1], background_colour[2], 1.0)
if len(self.jitters) > 1:
glClear(GL_ACCUM_BUFFER_BIT)
@@ -613,7 +612,7 @@ class Scene(glchess.scene.Scene):
def transformCamera(self):
"""Perform the camera matrix transformation"""
- gluLookAt(0.0, 90.0, 45.0,
+ gluLookAt(0.0, 80.0, 40.0,
0.0, 0.0, 5.0,
0.0, 1.0, 0.0)
diff --git a/glchess/src/lib/ui/ui.py b/glchess/src/lib/ui/ui.py
index fe5d14e..260a4a2 100644
--- a/glchess/src/lib/ui/ui.py
+++ b/glchess/src/lib/ui/ui.py
@@ -142,11 +142,11 @@ class ViewFeedback:
"""
assert(False)
- def renderGL(self):
+ def renderGL(self, background_color = (0, 0, 0)):
"""Render the scene using OpenGL"""
assert(False)
- def renderCairoStatic(self, context):
+ def renderCairoStatic(self, context, background_color = (0, 0, 0)):
"""Render the static elements of the scene.
'context' is the cairo context to modify.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]