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
|
#endif
|
||||||
|
|
||||||
if (!grSstWinOpen(hWnd, sizeToScreenResolution(resolution),
|
if (!grSstWinOpen(hWnd, sizeToScreenResolution(resolution),
|
||||||
floatToScreenRefresh(refreshRate), GR_COLORFORMAT_RGBA,
|
floatToScreenRefresh(refreshRate), GR_COLORFORMAT_ARGB,
|
||||||
GR_ORIGIN_LOWER_LEFT, 2, 1))
|
GR_ORIGIN_LOWER_LEFT, 2, 1))
|
||||||
@throw [OFInitializationFailedException
|
@throw [OFInitializationFailedException
|
||||||
exceptionWithClass: self.class];
|
exceptionWithClass: self.class];
|
||||||
|
|
||||||
|
grDepthBufferMode(GR_DEPTHBUFFER_WBUFFER);
|
||||||
|
grDepthMask(FXTRUE);
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
|
@ -196,7 +199,7 @@ grGlideShutdownCdecl(void)
|
||||||
|
|
||||||
- (void)beginFrame
|
- (void)beginFrame
|
||||||
{
|
{
|
||||||
grBufferClear(0, 0, 0);
|
grBufferClear(0, 0, GR_WDEPTHVALUE_FARTHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawPolygonWithVertices: (const O3DVertex *)vertices
|
- (void)drawPolygonWithVertices: (const O3DVertex *)vertices
|
||||||
|
@ -216,10 +219,10 @@ grGlideShutdownCdecl(void)
|
||||||
(vertices[i].position.x + 1) * halfWidth;
|
(vertices[i].position.x + 1) * halfWidth;
|
||||||
glideVertices[i].y =
|
glideVertices[i].y =
|
||||||
(vertices[i].position.y + 1) * halfHeight;
|
(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].r = vertices[i].color.r * 255;
|
||||||
glideVertices[i].g = vertices[i].color.g * 255;
|
glideVertices[i].g = vertices[i].color.g * 255;
|
||||||
glideVertices[i].b = vertices[i].color.b * 255;
|
glideVertices[i].b = vertices[i].color.b * 255;
|
||||||
glideVertices[i].a = vertices[i].color.a * 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grDrawPolygonVertexList((int)count, glideVertices);
|
grDrawPolygonVertexList((int)count, glideVertices);
|
||||||
|
|
|
@ -19,10 +19,10 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef struct OF_BOXABLE {
|
typedef struct OF_BOXABLE {
|
||||||
struct {
|
struct {
|
||||||
float x, y;
|
float x, y, z;
|
||||||
} position;
|
} position;
|
||||||
struct {
|
struct {
|
||||||
float r, g, b, a;
|
float r, g, b;
|
||||||
} color;
|
} color;
|
||||||
} O3DVertex;
|
} O3DVertex;
|
||||||
|
|
||||||
|
|
|
@ -32,21 +32,21 @@ OF_APPLICATION_DELEGATE(TestsAppDelegate)
|
||||||
options: nil] autorelease];
|
options: nil] autorelease];
|
||||||
|
|
||||||
const O3DVertex outerTriangle[] = {
|
const O3DVertex outerTriangle[] = {
|
||||||
{{ -1, -1 }, { 1, 0, 0 }},
|
{{ -1, -1, 1 }, { 1, 0, 0 }},
|
||||||
{{ 0, 1 }, { 0, 1, 0 }},
|
{{ 0, 1, 1 }, { 0, 1, 0 }},
|
||||||
{{ 1, -1 }, { 0, 0, 1 }}
|
{{ 1, -1, 1 }, { 0, 0, 1 }}
|
||||||
};
|
};
|
||||||
const O3DVertex innerTriangle[] = {
|
const O3DVertex innerTriangle[] = {
|
||||||
{{ -0.5, 0.5 }, { 1, 1, 0 }},
|
{{ -0.5, 0.5, 0 }, { 1, 1, 0 }},
|
||||||
{{ 0, -0.5 }, { 0, 1, 1 }},
|
{{ 0, -0.5, 0 }, { 0, 1, 1 }},
|
||||||
{{ 0.5, 0.5 }, { 1, 0, 1 }}
|
{{ 0.5, 0.5, 0 }, { 1, 0, 1 }}
|
||||||
};
|
};
|
||||||
|
|
||||||
OFDate *startDate = [OFDate date];
|
OFDate *startDate = [OFDate date];
|
||||||
while (-startDate.timeIntervalSinceNow < 5) {
|
while (-startDate.timeIntervalSinceNow < 5) {
|
||||||
[renderer beginFrame];
|
[renderer beginFrame];
|
||||||
[renderer drawPolygonWithVertices: outerTriangle count: 3];
|
|
||||||
[renderer drawPolygonWithVertices: innerTriangle count: 3];
|
[renderer drawPolygonWithVertices: innerTriangle count: 3];
|
||||||
|
[renderer drawPolygonWithVertices: outerTriangle count: 3];
|
||||||
[renderer endFrame];
|
[renderer endFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue