mirror of
https://github.com/aap/librw.git
synced 2025-12-20 01:19:51 +00:00
switched d3d im2d to use a VS so we can have fog
This commit is contained in:
@@ -112,12 +112,21 @@ im2DRenderTriangle(void *vertices, int32 numVertices, int32 vert1, int32 vert2,
|
||||
}
|
||||
|
||||
void
|
||||
im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||
im2DSetXform(void)
|
||||
{
|
||||
GLfloat xform[4];
|
||||
Camera *cam;
|
||||
cam = (Camera*)engine->currentCamera;
|
||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||
xform[2] = -1.0f;
|
||||
xform[3] = 1.0f;
|
||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||
}
|
||||
|
||||
void
|
||||
im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||
{
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(im2DVao);
|
||||
#endif
|
||||
@@ -126,11 +135,6 @@ im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im2DVertex), nil, GL_STREAM_DRAW);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, numVertices*sizeof(Im2DVertex), vertices);
|
||||
|
||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||
xform[2] = -1.0f;
|
||||
xform[3] = 1.0f;
|
||||
|
||||
if(im2dOverrideShader)
|
||||
im2dOverrideShader->use();
|
||||
else
|
||||
@@ -139,7 +143,7 @@ im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||
setAttribPointers(im2dattribDesc, 3);
|
||||
#endif
|
||||
|
||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||
im2DSetXform();
|
||||
|
||||
flushCache();
|
||||
glDrawArrays(primTypeMap[primType], 0, numVertices);
|
||||
@@ -153,10 +157,6 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
void *vertices, int32 numVertices,
|
||||
void *indices, int32 numIndices)
|
||||
{
|
||||
GLfloat xform[4];
|
||||
Camera *cam;
|
||||
cam = (Camera*)engine->currentCamera;
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(im2DVao);
|
||||
#endif
|
||||
@@ -169,11 +169,6 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im2DVertex), nil, GL_STREAM_DRAW);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, numVertices*sizeof(Im2DVertex), vertices);
|
||||
|
||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||
xform[2] = -1.0f;
|
||||
xform[3] = 1.0f;
|
||||
|
||||
if(im2dOverrideShader)
|
||||
im2dOverrideShader->use();
|
||||
else
|
||||
@@ -182,7 +177,7 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
setAttribPointers(im2dattribDesc, 3);
|
||||
#endif
|
||||
|
||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||
im2DSetXform();
|
||||
|
||||
flushCache();
|
||||
glDrawElements(primTypeMap[primType], numIndices,
|
||||
|
||||
@@ -131,7 +131,7 @@ struct Im2DVertex
|
||||
void setScreenY(float32 y) { this->y = y; }
|
||||
void setScreenZ(float32 z) { this->z = z; }
|
||||
// This is a bit unefficient but we have to counteract GL's divide, so multiply
|
||||
void setCameraZ(float32 z) { }
|
||||
void setCameraZ(float32 z) { this->w = z; }
|
||||
void setRecipCameraZ(float32 recipz) { this->w = 1.0f/recipz; }
|
||||
void setColor(uint8 r, uint8 g, uint8 b, uint8 a) {
|
||||
this->r = r; this->g = g; this->b = b; this->a = a; }
|
||||
|
||||
Reference in New Issue
Block a user