root/trunk/RBRapier/RBRapier/Renderer/Environment/Buffers.py

Revision 702, 5.6 kB (checked in by sholloway, 5 years ago)

Added GL prefix to Execute/Select/Deselect

Line 
1 #!/usr/bin/env python
2 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 ##~ License
4 ##~
5 ##- The RuneBlade Foundation library is intended to ease some
6 ##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)
7 ##- applications, while providing the flexibility to modularly change the
8 ##- architecture. Enjoy.
9 ##~
10 ##~ Copyright (C) 2002  TechGame Networks, LLC.
11 ##~
12 ##~ This library is free software; you can redistribute it and/or
13 ##~ modify it under the terms of the BSD style License as found in the
14 ##~ LICENSE file included with this distribution.
15 ##~
16 ##~ TechGame Networks, LLC can be reached at:
17 ##~ 3578 E. Hartsel Drive #211
18 ##~ Colorado Springs, Colorado, USA, 80920
19 ##~
20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 #~ Imports
24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
26 from OpenGL import GL
27 from RBRapier.Tools import Vector
28 from RBRapier.Renderer.AttributeMgr import AttributeChangeElement
29 from RBRapier.Renderer.BufferMgr import BufferChangeElement
30
31 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 #~ Definitions
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
35 class ClearColor(object):
36     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37     #~ Constants / Variables / Etc.
38     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39
40     AttributeChange = AttributeChangeElement(GL.GL_COLOR_BUFFER_BIT)
41     BufferClear = BufferChangeElement(GL.GL_COLOR_BUFFER_BIT)
42     Value = Vector.ColorVectorProperty('Value', (0., 0., 0., 1.))
43
44     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45     #~ Public
46     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47
48     def __init__(self, Color=None):
49         if Color is not None:
50             self.Value = Color
51
52     def GLExecute(self, context):
53         GL.glClearColor(*self.Value.tolist())
54
55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
57 class ColorMask(object):
58     Mask = Vector.Vector4Property('Mask ', (1., 1., 1., 1.))
59
60     def GLSelect(self, context):
61         GL.glColorMask(*self.Mask.tolist())
62
63     def GLDeselect(self, context):
64         GL.glColorMask(1,1,1,1)
65
66 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67
68 class ClearDepth(object):
69     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70     #~ Constants / Variables / Etc.
71     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
73     AttributeChange = AttributeChangeElement(GL.GL_DEPTH_BUFFER_BIT)
74     BufferClear = BufferChangeElement(GL.GL_DEPTH_BUFFER_BIT)
75     Value = 1.
76
77     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78     #~ Public
79     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
81     def __init__(self, Value=0.):
82         self.Value = Value
83
84     def GLExecute(self, context):
85         GL.glClearDepth(self.Value)
86
87 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88
89 class DepthMask(object):
90     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91     #~ Constants / Variables / Etc.
92     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
94     AttributeChange = AttributeChangeElement(GL.GL_DEPTH_BUFFER_BIT)
95     Mask = 1
96
97     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98     #~ Public Methods
99     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100
101     def GLSelect(self, context):
102         GL.glDepthMask(self.Mask)
103
104     def GLDeselect(self, context):
105         GL.glDepthMask(1)
106
107 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108
109 class ClearStencil(object):
110     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111     #~ Constants / Variables / Etc.
112     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113
114     AttributeChange = AttributeChangeElement(GL.GL_STENCIL_BUFFER_BIT)
115     BufferClear = BufferChangeElement(GL.GL_STENCIL_BUFFER_BIT)
116     Value = 0
117
118     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119     #~ Public
120     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121
122     def __init__(self, Value=0):
123         self.Value = Value
124
125     def GLExecute(self, context):
126         GL.glClearStencil(self.Value)
127
128 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129
130 class StencilMask(object):
131     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132     #~ Constants / Variables / Etc.
133     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134
135     AttributeChange = AttributeChangeElement(GL.GL_STENCIL_BUFFER_BIT)
136     Mask = -1
137
138     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139     #~ Public Methods
140     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141
142     def __init__(self, mask=-1):
143         self.Mask = mask
144
145     def GLSelect(self, context):
146         GL.glStencilMask(self.Mask)
147
148     def GLDeselect(self, context):
149         GL.glStencilMask(-1)
150
151 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152
153 class ClearAccum(object):
154     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155     #~ Constants / Variables / Etc.
156     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157
158     AttributeChange = AttributeChangeElement(GL.GL_ACCUM_BUFFER_BIT)
159     BufferClear = BufferChangeElement(GL.GL_ACCUM_BUFFER_BIT)
160
161     Value = Vector.ColorVectorProperty('Value', (0., 0., 0., 1.))
162
163     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164     #~ Public
165     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166
167     def __init__(self, Color=None):
168         if Color is not None:
169             self.Value = Color
170
171     def AccumBits():
172         bitflags = (GL.GL_ACCUM_RED_BITS, GL.GL_ACCUM_GREEN_BITS, GL.GL_ACCUM_BLUE_BITS, GL.GL_ACCUM_ALPHA_BITS)
173         return map(GL.glGetInteger, bitflags)
174     AccumBits = staticmethod(AccumBits)
175
176     def GLExecute(self, context):
177         GL.glClearAccum(*self.Value.tolist())
178
Note: See TracBrowser for help on using the browser.