DXGL r229 - Code Review
For
DXGL
(
recent comments
|
status changes
|
tags
|
authors
|
states
|
release notes
|
statistics
)
Jump to navigation
Jump to search
Repository:
DXGL
Revision:
<
r228
|
r229
|
r230
>
Date:
00:35, 6 August 2012
Author:
admin
Status:
new
Tags:
Comment:
Eliminate redundant clear state changes.
Modified paths:
/ddraw/glRenderer.cpp
(modified) (
history
)
/ddraw/glutil.cpp
(modified) (
history
)
/ddraw/glutil.h
(modified) (
history
)
Diff
[
purge
]
Index: ddraw/glRenderer.cpp
—
—
@@ -808,7 +808,9 @@
809
809
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl_caps.TextureMax);
810
810
CompileShaders();
811
811
InitFBO();
812
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
812
+ ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
813
+ ClearDepth(1.0);
814
+ ClearStencil(0);
813
815
glClear(GL_COLOR_BUFFER_BIT);
814
816
glFlush();
815
817
SetScissor(false,0,0,0,0);
—
—
@@ -1236,17 +1238,17 @@
1237
1239
if(D3DCLEAR_TARGET)
1238
1240
{
1239
1241
clearbits |= GL_COLOR_BUFFER_BIT;
1240
- glClearColor(color[0],color[1],color[2],color[3]);
1242
+ ClearColor(color[0],color[1],color[2],color[3]);
1241
1243
}
1242
1244
if(D3DCLEAR_ZBUFFER)
1243
1245
{
1244
1246
clearbits |= GL_DEPTH_BUFFER_BIT;
1245
- glClearDepth(dvZ);
1247
+ ClearDepth(dvZ);
1246
1248
}
1247
1249
if(D3DCLEAR_STENCIL)
1248
1250
{
1249
1251
clearbits |= GL_STENCIL_BUFFER_BIT;
1250
- glClearStencil(dwStencil);
1252
+ ClearStencil(dwStencil);
1251
1253
}
1252
1254
if(dwCount)
1253
1255
{
Index: ddraw/glutil.cpp
—
—
@@ -45,6 +45,12 @@
46
46
bool stencil = false;
47
47
GLint texlevel = 0;
48
48
GLint texwrap[16];
49
+GLclampf clearr = 0.0;
50
+GLclampf clearg = 0.0;
51
+GLclampf clearb = 0.0;
52
+GLclampf cleara = 0.0;
53
+GLclampd cleardepth = 1.0;
54
+GLint clearstencil = 0;
49
55
50
56
void InitFBO()
51
57
{
—
—
@@ -291,4 +297,34 @@
292
298
depthfar = rangefar;
293
299
glDepthRange(rangenear,rangefar);
294
300
}
301
+}
302
+
303
+void ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a)
304
+{
305
+ if((clearr != r) || (clearg != g) || (clearb != b) || (cleara != a))
306
+ {
307
+ clearr = r;
308
+ clearg = g;
309
+ clearb = b;
310
+ cleara = a;
311
+ glClearColor(r,g,b,a);
312
+ }
313
+}
314
+
315
+void ClearDepth(GLclampd depth)
316
+{
317
+ if(cleardepth != depth)
318
+ {
319
+ cleardepth = depth;
320
+ glClearDepth(depth);
321
+ }
322
+}
323
+
324
+void ClearStencil(GLint stencil)
325
+{
326
+ if(clearstencil != stencil)
327
+ {
328
+ clearstencil = stencil;
329
+ glClearStencil(stencil);
330
+ }
295
331
}
\ No newline at end of file
Index: ddraw/glutil.h
—
—
@@ -38,5 +38,8 @@
39
39
void SetMaterial(GLfloat ambient[4],GLfloat diffuse[4],GLfloat specular[4],GLfloat emission[4],GLfloat shininess);
40
40
void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height);
41
41
void SetDepthRange(GLclampd rangenear, GLclampd rangefar);
42
+void ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a);
43
+void ClearDepth(GLclampd depth);
44
+void ClearStencil(GLint stencil);
42
45
43
46
#endif //_GLUTIL_H
\ No newline at end of file
Navigation menu
Personal tools
Log in
Namespaces
Special page
English
expanded
collapsed
Views
More
expanded
collapsed
Search
Navigation
Home
Main page
Recent changes
Random page
MediaWiki help
Introduction
Progress
Downloads
Source code
Build from source
AppDB
Bug reports
Forums
Tools
Special pages
Printable version