Add W buffering
FossilOrigin-Name: ef98223fea88b74ac03f3288f0852d68a0154fed9fe88800b88d7b264812d97b
This commit is contained in:
parent
95fd0d1a5d
commit
f9c6e34b1e
3 changed files with 15 additions and 12 deletions
|
@ -171,10 +171,13 @@ grGlideShutdownCdecl(void)
|
|||
#endif
|
||||
|
||||
if (!grSstWinOpen(hWnd, sizeToScreenResolution(resolution),
|
||||
floatToScreenRefresh(refreshRate), GR_COLORFORMAT_RGBA,
|
||||
floatToScreenRefresh(refreshRate), GR_COLORFORMAT_ARGB,
|
||||
GR_ORIGIN_LOWER_LEFT, 2, 1))
|
||||
@throw [OFInitializationFailedException
|
||||
exceptionWithClass: self.class];
|
||||
|
||||
grDepthBufferMode(GR_DEPTHBUFFER_WBUFFER);
|
||||
grDepthMask(FXTRUE);
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
|
@ -196,7 +199,7 @@ grGlideShutdownCdecl(void)
|
|||
|
||||
- (void)beginFrame
|
||||
{
|
||||
grBufferClear(0, 0, 0);
|
||||
grBufferClear(0, 0, GR_WDEPTHVALUE_FARTHEST);
|
||||
}
|
||||
|
||||
- (void)drawPolygonWithVertices: (const O3DVertex *)vertices
|
||||
|
@ -216,10 +219,10 @@ grGlideShutdownCdecl(void)
|
|||
(vertices[i].position.x + 1) * halfWidth;
|
||||
glideVertices[i].y =
|
||||
(vertices[i].position.y + 1) * halfHeight;
|
||||
glideVertices[i].oow = 1.f / vertices[i].position.z;
|
||||
glideVertices[i].r = vertices[i].color.r * 255;
|
||||
glideVertices[i].g = vertices[i].color.g * 255;
|
||||
glideVertices[i].b = vertices[i].color.b * 255;
|
||||
glideVertices[i].a = vertices[i].color.a * 255;
|
||||
}
|
||||
|
||||
grDrawPolygonVertexList((int)count, glideVertices);
|
||||
|
|
|
@ -19,10 +19,10 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
|
||||
typedef struct OF_BOXABLE {
|
||||
struct {
|
||||
float x, y;
|
||||
float x, y, z;
|
||||
} position;
|
||||
struct {
|
||||
float r, g, b, a;
|
||||
float r, g, b;
|
||||
} color;
|
||||
} O3DVertex;
|
||||
|
||||
|
|
|
@ -32,21 +32,21 @@ OF_APPLICATION_DELEGATE(TestsAppDelegate)
|
|||
options: nil] autorelease];
|
||||
|
||||
const O3DVertex outerTriangle[] = {
|
||||
{{ -1, -1 }, { 1, 0, 0 }},
|
||||
{{ 0, 1 }, { 0, 1, 0 }},
|
||||
{{ 1, -1 }, { 0, 0, 1 }}
|
||||
{{ -1, -1, 1 }, { 1, 0, 0 }},
|
||||
{{ 0, 1, 1 }, { 0, 1, 0 }},
|
||||
{{ 1, -1, 1 }, { 0, 0, 1 }}
|
||||
};
|
||||
const O3DVertex innerTriangle[] = {
|
||||
{{ -0.5, 0.5 }, { 1, 1, 0 }},
|
||||
{{ 0, -0.5 }, { 0, 1, 1 }},
|
||||
{{ 0.5, 0.5 }, { 1, 0, 1 }}
|
||||
{{ -0.5, 0.5, 0 }, { 1, 1, 0 }},
|
||||
{{ 0, -0.5, 0 }, { 0, 1, 1 }},
|
||||
{{ 0.5, 0.5, 0 }, { 1, 0, 1 }}
|
||||
};
|
||||
|
||||
OFDate *startDate = [OFDate date];
|
||||
while (-startDate.timeIntervalSinceNow < 5) {
|
||||
[renderer beginFrame];
|
||||
[renderer drawPolygonWithVertices: outerTriangle count: 3];
|
||||
[renderer drawPolygonWithVertices: innerTriangle count: 3];
|
||||
[renderer drawPolygonWithVertices: outerTriangle count: 3];
|
||||
[renderer endFrame];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue