From e7e305e522612bf0d9469fe05dfeff4e6f7292c6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 6 May 2008 01:09:48 +0000 Subject: [PATCH] remove unused api --- panda/src/tinydisplay/Sources.pp | 10 +- panda/src/tinydisplay/api.c | 589 ------------ panda/src/tinydisplay/arrays.c | 206 ----- panda/src/tinydisplay/clear.c | 30 - panda/src/tinydisplay/clip.c | 44 +- panda/src/tinydisplay/get.c | 72 -- panda/src/tinydisplay/glu.c | 261 ------ panda/src/tinydisplay/init.c | 78 +- panda/src/tinydisplay/light.c | 155 ---- panda/src/tinydisplay/list.c | 255 ------ panda/src/tinydisplay/matrix.c | 241 ----- panda/src/tinydisplay/misc.c | 147 --- panda/src/tinydisplay/opinfo.h | 65 -- panda/src/tinydisplay/oscontext.c | 84 -- panda/src/tinydisplay/oscontext.h | 37 - panda/src/tinydisplay/select.c | 114 --- panda/src/tinydisplay/specbuf.h | 22 - .../tinydisplay/tinyGraphicsStateGuardian.I | 10 - .../tinydisplay/tinyGraphicsStateGuardian.cxx | 109 +-- .../tinydisplay/tinyGraphicsStateGuardian.h | 4 +- .../src/tinydisplay/tinySDLGraphicsWindow.cxx | 2 - panda/src/tinydisplay/tinyTextureContext.h | 1 - panda/src/tinydisplay/tinygl.h | 838 ------------------ panda/src/tinydisplay/tinyglu.h | 23 - panda/src/tinydisplay/vertex.c | 290 +----- panda/src/tinydisplay/zgl.h | 100 +-- 26 files changed, 65 insertions(+), 3722 deletions(-) delete mode 100644 panda/src/tinydisplay/api.c delete mode 100644 panda/src/tinydisplay/arrays.c delete mode 100644 panda/src/tinydisplay/clear.c delete mode 100644 panda/src/tinydisplay/get.c delete mode 100644 panda/src/tinydisplay/glu.c delete mode 100644 panda/src/tinydisplay/list.c delete mode 100644 panda/src/tinydisplay/matrix.c delete mode 100644 panda/src/tinydisplay/misc.c delete mode 100644 panda/src/tinydisplay/opinfo.h delete mode 100644 panda/src/tinydisplay/oscontext.c delete mode 100644 panda/src/tinydisplay/oscontext.h delete mode 100644 panda/src/tinydisplay/select.c delete mode 100644 panda/src/tinydisplay/specbuf.h delete mode 100644 panda/src/tinydisplay/tinygl.h delete mode 100644 panda/src/tinydisplay/tinyglu.h diff --git a/panda/src/tinydisplay/Sources.pp b/panda/src/tinydisplay/Sources.pp index e4501665b9..034139b1e7 100644 --- a/panda/src/tinydisplay/Sources.pp +++ b/panda/src/tinydisplay/Sources.pp @@ -21,11 +21,11 @@ tinyTextureContext.I tinyTextureContext.cxx tinyTextureContext.h \ tinyXGraphicsPipe.I tinyXGraphicsPipe.cxx tinyXGraphicsPipe.h \ tinyXGraphicsWindow.h tinyXGraphicsWindow.I tinyXGraphicsWindow.cxx \ - api.c arrays.c clear.c clip.c error.c get.c \ - glu.c image_util.c init.c light.c list.c \ - matrix.c memory.c misc.c msghandling.c msghandling.h \ - opinfo.h oscontext.c oscontext.h select.c specbuf.c \ - specbuf.h texture.c tinygl.h tinyglu.h vertex.c \ + clip.c error.c \ + image_util.c init.c light.c \ + memory.c msghandling.c msghandling.h \ + specbuf.c \ + texture.c vertex.c \ zbuffer.c zbuffer.h zdither.c zfeatures.h zgl.h zline.c \ zline.h zmath.c zmath.h ztriangle.c ztriangle.h ztriangle_two.h diff --git a/panda/src/tinydisplay/api.c b/panda/src/tinydisplay/api.c deleted file mode 100644 index a669a92de9..0000000000 --- a/panda/src/tinydisplay/api.c +++ /dev/null @@ -1,589 +0,0 @@ -#include "zgl.h" -#include -/* glVertex */ - -void glVertex4f(float x,float y,float z,float w) -{ - GLParam p[5]; - - p[0].op=OP_Vertex; - p[1].f=x; - p[2].f=y; - p[3].f=z; - p[4].f=w; - - gl_add_op(p); -} - -void glVertex2f(float x,float y) -{ - glVertex4f(x,y,0,1); -} - -void glVertex3f(float x,float y,float z) -{ - glVertex4f(x,y,z,1); -} - -void glVertex3fv(float *v) -{ - glVertex4f(v[0],v[1],v[2],1); -} - -/* glNormal */ - -void glNormal3f(float x,float y,float z) -{ - GLParam p[4]; - - p[0].op=OP_Normal; - p[1].f=x; - p[2].f=y; - p[3].f=z; - - gl_add_op(p); -} - -void glNormal3fv(float *v) -{ - glNormal3f(v[0],v[1],v[2]); -} - -/* glColor */ - -void glColor4f(float r,float g,float b,float a) -{ - GLParam p[8]; - - p[0].op=OP_Color; - p[1].f=r; - p[2].f=g; - p[3].f=b; - p[4].f=a; - /* direct convertion to integer to go faster if no shading */ - p[5].ui = (unsigned int) (r * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) + - ZB_POINT_RED_MIN); - p[6].ui = (unsigned int) (g * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) + - ZB_POINT_GREEN_MIN); - p[7].ui = (unsigned int) (b * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + - ZB_POINT_BLUE_MIN); - gl_add_op(p); -} - -void glColor4fv(float *v) -{ - GLParam p[8]; - - p[0].op=OP_Color; - p[1].f=v[0]; - p[2].f=v[1]; - p[3].f=v[2]; - p[4].f=v[3]; - /* direct convertion to integer to go faster if no shading */ - p[5].ui = (unsigned int) (v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) + - ZB_POINT_RED_MIN); - p[6].ui = (unsigned int) (v[1] * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) + - ZB_POINT_GREEN_MIN); - p[7].ui = (unsigned int) (v[2] * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + - ZB_POINT_BLUE_MIN); - gl_add_op(p); -} - -void glColor3f(float x,float y,float z) -{ - glColor4f(x,y,z,1); -} - -void glColor3fv(float *v) -{ - glColor4f(v[0],v[1],v[2],1); -} - - -/* TexCoord */ - -void glTexCoord4f(float s,float t,float r,float q) -{ - GLParam p[5]; - - p[0].op=OP_TexCoord; - p[1].f=s; - p[2].f=t; - p[3].f=r; - p[4].f=q; - - gl_add_op(p); -} - -void glTexCoord2f(float s,float t) -{ - glTexCoord4f(s,t,0,1); -} - -void glTexCoord2fv(float *v) -{ - glTexCoord4f(v[0],v[1],0,1); -} - -void glEdgeFlag(int flag) -{ - GLParam p[2]; - - p[0].op=OP_EdgeFlag; - p[1].i=flag; - - gl_add_op(p); -} - -/* misc */ - -void glShadeModel(int mode) -{ - GLParam p[2]; - - assert(mode == GL_FLAT || mode == GL_SMOOTH); - - p[0].op=OP_ShadeModel; - p[1].i=mode; - - gl_add_op(p); -} - -void glCullFace(int mode) -{ - GLParam p[2]; - - assert(mode == GL_BACK || - mode == GL_FRONT || - mode == GL_FRONT_AND_BACK); - - p[0].op=OP_CullFace; - p[1].i=mode; - - gl_add_op(p); -} - -void glFrontFace(int mode) -{ - GLParam p[2]; - - assert(mode == GL_CCW || mode == GL_CW); - - mode = (mode != GL_CCW); - - p[0].op=OP_FrontFace; - p[1].i=mode; - - gl_add_op(p); -} - -void glPolygonMode(int face,int mode) -{ - GLParam p[3]; - - assert(face == GL_BACK || - face == GL_FRONT || - face == GL_FRONT_AND_BACK); - assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL); - - p[0].op=OP_PolygonMode; - p[1].i=face; - p[2].i=mode; - - gl_add_op(p); -} - - -/* glEnable / glDisable */ - -void glEnable(int cap) -{ - GLParam p[3]; - - p[0].op=OP_EnableDisable; - p[1].i=cap; - p[2].i=1; - - gl_add_op(p); -} - -void glDisable(int cap) -{ - GLParam p[3]; - - p[0].op=OP_EnableDisable; - p[1].i=cap; - p[2].i=0; - - gl_add_op(p); -} - -/* glBegin / glEnd */ - -void glBegin(int mode) -{ - GLParam p[2]; - - p[0].op=OP_Begin; - p[1].i=mode; - - gl_add_op(p); -} - -void glEnd(void) -{ - GLParam p[1]; - - p[0].op=OP_End; - - gl_add_op(p); -} - -/* matrix */ - -void glMatrixMode(int mode) -{ - GLParam p[2]; - - p[0].op=OP_MatrixMode; - p[1].i=mode; - - gl_add_op(p); -} - -void glLoadMatrixf(const float *m) -{ - GLParam p[17]; - int i; - - p[0].op=OP_LoadMatrix; - for(i=0;i<16;i++) p[i+1].f=m[i]; - - gl_add_op(p); -} - -void glLoadIdentity(void) -{ - GLParam p[1]; - - p[0].op=OP_LoadIdentity; - - gl_add_op(p); -} - -void glMultMatrixf(const float *m) -{ - GLParam p[17]; - int i; - - p[0].op=OP_MultMatrix; - for(i=0;i<16;i++) p[i+1].f=m[i]; - - gl_add_op(p); -} - -void glPushMatrix(void) -{ - GLParam p[1]; - - p[0].op=OP_PushMatrix; - - gl_add_op(p); -} - -void glPopMatrix(void) -{ - GLParam p[1]; - - p[0].op=OP_PopMatrix; - - gl_add_op(p); -} - -void glRotatef(float angle,float x,float y,float z) -{ - GLParam p[5]; - - p[0].op=OP_Rotate; - p[1].f=angle; - p[2].f=x; - p[3].f=y; - p[4].f=z; - - gl_add_op(p); -} - -void glTranslatef(float x,float y,float z) -{ - GLParam p[4]; - - p[0].op=OP_Translate; - p[1].f=x; - p[2].f=y; - p[3].f=z; - - gl_add_op(p); -} - -void glScalef(float x,float y,float z) -{ - GLParam p[4]; - - p[0].op=OP_Scale; - p[1].f=x; - p[2].f=y; - p[3].f=z; - - gl_add_op(p); -} - - -void glViewport(int x,int y,int width,int height) -{ - GLParam p[5]; - - p[0].op=OP_Viewport; - p[1].i=x; - p[2].i=y; - p[3].i=width; - p[4].i=height; - - gl_add_op(p); -} - -void glFrustum(double left,double right,double bottom,double top, - double near,double farv) -{ - GLParam p[7]; - - p[0].op=OP_Frustum; - p[1].f=left; - p[2].f=right; - p[3].f=bottom; - p[4].f=top; - p[5].f=near; - p[6].f=farv; - - gl_add_op(p); -} - -/* lightening */ - -void glMaterialfv(int mode,int type,float *v) -{ - GLParam p[7]; - int i,n; - - assert(mode == GL_FRONT || mode == GL_BACK || mode==GL_FRONT_AND_BACK); - - p[0].op=OP_Material; - p[1].i=mode; - p[2].i=type; - n=4; - if (type == GL_SHININESS) n=1; - for(i=0;i<4;i++) p[3+i].f=v[i]; - for(i=n;i<4;i++) p[3+i].f=0; - - gl_add_op(p); -} - -void glMaterialf(int mode,int type,float v) -{ - GLParam p[7]; - int i; - - p[0].op=OP_Material; - p[1].i=mode; - p[2].i=type; - p[3].f=v; - for(i=0;i<3;i++) p[4+i].f=0; - - gl_add_op(p); -} - -void glColorMaterial(int mode,int type) -{ - GLParam p[3]; - - p[0].op=OP_ColorMaterial; - p[1].i=mode; - p[2].i=type; - - gl_add_op(p); -} - -void glLightfv(int light,int type,float *v) -{ - GLParam p[7]; - int i; - - p[0].op=OP_Light; - p[1].i=light; - p[2].i=type; - /* TODO: 3 composants ? */ - for(i=0;i<4;i++) p[3+i].f=v[i]; - - gl_add_op(p); -} - - -void glLightf(int light,int type,float v) -{ - GLParam p[7]; - int i; - - p[0].op=OP_Light; - p[1].i=light; - p[2].i=type; - p[3].f=v; - for(i=0;i<3;i++) p[4+i].f=0; - - gl_add_op(p); -} - -void glLightModeli(int pname,int param) -{ - GLParam p[6]; - int i; - - p[0].op=OP_LightModel; - p[1].i=pname; - p[2].f=(float)param; - for(i=0;i<4;i++) p[3+i].f=0; - - gl_add_op(p); -} - -void glLightModelfv(int pname,float *param) -{ - GLParam p[6]; - int i; - - p[0].op=OP_LightModel; - p[1].i=pname; - for(i=0;i<4;i++) p[2+i].f=param[i]; - - gl_add_op(p); -} - -/* clear */ - -void glClear(int mask) -{ - GLParam p[2]; - - p[0].op=OP_Clear; - p[1].i=mask; - - gl_add_op(p); -} - -void glClearColor(float r,float g,float b,float a) -{ - GLParam p[5]; - - p[0].op=OP_ClearColor; - p[1].f=r; - p[2].f=g; - p[3].f=b; - p[4].f=a; - - gl_add_op(p); -} - -void glClearDepth(double depth) -{ - GLParam p[2]; - - p[0].op=OP_ClearDepth; - p[1].f=depth; - - gl_add_op(p); -} - - -/* selection */ - -void glInitNames(void) -{ - GLParam p[1]; - - p[0].op=OP_InitNames; - - gl_add_op(p); -} - -void glPushName(unsigned int name) -{ - GLParam p[2]; - - p[0].op=OP_PushName; - p[1].i=name; - - gl_add_op(p); -} - -void glPopName(void) -{ - GLParam p[1]; - - p[0].op=OP_PopName; - - gl_add_op(p); -} - -void glLoadName(unsigned int name) -{ - GLParam p[2]; - - p[0].op=OP_LoadName; - p[1].i=name; - - gl_add_op(p); -} - -void -glPolygonOffset(GLfloat factor, GLfloat units) -{ - GLParam p[3]; - p[0].op = OP_PolygonOffset; - p[1].f = factor; - p[2].f = units; -} - -/* Special Functions */ - -void glCallList(unsigned int list) -{ - GLParam p[2]; - - p[0].op=OP_CallList; - p[1].i=list; - - gl_add_op(p); -} - -void glFlush(void) -{ - /* nothing to do */ -} - -void glHint(int target,int mode) -{ - GLParam p[3]; - - p[0].op=OP_Hint; - p[1].i=target; - p[2].i=mode; - - gl_add_op(p); -} - -/* Non standard functions */ - -void glDebug(int mode) -{ - GLContext *c=gl_get_context(); - c->print_flag=mode; -} - diff --git a/panda/src/tinydisplay/arrays.c b/panda/src/tinydisplay/arrays.c deleted file mode 100644 index 04bffc8a32..0000000000 --- a/panda/src/tinydisplay/arrays.c +++ /dev/null @@ -1,206 +0,0 @@ -#include "zgl.h" -#include -#include - -#define VERTEX_ARRAY 0x0001 -#define COLOR_ARRAY 0x0002 -#define NORMAL_ARRAY 0x0004 -#define TEXCOORD_ARRAY 0x0008 - -void -glopArrayElement(GLContext *c, GLParam *param) -{ - int i; - int states = c->client_states; - int idx = param[1].i; - - if (states & COLOR_ARRAY) { - GLParam p[5]; - int size = c->color_array_size; - i = idx * (size + c->color_array_stride); - p[1].f = c->color_array[i]; - p[2].f = c->color_array[i+1]; - p[3].f = c->color_array[i+2]; - p[4].f = size > 3 ? c->color_array[i+3] : 1.0f; - glopColor(c, p); - } - if (states & NORMAL_ARRAY) { - i = idx * (3 + c->normal_array_stride); - c->current_normal.X = c->normal_array[i]; - c->current_normal.Y = c->normal_array[i+1]; - c->current_normal.Z = c->normal_array[i+2]; - c->current_normal.Z = 0.0f; - } - if (states & TEXCOORD_ARRAY) { - int size = c->texcoord_array_size; - i = idx * (size + c->texcoord_array_stride); - c->current_tex_coord.X = c->texcoord_array[i]; - c->current_tex_coord.Y = c->texcoord_array[i+1]; - c->current_tex_coord.Z = size > 2 ? c->texcoord_array[i+2] : 0.0f; - c->current_tex_coord.W = size > 3 ? c->texcoord_array[i+3] : 1.0f; - } - if (states & VERTEX_ARRAY) { - GLParam p[5]; - int size = c->vertex_array_size; - i = idx * (size + c->vertex_array_stride); - p[1].f = c->vertex_array[i]; - p[2].f = c->vertex_array[i+1]; - p[3].f = size > 2 ? c->vertex_array[i+2] : 0.0f; - p[4].f = size > 3 ? c->vertex_array[i+3] : 1.0f; - glopVertex(c, p); - } -} - -void -glArrayElement(GLint i) -{ - GLParam p[2]; - p[0].op = OP_ArrayElement; - p[1].i = i; - gl_add_op(p); -} - - -void -glopEnableClientState(GLContext *c, GLParam *p) -{ - c->client_states |= p[1].i; -} - -void -glEnableClientState(GLenum array) -{ - GLParam p[2]; - p[0].op = OP_EnableClientState; - - switch(array) { - case GL_VERTEX_ARRAY: - p[1].i = VERTEX_ARRAY; - break; - case GL_NORMAL_ARRAY: - p[1].i = NORMAL_ARRAY; - break; - case GL_COLOR_ARRAY: - p[1].i = COLOR_ARRAY; - break; - case GL_TEXTURE_COORD_ARRAY: - p[1].i = TEXCOORD_ARRAY; - break; - default: - assert(0); - break; - } - gl_add_op(p); -} - -void -glopDisableClientState(GLContext *c, GLParam *p) -{ - c->client_states &= p[1].i; -} - -void -glDisableClientState(GLenum array) -{ - GLParam p[2]; - p[0].op = OP_DisableClientState; - - switch(array) { - case GL_VERTEX_ARRAY: - p[1].i = ~VERTEX_ARRAY; - break; - case GL_NORMAL_ARRAY: - p[1].i = ~NORMAL_ARRAY; - break; - case GL_COLOR_ARRAY: - p[1].i = ~COLOR_ARRAY; - break; - case GL_TEXTURE_COORD_ARRAY: - p[1].i = ~TEXCOORD_ARRAY; - break; - default: - assert(0); - break; - } - gl_add_op(p); -} - -void -glopVertexPointer(GLContext *c, GLParam *p) -{ - c->vertex_array_size = p[1].i; - c->vertex_array_stride = p[2].i; - c->vertex_array = p[3].p; -} - -void -glVertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer) -{ - GLParam p[4]; - assert(type == GL_FLOAT); - p[0].op = OP_VertexPointer; - p[1].i = size; - p[2].i = stride; - p[3].p = (void*)pointer; - gl_add_op(p); -} - -void -glopColorPointer(GLContext *c, GLParam *p) -{ - c->color_array_size = p[1].i; - c->color_array_stride = p[2].i; - c->color_array = p[3].p; -} - -void -glColorPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer) -{ - GLParam p[4]; - assert(type == GL_FLOAT); - p[0].op = OP_ColorPointer; - p[1].i = size; - p[2].i = stride; - p[3].p = (void*)pointer; - gl_add_op(p); -} - -void -glopNormalPointer(GLContext *c, GLParam *p) -{ - c->normal_array_stride = p[1].i; - c->normal_array = p[2].p; -} - -void -glNormalPointer(GLenum type, GLsizei stride, - const GLvoid *pointer) -{ - GLParam p[3]; - assert(type == GL_FLOAT); - p[0].op = OP_NormalPointer; - p[1].i = stride; - p[2].p = (void*)pointer; -} - -void -glopTexCoordPointer(GLContext *c, GLParam *p) -{ - c->texcoord_array_size = p[1].i; - c->texcoord_array_stride = p[2].i; - c->texcoord_array = p[3].p; -} - -void -glTexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer) -{ - GLParam p[4]; - assert(type == GL_FLOAT); - p[0].op = OP_TexCoordPointer; - p[1].i = size; - p[2].i = stride; - p[3].p = (void*)pointer; -} diff --git a/panda/src/tinydisplay/clear.c b/panda/src/tinydisplay/clear.c deleted file mode 100644 index b7b44c4c05..0000000000 --- a/panda/src/tinydisplay/clear.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "zgl.h" - - -void glopClearColor(GLContext *c,GLParam *p) -{ - c->clear_color.v[0]=p[1].f; - c->clear_color.v[1]=p[2].f; - c->clear_color.v[2]=p[3].f; - c->clear_color.v[3]=p[4].f; -} -void glopClearDepth(GLContext *c,GLParam *p) -{ - c->clear_depth=p[1].f; -} - - -void glopClear(GLContext *c,GLParam *p) -{ - int mask=p[1].i; - int z=0; - int r=(int)(c->clear_color.v[0]*65535); - int g=(int)(c->clear_color.v[1]*65535); - int b=(int)(c->clear_color.v[2]*65535); - - /* TODO : correct value of Z */ - - ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, - mask & GL_COLOR_BUFFER_BIT,r,g,b,0); -} - diff --git a/panda/src/tinydisplay/clip.c b/panda/src/tinydisplay/clip.c index 2f7a8e3e37..7ab5bdfa45 100644 --- a/panda/src/tinydisplay/clip.c +++ b/panda/src/tinydisplay/clip.c @@ -41,28 +41,12 @@ void gl_transform_to_viewport(GLContext *c,GLVertex *v) } -static void gl_add_select1(GLContext *c,int z1,int z2,int z3) -{ - unsigned int min,max; - min=max=z1; - if (z2max) max=z2; - if (z3>max) max=z3; - - gl_add_select(c,0xffffffff-min,0xffffffff-max); -} - /* point */ void gl_draw_point(GLContext *c,GLVertex *p0) { if (p0->clip_code == 0) { - if (c->render_mode == GL_SELECT) { - gl_add_select(c,p0->zp.z,p0->zp.z); - } else { - ZB_plot(c->zb,&p0->zp); - } + ZB_plot(c->zb,&p0->zp); } } @@ -114,14 +98,10 @@ void gl_draw_line(GLContext *c,GLVertex *p1,GLVertex *p2) cc2=p2->clip_code; if ( (cc1 | cc2) == 0) { - if (c->render_mode == GL_SELECT) { - gl_add_select1(c,p1->zp.z,p2->zp.z,p2->zp.z); - } else { - if (c->depth_test) - ZB_line_z(c->zb,&p1->zp,&p2->zp); - else - ZB_line(c->zb,&p1->zp,&p2->zp); - } + if (c->depth_test) + ZB_line_z(c->zb,&p1->zp,&p2->zp); + else + ZB_line(c->zb,&p1->zp,&p2->zp); } else if ( (cc1&cc2) != 0 ) { return; } else { @@ -209,7 +189,7 @@ float (*clip_proc[6])(V4 *,V4 *,V4 *)= { static inline void updateTmp(GLContext *c, GLVertex *q,GLVertex *p0,GLVertex *p1,float t) { - if (c->current_shade_model == GL_SMOOTH) { + if (c->smooth_shade_model) { q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t; q->color.v[1]=p0->color.v[1] + (p1->color.v[1]-p0->color.v[1])*t; q->color.v[2]=p0->color.v[2] + (p1->color.v[2]-p0->color.v[2])*t; @@ -260,14 +240,12 @@ void gl_draw_triangle(GLContext *c, /* back face culling */ if (c->cull_face_enabled) { /* most used case first */ - if (c->current_cull_face == GL_BACK) { + if (c->cull_clockwise) { if (front == 0) return; c->draw_triangle_front(c,p0,p1,p2); - } else if (c->current_cull_face == GL_FRONT) { + } else { if (front != 0) return; c->draw_triangle_back(c,p0,p1,p2); - } else { - return; } } else { /* no culling */ @@ -366,12 +344,6 @@ static void gl_draw_triangle_clip(GLContext *c, } -void gl_draw_triangle_select(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2) -{ - gl_add_select1(c,p0->zp.z,p1->zp.z,p2->zp.z); -} - #ifdef PROFILE int count_triangles,count_triangles_textured,count_pixels; #endif diff --git a/panda/src/tinydisplay/get.c b/panda/src/tinydisplay/get.c deleted file mode 100644 index 4b16aa1776..0000000000 --- a/panda/src/tinydisplay/get.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "zgl.h" - -void glGetIntegerv(int pname,int *params) -{ - GLContext *c=gl_get_context(); - - switch(pname) { - case GL_VIEWPORT: - params[0]=c->viewport.xmin; - params[1]=c->viewport.ymin; - params[2]=c->viewport.xsize; - params[3]=c->viewport.ysize; - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: - *params = MAX_MODELVIEW_STACK_DEPTH; - break; - case GL_MAX_PROJECTION_STACK_DEPTH: - *params = MAX_PROJECTION_STACK_DEPTH; - break; - case GL_MAX_LIGHTS: - *params = MAX_LIGHTS; - break; - case GL_MAX_TEXTURE_SIZE: - *params = 256; /* not completely true, but... */ - break; - case GL_MAX_TEXTURE_STACK_DEPTH: - *params = MAX_TEXTURE_STACK_DEPTH; - break; - default: - gl_fatal_error("glGet: option not implemented"); - break; - } -} - -void glGetFloatv(int pname, float *v) -{ - int i; - int mnr = 0; /* just a trick to return the correct matrix */ - GLContext *c = gl_get_context(); - switch (pname) { - case GL_TEXTURE_MATRIX: - mnr++; - case GL_PROJECTION_MATRIX: - mnr++; - case GL_MODELVIEW_MATRIX: - { - float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; - for (i = 0; i < 4; i++) { - *v++ = p[0]; - *v++ = p[4]; - *v++ = p[8]; - *v++ = p[12]; - p++; - } - } - break; - case GL_LINE_WIDTH: - *v = 1.0f; - break; - case GL_LINE_WIDTH_RANGE: - v[0] = v[1] = 1.0f; - break; - case GL_POINT_SIZE: - *v = 1.0f; - break; - case GL_POINT_SIZE_RANGE: - v[0] = v[1] = 1.0f; - default: - fprintf(stderr,"warning: unknown pname in glGetFloatv()\n"); - break; - } -} diff --git a/panda/src/tinydisplay/glu.c b/panda/src/tinydisplay/glu.c deleted file mode 100644 index 56b6eac8e9..0000000000 --- a/panda/src/tinydisplay/glu.c +++ /dev/null @@ -1,261 +0,0 @@ -#include -#include -#include "tinygl.h" -#include "tinyglu.h" - - -void drawTorus(float rc, int numc, float rt, int numt) -{ - int i, j, k; - double s, t; - double x, y, z; - double pi, twopi; - - pi = 3.14159265358979323846; - twopi = 2 * pi; - - for (i = 0; i < numc; i++) { - glBegin(GL_QUAD_STRIP); - for (j = 0; j <= numt; j++) { - for (k = 1; k >= 0; k--) { - s = (i + k) % numc + 0.5; - t = j % numt; - - x = cos(t*twopi/numt) * cos(s*twopi/numc); - y = sin(t*twopi/numt) * cos(s*twopi/numc); - z = sin(s*twopi/numc); - glNormal3f(x, y, z); - - x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt); - y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt); - z = rc * sin(s*twopi/numc); - glVertex3f(x, y, z); - } - } - glEnd(); - } -} - -static void normal3f( GLfloat x, GLfloat y, GLfloat z ) -{ - GLdouble mag; - - mag = sqrt( x*x + y*y + z*z ); - if (mag>0.00001F) { - x /= mag; - y /= mag; - z /= mag; - } - glNormal3f( x, y, z ); -} - -void gluPerspective( GLdouble fovy, GLdouble aspect, - GLdouble zNear, GLdouble zFar ) -{ - GLdouble xmin, xmax, ymin, ymax; - - ymax = zNear * tan( fovy * M_PI / 360.0 ); - ymin = -ymax; - - xmin = ymin * aspect; - xmax = ymax * aspect; - - glFrustum( xmin, xmax, ymin, ymax, zNear, zFar ); -} - -GLUquadricObj *gluNewQuadric(void) -{ - return NULL; -} - -void gluQuadricDrawStyle(GLUquadricObj *obj, int style) -{ -} - -void gluCylinder( GLUquadricObj *qobj, - GLdouble baseRadius, GLdouble topRadius, GLdouble height, - GLint slices, GLint stacks ) -{ - GLdouble da, r, dr, dz; - GLfloat z, nz, nsign; - GLint i, j; - GLfloat du = 1.0 / slices; - GLfloat dv = 1.0 / stacks; - GLfloat tcx = 0.0, tcy = 0.0; - - nsign = 1.0; - - da = 2.0*M_PI / slices; - dr = (topRadius-baseRadius) / stacks; - dz = height / stacks; - nz = (baseRadius-topRadius) / height; /* Z component of normal vectors */ - - for (i=0;i=0;j--) { - theta = (j==slices) ? 0.0 : j * dtheta; - x = -sin(theta) * sin(rho); - y = cos(theta) * sin(rho); - z = nsign * cos(rho); - if (normals) glNormal3f( x*nsign, y*nsign, z*nsign ); - glTexCoord2f(s,1-t); - s -= ds; - glVertex3f( x*radius, y*radius, z*radius ); - } - glEnd(); -} diff --git a/panda/src/tinydisplay/init.c b/panda/src/tinydisplay/init.c index 11a94a819f..5e9ef673f4 100644 --- a/panda/src/tinydisplay/init.c +++ b/panda/src/tinydisplay/init.c @@ -2,21 +2,12 @@ GLContext *gl_ctx; -void glInit(void *zbuffer1) +void glInit(GLContext *c, ZBuffer *zbuffer) { - ZBuffer *zbuffer=(ZBuffer *)zbuffer1; - GLContext *c; GLViewport *v; int i; - c=gl_zalloc(sizeof(GLContext)); - gl_ctx=c; - c->zb=zbuffer; - - /* allocate GLVertex array */ - c->vertex_max = POLYGON_MAX_VERTEX; - c->vertex = gl_malloc(POLYGON_MAX_VERTEX*sizeof(GLVertex)); /* viewport */ v=&c->viewport; @@ -26,31 +17,7 @@ void glInit(void *zbuffer1) v->ysize=zbuffer->ysize; v->updated=1; - /* lists */ - - c->exec_flag=1; - c->compile_flag=0; - c->print_flag=0; - - c->in_begin=0; - /* lights */ - for(i=0;ilights[i]; - l->ambient=gl_V4_New(0,0,0,1); - l->diffuse=gl_V4_New(1,1,1,1); - l->specular=gl_V4_New(1,1,1,1); - l->position=gl_V4_New(0,0,1,0); - l->norm_position=gl_V3_New(0,0,1); - l->spot_direction=gl_V3_New(0,0,-1); - l->norm_spot_direction=gl_V3_New(0,0,-1); - l->spot_exponent=0; - l->spot_cutoff=180; - l->attenuation[0]=1; - l->attenuation[1]=0; - l->attenuation[2]=0; - l->enabled=0; - } c->first_light=NULL; c->ambient_light_model=gl_V4_New(0.2,0.2,0.2,1); c->local_light_model=0; @@ -66,9 +33,6 @@ void glInit(void *zbuffer1) m->specular=gl_V4_New(0,0,0,1); m->shininess=0; } - c->current_color_material_mode=GL_FRONT_AND_BACK; - c->current_color_material_type=GL_AMBIENT_AND_DIFFUSE; - c->color_material_enabled=0; /* default state */ c->current_color.X=1.0; @@ -91,12 +55,7 @@ void glInit(void *zbuffer1) c->current_tex_coord.Z=0; c->current_tex_coord.W=1; - c->polygon_mode_front=GL_FILL; - c->polygon_mode_back=GL_FILL; - c->current_front_face=0; /* 0 = GL_CCW 1 = GL_CW */ - c->current_cull_face=GL_BACK; - c->current_shade_model=GL_SMOOTH; c->cull_face_enabled=0; /* clear */ @@ -105,42 +64,10 @@ void glInit(void *zbuffer1) c->clear_color.v[2]=0; c->clear_color.v[3]=0; c->clear_depth=0; - - /* selection */ - c->render_mode=GL_RENDER; - c->select_buffer=NULL; - c->name_stack_size=0; - - /* matrix */ - c->matrix_mode=0; - - c->matrix_stack_depth_max[0]=MAX_MODELVIEW_STACK_DEPTH; - c->matrix_stack_depth_max[1]=MAX_PROJECTION_STACK_DEPTH; - c->matrix_stack_depth_max[2]=MAX_TEXTURE_STACK_DEPTH; - - for(i=0;i<3;i++) { - c->matrix_stack[i]=gl_zalloc(c->matrix_stack_depth_max[i] * sizeof(M4)); - c->matrix_stack_ptr[i]=c->matrix_stack[i]; - } - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - c->matrix_model_projection_updated=1; - - /* opengl 1.1 arrays */ - c->client_states = 0; /* opengl 1.1 polygon offset */ c->offset_states = 0; - /* clear the resize callback function pointer */ - c->gl_resize_viewport = NULL; - /* specular buffer */ c->specbuf_first = NULL; c->specbuf_used_counter = 0; @@ -150,8 +77,7 @@ void glInit(void *zbuffer1) c->depth_test = 0; } -void glClose(void) +void glClose(GLContext *c) { - GLContext *c=gl_get_context(); gl_free(c); } diff --git a/panda/src/tinydisplay/light.c b/panda/src/tinydisplay/light.c index 36c368143a..7c546e0703 100644 --- a/panda/src/tinydisplay/light.c +++ b/panda/src/tinydisplay/light.c @@ -1,161 +1,6 @@ #include "zgl.h" #include "msghandling.h" -void glopMaterial(GLContext *c,GLParam *p) -{ - int mode=p[1].i; - int type=p[2].i; - float *v=&p[3].f; - int i; - GLMaterial *m; - - if (mode == GL_FRONT_AND_BACK) { - p[1].i=GL_FRONT; - glopMaterial(c,p); - mode=GL_BACK; - } - if (mode == GL_FRONT) m=&c->materials[0]; - else m=&c->materials[1]; - - switch(type) { - case GL_EMISSION: - for(i=0;i<4;i++) - m->emission.v[i]=v[i]; - break; - case GL_AMBIENT: - for(i=0;i<4;i++) - m->ambient.v[i]=v[i]; - break; - case GL_DIFFUSE: - for(i=0;i<4;i++) - m->diffuse.v[i]=v[i]; - break; - case GL_SPECULAR: - for(i=0;i<4;i++) - m->specular.v[i]=v[i]; - break; - case GL_SHININESS: - m->shininess=v[0]; - m->shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION; - break; - case GL_AMBIENT_AND_DIFFUSE: - for(i=0;i<4;i++) - m->diffuse.v[i]=v[i]; - for(i=0;i<4;i++) - m->ambient.v[i]=v[i]; - break; - default: - assert(0); - } -} - -void glopColorMaterial(GLContext *c,GLParam *p) -{ - int mode=p[1].i; - int type=p[2].i; - - c->current_color_material_mode=mode; - c->current_color_material_type=type; -} - -void glopLight(GLContext *c,GLParam *p) -{ - int light=p[1].i; - int type=p[2].i; - V4 v; - GLLight *l; - int i; - - assert(light >= GL_LIGHT0 && light < GL_LIGHT0+MAX_LIGHTS ); - - l=&c->lights[light-GL_LIGHT0]; - - for(i=0;i<4;i++) v.v[i]=p[3+i].f; - - switch(type) { - case GL_AMBIENT: - l->ambient=v; - break; - case GL_DIFFUSE: - l->diffuse=v; - break; - case GL_SPECULAR: - l->specular=v; - break; - case GL_POSITION: - { - V4 pos; - gl_M4_MulV4(&pos,c->matrix_stack_ptr[0],&v); - - l->position=pos; - - if (l->position.v[3] == 0) { - l->norm_position.X=pos.X; - l->norm_position.Y=pos.Y; - l->norm_position.Z=pos.Z; - - gl_V3_Norm(&l->norm_position); - } - } - break; - case GL_SPOT_DIRECTION: - for(i=0;i<3;i++) { - l->spot_direction.v[i]=v.v[i]; - l->norm_spot_direction.v[i]=v.v[i]; - } - gl_V3_Norm(&l->norm_spot_direction); - break; - case GL_SPOT_EXPONENT: - l->spot_exponent=v.v[0]; - break; - case GL_SPOT_CUTOFF: - { - float a=v.v[0]; - assert(a == 180 || (a>=0 && a<=90)); - l->spot_cutoff=a; - if (a != 180) l->cos_spot_cutoff=cos(a * M_PI / 180.0); - } - break; - case GL_CONSTANT_ATTENUATION: - l->attenuation[0]=v.v[0]; - break; - case GL_LINEAR_ATTENUATION: - l->attenuation[1]=v.v[0]; - break; - case GL_QUADRATIC_ATTENUATION: - l->attenuation[2]=v.v[0]; - break; - default: - assert(0); - } -} - - -void glopLightModel(GLContext *c,GLParam *p) -{ - int pname=p[1].i; - float *v=&p[2].f; - int i; - - switch(pname) { - case GL_LIGHT_MODEL_AMBIENT: - for(i=0;i<4;i++) - c->ambient_light_model.v[i]=v[i]; - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - c->local_light_model=(int)v[0]; - break; - case GL_LIGHT_MODEL_TWO_SIDE: - c->light_model_two_side = (int)v[0]; - break; - default: - tgl_warning("glopLightModel: illegal pname: 0x%x\n", pname); - //assert(0); - break; - } -} - - static inline float clampf(float a,float min,float max) { if (ashared_state.lists[list]; -} - -static void delete_list(GLContext *c,int list) -{ - GLParamBuffer *pb,*pb1; - GLList *l; - - l=find_list(c,list); - assert(l != NULL); - - /* free param buffer */ - pb=l->first_op_buffer; - while (pb!=NULL) { - pb1=pb->next; - gl_free(pb); - pb=pb1; - } - - gl_free(l); - c->shared_state.lists[list]=NULL; -} - -static GLList *alloc_list(GLContext *c,int list) -{ - GLList *l; - GLParamBuffer *ob; - - l=gl_zalloc(sizeof(GLList)); - ob=gl_zalloc(sizeof(GLParamBuffer)); - - ob->next=NULL; - l->first_op_buffer=ob; - - ob->ops[0].op=OP_EndList; - - c->shared_state.lists[list]=l; - return l; -} - - -void gl_print_op(FILE *f,GLParam *p) -{ - int op; - char *s; - - op=p[0].op; - p++; - s=op_table_str[op]; - while (*s != 0) { - if (*s == '%') { - s++; - switch (*s++) { - case 'f': - fprintf(f,"%g",p[0].f); - break; - default: - fprintf(f,"%d",p[0].i); - break; - } - p++; - } else { - fputc(*s,f); - s++; - } - } - fprintf(f,"\n"); -} - - -void gl_compile_op(GLContext *c,GLParam *p) -{ - int op,op_size; - GLParamBuffer *ob,*ob1; - int index,i; - - op=p[0].op; - op_size=op_table_size[op]; - index=c->current_op_buffer_index; - ob=c->current_op_buffer; - - /* we should be able to add a NextBuffer opcode */ - if ((index + op_size) > (OP_BUFFER_MAX_SIZE-2)) { - - ob1=gl_zalloc(sizeof(GLParamBuffer)); - ob1->next=NULL; - - ob->next=ob1; - ob->ops[index].op=OP_NextBuffer; - ob->ops[index+1].p=(void *)ob1; - - c->current_op_buffer=ob1; - ob=ob1; - index=0; - } - - for(i=0;iops[index]=p[i]; - index++; - } - c->current_op_buffer_index=index; -} - -void gl_add_op(GLParam *p) -{ - GLContext *c=gl_get_context(); - int op; - - op=p[0].op; - if (c->exec_flag) { - op_table_func[op](c,p); - } - if (c->compile_flag) { - gl_compile_op(c,p); - } - if (c->print_flag) { - gl_print_op(stderr,p); - } -} - -/* this opcode is never called directly */ -void glopEndList(GLContext *c,GLParam *p) -{ - assert(0); -} - -/* this opcode is never called directly */ -void glopNextBuffer(GLContext *c,GLParam *p) -{ - assert(0); -} - - -void glopCallList(GLContext *c,GLParam *p) -{ - GLList *l; - int list,op; - - list=p[1].ui; - l=find_list(c,list); - if (l == NULL) gl_fatal_error("list %d not defined",list); - p=l->first_op_buffer->ops; - - while (1) { - op=p[0].op; - if (op == OP_EndList) break; - if (op == OP_NextBuffer) { - p=(GLParam *)p[1].p; - } else { - op_table_func[op](c,p); - p+=op_table_size[op]; - } - } -} - - - -void glNewList(unsigned int list,int mode) -{ - GLList *l; - GLContext *c=gl_get_context(); - - assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE); - assert(c->compile_flag == 0); - - l=find_list(c,list); - if (l!=NULL) delete_list(c,list); - l=alloc_list(c,list); - - c->current_op_buffer=l->first_op_buffer; - c->current_op_buffer_index=0; - - c->compile_flag=1; - c->exec_flag=(mode == GL_COMPILE_AND_EXECUTE); -} - -void glEndList(void) -{ - GLContext *c=gl_get_context(); - GLParam p[1]; - - assert(c->compile_flag == 1); - - /* end of list */ - p[0].op=OP_EndList; - gl_compile_op(c,p); - - c->compile_flag=0; - c->exec_flag=1; -} - -int glIsList(unsigned int list) -{ - GLContext *c=gl_get_context(); - GLList *l; - l=find_list(c,list); - return (l != NULL); -} - -unsigned int glGenLists(int range) -{ - GLContext *c=gl_get_context(); - int count,i,list; - GLList **lists; - - lists=c->shared_state.lists; - count=0; - for(i=0;imatrix_model_projection_updated=(c->matrix_mode<=1); -} - - -void glopMatrixMode(GLContext *c,GLParam *p) -{ - int mode=p[1].i; - switch(mode) { - case GL_MODELVIEW: - c->matrix_mode=0; - break; - case GL_PROJECTION: - c->matrix_mode=1; - break; - case GL_TEXTURE: - c->matrix_mode=2; - break; - default: - assert(0); - } -} - -void glopLoadMatrix(GLContext *c,GLParam *p) -{ - M4 *m; - int i; - - GLParam *q; - - m=c->matrix_stack_ptr[c->matrix_mode]; - q=p+1; - - for(i=0;i<4;i++) { - m->m[0][i]=q[0].f; - m->m[1][i]=q[1].f; - m->m[2][i]=q[2].f; - m->m[3][i]=q[3].f; - q+=4; - } - - gl_matrix_update(c); -} - -void glopLoadIdentity(GLContext *c,GLParam *p) -{ - - gl_M4_Id(c->matrix_stack_ptr[c->matrix_mode]); - - gl_matrix_update(c); -} - -void glopMultMatrix(GLContext *c,GLParam *p) -{ - M4 m; - int i; - - GLParam *q; - q=p+1; - - for(i=0;i<4;i++) { - m.m[0][i]=q[0].f; - m.m[1][i]=q[1].f; - m.m[2][i]=q[2].f; - m.m[3][i]=q[3].f; - q+=4; - } - - gl_M4_MulLeft(c->matrix_stack_ptr[c->matrix_mode],&m); - - gl_matrix_update(c); -} - - -void glopPushMatrix(GLContext *c,GLParam *p) -{ - int n=c->matrix_mode; - M4 *m; - - assert( (c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1 ) - < c->matrix_stack_depth_max[n] ); - - m=++c->matrix_stack_ptr[n]; - - gl_M4_Move(&m[0],&m[-1]); - - gl_matrix_update(c); -} - -void glopPopMatrix(GLContext *c,GLParam *p) -{ - int n=c->matrix_mode; - - assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] ); - c->matrix_stack_ptr[n]--; - gl_matrix_update(c); -} - - -void glopRotate(GLContext *c,GLParam *p) -{ - M4 m; - float u[3]; - float angle; - int dir_code; - - angle = p[1].f * M_PI / 180.0; - u[0]=p[2].f; - u[1]=p[3].f; - u[2]=p[4].f; - - /* simple case detection */ - dir_code = ((u[0] != 0)<<2) | ((u[1] != 0)<<1) | (u[2] != 0); - - switch(dir_code) { - case 0: - gl_M4_Id(&m); - break; - case 4: - if (u[0] < 0) angle=-angle; - gl_M4_Rotate(&m,angle,0); - break; - case 2: - if (u[1] < 0) angle=-angle; - gl_M4_Rotate(&m,angle,1); - break; - case 1: - if (u[2] < 0) angle=-angle; - gl_M4_Rotate(&m,angle,2); - break; - default: - { - float cost, sint; - - /* normalize vector */ - float len = u[0]*u[0]+u[1]*u[1]+u[2]*u[2]; - if (len == 0.0f) return; - len = 1.0f / sqrt(len); - u[0] *= len; - u[1] *= len; - u[2] *= len; - - /* store cos and sin values */ - cost=cos(angle); - sint=sin(angle); - - /* fill in the values */ - m.m[3][0]=m.m[3][1]=m.m[3][2]= - m.m[0][3]=m.m[1][3]=m.m[2][3]=0.0f; - m.m[3][3]=1.0f; - - /* do the math */ - m.m[0][0]=u[0]*u[0]+cost*(1-u[0]*u[0]); - m.m[1][0]=u[0]*u[1]*(1-cost)-u[2]*sint; - m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint; - m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint; - m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]); - m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint; - m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint; - m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint; - m.m[2][2]=u[2]*u[2]+cost*(1-u[2]*u[2]); - } - } - - gl_M4_MulLeft(c->matrix_stack_ptr[c->matrix_mode],&m); - - gl_matrix_update(c); -} - -void glopScale(GLContext *c,GLParam *p) -{ - float *m; - float x=p[1].f,y=p[2].f,z=p[3].f; - - m=&c->matrix_stack_ptr[c->matrix_mode]->m[0][0]; - - m[0] *= x; m[1] *= y; m[2] *= z; - m[4] *= x; m[5] *= y; m[6] *= z; - m[8] *= x; m[9] *= y; m[10] *= z; - m[12] *= x; m[13] *= y; m[14] *= z; - gl_matrix_update(c); -} - -void glopTranslate(GLContext *c,GLParam *p) -{ - float *m; - float x=p[1].f,y=p[2].f,z=p[3].f; - - m=&c->matrix_stack_ptr[c->matrix_mode]->m[0][0]; - - m[3] = m[0] * x + m[1] * y + m[2] * z + m[3]; - m[7] = m[4] * x + m[5] * y + m[6] * z + m[7]; - m[11] = m[8] * x + m[9] * y + m[10] * z + m[11]; - m[15] = m[12] * x + m[13] * y + m[14] * z + m[15]; - - gl_matrix_update(c); -} - - -void glopFrustum(GLContext *c,GLParam *p) -{ - float *r; - M4 m; - float left=p[1].f; - float right=p[2].f; - float bottom=p[3].f; - float top=p[4].f; - float near=p[5].f; - float farp=p[6].f; - float x,y,A,B,C,D; - - x = (2.0*near) / (right-left); - y = (2.0*near) / (top-bottom); - A = (right+left) / (right-left); - B = (top+bottom) / (top-bottom); - C = -(farp+near) / ( farp-near); - D = -(2.0*farp*near) / (farp-near); - - r=&m.m[0][0]; - r[0]= x; r[1]=0; r[2]=A; r[3]=0; - r[4]= 0; r[5]=y; r[6]=B; r[7]=0; - r[8]= 0; r[9]=0; r[10]=C; r[11]=D; - r[12]= 0; r[13]=0; r[14]=-1; r[15]=0; - - gl_M4_MulLeft(c->matrix_stack_ptr[c->matrix_mode],&m); - - gl_matrix_update(c); -} - diff --git a/panda/src/tinydisplay/misc.c b/panda/src/tinydisplay/misc.c deleted file mode 100644 index 6b827712af..0000000000 --- a/panda/src/tinydisplay/misc.c +++ /dev/null @@ -1,147 +0,0 @@ -#include "zgl.h" -#include "msghandling.h" - -void glopViewport(GLContext *c,GLParam *p) -{ - int xsize,ysize,xmin,ymin,xsize_req,ysize_req; - - xmin=p[1].i; - ymin=p[2].i; - xsize=p[3].i; - ysize=p[4].i; - - /* we may need to resize the zbuffer */ - - if (c->viewport.xmin != xmin || - c->viewport.ymin != ymin || - c->viewport.xsize != xsize || - c->viewport.ysize != ysize) { - - xsize_req=xmin+xsize; - ysize_req=ymin+ysize; - - if (c->gl_resize_viewport && - c->gl_resize_viewport(c,&xsize_req,&ysize_req) != 0) { - gl_fatal_error("glViewport: error while resizing display"); - } - - xsize=xsize_req-xmin; - ysize=ysize_req-ymin; - if (xsize <= 0 || ysize <= 0) { - gl_fatal_error("glViewport: size too small"); - } - - tgl_trace("glViewport: %d %d %d %d\n", - xmin, ymin, xsize, ysize); - c->viewport.xmin=xmin; - c->viewport.ymin=ymin; - c->viewport.xsize=xsize; - c->viewport.ysize=ysize; - - c->viewport.updated=1; - } -} - -void glopEnableDisable(GLContext *c,GLParam *p) -{ - int code=p[1].i; - int v=p[2].i; - - switch(code) { - case GL_CULL_FACE: - c->cull_face_enabled=v; - break; - case GL_LIGHTING: - c->lighting_enabled=v; - break; - case GL_COLOR_MATERIAL: - c->color_material_enabled=v; - break; - case GL_TEXTURE_2D: - c->texture_2d_enabled=v; - break; - case GL_NORMALIZE: - c->normalize_enabled=v; - break; - case GL_DEPTH_TEST: - c->depth_test = v; - break; - case GL_POLYGON_OFFSET_FILL: - if (v) c->offset_states |= TGL_OFFSET_FILL; - else c->offset_states &= ~TGL_OFFSET_FILL; - break; - case GL_POLYGON_OFFSET_POINT: - if (v) c->offset_states |= TGL_OFFSET_POINT; - else c->offset_states &= ~TGL_OFFSET_POINT; - break; - case GL_POLYGON_OFFSET_LINE: - if (v) c->offset_states |= TGL_OFFSET_LINE; - else c->offset_states &= ~TGL_OFFSET_LINE; - break; - default: - if (code>=GL_LIGHT0 && codecurrent_shade_model=code; -} - -void glopCullFace(GLContext *c,GLParam *p) -{ - int code=p[1].i; - c->current_cull_face=code; -} - -void glopFrontFace(GLContext *c,GLParam *p) -{ - int code=p[1].i; - c->current_front_face=code; -} - -void glopPolygonMode(GLContext *c,GLParam *p) -{ - int face=p[1].i; - int mode=p[2].i; - - switch(face) { - case GL_BACK: - c->polygon_mode_back=mode; - break; - case GL_FRONT: - c->polygon_mode_front=mode; - break; - case GL_FRONT_AND_BACK: - c->polygon_mode_front=mode; - c->polygon_mode_back=mode; - break; - default: - assert(0); - } -} - -void glopHint(GLContext *c,GLParam *p) -{ -#if 0 - int target=p[1].i; - int mode=p[2].i; - - /* do nothing */ -#endif -} - -void -glopPolygonOffset(GLContext *c, GLParam *p) -{ - c->offset_factor = p[1].f; - c->offset_units = p[2].f; -} diff --git a/panda/src/tinydisplay/opinfo.h b/panda/src/tinydisplay/opinfo.h deleted file mode 100644 index 0b50312fe1..0000000000 --- a/panda/src/tinydisplay/opinfo.h +++ /dev/null @@ -1,65 +0,0 @@ - - -ADD_OP(Color,7,"%f %f %f %f %d %d %d") -ADD_OP(TexCoord,4,"%f %f %f %f") -ADD_OP(EdgeFlag,1,"%d") -ADD_OP(Normal,3,"%f %f %f") - -ADD_OP(Begin,1,"%C") -ADD_OP(Vertex,4,"%f %f %f %f") -ADD_OP(End,0,"") - -ADD_OP(EnableDisable,2,"%C %d") - -ADD_OP(MatrixMode,1,"%C") -ADD_OP(LoadMatrix,16,"") -ADD_OP(LoadIdentity,0,"") -ADD_OP(MultMatrix,16,"") -ADD_OP(PushMatrix,0,"") -ADD_OP(PopMatrix,0,"") -ADD_OP(Rotate,4,"%f %f %f %f") -ADD_OP(Translate,3,"%f %f %f") -ADD_OP(Scale,3,"%f %f %f") - -ADD_OP(Viewport,4,"%d %d %d %d") -ADD_OP(Frustum,6,"%f %f %f %f %f %f") - -ADD_OP(Material,6,"%C %C %f %f %f %f") -ADD_OP(ColorMaterial,2,"%C %C") -ADD_OP(Light,6,"%C %C %f %f %f %f") -ADD_OP(LightModel,5,"%C %f %f %f %f") - -ADD_OP(Clear,1,"%d") -ADD_OP(ClearColor,4,"%f %f %f %f") -ADD_OP(ClearDepth,1,"%f") - -ADD_OP(InitNames,0,"") -ADD_OP(PushName,1,"%d") -ADD_OP(PopName,0,"") -ADD_OP(LoadName,1,"%d") - -ADD_OP(ShadeModel,1,"%C") -ADD_OP(CullFace,1,"%C") -ADD_OP(FrontFace,1,"%C") -ADD_OP(PolygonMode,2,"%C %C") - -ADD_OP(CallList,1,"%d") -ADD_OP(Hint,2,"%C %C") - -/* special opcodes */ -ADD_OP(EndList,0,"") -ADD_OP(NextBuffer,1,"%p") - -/* opengl 1.1 arrays */ -ADD_OP(ArrayElement, 1, "%d") -ADD_OP(EnableClientState, 1, "%C") -ADD_OP(DisableClientState, 1, "%C") -ADD_OP(VertexPointer, 4, "%d %C %d %p") -ADD_OP(ColorPointer, 4, "%d %C %d %p") -ADD_OP(NormalPointer, 3, "%C %d %p") -ADD_OP(TexCoordPointer, 4, "%d %C %d %p") - -/* opengl 1.1 polygon offset */ -ADD_OP(PolygonOffset, 2, "%f %f") - -#undef ADD_OP diff --git a/panda/src/tinydisplay/oscontext.c b/panda/src/tinydisplay/oscontext.c deleted file mode 100644 index bc95709561..0000000000 --- a/panda/src/tinydisplay/oscontext.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "oscontext.h" -#include "zbuffer.h" -#include "zgl.h" -#include "tinygl.h" -#include -#include - -static int buffercnt = 0; - -ostgl_context * -ostgl_create_context(const int xsize, - const int ysize, - const int depth, - void **framebuffers, - const int numbuffers) -{ - ostgl_context *context; - int i; - ZBuffer *zb; - - assert(depth == 16); /* support for other depths must include bpp - convertion */ - assert(numbuffers >= 1); - - context = gl_malloc(sizeof(ostgl_context)); - assert(context); - context->zbs = gl_malloc(sizeof(void*)*numbuffers); - context->framebuffers = gl_malloc(sizeof(void*)*numbuffers); - - assert(context->zbs != NULL && context->framebuffers != NULL); - - for (i = 0; i < numbuffers; i++) { - context->framebuffers[i] = framebuffers[i]; - zb = ZB_open(xsize, ysize, ZB_MODE_5R6G5B, 0, NULL, NULL, framebuffers[i]); - if (zb == NULL) { - fprintf(stderr, "Error while initializing Z buffer\n"); - exit(1); - } - context->zbs[i] = zb; - } - if (++buffercnt == 1) { - glInit(context->zbs[0]); - } - context->xsize = xsize; - context->ysize = ysize; - context->numbuffers = numbuffers; - return context; -} - -void -ostgl_delete_context(ostgl_context *context) -{ - int i; - for (i = 0; i < context->numbuffers; i++) { - ZB_close(context->zbs[i]); - } - gl_free(context->zbs); - gl_free(context->framebuffers); - gl_free(context); - - if (--buffercnt == 0) { - glClose(); - } -} - -void -ostgl_make_current(ostgl_context *oscontext, const int idx) -{ - GLContext *context = gl_get_context(); - assert(idx < oscontext->numbuffers); - context->zb = oscontext->zbs[idx]; -} - -void -ostgl_resize(ostgl_context *context, - const int xsize, - const int ysize, - void **framebuffers) -{ - int i; - for (i = 0; i < context->numbuffers; i++) { - ZB_resize(context->zbs[i], framebuffers[i], xsize, ysize); - } -} diff --git a/panda/src/tinydisplay/oscontext.h b/panda/src/tinydisplay/oscontext.h deleted file mode 100644 index a044f22586..0000000000 --- a/panda/src/tinydisplay/oscontext.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _tgl_osbuffer_h_ -#define _tgl_osbuffer_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - void **zbs; - void **framebuffers; - int numbuffers; - int xsize, ysize; -} ostgl_context; - -ostgl_context * -ostgl_create_context(const int xsize, - const int ysize, - const int depth, - void **framebuffers, - const int numbuffers); -void -ostgl_delete_context(ostgl_context *context); - -void -ostgl_make_current(ostgl_context *context, const int index); - -void -ostgl_resize(ostgl_context * context, - const int xsize, - const int ysize, - void **framebuffers); - -#ifdef __cplusplus -} -#endif - -#endif /* _tgl_osbuffer_h_ */ diff --git a/panda/src/tinydisplay/select.c b/panda/src/tinydisplay/select.c deleted file mode 100644 index bf416eec16..0000000000 --- a/panda/src/tinydisplay/select.c +++ /dev/null @@ -1,114 +0,0 @@ -#include "zgl.h" - -int glRenderMode(int mode) -{ - GLContext *c=gl_get_context(); - int result=0; - - switch(c->render_mode) { - case GL_RENDER: - break; - case GL_SELECT: - if (c->select_overflow) { - result=-c->select_hits; - } else { - result=c->select_hits; - } - c->select_overflow=0; - c->select_ptr=c->select_buffer; - c->name_stack_size=0; - break; - default: - assert(0); - } - switch(mode) { - case GL_RENDER: - c->render_mode=GL_RENDER; - break; - case GL_SELECT: - c->render_mode=GL_SELECT; - assert( c->select_buffer != NULL); - c->select_ptr=c->select_buffer; - c->select_hits=0; - c->select_overflow=0; - c->select_hit=NULL; - break; - default: - assert(0); - } - return result; -} - -void glSelectBuffer(int size,unsigned int *buf) -{ - GLContext *c=gl_get_context(); - - assert(c->render_mode != GL_SELECT); - - c->select_buffer=buf; - c->select_size=size; -} - - -void glopInitNames(GLContext *c,GLParam *p) -{ - if (c->render_mode == GL_SELECT) { - c->name_stack_size=0; - c->select_hit=NULL; - } -} - -void glopPushName(GLContext *c,GLParam *p) -{ - if (c->render_mode == GL_SELECT) { - assert(c->name_stack_sizename_stack[c->name_stack_size++]=p[1].i; - c->select_hit=NULL; - } -} - -void glopPopName(GLContext *c,GLParam *p) -{ - if (c->render_mode == GL_SELECT) { - assert(c->name_stack_size>0); - c->name_stack_size--; - c->select_hit=NULL; - } -} - -void glopLoadName(GLContext *c,GLParam *p) -{ - if (c->render_mode == GL_SELECT) { - assert(c->name_stack_size>0); - c->name_stack[c->name_stack_size-1]=p[1].i; - c->select_hit=NULL; - } -} - -void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax) -{ - unsigned int *ptr; - int n,i; - - if (!c->select_overflow) { - if (c->select_hit==NULL) { - n=c->name_stack_size; - if ((c->select_ptr-c->select_buffer+3+n) > - c->select_size) { - c->select_overflow=1; - } else { - ptr=c->select_ptr; - c->select_hit=ptr; - *ptr++=c->name_stack_size; - *ptr++=zmin; - *ptr++=zmax; - for(i=0;iname_stack[i]; - c->select_ptr=ptr; - c->select_hits++; - } - } else { - if (zminselect_hit[1]) c->select_hit[1]=zmin; - if (zmax>c->select_hit[2]) c->select_hit[2]=zmax; - } - } -} diff --git a/panda/src/tinydisplay/specbuf.h b/panda/src/tinydisplay/specbuf.h deleted file mode 100644 index ae5da3f877..0000000000 --- a/panda/src/tinydisplay/specbuf.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _tgl_specbuf_h_ -#define _tgl_specbuf_h_ - -/* Max # of specular light pow buffers */ -#define MAX_SPECULAR_BUFFERS 8 -/* # of entries in specular buffer */ -#define SPECULAR_BUFFER_SIZE 1024 -/* specular buffer granularity */ -#define SPECULAR_BUFFER_RESOLUTION 1024 - -typedef struct GLSpecBuf { - int shininess_i; - int last_used; - float buf[SPECULAR_BUFFER_SIZE+1]; - struct GLSpecBuf *next; -} GLSpecBuf; - -GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, - const float shininess); -void specbuf_cleanup(GLContext *c); /* free all memory used */ - -#endif /* _tgl_specbuf_h_ */ \ No newline at end of file diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I index 553e03de64..ab6f5b48e1 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I @@ -16,13 +16,3 @@ // //////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::get_light_id -// Access: Private, Static -// Description: Convert index to gl light id -//////////////////////////////////////////////////////////////////// -INLINE GLenum TinyGraphicsStateGuardian:: -get_light_id(int index) { - return GL_LIGHT0 + index; -} diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 4d53bec96f..2461787d4e 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -496,67 +496,6 @@ static const ZB_fillTriangleFunc fill_tri_funcs }, }; -static inline void tgl_vertex_transform(GLContext * c, GLVertex * v) -{ - float *m; - V4 *n; - - if (c->lighting_enabled) { - /* eye coordinates needed for lighting */ - - m = &c->matrix_stack_ptr[0]->m[0][0]; - v->ec.X = (v->coord.X * m[0] + v->coord.Y * m[1] + - v->coord.Z * m[2] + m[3]); - v->ec.Y = (v->coord.X * m[4] + v->coord.Y * m[5] + - v->coord.Z * m[6] + m[7]); - v->ec.Z = (v->coord.X * m[8] + v->coord.Y * m[9] + - v->coord.Z * m[10] + m[11]); - v->ec.W = (v->coord.X * m[12] + v->coord.Y * m[13] + - v->coord.Z * m[14] + m[15]); - - /* projection coordinates */ - m = &c->matrix_stack_ptr[1]->m[0][0]; - v->pc.X = (v->ec.X * m[0] + v->ec.Y * m[1] + - v->ec.Z * m[2] + v->ec.W * m[3]); - v->pc.Y = (v->ec.X * m[4] + v->ec.Y * m[5] + - v->ec.Z * m[6] + v->ec.W * m[7]); - v->pc.Z = (v->ec.X * m[8] + v->ec.Y * m[9] + - v->ec.Z * m[10] + v->ec.W * m[11]); - v->pc.W = (v->ec.X * m[12] + v->ec.Y * m[13] + - v->ec.Z * m[14] + v->ec.W * m[15]); - - m = &c->matrix_model_view_inv.m[0][0]; - n = &c->current_normal; - - v->normal.X = (n->X * m[0] + n->Y * m[1] + n->Z * m[2]); - v->normal.Y = (n->X * m[4] + n->Y * m[5] + n->Z * m[6]); - v->normal.Z = (n->X * m[8] + n->Y * m[9] + n->Z * m[10]); - - if (c->normalize_enabled) { - gl_V3_Norm(&v->normal); - } - } else { - /* no eye coordinates needed, no normal */ - /* NOTE: W = 1 is assumed */ - m = &c->matrix_model_projection.m[0][0]; - - v->pc.X = (v->coord.X * m[0] + v->coord.Y * m[1] + - v->coord.Z * m[2] + m[3]); - v->pc.Y = (v->coord.X * m[4] + v->coord.Y * m[5] + - v->coord.Z * m[6] + m[7]); - v->pc.Z = (v->coord.X * m[8] + v->coord.Y * m[9] + - v->coord.Z * m[10] + m[11]); - if (c->matrix_model_projection_no_w_transform) { - v->pc.W = m[15]; - } else { - v->pc.W = (v->coord.X * m[12] + v->coord.Y * m[13] + - v->coord.Z * m[14] + m[15]); - } - } - - v->clip_code = gl_clipcode(v->pc.X, v->pc.Y, v->pc.Z, v->pc.W); -} - //////////////////////////////////////////////////////////////////// // Function: TinyGraphicsStateGuardian::Constructor // Access: Public @@ -592,9 +531,13 @@ reset() { free_pointers(); GraphicsStateGuardian::reset(); - glInit(_current_frame_buffer); + if (_c != (GLContext *)NULL) { + glClose(_c); + _c = NULL; + } - _c = gl_get_context(); + _c = (GLContext *)gl_zalloc(sizeof(GLContext)); + glInit(_c, _current_frame_buffer); _c->draw_triangle_front = gl_draw_triangle_fill; _c->draw_triangle_back = gl_draw_triangle_fill; @@ -631,6 +574,24 @@ free_pointers() { _vertices_size = 0; } +//////////////////////////////////////////////////////////////////// +// Function: TinyGraphicsStateGuardian::close_gsg +// Access: Protected, Virtual +// Description: This is called by the associated GraphicsWindow when +// close_window() is called. It should null out the +// _win pointer and possibly free any open resources +// associated with the GSG. +//////////////////////////////////////////////////////////////////// +void TinyGraphicsStateGuardian:: +close_gsg() { + GraphicsStateGuardian::close_gsg(); + + if (_c != (GLContext *)NULL) { + glClose(_c); + _c = NULL; + } +} + //////////////////////////////////////////////////////////////////// // Function: TinyGraphicsStateGuardian::depth_offset_decals // Access: Public, Virtual @@ -899,8 +860,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // coordinates, wipe out the current projection and modelview // matrix (so we don't attempt to transform it again). const TransformState *ident = TransformState::make_identity(); - load_matrix(_c->matrix_stack_ptr[0], ident); - load_matrix(_c->matrix_stack_ptr[1], ident); + load_matrix(&_c->matrix_model_view, ident); + load_matrix(&_c->matrix_projection, ident); load_matrix(&_c->matrix_model_view_inv, ident); load_matrix(&_c->matrix_model_projection, ident); _c->matrix_model_projection_no_w_transform = 1; @@ -913,12 +874,12 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // With the lighting equation, we need to keep the modelview and // projection matrices separate. - load_matrix(_c->matrix_stack_ptr[0], _internal_transform); - load_matrix(_c->matrix_stack_ptr[1], _projection_mat); + load_matrix(&_c->matrix_model_view, _internal_transform); + load_matrix(&_c->matrix_projection, _projection_mat); /* precompute inverse modelview */ M4 tmp; - gl_M4_Inv(&tmp, _c->matrix_stack_ptr[0]); + gl_M4_Inv(&tmp, &_c->matrix_model_view); gl_M4_Transpose(&_c->matrix_model_view_inv, &tmp); } @@ -935,9 +896,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } _transform_stale = false; } - - /* test if the texture matrix is not Identity */ - // _c->apply_texture_matrix = !gl_M4_IsId(_c->matrix_stack_ptr[2]); // Figure out the subset of vertices we will be using in this // operation. @@ -1089,7 +1047,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, _c->current_normal.W = 0.0f; } - tgl_vertex_transform(_c, v); + gl_vertex_transform(_c, v); if (_c->lighting_enabled) { gl_shade_vertex(_c, v); @@ -1164,7 +1122,10 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, shade_model = ShadeModelAttrib::M_flat; } int shading_state = 2; // smooth + _c->smooth_shade_model = true; + if (shade_model == ShadeModelAttrib::M_flat) { + _c->smooth_shade_model = false; shading_state = 1; // flat if (_c->current_color.X == 1.0f && _c->current_color.Y == 1.0f && @@ -1953,11 +1914,11 @@ do_issue_cull_face() { break; case CullFaceAttrib::M_cull_clockwise: _c->cull_face_enabled = true; - _c->current_cull_face = GL_BACK; + _c->cull_clockwise = true; break; case CullFaceAttrib::M_cull_counter_clockwise: _c->cull_face_enabled = true; - _c->current_cull_face = GL_FRONT; + _c->cull_clockwise = false; break; default: tinydisplay_cat.error() diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h index 0d8460c69e..460990e097 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h @@ -23,7 +23,6 @@ #include "graphicsStateGuardian.h" #include "tinySDLGraphicsPipe.h" -#include "tinygl.h" extern "C" { #include "zmath.h" @@ -50,6 +49,7 @@ public: virtual void reset(); virtual void free_pointers(); + virtual void close_gsg(); virtual bool depth_offset_decals(); @@ -121,8 +121,6 @@ private: void setup_material(GLMaterial *gl_material, const Material *material); static void load_matrix(M4 *matrix, const TransformState *transform); - INLINE static GLenum get_light_id(int index); - public: // Filled in by the Tiny*GraphicsWindow at begin_frame(). ZBuffer *_current_frame_buffer; diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index 95da2dcda7..182253cdbc 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -23,7 +23,6 @@ #include "mouseButton.h" #include "keyboardButton.h" #include "graphicsPipe.h" -#include "tinygl.h" TypeHandle TinySDLGraphicsWindow::_type_handle; @@ -253,7 +252,6 @@ set_properties_now(WindowProperties &properties) { //////////////////////////////////////////////////////////////////// void TinySDLGraphicsWindow:: close_window() { - glClose(); GraphicsWindow::close_window(); } diff --git a/panda/src/tinydisplay/tinyTextureContext.h b/panda/src/tinydisplay/tinyTextureContext.h index b4a68493bc..37bb48a2f7 100644 --- a/panda/src/tinydisplay/tinyTextureContext.h +++ b/panda/src/tinydisplay/tinyTextureContext.h @@ -22,7 +22,6 @@ #include "pandabase.h" #include "textureContext.h" #include "deletedChain.h" -#include "tinygl.h" struct GLTexture; diff --git a/panda/src/tinydisplay/tinygl.h b/panda/src/tinydisplay/tinygl.h deleted file mode 100644 index 24035047ad..0000000000 --- a/panda/src/tinydisplay/tinygl.h +++ /dev/null @@ -1,838 +0,0 @@ -/* - * The following constants come from Mesa - */ -#ifndef GL_H -#define GL_H - -#define GL_VERSION_1_1 1 - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - /* Boolean values */ - GL_FALSE = 0, - GL_TRUE = 1, - - /* Data types */ - GL_BYTE = 0x1400, - GL_UNSIGNED_BYTE = 0x1401, - GL_SHORT = 0x1402, - GL_UNSIGNED_SHORT = 0x1403, - GL_INT = 0x1404, - GL_UNSIGNED_INT = 0x1405, - GL_FLOAT = 0x1406, - GL_DOUBLE = 0x140A, - GL_2_BYTES = 0x1407, - GL_3_BYTES = 0x1408, - GL_4_BYTES = 0x1409, - - /* Primitives */ - GL_LINES = 0x0001, - GL_POINTS = 0x0000, - GL_LINE_STRIP = 0x0003, - GL_LINE_LOOP = 0x0002, - GL_TRIANGLES = 0x0004, - GL_TRIANGLE_STRIP = 0x0005, - GL_TRIANGLE_FAN = 0x0006, - GL_QUADS = 0x0007, - GL_QUAD_STRIP = 0x0008, - GL_POLYGON = 0x0009, - GL_EDGE_FLAG = 0x0B43, - - /* Vertex Arrays */ - GL_VERTEX_ARRAY = 0x8074, - GL_NORMAL_ARRAY = 0x8075, - GL_COLOR_ARRAY = 0x8076, - GL_INDEX_ARRAY = 0x8077, - GL_TEXTURE_COORD_ARRAY = 0x8078, - GL_EDGE_FLAG_ARRAY = 0x8079, - GL_VERTEX_ARRAY_SIZE = 0x807A, - GL_VERTEX_ARRAY_TYPE = 0x807B, - GL_VERTEX_ARRAY_STRIDE = 0x807C, - GL_VERTEX_ARRAY_COUNT = 0x807D, - GL_NORMAL_ARRAY_TYPE = 0x807E, - GL_NORMAL_ARRAY_STRIDE = 0x807F, - GL_NORMAL_ARRAY_COUNT = 0x8080, - GL_COLOR_ARRAY_SIZE = 0x8081, - GL_COLOR_ARRAY_TYPE = 0x8082, - GL_COLOR_ARRAY_STRIDE = 0x8083, - GL_COLOR_ARRAY_COUNT = 0x8084, - GL_INDEX_ARRAY_TYPE = 0x8085, - GL_INDEX_ARRAY_STRIDE = 0x8086, - GL_INDEX_ARRAY_COUNT = 0x8087, - GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088, - GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089, - GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A, - GL_TEXTURE_COORD_ARRAY_COUNT = 0x808B, - GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C, - GL_EDGE_FLAG_ARRAY_COUNT = 0x808D, - GL_VERTEX_ARRAY_POINTER = 0x808E, - GL_NORMAL_ARRAY_POINTER = 0x808F, - GL_COLOR_ARRAY_POINTER = 0x8090, - GL_INDEX_ARRAY_POINTER = 0x8091, - GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092, - GL_EDGE_FLAG_ARRAY_POINTER = 0x8093, - GL_V2F = 0x2A20, - GL_V3F = 0x2A21, - GL_C4UB_V2F = 0x2A22, - GL_C4UB_V3F = 0x2A23, - GL_C3F_V3F = 0x2A24, - GL_N3F_V3F = 0x2A25, - GL_C4F_N3F_V3F = 0x2A26, - GL_T2F_V3F = 0x2A27, - GL_T4F_V4F = 0x2A28, - GL_T2F_C4UB_V3F = 0x2A29, - GL_T2F_C3F_V3F = 0x2A2A, - GL_T2F_N3F_V3F = 0x2A2B, - GL_T2F_C4F_N3F_V3F = 0x2A2C, - GL_T4F_C4F_N3F_V4F = 0x2A2D, - - /* Matrix Mode */ - GL_MATRIX_MODE = 0x0BA0, - GL_MODELVIEW = 0x1700, - GL_PROJECTION = 0x1701, - GL_TEXTURE = 0x1702, - - /* Points */ - GL_POINT_SMOOTH = 0x0B10, - GL_POINT_SIZE = 0x0B11, - GL_POINT_SIZE_GRANULARITY = 0x0B13, - GL_POINT_SIZE_RANGE = 0x0B12, - - /* Lines */ - GL_LINE_SMOOTH = 0x0B20, - GL_LINE_STIPPLE = 0x0B24, - GL_LINE_STIPPLE_PATTERN = 0x0B25, - GL_LINE_STIPPLE_REPEAT = 0x0B26, - GL_LINE_WIDTH = 0x0B21, - GL_LINE_WIDTH_GRANULARITY = 0x0B23, - GL_LINE_WIDTH_RANGE = 0x0B22, - - /* Polygons */ - GL_POINT = 0x1B00, - GL_LINE = 0x1B01, - GL_FILL = 0x1B02, - GL_CCW = 0x0901, - GL_CW = 0x0900, - GL_FRONT = 0x0404, - GL_BACK = 0x0405, - GL_CULL_FACE = 0x0B44, - GL_CULL_FACE_MODE = 0x0B45, - GL_POLYGON_SMOOTH = 0x0B41, - GL_POLYGON_STIPPLE = 0x0B42, - GL_FRONT_FACE = 0x0B46, - GL_POLYGON_MODE = 0x0B40, - GL_POLYGON_OFFSET_FACTOR = 0x3038, - GL_POLYGON_OFFSET_UNITS = 0x2A00, - GL_POLYGON_OFFSET_POINT = 0x2A01, - GL_POLYGON_OFFSET_LINE = 0x2A02, - GL_POLYGON_OFFSET_FILL = 0x8037, - - /* Display Lists */ - GL_COMPILE = 0x1300, - GL_COMPILE_AND_EXECUTE = 0x1301, - GL_LIST_BASE = 0x0B32, - GL_LIST_INDEX = 0x0B33, - GL_LIST_MODE = 0x0B30, - - /* Depth buffer */ - GL_NEVER = 0x0200, - GL_LESS = 0x0201, - GL_GEQUAL = 0x0206, - GL_LEQUAL = 0x0203, - GL_GREATER = 0x0204, - GL_NOTEQUAL = 0x0205, - GL_EQUAL = 0x0202, - GL_ALWAYS = 0x0207, - GL_DEPTH_TEST = 0x0B71, - GL_DEPTH_BITS = 0x0D56, - GL_DEPTH_CLEAR_VALUE = 0x0B73, - GL_DEPTH_FUNC = 0x0B74, - GL_DEPTH_RANGE = 0x0B70, - GL_DEPTH_WRITEMASK = 0x0B72, - GL_DEPTH_COMPONENT = 0x1902, - - /* Lighting */ - GL_LIGHTING = 0x0B50, - GL_LIGHT0 = 0x4000, - GL_LIGHT1 = 0x4001, - GL_LIGHT2 = 0x4002, - GL_LIGHT3 = 0x4003, - GL_LIGHT4 = 0x4004, - GL_LIGHT5 = 0x4005, - GL_LIGHT6 = 0x4006, - GL_LIGHT7 = 0x4007, - GL_SPOT_EXPONENT = 0x1205, - GL_SPOT_CUTOFF = 0x1206, - GL_CONSTANT_ATTENUATION = 0x1207, - GL_LINEAR_ATTENUATION = 0x1208, - GL_QUADRATIC_ATTENUATION = 0x1209, - GL_AMBIENT = 0x1200, - GL_DIFFUSE = 0x1201, - GL_SPECULAR = 0x1202, - GL_SHININESS = 0x1601, - GL_EMISSION = 0x1600, - GL_POSITION = 0x1203, - GL_SPOT_DIRECTION = 0x1204, - GL_AMBIENT_AND_DIFFUSE = 0x1602, - GL_COLOR_INDEXES = 0x1603, - GL_LIGHT_MODEL_TWO_SIDE = 0x0B52, - GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51, - GL_LIGHT_MODEL_AMBIENT = 0x0B53, - GL_FRONT_AND_BACK = 0x0408, - GL_SHADE_MODEL = 0x0B54, - GL_FLAT = 0x1D00, - GL_SMOOTH = 0x1D01, - GL_COLOR_MATERIAL = 0x0B57, - GL_COLOR_MATERIAL_FACE = 0x0B55, - GL_COLOR_MATERIAL_PARAMETER = 0x0B56, - GL_NORMALIZE = 0x0BA1, - - /* User clipping planes */ - GL_CLIP_PLANE0 = 0x3000, - GL_CLIP_PLANE1 = 0x3001, - GL_CLIP_PLANE2 = 0x3002, - GL_CLIP_PLANE3 = 0x3003, - GL_CLIP_PLANE4 = 0x3004, - GL_CLIP_PLANE5 = 0x3005, - - /* Accumulation buffer */ - GL_ACCUM_RED_BITS = 0x0D58, - GL_ACCUM_GREEN_BITS = 0x0D59, - GL_ACCUM_BLUE_BITS = 0x0D5A, - GL_ACCUM_ALPHA_BITS = 0x0D5B, - GL_ACCUM_CLEAR_VALUE = 0x0B80, - GL_ACCUM = 0x0100, - GL_ADD = 0x0104, - GL_LOAD = 0x0101, - GL_MULT = 0x0103, - GL_RETURN = 0x0102, - - /* Alpha testing */ - GL_ALPHA_TEST = 0x0BC0, - GL_ALPHA_TEST_REF = 0x0BC2, - GL_ALPHA_TEST_FUNC = 0x0BC1, - - /* Blending */ - GL_BLEND = 0x0BE2, - GL_BLEND_SRC = 0x0BE1, - GL_BLEND_DST = 0x0BE0, - GL_ZERO = 0, - GL_ONE = 1, - GL_SRC_COLOR = 0x0300, - GL_ONE_MINUS_SRC_COLOR = 0x0301, - GL_DST_COLOR = 0x0306, - GL_ONE_MINUS_DST_COLOR = 0x0307, - GL_SRC_ALPHA = 0x0302, - GL_ONE_MINUS_SRC_ALPHA = 0x0303, - GL_DST_ALPHA = 0x0304, - GL_ONE_MINUS_DST_ALPHA = 0x0305, - GL_SRC_ALPHA_SATURATE = 0x0308, - GL_CONSTANT_COLOR = 0x8001, - GL_ONE_MINUS_CONSTANT_COLOR = 0x8002, - GL_CONSTANT_ALPHA = 0x8003, - GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004, - - /* Render Mode */ - GL_FEEDBACK = 0x1C01, - GL_RENDER = 0x1C00, - GL_SELECT = 0x1C02, - - /* Feedback */ - GL_2D = 0x0600, - GL_3D = 0x0601, - GL_3D_COLOR = 0x0602, - GL_3D_COLOR_TEXTURE = 0x0603, - GL_4D_COLOR_TEXTURE = 0x0604, - GL_POINT_TOKEN = 0x0701, - GL_LINE_TOKEN = 0x0702, - GL_LINE_RESET_TOKEN = 0x0707, - GL_POLYGON_TOKEN = 0x0703, - GL_BITMAP_TOKEN = 0x0704, - GL_DRAW_PIXEL_TOKEN = 0x0705, - GL_COPY_PIXEL_TOKEN = 0x0706, - GL_PASS_THROUGH_TOKEN = 0x0700, - - /* Fog */ - GL_FOG = 0x0B60, - GL_FOG_MODE = 0x0B65, - GL_FOG_DENSITY = 0x0B62, - GL_FOG_COLOR = 0x0B66, - GL_FOG_INDEX = 0x0B61, - GL_FOG_START = 0x0B63, - GL_FOG_END = 0x0B64, - GL_LINEAR = 0x2601, - GL_EXP = 0x0800, - GL_EXP2 = 0x0801, - - /* Logic Ops */ - GL_LOGIC_OP = 0x0BF1, - GL_LOGIC_OP_MODE = 0x0BF0, - GL_CLEAR = 0x1500, - GL_SET = 0x150F, - GL_COPY = 0x1503, - GL_COPY_INVERTED = 0x150C, - GL_NOOP = 0x1505, - GL_INVERT = 0x150A, - GL_AND = 0x1501, - GL_NAND = 0x150E, - GL_OR = 0x1507, - GL_NOR = 0x1508, - GL_XOR = 0x1506, - GL_EQUIV = 0x1509, - GL_AND_REVERSE = 0x1502, - GL_AND_INVERTED = 0x1504, - GL_OR_REVERSE = 0x150B, - GL_OR_INVERTED = 0x150D, - - /* Stencil */ - GL_STENCIL_TEST = 0x0B90, - GL_STENCIL_WRITEMASK = 0x0B98, - GL_STENCIL_BITS = 0x0D57, - GL_STENCIL_FUNC = 0x0B92, - GL_STENCIL_VALUE_MASK = 0x0B93, - GL_STENCIL_REF = 0x0B97, - GL_STENCIL_FAIL = 0x0B94, - GL_STENCIL_PASS_DEPTH_PASS = 0x0B96, - GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95, - GL_STENCIL_CLEAR_VALUE = 0x0B91, - GL_STENCIL_INDEX = 0x1901, - GL_KEEP = 0x1E00, - GL_REPLACE = 0x1E01, - GL_INCR = 0x1E02, - GL_DECR = 0x1E03, - - /* Buffers, Pixel Drawing/Reading */ - GL_NONE = 0, - GL_LEFT = 0x0406, - GL_RIGHT = 0x0407, - /*GL_FRONT = 0x0404, */ - /*GL_BACK = 0x0405, */ - /*GL_FRONT_AND_BACK = 0x0408, */ - GL_FRONT_LEFT = 0x0400, - GL_FRONT_RIGHT = 0x0401, - GL_BACK_LEFT = 0x0402, - GL_BACK_RIGHT = 0x0403, - GL_AUX0 = 0x0409, - GL_AUX1 = 0x040A, - GL_AUX2 = 0x040B, - GL_AUX3 = 0x040C, - GL_COLOR_INDEX = 0x1900, - GL_RED = 0x1903, - GL_GREEN = 0x1904, - GL_BLUE = 0x1905, - GL_ALPHA = 0x1906, - GL_LUMINANCE = 0x1909, - GL_LUMINANCE_ALPHA = 0x190A, - GL_ALPHA_BITS = 0x0D55, - GL_RED_BITS = 0x0D52, - GL_GREEN_BITS = 0x0D53, - GL_BLUE_BITS = 0x0D54, - GL_INDEX_BITS = 0x0D51, - GL_SUBPIXEL_BITS = 0x0D50, - GL_AUX_BUFFERS = 0x0C00, - GL_READ_BUFFER = 0x0C02, - GL_DRAW_BUFFER = 0x0C01, - GL_DOUBLEBUFFER = 0x0C32, - GL_STEREO = 0x0C33, - GL_BITMAP = 0x1A00, - GL_COLOR = 0x1800, - GL_DEPTH = 0x1801, - GL_STENCIL = 0x1802, - GL_DITHER = 0x0BD0, - GL_RGB = 0x1907, - GL_RGBA = 0x1908, - - /* Implementation limits */ - GL_MAX_LIST_NESTING = 0x0B31, - GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35, - GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36, - GL_MAX_NAME_STACK_DEPTH = 0x0D37, - GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38, - GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39, - GL_MAX_EVAL_ORDER = 0x0D30, - GL_MAX_LIGHTS = 0x0D31, - GL_MAX_CLIP_PLANES = 0x0D32, - GL_MAX_TEXTURE_SIZE = 0x0D33, - GL_MAX_PIXEL_MAP_TABLE = 0x0D34, - GL_MAX_VIEWPORT_DIMS = 0x0D3A, - GL_MAX_CLIENT_ATTRIB_STACK_DEPTH= 0x0D3B, - - /* Gets */ - GL_ATTRIB_STACK_DEPTH = 0x0BB0, - GL_COLOR_CLEAR_VALUE = 0x0C22, - GL_COLOR_WRITEMASK = 0x0C23, - GL_CURRENT_INDEX = 0x0B01, - GL_CURRENT_COLOR = 0x0B00, - GL_CURRENT_NORMAL = 0x0B02, - GL_CURRENT_RASTER_COLOR = 0x0B04, - GL_CURRENT_RASTER_DISTANCE = 0x0B09, - GL_CURRENT_RASTER_INDEX = 0x0B05, - GL_CURRENT_RASTER_POSITION = 0x0B07, - GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06, - GL_CURRENT_RASTER_POSITION_VALID = 0x0B08, - GL_CURRENT_TEXTURE_COORDS = 0x0B03, - GL_INDEX_CLEAR_VALUE = 0x0C20, - GL_INDEX_MODE = 0x0C30, - GL_INDEX_WRITEMASK = 0x0C21, - GL_MODELVIEW_MATRIX = 0x0BA6, - GL_MODELVIEW_STACK_DEPTH = 0x0BA3, - GL_NAME_STACK_DEPTH = 0x0D70, - GL_PROJECTION_MATRIX = 0x0BA7, - GL_PROJECTION_STACK_DEPTH = 0x0BA4, - GL_RENDER_MODE = 0x0C40, - GL_RGBA_MODE = 0x0C31, - GL_TEXTURE_MATRIX = 0x0BA8, - GL_TEXTURE_STACK_DEPTH = 0x0BA5, - GL_VIEWPORT = 0x0BA2, - - - /* Evaluators */ - GL_AUTO_NORMAL = 0x0D80, - GL_MAP1_COLOR_4 = 0x0D90, - GL_MAP1_GRID_DOMAIN = 0x0DD0, - GL_MAP1_GRID_SEGMENTS = 0x0DD1, - GL_MAP1_INDEX = 0x0D91, - GL_MAP1_NORMAL = 0x0D92, - GL_MAP1_TEXTURE_COORD_1 = 0x0D93, - GL_MAP1_TEXTURE_COORD_2 = 0x0D94, - GL_MAP1_TEXTURE_COORD_3 = 0x0D95, - GL_MAP1_TEXTURE_COORD_4 = 0x0D96, - GL_MAP1_VERTEX_3 = 0x0D97, - GL_MAP1_VERTEX_4 = 0x0D98, - GL_MAP2_COLOR_4 = 0x0DB0, - GL_MAP2_GRID_DOMAIN = 0x0DD2, - GL_MAP2_GRID_SEGMENTS = 0x0DD3, - GL_MAP2_INDEX = 0x0DB1, - GL_MAP2_NORMAL = 0x0DB2, - GL_MAP2_TEXTURE_COORD_1 = 0x0DB3, - GL_MAP2_TEXTURE_COORD_2 = 0x0DB4, - GL_MAP2_TEXTURE_COORD_3 = 0x0DB5, - GL_MAP2_TEXTURE_COORD_4 = 0x0DB6, - GL_MAP2_VERTEX_3 = 0x0DB7, - GL_MAP2_VERTEX_4 = 0x0DB8, - GL_COEFF = 0x0A00, - GL_DOMAIN = 0x0A02, - GL_ORDER = 0x0A01, - - /* Hints */ - GL_FOG_HINT = 0x0C54, - GL_LINE_SMOOTH_HINT = 0x0C52, - GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50, - GL_POINT_SMOOTH_HINT = 0x0C51, - GL_POLYGON_SMOOTH_HINT = 0x0C53, - GL_DONT_CARE = 0x1100, - GL_FASTEST = 0x1101, - GL_NICEST = 0x1102, - - /* Scissor box */ - GL_SCISSOR_TEST = 0x0C11, - GL_SCISSOR_BOX = 0x0C10, - - /* Pixel Mode / Transfer */ - GL_MAP_COLOR = 0x0D10, - GL_MAP_STENCIL = 0x0D11, - GL_INDEX_SHIFT = 0x0D12, - GL_INDEX_OFFSET = 0x0D13, - GL_RED_SCALE = 0x0D14, - GL_RED_BIAS = 0x0D15, - GL_GREEN_SCALE = 0x0D18, - GL_GREEN_BIAS = 0x0D19, - GL_BLUE_SCALE = 0x0D1A, - GL_BLUE_BIAS = 0x0D1B, - GL_ALPHA_SCALE = 0x0D1C, - GL_ALPHA_BIAS = 0x0D1D, - GL_DEPTH_SCALE = 0x0D1E, - GL_DEPTH_BIAS = 0x0D1F, - GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1, - GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0, - GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2, - GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3, - GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4, - GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5, - GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6, - GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7, - GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8, - GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9, - GL_PIXEL_MAP_S_TO_S = 0x0C71, - GL_PIXEL_MAP_I_TO_I = 0x0C70, - GL_PIXEL_MAP_I_TO_R = 0x0C72, - GL_PIXEL_MAP_I_TO_G = 0x0C73, - GL_PIXEL_MAP_I_TO_B = 0x0C74, - GL_PIXEL_MAP_I_TO_A = 0x0C75, - GL_PIXEL_MAP_R_TO_R = 0x0C76, - GL_PIXEL_MAP_G_TO_G = 0x0C77, - GL_PIXEL_MAP_B_TO_B = 0x0C78, - GL_PIXEL_MAP_A_TO_A = 0x0C79, - GL_PACK_ALIGNMENT = 0x0D05, - GL_PACK_LSB_FIRST = 0x0D01, - GL_PACK_ROW_LENGTH = 0x0D02, - GL_PACK_SKIP_PIXELS = 0x0D04, - GL_PACK_SKIP_ROWS = 0x0D03, - GL_PACK_SWAP_BYTES = 0x0D00, - GL_UNPACK_ALIGNMENT = 0x0CF5, - GL_UNPACK_LSB_FIRST = 0x0CF1, - GL_UNPACK_ROW_LENGTH = 0x0CF2, - GL_UNPACK_SKIP_PIXELS = 0x0CF4, - GL_UNPACK_SKIP_ROWS = 0x0CF3, - GL_UNPACK_SWAP_BYTES = 0x0CF0, - GL_ZOOM_X = 0x0D16, - GL_ZOOM_Y = 0x0D17, - - /* Texture mapping */ - GL_TEXTURE_ENV = 0x2300, - GL_TEXTURE_ENV_MODE = 0x2200, - GL_TEXTURE_1D = 0x0DE0, - GL_TEXTURE_2D = 0x0DE1, - GL_TEXTURE_WRAP_S = 0x2802, - GL_TEXTURE_WRAP_T = 0x2803, - GL_TEXTURE_MAG_FILTER = 0x2800, - GL_TEXTURE_MIN_FILTER = 0x2801, - GL_TEXTURE_ENV_COLOR = 0x2201, - GL_TEXTURE_GEN_S = 0x0C60, - GL_TEXTURE_GEN_T = 0x0C61, - GL_TEXTURE_GEN_MODE = 0x2500, - GL_TEXTURE_BORDER_COLOR = 0x1004, - GL_TEXTURE_WIDTH = 0x1000, - GL_TEXTURE_HEIGHT = 0x1001, - GL_TEXTURE_BORDER = 0x1005, - GL_TEXTURE_COMPONENTS = 0x1003, - GL_NEAREST_MIPMAP_NEAREST = 0x2700, - GL_NEAREST_MIPMAP_LINEAR = 0x2702, - GL_LINEAR_MIPMAP_NEAREST = 0x2701, - GL_LINEAR_MIPMAP_LINEAR = 0x2703, - GL_OBJECT_LINEAR = 0x2401, - GL_OBJECT_PLANE = 0x2501, - GL_EYE_LINEAR = 0x2400, - GL_EYE_PLANE = 0x2502, - GL_SPHERE_MAP = 0x2402, - GL_DECAL = 0x2101, - GL_MODULATE = 0x2100, - GL_NEAREST = 0x2600, - GL_REPEAT = 0x2901, - GL_CLAMP = 0x2900, - GL_S = 0x2000, - GL_T = 0x2001, - GL_R = 0x2002, - GL_Q = 0x2003, - GL_TEXTURE_GEN_R = 0x0C62, - GL_TEXTURE_GEN_Q = 0x0C63, - - GL_PROXY_TEXTURE_1D = 0x8063, - GL_PROXY_TEXTURE_2D = 0x8064, - GL_TEXTURE_PRIORITY = 0x8066, - GL_TEXTURE_RESIDENT = 0x8067, - GL_TEXTURE_1D_BINDING = 0x8068, - GL_TEXTURE_2D_BINDING = 0x8069, - - /* Internal texture formats */ - GL_ALPHA4 = 0x803B, - GL_ALPHA8 = 0x803C, - GL_ALPHA12 = 0x803D, - GL_ALPHA16 = 0x803E, - GL_LUMINANCE4 = 0x803F, - GL_LUMINANCE8 = 0x8040, - GL_LUMINANCE12 = 0x8041, - GL_LUMINANCE16 = 0x8042, - GL_LUMINANCE4_ALPHA4 = 0x8043, - GL_LUMINANCE6_ALPHA2 = 0x8044, - GL_LUMINANCE8_ALPHA8 = 0x8045, - GL_LUMINANCE12_ALPHA4 = 0x8046, - GL_LUMINANCE12_ALPHA12 = 0x8047, - GL_LUMINANCE16_ALPHA16 = 0x8048, - GL_INTENSITY = 0x8049, - GL_INTENSITY4 = 0x804A, - GL_INTENSITY8 = 0x804B, - GL_INTENSITY12 = 0x804C, - GL_INTENSITY16 = 0x804D, - GL_R3_G3_B2 = 0x2A10, - GL_RGB4 = 0x804F, - GL_RGB5 = 0x8050, - GL_RGB8 = 0x8051, - GL_RGB10 = 0x8052, - GL_RGB12 = 0x8053, - GL_RGB16 = 0x8054, - GL_RGBA2 = 0x8055, - GL_RGBA4 = 0x8056, - GL_RGB5_A1 = 0x8057, - GL_RGBA8 = 0x8058, - GL_RGB10_A2 = 0x8059, - GL_RGBA12 = 0x805A, - GL_RGBA16 = 0x805B, - - /* Utility */ - GL_VENDOR = 0x1F00, - GL_RENDERER = 0x1F01, - GL_VERSION = 0x1F02, - GL_EXTENSIONS = 0x1F03, - - /* Errors */ - GL_INVALID_VALUE = 0x0501, - GL_INVALID_ENUM = 0x0500, - GL_INVALID_OPERATION = 0x0502, - GL_STACK_OVERFLOW = 0x0503, - GL_STACK_UNDERFLOW = 0x0504, - GL_OUT_OF_MEMORY = 0x0505, - - /* - * 1.0 Extensions - */ - /* GL_EXT_blend_minmax and GL_EXT_blend_color */ - GL_CONSTANT_COLOR_EXT = 0x8001, - GL_ONE_MINUS_CONSTANT_COLOR_EXT = 0x8002, - GL_CONSTANT_ALPHA_EXT = 0x8003, - GL_ONE_MINUS_CONSTANT_ALPHA_EXT = 0x8004, - GL_BLEND_EQUATION_EXT = 0x8009, - GL_MIN_EXT = 0x8007, - GL_MAX_EXT = 0x8008, - GL_FUNC_ADD_EXT = 0x8006, - GL_FUNC_SUBTRACT_EXT = 0x800A, - GL_FUNC_REVERSE_SUBTRACT_EXT = 0x800B, - GL_BLEND_COLOR_EXT = 0x8005, - - /* GL_EXT_polygon_offset */ - GL_POLYGON_OFFSET_EXT = 0x8037, - GL_POLYGON_OFFSET_FACTOR_EXT = 0x8038, - GL_POLYGON_OFFSET_BIAS_EXT = 0x8039, - - /* GL_EXT_vertex_array */ - GL_VERTEX_ARRAY_EXT = 0x8074, - GL_NORMAL_ARRAY_EXT = 0x8075, - GL_COLOR_ARRAY_EXT = 0x8076, - GL_INDEX_ARRAY_EXT = 0x8077, - GL_TEXTURE_COORD_ARRAY_EXT = 0x8078, - GL_EDGE_FLAG_ARRAY_EXT = 0x8079, - GL_VERTEX_ARRAY_SIZE_EXT = 0x807A, - GL_VERTEX_ARRAY_TYPE_EXT = 0x807B, - GL_VERTEX_ARRAY_STRIDE_EXT = 0x807C, - GL_VERTEX_ARRAY_COUNT_EXT = 0x807D, - GL_NORMAL_ARRAY_TYPE_EXT = 0x807E, - GL_NORMAL_ARRAY_STRIDE_EXT = 0x807F, - GL_NORMAL_ARRAY_COUNT_EXT = 0x8080, - GL_COLOR_ARRAY_SIZE_EXT = 0x8081, - GL_COLOR_ARRAY_TYPE_EXT = 0x8082, - GL_COLOR_ARRAY_STRIDE_EXT = 0x8083, - GL_COLOR_ARRAY_COUNT_EXT = 0x8084, - GL_INDEX_ARRAY_TYPE_EXT = 0x8085, - GL_INDEX_ARRAY_STRIDE_EXT = 0x8086, - GL_INDEX_ARRAY_COUNT_EXT = 0x8087, - GL_TEXTURE_COORD_ARRAY_SIZE_EXT = 0x8088, - GL_TEXTURE_COORD_ARRAY_TYPE_EXT = 0x8089, - GL_TEXTURE_COORD_ARRAY_STRIDE_EXT= 0x808A, - GL_TEXTURE_COORD_ARRAY_COUNT_EXT= 0x808B, - GL_EDGE_FLAG_ARRAY_STRIDE_EXT = 0x808C, - GL_EDGE_FLAG_ARRAY_COUNT_EXT = 0x808D, - GL_VERTEX_ARRAY_POINTER_EXT = 0x808E, - GL_NORMAL_ARRAY_POINTER_EXT = 0x808F, - GL_COLOR_ARRAY_POINTER_EXT = 0x8090, - GL_INDEX_ARRAY_POINTER_EXT = 0x8091, - GL_TEXTURE_COORD_ARRAY_POINTER_EXT= 0x8092, - GL_EDGE_FLAG_ARRAY_POINTER_EXT = 0x8093 - -}; - -enum { - GL_CURRENT_BIT = 0x00000001, - GL_POINT_BIT = 0x00000002, - GL_LINE_BIT = 0x00000004, - GL_POLYGON_BIT = 0x00000008, - GL_POLYGON_STIPPLE_BIT = 0x00000010, - GL_PIXEL_MODE_BIT = 0x00000020, - GL_LIGHTING_BIT = 0x00000040, - GL_FOG_BIT = 0x00000080, - GL_DEPTH_BUFFER_BIT = 0x00000100, - GL_ACCUM_BUFFER_BIT = 0x00000200, - GL_STENCIL_BUFFER_BIT = 0x00000400, - GL_VIEWPORT_BIT = 0x00000800, - GL_TRANSFORM_BIT = 0x00001000, - GL_ENABLE_BIT = 0x00002000, - GL_COLOR_BUFFER_BIT = 0x00004000, - GL_HINT_BIT = 0x00008000, - GL_EVAL_BIT = 0x00010000, - GL_LIST_BIT = 0x00020000, - GL_TEXTURE_BIT = 0x00040000, - GL_SCISSOR_BIT = 0x00080000, - GL_ALL_ATTRIB_BITS = 0x000fffff -}; - -/* some types */ - -typedef int GLenum; -typedef void GLvoid; -typedef unsigned char GLboolean; -typedef signed char GLbyte; /* 1-byte signed */ -typedef short GLshort; /* 2-byte signed */ -typedef int GLint; /* 4-byte signed */ -typedef unsigned char GLubyte; /* 1-byte unsigned */ -typedef unsigned short GLushort; /* 2-byte unsigned */ -typedef unsigned int GLuint; /* 4-byte unsigned */ -typedef float GLfloat; /* single precision float */ -typedef double GLdouble; /* double precision float */ -typedef int GLsizei; - -/* functions */ - -void glEnable(int code); -void glDisable(int code); - -void glShadeModel(int mode); -void glCullFace(int mode); -void glPolygonMode(int face,int mode); - -void glBegin(int type); -void glEnd(void); - -#define PROTO_GL1(name) \ -void gl ## name ## 1f(float); \ -void gl ## name ## 1d(double); \ -void gl ## name ## 1fv(float *); \ -void gl ## name ## 1dv(double *); - -#define PROTO_GL2(name) \ -void gl ## name ## 2f(float ,float); \ -void gl ## name ## 2d(double ,double); \ -void gl ## name ## 2fv(float *); \ -void gl ## name ## 2dv(double *); - -#define PROTO_GL3(name) \ -void gl ## name ## 3f(float ,float ,float); \ -void gl ## name ## 3d(double ,double ,double); \ -void gl ## name ## 3fv(float *); \ -void gl ## name ## 3dv(double *); - -#define PROTO_GL4(name) \ -void gl ## name ## 4f(float ,float ,float, float ); \ -void gl ## name ## 4d(double ,double ,double, double ); \ -void gl ## name ## 4fv(float *); \ -void gl ## name ## 4dv(double *); - -PROTO_GL2(Vertex) -PROTO_GL3(Vertex) -PROTO_GL4(Vertex) - -PROTO_GL3(Color) -PROTO_GL4(Color) - -PROTO_GL3(Normal) - -PROTO_GL1(TexCoord) -PROTO_GL2(TexCoord) -PROTO_GL3(TexCoord) -PROTO_GL4(TexCoord) - -void glEdgeFlag(int flag); - -/* matrix */ -void glMatrixMode(int mode); -void glLoadMatrixf(const float *m); -void glLoadIdentity(void); -void glMultMatrixf(const float *m); -void glPushMatrix(void); -void glPopMatrix(void); -void glRotatef(float angle,float x,float y,float z); -void glTranslatef(float x,float y,float z); -void glScalef(float x,float y,float z); - -void glViewport(int x,int y,int width,int height); -void glFrustum(double left,double right,double bottom,double top, - double near,double far); - -/* lists */ -unsigned int glGenLists(int range); -int glIsList(unsigned int list); -void glNewList(unsigned int list,int mode); -void glEndList(void); -void glCallList(unsigned int list); - -/* clear */ -void glClear(int mask); -void glClearColor(float r,float g,float b,float a); -void glClearDepth(double depth); - -/* selection */ -int glRenderMode(int mode); -void glSelectBuffer(int size,unsigned int *buf); - -void glInitNames(void); -void glPushName(unsigned int name); -void glPopName(void); -void glLoadName(unsigned int name); - -/* textures */ -void glGenTextures(int n, unsigned int *textures); -void glDeleteTextures(int n, const unsigned int *textures); -void glBindTexture(int target,int texture); -void glTexImage2D( int target, int level, int components, - int width, int height, int border, - int format, int type, void *pixels); -void glTexEnvi(int target,int pname,int param); -void glTexParameteri(int target,int pname,int param); -void glPixelStorei(int pname,int param); - -/* lighting */ - -void glMaterialfv(int mode,int type,float *v); -void glMaterialf(int mode,int type,float v); -void glColorMaterial(int mode,int type); - -void glLightfv(int light,int type,float *v); -void glLightf(int light,int type,float v); -void glLightModeli(int pname,int param); -void glLightModelfv(int pname,float *param); - -/* misc */ - -void glFlush(void); -void glHint(int target,int mode); -void glGetIntegerv(int pname,int *params); -void glGetFloatv(int pname, float *v); -void glFrontFace(int mode); - -/* opengl 1.2 arrays */ -void glEnableClientState(GLenum array); -void glDisableClientState(GLenum array); -void glArrayElement(GLint i); -void glVertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer); -void glColorPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer); -void glNormalPointer(GLenum type, GLsizei stride, - const GLvoid *pointer); -void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer); - -/* opengl 1.2 polygon offset */ -void glPolygonOffset(GLfloat factor, GLfloat units); - -/* not implemented, just added to compile */ - /* -inline void glPointSize(float) {} -inline void glLineWidth(float) {} -inline void glDeleteLists(int, int) {} -inline void glDepthFunc(int) {} -inline void glBlendFunc(int, int) {} -inline void glTexEnvf(int, int, int) {} -inline void glOrtho(float,float,float,float,float,float){} -inline void glVertex2i(int,int) {} -inline void glDepthMask(int) {} -inline void glFogi(int, int) {} -inline void glFogfv(int, const float*) {} -inline void glFogf(int, float) {} -inline void glRasterPos2f(float, float) {} -inline void glPolygonStipple(void*) {} -inline void glTexParameterf(int, int, int) {}; - */ -/* non compatible functions */ - -void glDebug(int mode); - -void glInit(void *zbuffer); -void glClose(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/panda/src/tinydisplay/tinyglu.h b/panda/src/tinydisplay/tinyglu.h deleted file mode 100644 index 8e4bbdf655..0000000000 --- a/panda/src/tinydisplay/tinyglu.h +++ /dev/null @@ -1,23 +0,0 @@ - -void gluPerspective( GLdouble fovy, GLdouble aspect, - GLdouble zNear, GLdouble zFar ); - -typedef struct { - int draw_style; -} GLUquadricObj; - -#define GLU_LINE 0 - -GLUquadricObj *gluNewQuadric(void); -void gluQuadricDrawStyle(GLUquadricObj *obj, int style); - -void gluSphere(GLUquadricObj *qobj, - float radius,int slices,int stacks); -void gluCylinder( GLUquadricObj *qobj, - GLdouble baseRadius, GLdouble topRadius, GLdouble height, - GLint slices, GLint stacks ); -void gluDisk( GLUquadricObj *qobj, - GLdouble innerRadius, GLdouble outerRadius, - GLint slices, GLint loops ); - -void drawTorus(float rc, int numc, float rt, int numt); diff --git a/panda/src/tinydisplay/vertex.c b/panda/src/tinydisplay/vertex.c index fba437a016..3469c12d5a 100644 --- a/panda/src/tinydisplay/vertex.c +++ b/panda/src/tinydisplay/vertex.c @@ -1,58 +1,6 @@ #include "zgl.h" #include "string.h" -void glopNormal(GLContext * c, GLParam * p) -{ - V3 v; - - v.X = p[1].f; - v.Y = p[2].f; - v.Z = p[3].f; - - c->current_normal.X = v.X; - c->current_normal.Y = v.Y; - c->current_normal.Z = v.Z; - c->current_normal.W = 0; -} - -void glopTexCoord(GLContext * c, GLParam * p) -{ - c->current_tex_coord.X = p[1].f; - c->current_tex_coord.Y = p[2].f; - c->current_tex_coord.Z = p[3].f; - c->current_tex_coord.W = p[4].f; -} - -void glopEdgeFlag(GLContext * c, GLParam * p) -{ - c->current_edge_flag = p[1].i; -} - -void glopColor(GLContext * c, GLParam * p) -{ - - c->current_color.X = p[1].f; - c->current_color.Y = p[2].f; - c->current_color.Z = p[3].f; - c->current_color.W = p[4].f; - c->longcurrent_color[0] = p[5].ui; - c->longcurrent_color[1] = p[6].ui; - c->longcurrent_color[2] = p[7].ui; - - if (c->color_material_enabled) { - GLParam q[7]; - q[0].op = OP_Material; - q[1].i = c->current_color_material_mode; - q[2].i = c->current_color_material_type; - q[3].f = p[1].f; - q[4].f = p[2].f; - q[5].f = p[3].f; - q[6].f = p[4].f; - glopMaterial(c, q); - } -} - - void gl_eval_viewport(GLContext * c) { GLViewport *v; @@ -69,81 +17,9 @@ void gl_eval_viewport(GLContext * c) v->scale.Z = -((zsize - 0.5) / 2.0); } -void glopBegin(GLContext * c, GLParam * p) -{ - int type; - M4 tmp; - - assert(c->in_begin == 0); - - type = p[1].i; - c->begin_type = type; - c->in_begin = 1; - c->vertex_n = 0; - c->vertex_cnt = 0; - - if (c->matrix_model_projection_updated) { - - if (c->lighting_enabled) { - /* precompute inverse modelview */ - gl_M4_Inv(&tmp, c->matrix_stack_ptr[0]); - gl_M4_Transpose(&c->matrix_model_view_inv, &tmp); - } else { - float *m = &c->matrix_model_projection.m[0][0]; - /* precompute projection matrix */ - gl_M4_Mul(&c->matrix_model_projection, - c->matrix_stack_ptr[1], - c->matrix_stack_ptr[0]); - /* test to accelerate computation */ - c->matrix_model_projection_no_w_transform = 0; - if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0) - c->matrix_model_projection_no_w_transform = 1; - } - - /* test if the texture matrix is not Identity */ - c->apply_texture_matrix = !gl_M4_IsId(c->matrix_stack_ptr[2]); - - c->matrix_model_projection_updated = 0; - } - /* viewport */ - if (c->viewport.updated) { - gl_eval_viewport(c); - c->viewport.updated = 0; - } - /* triangle drawing functions */ - if (c->render_mode == GL_SELECT) { - c->draw_triangle_front = gl_draw_triangle_select; - c->draw_triangle_back = gl_draw_triangle_select; - } else { - switch (c->polygon_mode_front) { - case GL_POINT: - c->draw_triangle_front = gl_draw_triangle_point; - break; - case GL_LINE: - c->draw_triangle_front = gl_draw_triangle_line; - break; - default: - c->draw_triangle_front = gl_draw_triangle_fill; - break; - } - - switch (c->polygon_mode_back) { - case GL_POINT: - c->draw_triangle_back = gl_draw_triangle_point; - break; - case GL_LINE: - c->draw_triangle_back = gl_draw_triangle_line; - break; - default: - c->draw_triangle_back = gl_draw_triangle_fill; - break; - } - } -} - /* coords, tranformation , clip code and projection */ /* TODO : handle all cases */ -static inline void gl_vertex_transform(GLContext * c, GLVertex * v) +void gl_vertex_transform(GLContext * c, GLVertex * v) { float *m; V4 *n; @@ -151,7 +27,7 @@ static inline void gl_vertex_transform(GLContext * c, GLVertex * v) if (c->lighting_enabled) { /* eye coordinates needed for lighting */ - m = &c->matrix_stack_ptr[0]->m[0][0]; + m = &c->matrix_model_view.m[0][0]; v->ec.X = (v->coord.X * m[0] + v->coord.Y * m[1] + v->coord.Z * m[2] + m[3]); v->ec.Y = (v->coord.X * m[4] + v->coord.Y * m[5] + @@ -162,7 +38,7 @@ static inline void gl_vertex_transform(GLContext * c, GLVertex * v) v->coord.Z * m[14] + m[15]); /* projection coordinates */ - m = &c->matrix_stack_ptr[1]->m[0][0]; + m = &c->matrix_projection.m[0][0]; v->pc.X = (v->ec.X * m[0] + v->ec.Y * m[1] + v->ec.Z * m[2] + v->ec.W * m[3]); v->pc.Y = (v->ec.X * m[4] + v->ec.Y * m[5] + @@ -203,163 +79,3 @@ static inline void gl_vertex_transform(GLContext * c, GLVertex * v) v->clip_code = gl_clipcode(v->pc.X, v->pc.Y, v->pc.Z, v->pc.W); } - -void glopVertex(GLContext * c, GLParam * p) -{ - GLVertex *v; - int n, i, cnt; - - assert(c->in_begin != 0); - - n = c->vertex_n; - cnt = c->vertex_cnt; - cnt++; - c->vertex_cnt = cnt; - - /* quick fix to avoid crashes on large polygons */ - if (n >= c->vertex_max) { - GLVertex *newarray; - c->vertex_max <<= 1; /* just double size */ - newarray = gl_malloc(sizeof(GLVertex) * c->vertex_max); - if (!newarray) { - gl_fatal_error("unable to allocate GLVertex array.\n"); - } - memcpy(newarray, c->vertex, n * sizeof(GLVertex)); - gl_free(c->vertex); - c->vertex = newarray; - } - /* new vertex entry */ - v = &c->vertex[n]; - n++; - - v->coord.X = p[1].f; - v->coord.Y = p[2].f; - v->coord.Z = p[3].f; - v->coord.W = p[4].f; - - gl_vertex_transform(c, v); - - /* color */ - - if (c->lighting_enabled) { - gl_shade_vertex(c, v); - } else { - v->color = c->current_color; - } - - /* tex coords */ - - if (c->texture_2d_enabled) { - if (c->apply_texture_matrix) { - gl_M4_MulV4(&v->tex_coord, c->matrix_stack_ptr[2], &c->current_tex_coord); - } else { - v->tex_coord = c->current_tex_coord; - } - } - /* precompute the mapping to the viewport */ - if (v->clip_code == 0) - gl_transform_to_viewport(c, v); - - /* edge flag */ - - v->edge_flag = c->current_edge_flag; - - switch (c->begin_type) { - case GL_POINTS: - gl_draw_point(c, &c->vertex[0]); - n = 0; - break; - - case GL_LINES: - if (n == 2) { - gl_draw_line(c, &c->vertex[0], &c->vertex[1]); - n = 0; - } - break; - case GL_LINE_STRIP: - case GL_LINE_LOOP: - if (n == 1) { - c->vertex[2] = c->vertex[0]; - } else if (n == 2) { - gl_draw_line(c, &c->vertex[0], &c->vertex[1]); - c->vertex[0] = c->vertex[1]; - n = 1; - } - break; - - case GL_TRIANGLES: - if (n == 3) { - gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); - n = 0; - } - break; - case GL_TRIANGLE_STRIP: - if (cnt >= 3) { - if (n == 3) - n = 0; - /* needed to respect triangle orientation */ - switch(cnt & 1) { - case 0: - gl_draw_triangle(c,&c->vertex[2],&c->vertex[1],&c->vertex[0]); - break; - default: - case 1: - gl_draw_triangle(c,&c->vertex[0],&c->vertex[1],&c->vertex[2]); - break; - } - } - break; - case GL_TRIANGLE_FAN: - if (n == 3) { - gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); - c->vertex[1] = c->vertex[2]; - n = 2; - } - break; - - case GL_QUADS: - if (n == 4) { - c->vertex[2].edge_flag = 0; - gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); - c->vertex[2].edge_flag = 1; - c->vertex[0].edge_flag = 0; - gl_draw_triangle(c, &c->vertex[0], &c->vertex[2], &c->vertex[3]); - n = 0; - } - break; - - case GL_QUAD_STRIP: - if (n == 4) { - gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); - gl_draw_triangle(c, &c->vertex[1], &c->vertex[3], &c->vertex[2]); - for (i = 0; i < 2; i++) - c->vertex[i] = c->vertex[i + 2]; - n = 2; - } - break; - case GL_POLYGON: - break; - default: - gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); - } - - c->vertex_n = n; -} - -void glopEnd(GLContext * c, GLParam * param) -{ - assert(c->in_begin == 1); - - if (c->begin_type == GL_LINE_LOOP) { - if (c->vertex_cnt >= 3) { - gl_draw_line(c, &c->vertex[0], &c->vertex[2]); - } - } else if (c->begin_type == GL_POLYGON) { - int i = c->vertex_cnt; - while (i >= 3) { - i--; - gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]); - } - } - c->in_begin = 0; -} diff --git a/panda/src/tinydisplay/zgl.h b/panda/src/tinydisplay/zgl.h index f503afc72d..f9f1a9c576 100644 --- a/panda/src/tinydisplay/zgl.h +++ b/panda/src/tinydisplay/zgl.h @@ -5,7 +5,6 @@ #include #include #include -#include "tinygl.h" #include "zbuffer.h" #include "zmath.h" #include "zfeatures.h" @@ -13,14 +12,6 @@ #define DEBUG /* #define NDEBUG */ -enum { - -#define ADD_OP(a,b,c) OP_ ## a , - -#include "opinfo.h" - -}; - /* initially # of allocated GLVertexes (will grow when necessary) */ #define POLYGON_MAX_VERTEX 16 @@ -162,29 +153,14 @@ typedef struct GLContext { /* materials */ GLMaterial materials[2]; - int color_material_enabled; - int current_color_material_mode; - int current_color_material_type; /* textures */ GLTexture *current_texture; int texture_2d_enabled; - /* shared state */ - GLSharedState shared_state; - - /* current list */ - GLParamBuffer *current_op_buffer; - int current_op_buffer_index; - int exec_flag,compile_flag,print_flag; - /* matrix */ - - int matrix_mode; - M4 *matrix_stack[3]; - M4 *matrix_stack_ptr[3]; - int matrix_stack_depth_max[3]; - + M4 matrix_projection; + M4 matrix_model_view; M4 matrix_model_view_inv; M4 matrix_model_projection; int matrix_model_projection_updated; @@ -195,29 +171,14 @@ typedef struct GLContext { GLViewport viewport; /* current state */ - int polygon_mode_back; - int polygon_mode_front; - int current_front_face; - int current_shade_model; - int current_cull_face; + int smooth_shade_model; int cull_face_enabled; + int cull_clockwise; int normalize_enabled; gl_draw_triangle_func draw_triangle_front,draw_triangle_back; ZB_fillTriangleFunc zb_fill_tri; - /* selection */ - int render_mode; - unsigned int *select_buffer; - int select_size; - unsigned int *select_ptr,*select_hit; - int select_overflow; - int select_hits; - - /* names */ - unsigned int name_stack[MAX_NAME_STACK_DEPTH]; - int name_stack_size; - /* clear */ float clear_depth; V4 clear_color; @@ -228,51 +189,25 @@ typedef struct GLContext { V4 current_normal; V4 current_tex_coord; int current_edge_flag; - - /* glBegin / glEnd */ - int in_begin; - int begin_type; - int vertex_n,vertex_cnt; - int vertex_max; - GLVertex *vertex; - - /* opengl 1.1 arrays */ - float *vertex_array; - int vertex_array_size; - int vertex_array_stride; - float *normal_array; - int normal_array_stride; - float *color_array; - int color_array_size; - int color_array_stride; - float *texcoord_array; - int texcoord_array_size; - int texcoord_array_stride; - int client_states; /* opengl 1.1 polygon offset */ float offset_factor; float offset_units; int offset_states; + + /* depth test */ + int depth_test; /* specular buffer. could probably be shared between contexts, but that wouldn't be 100% thread safe */ GLSpecBuf *specbuf_first; int specbuf_used_counter; int specbuf_num_buffers; - - /* opaque structure for user's use */ - void *opaque; - /* resize viewport function */ - int (*gl_resize_viewport)(struct GLContext *c,int *xsize,int *ysize); - - /* depth test */ - int depth_test; } GLContext; -extern GLContext *gl_ctx; - -void gl_add_op(GLParam *p); +/* init.c */ +void glInit(GLContext *c, ZBuffer *zbuffer); +void glClose(GLContext *c); /* clip.c */ void gl_transform_to_viewport(GLContext *c,GLVertex *v); @@ -286,22 +221,14 @@ void gl_draw_triangle_line(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2); void gl_draw_triangle_fill(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2); -void gl_draw_triangle_select(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); - -/* matrix.c */ -void gl_print_matrix(const float *m); -/* -void glopLoadIdentity(GLContext *c,GLParam *p); -void glopTranslate(GLContext *c,GLParam *p);*/ /* light.c */ -void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax); void gl_enable_disable_light(GLContext *c,int light,int v); void gl_shade_vertex(GLContext *c,GLVertex *v); /* vertex.c */ void gl_eval_viewport(GLContext *c); +void gl_vertex_transform(GLContext * c, GLVertex * v); /* image_util.c */ void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb, @@ -339,11 +266,6 @@ void dprintf(const char *, ...); #endif #endif /* !BEOS */ -/* glopXXX functions */ - -#define ADD_OP(a,b,c) void glop ## a (GLContext *,GLParam *); -#include "opinfo.h" - /* this clip epsilon is needed to avoid some rounding errors after several clipping stages */