TINYGL: Cleanup function arguments

This commit is contained in:
Paweł Kołodziejski 2021-12-27 13:22:38 +01:00
parent 9accbf1c30
commit 6e6696271e
No known key found for this signature in database
GPG key ID: 0BDADC9E74440FF7
7 changed files with 176 additions and 172 deletions

View file

@ -29,7 +29,7 @@
// glVertex // glVertex
void tglVertex4f(float x, float y, float z, float w) { void tglVertex4f(TGLfloat x, TGLfloat y, TGLfloat z, TGLfloat w) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
@ -42,21 +42,21 @@ void tglVertex4f(float x, float y, float z, float w) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglVertex2f(float x, float y) { void tglVertex2f(TGLfloat x, TGLfloat y) {
tglVertex4f(x, y, 0, 1); tglVertex4f(x, y, 0, 1);
} }
void tglVertex3f(float x, float y, float z) { void tglVertex3f(TGLfloat x, TGLfloat y, TGLfloat z) {
tglVertex4f(x, y, z, 1); tglVertex4f(x, y, z, 1);
} }
void tglVertex3fv(const float *v) { void tglVertex3fv(const TGLfloat *v) {
tglVertex4f(v[0], v[1], v[2], 1); tglVertex4f(v[0], v[1], v[2], 1);
} }
// glNormal // glNormal
void tglNormal3f(float x, float y, float z) { void tglNormal3f(TGLfloat x, TGLfloat y, TGLfloat z) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[4]; TinyGL::GLParam p[4];
@ -68,13 +68,13 @@ void tglNormal3f(float x, float y, float z) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglNormal3fv(const float *v) { void tglNormal3fv(const TGLfloat *v) {
tglNormal3f(v[0], v[1], v[2]); tglNormal3f(v[0], v[1], v[2]);
} }
// glColor // glColor
void tglColor4f(float r, float g, float b, float a) { void tglColor4f(TGLfloat r, TGLfloat g, TGLfloat b, TGLfloat a) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[9]; TinyGL::GLParam p[9];
@ -86,29 +86,29 @@ void tglColor4f(float r, float g, float b, float a) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglColor4fv(const float *v) { void tglColor4fv(const TGLfloat *v) {
tglColor4f(v[0], v[1], v[2], v[3]); tglColor4f(v[0], v[1], v[2], v[3]);
} }
void tglColor3f(float x, float y, float z) { void tglColor3f(TGLfloat x, TGLfloat y, TGLfloat z) {
tglColor4f(x, y, z, 1); tglColor4f(x, y, z, 1);
} }
void tglColor3fv(const float *v) { void tglColor3fv(const TGLfloat *v) {
tglColor4f(v[0], v[1], v[2], 1); tglColor4f(v[0], v[1], v[2], 1);
} }
void tglColor3ub(unsigned char r, unsigned char g, unsigned char b) { void tglColor3ub(TGLubyte r, TGLubyte g, TGLubyte b) {
tglColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); tglColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
} }
void tglColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { void tglColor4ub(TGLubyte r, TGLubyte g, TGLubyte b, TGLubyte a) {
tglColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); tglColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
} }
// TexCoord // TexCoord
void tglTexCoord4f(float s, float t, float r, float q) { void tglTexCoord4f(TGLfloat s, TGLfloat t, TGLfloat r, TGLfloat q) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
@ -121,47 +121,47 @@ void tglTexCoord4f(float s, float t, float r, float q) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglTexCoord3f(float s, float t, float q) { void tglTexCoord3f(TGLfloat s, TGLfloat t, TGLfloat q) {
tglTexCoord4f(s, t, q, 1); tglTexCoord4f(s, t, q, 1);
} }
void tglTexCoord2f(float s, float t) { void tglTexCoord2f(TGLfloat s, TGLfloat t) {
tglTexCoord4f(s, t, 0, 1); tglTexCoord4f(s, t, 0, 1);
} }
void tglTexCoord1f(float s) { void tglTexCoord1f(TGLfloat s) {
tglTexCoord4f(s, 0, 0, 1); tglTexCoord4f(s, 0, 0, 1);
} }
void tglTexCoord4fv(const float *v) { void tglTexCoord4fv(const TGLfloat *v) {
tglTexCoord4f(v[0], v[1], v[2], v[3]); tglTexCoord4f(v[0], v[1], v[2], v[3]);
} }
void tglTexCoord3fv(const float *v) { void tglTexCoord3fv(const TGLfloat *v) {
tglTexCoord4f(v[0], v[1], v[2], 1); tglTexCoord4f(v[0], v[1], v[2], 1);
} }
void tglTexCoord2fv(const float *v) { void tglTexCoord2fv(const TGLfloat *v) {
tglTexCoord4f(v[0], v[1], 0, 1); tglTexCoord4f(v[0], v[1], 0, 1);
} }
void tglTexCoord1fv(const float *v) { void tglTexCoord1fv(const TGLfloat *v) {
tglTexCoord4f(v[0], 0, 0, 1); tglTexCoord4f(v[0], 0, 0, 1);
} }
// misc // misc
void tglEdgeFlag(int flag) { void tglEdgeFlag(TGLboolean flag) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
p[0].op = TinyGL::OP_EdgeFlag; p[0].op = TinyGL::OP_EdgeFlag;
p[1].i = flag; p[1].i = flag == TGL_TRUE ? 1 : 0;;
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglShadeModel(int mode) { void tglShadeModel(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -173,7 +173,7 @@ void tglShadeModel(int mode) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglCullFace(int mode) { void tglCullFace(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -185,7 +185,7 @@ void tglCullFace(int mode) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglFrontFace(int mode) { void tglFrontFace(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -204,19 +204,19 @@ void tglColorMask(TGLboolean r, TGLboolean g, TGLboolean b, TGLboolean a) {
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
p[0].op = TinyGL::OP_ColorMask; p[0].op = TinyGL::OP_ColorMask;
p[1].i = r; p[1].i = r == TGL_TRUE ? 1 : 0;
p[2].i = g; p[2].i = g == TGL_TRUE ? 1 : 0;
p[3].i = b; p[3].i = b == TGL_TRUE ? 1 : 0;
p[4].i = a; p[4].i = a == TGL_TRUE ? 1 : 0;;
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglDepthMask(int enableWrite) { void tglDepthMask(TGLboolean flag) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
p[0].op = TinyGL::OP_DepthMask; p[0].op = TinyGL::OP_DepthMask;
p[1].i = enableWrite; p[1].i = flag == TGL_TRUE ? 1 : 0;
c->gl_add_op(p); c->gl_add_op(p);
} }
@ -241,7 +241,7 @@ void tglBlendFunc(TGLenum sfactor, TGLenum dfactor) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglAlphaFunc(TGLenum func, float ref) { void tglAlphaFunc(TGLenum func, TGLclampf ref) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -283,7 +283,7 @@ void tglStencilOp(TGLenum sfail, TGLenum dpfail, TGLenum dppass) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglPolygonMode(int face, int mode) { void tglPolygonMode(TGLenum face, TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -299,7 +299,7 @@ void tglPolygonMode(int face, int mode) {
// glEnable, glDisable // glEnable, glDisable
void tglEnable(int cap) { void tglEnable(TGLenum cap) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -310,7 +310,7 @@ void tglEnable(int cap) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglDisable(int cap) { void tglDisable(TGLenum cap) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -323,7 +323,7 @@ void tglDisable(int cap) {
// glBegin, glEnd // glBegin, glEnd
void tglBegin(int mode) { void tglBegin(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -344,7 +344,7 @@ void tglEnd() {
// matrix // matrix
void tglMatrixMode(int mode) { void tglMatrixMode(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -354,7 +354,7 @@ void tglMatrixMode(int mode) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLoadMatrixf(const float *m) { void tglLoadMatrixf(const TGLfloat *m) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[17]; TinyGL::GLParam p[17];
@ -374,7 +374,7 @@ void tglLoadIdentity() {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglMultMatrixf(const float *m) { void tglMultMatrixf(const TGLfloat *m) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[17]; TinyGL::GLParam p[17];
@ -403,7 +403,7 @@ void tglPopMatrix() {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglRotatef(float angle, float x, float y, float z) { void tglRotatef(TGLfloat angle, TGLfloat x, TGLfloat y, TGLfloat z) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
@ -416,7 +416,7 @@ void tglRotatef(float angle, float x, float y, float z) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglTranslatef(float x, float y, float z) { void tglTranslatef(TGLfloat x, TGLfloat y, TGLfloat z) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[4]; TinyGL::GLParam p[4];
@ -428,7 +428,7 @@ void tglTranslatef(float x, float y, float z) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglScalef(float x, float y, float z) { void tglScalef(TGLfloat x, TGLfloat y, TGLfloat z) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[4]; TinyGL::GLParam p[4];
@ -440,7 +440,7 @@ void tglScalef(float x, float y, float z) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglViewport(int x, int y, int width, int height) { void tglViewport(TGLint x, TGLint y, TGLsizei width, TGLsizei height) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
@ -453,7 +453,7 @@ void tglViewport(int x, int y, int width, int height) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglFrustum(double left, double right, double bottom, double top, double nearv, double farv) { void tglFrustum(TGLdouble left, TGLdouble right, TGLdouble bottom, TGLdouble top, TGLdouble nearv, TGLdouble farv) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
@ -468,7 +468,7 @@ void tglFrustum(double left, double right, double bottom, double top, double nea
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglOrtho(double left, double right, double bottom, double top, double zNear, double zFar) { void tglOrtho(TGLdouble left, TGLdouble right, TGLdouble bottom, TGLdouble top, TGLdouble zNear, TGLdouble zFar) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
@ -485,7 +485,7 @@ void tglOrtho(double left, double right, double bottom, double top, double zNear
// lightening // lightening
void tglMaterialfv(int mode, int type, const float *v) { void tglMaterialfv(TGLenum mode, TGLenum type, const TGLfloat *v) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
int n; int n;
@ -506,7 +506,7 @@ void tglMaterialfv(int mode, int type, const float *v) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglMaterialf(int mode, int type, float v) { void tglMaterialf(TGLenum mode, TGLenum type, TGLfloat v) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
@ -520,7 +520,7 @@ void tglMaterialf(int mode, int type, float v) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglColorMaterial(int mode, int type) { void tglColorMaterial(TGLenum mode, TGLenum type) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -531,7 +531,7 @@ void tglColorMaterial(int mode, int type) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLightfv(int light, int type, const float *v) { void tglLightfv(TGLenum light, TGLenum type, const TGLfloat *v) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
@ -548,7 +548,7 @@ void tglLightfv(int light, int type, const float *v) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLightf(int light, int type, float v) { void tglLightf(TGLenum light, TGLenum type, TGLfloat v) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[7]; TinyGL::GLParam p[7];
@ -562,7 +562,7 @@ void tglLightf(int light, int type, float v) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLightModeli(int pname, int param) { void tglLightModeli(TGLenum pname, TGLint param) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[6]; TinyGL::GLParam p[6];
@ -575,7 +575,7 @@ void tglLightModeli(int pname, int param) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLightModelfv(int pname, const float *param) { void tglLightModelfv(TGLenum pname, const TGLfloat *param) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[6]; TinyGL::GLParam p[6];
@ -589,7 +589,7 @@ void tglLightModelfv(int pname, const float *param) {
// clear // clear
void tglClear(int mask) { void tglClear(TGLbitfield mask) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -599,7 +599,7 @@ void tglClear(int mask) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglClearColor(float r, float g, float b, float a) { void tglClearColor(TGLfloat r, TGLfloat g, TGLfloat b, TGLfloat a) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[5]; TinyGL::GLParam p[5];
@ -612,7 +612,7 @@ void tglClearColor(float r, float g, float b, float a) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglClearDepth(double depth) { void tglClearDepth(TGLdouble depth) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -634,25 +634,26 @@ void tglClearStencil(TGLint s) {
// textures // textures
void tglTexImage2D(int target, int level, int components, int width, int height, int border, int format, int type, void *pixels) { void tglTexImage2D(TGLenum target, TGLint level, TGLint internalformat, TGLsizei width,
TGLsizei height, TGLint border, TGLenum format, TGLenum type, const void *pixels) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[10]; TinyGL::GLParam p[10];
p[0].op = TinyGL::OP_TexImage2D; p[0].op = TinyGL::OP_TexImage2D;
p[1].i = target; p[1].i = target;
p[2].i = level; p[2].i = level;
p[3].i = components; p[3].i = internalformat;
p[4].i = width; p[4].i = width;
p[5].i = height; p[5].i = height;
p[6].i = border; p[6].i = border;
p[7].i = format; p[7].i = format;
p[8].i = type; p[8].i = type;
p[9].p = pixels; p[9].p = const_cast<void *>(pixels);
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglBindTexture(int target, int texture) { void tglBindTexture(TGLenum target, TGLuint texture) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -663,7 +664,7 @@ void tglBindTexture(int target, int texture) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglTexEnvi(int target, int pname, int param) { void tglTexEnvi(TGLenum target, TGLenum pname, TGLint param) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[8]; TinyGL::GLParam p[8];
@ -679,7 +680,7 @@ void tglTexEnvi(int target, int pname, int param) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglTexParameteri(int target, int pname, int param) { void tglTexParameteri(TGLenum target, TGLenum pname, TGLint param) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[8]; TinyGL::GLParam p[8];
@ -695,7 +696,7 @@ void tglTexParameteri(int target, int pname, int param) {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglPixelStorei(int pname, int param) { void tglPixelStorei(TGLenum pname, TGLint param) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -717,7 +718,7 @@ void tglInitNames() {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglPushName(uint name) { void tglPushName(TGLuint name) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -736,7 +737,7 @@ void tglPopName() {
c->gl_add_op(p); c->gl_add_op(p);
} }
void tglLoadName(uint name) { void tglLoadName(TGLuint name) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -759,7 +760,7 @@ void tglPolygonOffset(TGLfloat factor, TGLfloat units) {
// Special Functions // Special Functions
void tglCallList(uint list) { void tglCallList(TGLuint list) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2]; TinyGL::GLParam p[2];
@ -773,7 +774,7 @@ void tglFlush() {
// nothing to do // nothing to do
} }
void tglHint(int target, int mode) { void tglHint(TGLenum target, TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3]; TinyGL::GLParam p[3];
@ -786,7 +787,7 @@ void tglHint(int target, int mode) {
// Non standard functions // Non standard functions
void tglDebug(int mode) { void tglDebug(TGLenum mode) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
c->print_flag = mode; c->print_flag = mode;
} }

View file

@ -30,42 +30,42 @@
#include "graphics/tinygl/zgl.h" #include "graphics/tinygl/zgl.h"
void tglGetIntegerv(int pname, int *params) { void tglGetIntegerv(TGLenum pname, TGLint *data) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
switch (pname) { switch (pname) {
case TGL_VIEWPORT: case TGL_VIEWPORT:
params[0] = c->viewport.xmin; data[0] = c->viewport.xmin;
params[1] = c->viewport.ymin; data[1] = c->viewport.ymin;
params[2] = c->viewport.xsize; data[2] = c->viewport.xsize;
params[3] = c->viewport.ysize; data[3] = c->viewport.ysize;
break; break;
case TGL_MAX_MODELVIEW_STACK_DEPTH: case TGL_MAX_MODELVIEW_STACK_DEPTH:
*params = MAX_MODELVIEW_STACK_DEPTH; *data = MAX_MODELVIEW_STACK_DEPTH;
break; break;
case TGL_MAX_PROJECTION_STACK_DEPTH: case TGL_MAX_PROJECTION_STACK_DEPTH:
*params = MAX_PROJECTION_STACK_DEPTH; *data = MAX_PROJECTION_STACK_DEPTH;
break; break;
case TGL_MAX_LIGHTS: case TGL_MAX_LIGHTS:
*params = T_MAX_LIGHTS; *data = T_MAX_LIGHTS;
break; break;
case TGL_MAX_TEXTURE_SIZE: case TGL_MAX_TEXTURE_SIZE:
*params = c->_textureSize; *data = c->_textureSize;
break; break;
case TGL_MAX_TEXTURE_STACK_DEPTH: case TGL_MAX_TEXTURE_STACK_DEPTH:
*params = MAX_TEXTURE_STACK_DEPTH; *data = MAX_TEXTURE_STACK_DEPTH;
break; break;
case TGL_BLEND: case TGL_BLEND:
*params = c->blending_enabled; *data = c->blending_enabled;
break; break;
case TGL_ALPHA_TEST: case TGL_ALPHA_TEST:
*params = c->alpha_test_enabled; *data = c->alpha_test_enabled;
break; break;
case TGL_DEPTH_TEST: case TGL_DEPTH_TEST:
*params = c->depth_test_enabled; *data = c->depth_test_enabled;
break; break;
case TGL_STENCIL_TEST: case TGL_STENCIL_TEST:
*params = c->stencil_test_enabled; *data = c->stencil_test_enabled;
break; break;
default: default:
error("tglGet: option not implemented"); error("tglGet: option not implemented");
@ -73,9 +73,8 @@ void tglGetIntegerv(int pname, int *params) {
} }
} }
void tglGetFloatv(int pname, float *v) { void tglGetFloatv(TGLenum pname, TGLfloat *data) {
int i; int i, mnr = 0; // just a trick to return the correct matrix
int mnr = 0; // just a trick to return the correct matrix
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
switch (pname) { switch (pname) {
case TGL_TEXTURE_MATRIX: case TGL_TEXTURE_MATRIX:
@ -87,25 +86,25 @@ void tglGetFloatv(int pname, float *v) {
case TGL_MODELVIEW_MATRIX: { case TGL_MODELVIEW_MATRIX: {
float *p = &c->matrix_stack_ptr[mnr]->_m[0][0]; float *p = &c->matrix_stack_ptr[mnr]->_m[0][0];
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
*v++ = p[0]; *data++ = p[0];
*v++ = p[4]; *data++ = p[4];
*v++ = p[8]; *data++ = p[8];
*v++ = p[12]; *data++ = p[12];
p++; p++;
} }
} }
break; break;
case TGL_LINE_WIDTH: case TGL_LINE_WIDTH:
*v = 1.0f; *data = 1.0f;
break; break;
case TGL_LINE_WIDTH_RANGE: case TGL_LINE_WIDTH_RANGE:
v[0] = v[1] = 1.0f; data[0] = data[1] = 1.0f;
break; break;
case TGL_POINT_SIZE: case TGL_POINT_SIZE:
*v = 1.0f; *data = 1.0f;
break; break;
case TGL_POINT_SIZE_RANGE: case TGL_POINT_SIZE_RANGE:
v[0] = v[1] = 1.0f; data[0] = data[1] = 1.0f;
break; break;
default: default:
fprintf(stderr, "warning: unknown pname in glGetFloatv()\n"); fprintf(stderr, "warning: unknown pname in glGetFloatv()\n");

View file

@ -708,42 +708,45 @@ typedef unsigned int TGLuint; // 4-byte unsigned
typedef float TGLfloat; // single precision float typedef float TGLfloat; // single precision float
typedef double TGLdouble; // double precision float typedef double TGLdouble; // double precision float
typedef int TGLsizei; typedef int TGLsizei;
typedef unsigned int TGLbitfield;
typedef float TGLclampf;
typedef double TGLclampd;
// functions // functions
void tglEnable(int code); void tglEnable(TGLenum code);
void tglDisable(int code); void tglDisable(TGLenum code);
void tglShadeModel(int mode); void tglShadeModel(TGLenum mode);
void tglCullFace(int mode); void tglCullFace(TGLenum mode);
void tglPolygonMode(int face, int mode); void tglPolygonMode(TGLenum face, TGLenum mode);
void tglBegin(int type); void tglBegin(TGLenum type);
void tglEnd(); void tglEnd();
#define PROTO_GL1(name) \ #define PROTO_GL1(name) \
void tgl ## name ## 1f(float); \ void tgl ## name ## 1f(TGLfloat); \
void tgl ## name ## 1d(double); \ void tgl ## name ## 1d(TGLdouble); \
void tgl ## name ## 1fv(const float *); \ void tgl ## name ## 1fv(const TGLfloat *); \
void tgl ## name ## 1dv(const double *); void tgl ## name ## 1dv(const TGLdouble *);
#define PROTO_GL2(name) \ #define PROTO_GL2(name) \
void tgl ## name ## 2f(float, float); \ void tgl ## name ## 2f(TGLfloat, TGLfloat); \
void tgl ## name ## 2d(double, double); \ void tgl ## name ## 2d(TGLdouble, TGLdouble); \
void tgl ## name ## 2fv(const float *); \ void tgl ## name ## 2fv(const TGLfloat *); \
void tgl ## name ## 2dv(const double *); void tgl ## name ## 2dv(const TGLdouble *);
#define PROTO_GL3(name) \ #define PROTO_GL3(name) \
void tgl ## name ## 3f(float, float, float); \ void tgl ## name ## 3f(TGLfloat, TGLfloat, TGLfloat); \
void tgl ## name ## 3d(double, double, double); \ void tgl ## name ## 3d(TGLdouble, TGLdouble, TGLdouble); \
void tgl ## name ## 3fv(const float *); \ void tgl ## name ## 3fv(const TGLfloat *); \
void tgl ## name ## 3dv(const double *); void tgl ## name ## 3dv(const TGLdouble *);
#define PROTO_GL4(name) \ #define PROTO_GL4(name) \
void tgl ## name ## 4f(float, float, float, float); \ void tgl ## name ## 4f(TGLfloat, TGLfloat, TGLfloat, TGLfloat); \
void tgl ## name ## 4d(double, double, double, double); \ void tgl ## name ## 4d(TGLdouble, TGLdouble, TGLdouble, TGLdouble); \
void tgl ## name ## 4fv(const float *); \ void tgl ## name ## 4fv(const TGLfloat *); \
void tgl ## name ## 4dv(const double *); void tgl ## name ## 4dv(const TGLdouble *);
PROTO_GL2(Vertex) PROTO_GL2(Vertex)
PROTO_GL3(Vertex) PROTO_GL3(Vertex)
@ -751,9 +754,8 @@ PROTO_GL4(Vertex)
PROTO_GL3(Color) PROTO_GL3(Color)
PROTO_GL4(Color) PROTO_GL4(Color)
void tglColor3ub(unsigned char r, unsigned char g, unsigned char b); void tglColor3ub(TGLubyte r, TGLubyte g, TGLubyte b);
void tglColor4ub(unsigned char r, unsigned char g, unsigned char b, void tglColor4ub(TGLubyte r, TGLubyte g, TGLubyte b, TGLubyte a);
unsigned char a);
PROTO_GL3(Normal) PROTO_GL3(Normal)
@ -762,35 +764,36 @@ PROTO_GL2(TexCoord)
PROTO_GL3(TexCoord) PROTO_GL3(TexCoord)
PROTO_GL4(TexCoord) PROTO_GL4(TexCoord)
void tglEdgeFlag(int flag); void tglEdgeFlag(TGLboolean flag);
// matrix // matrix
void tglMatrixMode(int mode); void tglMatrixMode(TGLenum mode);
void tglLoadMatrixf(const float *m); void tglLoadMatrixf(const TGLfloat *m);
void tglLoadIdentity(); void tglLoadIdentity();
void tglMultMatrixf(const float *m); void tglMultMatrixf(const TGLfloat *m);
void tglPushMatrix(); void tglPushMatrix();
void tglPopMatrix(); void tglPopMatrix();
void tglRotatef(float angle, float x, float y, float z); void tglRotatef(TGLfloat angle, TGLfloat x, TGLfloat y, TGLfloat z);
void tglTranslatef(float x, float y, float z); void tglTranslatef(TGLfloat x, TGLfloat y, TGLfloat z);
void tglScalef(float x, float y, float z); void tglScalef(TGLfloat x, TGLfloat y, TGLfloat z);
void tglViewport(int x, int y, int width, int height); void tglViewport(TGLint x, TGLint y, TGLsizei width, TGLsizei height);
void tglFrustum(double left, double right, double bottom, double top, void tglFrustum(TGLdouble left, TGLdouble right, TGLdouble bottom, TGLdouble top,
double nearv, double farv); TGLdouble nearv, TGLdouble farv);
void tglOrtho(double left, double right, double bottom, double top, double zNear, double zFar); void tglOrtho(TGLdouble left, TGLdouble right, TGLdouble bottom, TGLdouble top,
TGLdouble zNear, TGLdouble zFar);
// lists // lists
unsigned int tglGenLists(int range); TGLuint tglGenLists(TGLsizei range);
int tglIsList(unsigned int list); TGLboolean tglIsList(TGLuint list);
void tglNewList(unsigned int list, int mode); void tglNewList(TGLuint list, TGLenum mode);
void tglEndList(); void tglEndList();
void tglCallList(unsigned int list); void tglCallList(TGLuint list);
// clear // clear
void tglClear(int mask); void tglClear(TGLbitfield mask);
void tglClearColor(float r, float g, float b, float a); void tglClearColor(TGLfloat r, TGLfloat g, TGLfloat b, TGLfloat a);
void tglClearDepth(double depth); void tglClearDepth(TGLdouble depth);
void tglClearStencil(TGLint s); void tglClearStencil(TGLint s);
// stencil buffer // stencil buffer
@ -799,47 +802,47 @@ void tglStencilOp(TGLenum sfail, TGLenum dpfail, TGLenum dppass);
void tglStencilMask(TGLuint mask); void tglStencilMask(TGLuint mask);
// selection // selection
int tglRenderMode(int mode); int tglRenderMode(TGLenum mode);
void tglSelectBuffer(int size, unsigned int *buf); void tglSelectBuffer(TGLsizei size, TGLuint *buffer);
void tglInitNames(); void tglInitNames();
void tglPushName(unsigned int name); void tglPushName(TGLuint name);
void tglPopName(); void tglPopName();
void tglLoadName(unsigned int name); void tglLoadName(TGLuint name);
// textures // textures
void tglGenTextures(int n, unsigned int *textures); void tglGenTextures(TGLsizei n, TGLuint *textures);
void tglDeleteTextures(int n, const unsigned int *textures); void tglDeleteTextures(TGLsizei n, const TGLuint *textures);
void tglBindTexture(int target, int texture); void tglBindTexture(TGLenum target, TGLuint texture);
void tglTexImage2D(int target, int level, int components, void tglTexImage2D(TGLenum target, TGLint level, TGLint internalformat,
int width, int height, int border, TGLsizei width, TGLsizei height, TGLint border,
int format, int type, void *pixels); TGLenum format, TGLenum type, const void *pixels);
void tglTexEnvi(int target, int pname, int param); void tglTexEnvi(TGLenum target, TGLenum pname, TGLint param);
void tglTexParameteri(int target, int pname, int param); void tglTexParameteri(TGLenum target, TGLenum pname, TGLint param);
void tglPixelStorei(int pname, int param); void tglPixelStorei(TGLenum pname, TGLint param);
// lighting // lighting
void tglMaterialfv(int mode, int type, const float *v); void tglMaterialfv(TGLenum mode, TGLenum type, const TGLfloat *v);
void tglMaterialf(int mode, int type, float v); void tglMaterialf(TGLenum mode, TGLenum type, TGLfloat v);
void tglColorMaterial(int mode, int type); void tglColorMaterial(TGLenum mode, TGLenum type);
void tglLightfv(int light, int type, const float *v); void tglLightfv(TGLenum light, TGLenum type, const TGLfloat *v);
void tglLightf(int light, int type, const float v); void tglLightf(TGLenum light, TGLenum type, const TGLfloat v);
void tglLightModeli(int pname, int param); void tglLightModeli(TGLenum pname, TGLint param);
void tglLightModelfv(int pname, const float *param); void tglLightModelfv(TGLenum pname, const TGLfloat *param);
// misc // misc
void tglFlush(); void tglFlush();
void tglHint(int target, int mode); void tglHint(TGLenum target, TGLenum mode);
void tglGetIntegerv(int pname, int *params); void tglGetIntegerv(TGLenum pname, TGLint *data);
void tglGetFloatv(int pname, float *v); void tglGetFloatv(TGLenum pname, TGLfloat *data);
void tglFrontFace(int mode); void tglFrontFace(TGLenum mode);
void tglColorMask(TGLboolean r, TGLboolean g, TGLboolean b, TGLboolean a); void tglColorMask(TGLboolean r, TGLboolean g, TGLboolean b, TGLboolean a);
void tglDepthMask(int enableWrite); void tglDepthMask(TGLboolean flag);
void tglBlendFunc(TGLenum sfactor, TGLenum dfactor); void tglBlendFunc(TGLenum sfactor, TGLenum dfactor);
void tglAlphaFunc(TGLenum func, float ref); void tglAlphaFunc(TGLenum func, TGLclampf ref);
void tglDepthFunc(TGLenum func); void tglDepthFunc(TGLenum func);
// arrays // arrays
@ -857,6 +860,6 @@ void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoi
void tglPolygonOffset(TGLfloat factor, TGLfloat units); void tglPolygonOffset(TGLfloat factor, TGLfloat units);
// custom extensions // custom extensions
void tglDebug(int mode); void tglDebug(TGLenum mode);
#endif #endif

View file

@ -205,7 +205,7 @@ void GLContext::glopCallList(GLParam *p) {
} }
} }
void tglNewList(uint list, int mode) { void tglNewList(TGLuint list, TGLenum mode) {
GLList *l; GLList *l;
GLContext *c = gl_get_context(); GLContext *c = gl_get_context();
@ -238,14 +238,14 @@ void tglEndList() {
c->exec_flag = 1; c->exec_flag = 1;
} }
int tglIsList(uint list) { TGLboolean tglIsList(TGLuint list) {
GLContext *c = gl_get_context(); GLContext *c = gl_get_context();
GLList *l = find_list(c, list); GLList *l = find_list(c, list);
return (l != NULL); return (l != nullptr);
} }
unsigned int tglGenLists(int range) { TGLuint tglGenLists(TGLsizei range) {
GLContext *c = gl_get_context(); GLContext *c = gl_get_context();
int count, list; int count, list;
GLList **lists; GLList **lists;

View file

@ -29,7 +29,7 @@
namespace TinyGL { namespace TinyGL {
int tglRenderMode(int mode) { TGLint tglRenderMode(TGLenum mode) {
GLContext *c = gl_get_context(); GLContext *c = gl_get_context();
int result = 0; int result = 0;
@ -67,12 +67,12 @@ int tglRenderMode(int mode) {
return result; return result;
} }
void tglSelectBuffer(int size, uint *buf) { void tglSelectBuffer(TGLsizei size, TGLuint *buffer) {
GLContext *c = gl_get_context(); GLContext *c = gl_get_context();
assert(c->render_mode != TGL_SELECT); assert(c->render_mode != TGL_SELECT);
c->select_buffer = buf; c->select_buffer = buffer;
c->select_size = size; c->select_size = size;
} }

View file

@ -288,7 +288,7 @@ void GLContext::glopPixelStore(GLParam *p) {
} // end of namespace TinyGL } // end of namespace TinyGL
void tglGenTextures(int n, uint *textures) { void tglGenTextures(TGLsizei n, TGLuint *textures) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
@ -297,7 +297,7 @@ void tglGenTextures(int n, uint *textures) {
c->maxTextureName += n; c->maxTextureName += n;
} }
void tglDeleteTextures(int n, const uint *textures) { void tglDeleteTextures(TGLsizei n, const TGLuint *textures) {
TinyGL::GLContext *c = TinyGL::gl_get_context(); TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLTexture *t; TinyGL::GLTexture *t;

View file

@ -29,7 +29,8 @@
namespace TinyGL { namespace TinyGL {
void createContext(int screenW, int screenH, Graphics::PixelFormat pixelFormat, int textureSize, bool enableStencilBuffer, bool dirtyRectsEnable = true); void createContext(int screenW, int screenH, Graphics::PixelFormat pixelFormat,
int textureSize, bool enableStencilBuffer, bool dirtyRectsEnable = true);
void destroyContext(); void destroyContext();
void presentBuffer(); void presentBuffer();
void presentBuffer(Common::List<Common::Rect> &dirtyAreas); void presentBuffer(Common::List<Common::Rect> &dirtyAreas);