root/trunk/RBRapier/RBRapier/Renderer/Appearance/PolygonRasterization.py

Revision 702, 5.1 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 RBRapier.Renderer.AttributeMgr import AttributeChangeElement
27 from OpenGL import GL
28
29 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 #~ Definitions
31 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33 class FaceCulling(object):
34     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35     #~ Constants / Variables / Etc.
36     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38     AttributeChange = AttributeChangeElement(GL.GL_POLYGON_BIT)
39     FrontFace = GL.GL_CCW
40     CullFace = GL.GL_BACK
41
42     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43     #~ Public Methods
44     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45
46     def __init__(self, FrontFace=None, CullFace=None):
47         if FrontFace is not None: self.FrontFace = FrontFace
48         if CullFace is not None: self.CullFace = CullFace
49
50     def GLSelect(self, context):
51         GL.glFrontFace(self.FrontFace)
52         GL.glCullFace(self.CullFace)
53         context.StateMgr.Enable(GL.GL_CULL_FACE)
54
55     def GLDeselect(self, context):
56         context.StateMgr.Disable(GL.GL_CULL_FACE)
57
58 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
60 class PolygonDrawStyle(object):
61     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62     #~ Constants / Variables / Etc.
63     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
65     AttributeChange = AttributeChangeElement(GL.GL_POLYGON_BIT)
66     FrontStyle = GL.GL_FILL
67     BackStyle = GL.GL_FILL
68
69     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70     #~ Public Methods
71     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
73     def __init__(self, FrontStyle=GL.GL_FILL, BackStyle=GL.GL_FILL):
74         self.FrontStyle = FrontStyle
75         self.BackStyle = BackStyle
76
77     def GLSelect(self, context):
78         FrontStyle = self.FrontStyle
79         BackStyle = self.BackStyle
80         if FrontStyle == BackStyle:
81             GL.glPolygonMode(GL.GL_FRONT_AND_BACK, FrontStyle)
82         else:
83             GL.glPolygonMode(GL.GL_FRONT, FrontStyle)
84             GL.glPolygonMode(GL.GL_BACK, BackStyle)
85
86     def GLDeselect(self, context):
87         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
88    
89 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90
91 class PolygonOffset(object):
92     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93     #~ Constants / Variables / Etc.
94     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95
96     AttributeChange = AttributeChangeElement(GL.GL_POLYGON_BIT)
97     Mode = GL.GL_POLYGON_OFFSET_FILL
98     Factor = 1.0
99     Units = 1.0
100
101     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102     #~ Public Methods
103     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
105     def GLSelect(self, context):
106         context.StateMgr.Enable(self.Mode)
107         GL.glPolygonOffset(self.Factor, self.Units)
108
109     def Delect(self, context):
110         context.StateMgr.Disable(self.Mode)
111
112 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113
114 class PolygonStipple(object):
115     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116     #~ Constants / Variables / Etc.
117     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118
119     AttributeChange = AttributeChangeElement(GL.GL_POLYGON_STIPPLE_BIT)
120     Stipple = "\xff"*32*32 # 32x32x8 bitmask
121
122     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123     #~ Public Methods
124     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125
126     def GLSelect(self, context):
127         context.StateMgr.Enable(GL.GL_POLYGON_STIPPLE)
128         GL.glPolygonStipple(self.Stipple)
129
130     def GLDeselect(self, context):
131         context.StateMgr.Disable(GL.GL_POLYGON_STIPPLE)
132
133 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134
135 class PolygonSmooth(object):
136     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137     #~ Constants / Variables / Etc.
138     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
140     AttributeChange = AttributeChangeElement(GL.GL_POLYGON_BIT | GL.GL_HINT_BIT)
141     SmoothHint = GL.GL_DONT_CARE
142
143     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144     #~ Public Methods
145     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146
147     def GLSelect(self, context):
148         context.StateMgr.Enable(GL.GL_POLYGON_SMOOTH)
149         GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, self.SmoothHint)
150
151     def GLDeselect(self, context):
152         context.StateMgr.Disable(GL.GL_POLYGON_SMOOTH)
153
Note: See TracBrowser for help on using the browser.