mirror of
https://github.com/aap/librw.git
synced 2025-12-19 17:09:51 +00:00
fixed sky mipmap stream write; experimented with software pipeline
This commit is contained in:
@@ -859,6 +859,9 @@ Device renderdevice = {
|
||||
gl3::showRaster,
|
||||
gl3::setRenderState,
|
||||
gl3::getRenderState,
|
||||
gl3::im2DRenderLine,
|
||||
gl3::im2DRenderTriangle,
|
||||
gl3::im2DRenderPrimitive,
|
||||
gl3::im2DRenderIndexedPrimitive,
|
||||
gl3::im3DTransform,
|
||||
gl3::im3DRenderIndexed,
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifdef RW_OPENGL
|
||||
#include <GL/glew.h>
|
||||
#include "rwgl3.h"
|
||||
#include "rwgl3impl.h"
|
||||
#include "rwgl3shader.h"
|
||||
|
||||
namespace rw {
|
||||
@@ -73,6 +74,53 @@ closeIm2D(void)
|
||||
im2dShader = nil;
|
||||
}
|
||||
|
||||
static Im2DVertex tmpprimbuf[3];
|
||||
|
||||
void
|
||||
im2DRenderLine(void *vertices, int32 numVertices, int32 vert1, int32 vert2)
|
||||
{
|
||||
Im2DVertex *verts = (Im2DVertex*)vertices;
|
||||
tmpprimbuf[0] = verts[vert1];
|
||||
tmpprimbuf[1] = verts[vert2];
|
||||
im2DRenderPrimitive(PRIMTYPELINELIST, tmpprimbuf, 2);
|
||||
}
|
||||
|
||||
void
|
||||
im2DRenderTriangle(void *vertices, int32 numVertices, int32 vert1, int32 vert2, int32 vert3)
|
||||
{
|
||||
Im2DVertex *verts = (Im2DVertex*)vertices;
|
||||
tmpprimbuf[0] = verts[vert1];
|
||||
tmpprimbuf[1] = verts[vert2];
|
||||
tmpprimbuf[2] = verts[vert3];
|
||||
im2DRenderPrimitive(PRIMTYPETRILIST, tmpprimbuf, 3);
|
||||
}
|
||||
|
||||
void
|
||||
im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||
{
|
||||
GLfloat xform[4];
|
||||
Camera *cam;
|
||||
cam = (Camera*)engine->currentCamera;
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im2DVertex),
|
||||
vertices, GL_DYNAMIC_DRAW);
|
||||
|
||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||
xform[2] = -1.0f;
|
||||
xform[3] = 1.0f;
|
||||
|
||||
im2dShader->use();
|
||||
setAttribPointers(im2dattribDesc, 3);
|
||||
|
||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||
|
||||
flushCache();
|
||||
glDrawArrays(primTypeMap[primType], 0, numVertices);
|
||||
disableAttribPointers(im2dattribDesc, 3);
|
||||
}
|
||||
|
||||
void
|
||||
im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
void *vertices, int32 numVertices,
|
||||
|
||||
@@ -96,9 +96,15 @@ struct Im3DVertex
|
||||
void setZ(float32 z) { this->position.z = z; }
|
||||
void setColor(uint8 r, uint8 g, uint8 b, uint8 a) {
|
||||
this->r = r; this->g = g; this->b = b; this->a = a; }
|
||||
RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); }
|
||||
void setU(float32 u) { this->u = u; }
|
||||
void setV(float32 v) { this->v = v; }
|
||||
|
||||
float getX(void) { return this->position.x; }
|
||||
float getY(void) { return this->position.y; }
|
||||
float getZ(void) { return this->position.z; }
|
||||
RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); }
|
||||
float getU(void) { return this->u; }
|
||||
float getV(void) { return this->v; }
|
||||
};
|
||||
|
||||
struct Im2DVertex
|
||||
@@ -116,6 +122,14 @@ struct Im2DVertex
|
||||
this->r = r; this->g = g; this->b = b; this->a = a; }
|
||||
void setU(float32 u, float recipz) { this->u = u; }
|
||||
void setV(float32 v, float recipz) { this->v = v; }
|
||||
|
||||
float getScreenX(void) { return this->x; }
|
||||
float getScreenY(void) { return this->y; }
|
||||
float getScreenZ(void) { return this->z; }
|
||||
float getCameraZ(void) { return this->w; }
|
||||
RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); }
|
||||
float getU(void) { return this->u; }
|
||||
float getV(void) { return this->v; }
|
||||
};
|
||||
|
||||
void setAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
|
||||
|
||||
@@ -6,6 +6,12 @@ namespace gl3 {
|
||||
extern uint32 im2DVbo, im2DIbo;
|
||||
void openIm2D(void);
|
||||
void closeIm2D(void);
|
||||
void im2DRenderLine(void *vertices, int32 numVertices,
|
||||
int32 vert1, int32 vert2);
|
||||
void im2DRenderTriangle(void *vertices, int32 numVertices,
|
||||
int32 vert1, int32 vert2, int32 vert3);
|
||||
void im2DRenderPrimitive(PrimitiveType primType,
|
||||
void *vertices, int32 numVertices);
|
||||
void im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
void *vertices, int32 numVertices, void *indices, int32 numIndices);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user