Hi All,
This patch binds opengl at runtime, so we can build binaries with OpenGL enabled and still use some parts of ddraw on systems without OpenGL.
I haven't tested it appart from compiling it, so if somebody who knows more about ddraw could give it a go, and comment that would be great.
Mike
ChangeLog: * load OpenGL from ddraw at runtime
? dlls/ddraw/gl_private.h ? dlls/ddraw/x Index: dlls/ddraw/Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/ddraw/Makefile.in,v retrieving revision 1.28 diff -u -r1.28 Makefile.in --- dlls/ddraw/Makefile.in 21 Nov 2002 21:04:16 -0000 1.28 +++ dlls/ddraw/Makefile.in 15 May 2003 04:10:43 -0000 @@ -5,7 +5,7 @@ MODULE = ddraw.dll IMPORTS = user32 gdi32 kernel32 EXTRAINCL = @X_CFLAGS@ -EXTRALIBS = $(LIBUUID) @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ +EXTRALIBS = $(LIBUUID) @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o Index: dlls/ddraw/d3dexecutebuffer.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/d3dexecutebuffer.c,v retrieving revision 1.26 diff -u -r1.26 d3dexecutebuffer.c --- dlls/ddraw/d3dexecutebuffer.c 11 May 2003 03:28:53 -0000 1.26 +++ dlls/ddraw/d3dexecutebuffer.c 15 May 2003 04:10:44 -0000 @@ -82,12 +82,12 @@ #define DO_VERTEX(index) \ { \ - glTexCoord2f(vx[index].u, \ + pglTexCoord2f(vx[index].u, \ vx[index].v); \ - glNormal3f(vx[index].nx, \ + pglNormal3f(vx[index].nx, \ vx[index].ny, \ vx[index].nz); \ - glVertex4f(vx[index].x, \ + pglVertex4f(vx[index].x, \ vx[index].y, \ vx[index].z, \ vx[index].w); \ @@ -102,12 +102,12 @@ { \ DWORD col = l_vx[index].c; \ \ - glColor3f(((col >> 16) & 0xFF) / 255.0, \ + pglColor3f(((col >> 16) & 0xFF) / 255.0, \ ((col >> 8) & 0xFF) / 255.0, \ ((col >> 0) & 0xFF) / 255.0); \ - glTexCoord2f(l_vx[index].u, \ + pglTexCoord2f(l_vx[index].u, \ l_vx[index].v); \ - glVertex4f(l_vx[index].x, \ + pglVertex4f(l_vx[index].x, \ l_vx[index].y, \ l_vx[index].z, \ l_vx[index].w); \ @@ -123,16 +123,16 @@ D3DTLVERTEX *vx = &(tl_vx[index]); \ DWORD col = vx->u5.color; \ \ - glColor3f(((col >> 16) & 0xFF) / 255.0, \ + pglColor3f(((col >> 16) & 0xFF) / 255.0, \ ((col >> 8) & 0xFF) / 255.0, \ ((col >> 0) & 0xFF) / 255.0); \ - glTexCoord2f(vx->u7.tu, vx->u8.tv); \ + pglTexCoord2f(vx->u7.tu, vx->u8.tv); \ if (vx->u4.rhw < 1e-8) \ - glVertex3f(vx->u1.sx, \ + pglVertex3f(vx->u1.sx, \ vx->u2.sy, \ vx->u3.sz); \ else \ - glVertex4f(vx->u1.sx / vx->u4.rhw, \ + pglVertex4f(vx->u1.sx / vx->u4.rhw, \ vx->u2.sy / vx->u4.rhw, \ vx->u3.sz / vx->u4.rhw, \ 1.0 / vx->u4.rhw); \ @@ -144,7 +144,7 @@ #define TRIANGLE_LOOP(macro) \ { \ - glBegin(GL_TRIANGLES); \ + pglBegin(GL_TRIANGLES); \ for (i = 0; i < count; i++) { \ LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr; \ \ @@ -179,7 +179,7 @@ \ instr += size; \ } \ - glEnd(); \ + pglEnd(); \ } @@ -237,7 +237,7 @@ switch (This->vertex_type) { case D3DVT_VERTEX: /* This time, there is lighting */ - glEnable(GL_LIGHTING); + pglEnable(GL_LIGHTING); if (TRACE_ON(ddraw)) { TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat); @@ -254,7 +254,7 @@ case D3DVT_LVERTEX: /* No lighting */ - glDisable(GL_LIGHTING); + pglDisable(GL_LIGHTING); if (TRACE_ON(ddraw)) { TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat); @@ -271,8 +271,8 @@ case D3DVT_TLVERTEX: { /* First, disable lighting and fogging */ - glDisable(GL_LIGHTING); - glDisable(GL_FOG); + pglDisable(GL_LIGHTING); + pglDisable(GL_FOG); d3ddevice_set_ortho(lpDevice); } break; @@ -320,15 +320,15 @@ /* Do the multiplication.. As I am VERY lazy, I let OpenGL do the multiplication for me */ - glMatrixMode(GL_PROJECTION); + pglMatrixMode(GL_PROJECTION); /* Save the current matrix */ - glPushMatrix(); + pglPushMatrix(); /* Load Matrix one and do the multiplication */ - glLoadMatrixf((float *) c); - glMultMatrixf((float *) b); - glGetFloatv(GL_PROJECTION_MATRIX, (float *) a); + pglLoadMatrixf((float *) c); + pglMultMatrixf((float *) b); + pglGetFloatv(GL_PROJECTION_MATRIX, (float *) a); /* Restore the current matrix */ - glPopMatrix(); + pglPopMatrix(); instr += size; } @@ -396,7 +396,7 @@ light[1] = ((dwLightState >> 8) & 0xFF) / 255.0; light[2] = ((dwLightState >> 0) & 0xFF) / 255.0; light[3] = 1.0; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light); + pglLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light); TRACE(" R:%02lx G:%02lx B:%02lx A:%02lx\n", ((dwLightState >> 16) & 0xFF), Index: dlls/ddraw/d3dlight.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/d3dlight.c,v retrieving revision 1.13 diff -u -r1.13 d3dlight.c --- dlls/ddraw/d3dlight.c 20 Jan 2003 23:24:05 -0000 1.13 +++ dlls/ddraw/d3dlight.c 15 May 2003 04:10:44 -0000 @@ -155,7 +155,7 @@ update(This); /* If was not active, activate it */ if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) == 0) { - glEnable(glThis->light_num); + pglEnable(glThis->light_num); glThis->parent.light.dwFlags |= D3DLIGHT_ACTIVE; } LEAVE_GL(); @@ -166,7 +166,7 @@ ENTER_GL(); /* If was not active, activate it */ if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) != 0) { - glDisable(glThis->light_num); + pglDisable(glThis->light_num); glThis->parent.light.dwFlags &= ~D3DLIGHT_ACTIVE; } LEAVE_GL(); Index: dlls/ddraw/d3dmaterial.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/d3dmaterial.c,v retrieving revision 1.14 diff -u -r1.14 d3dmaterial.c --- dlls/ddraw/d3dmaterial.c 7 Jan 2003 20:36:30 -0000 1.14 +++ dlls/ddraw/d3dmaterial.c 15 May 2003 04:10:44 -0000 @@ -290,16 +290,16 @@ /* Set the current Material */ ENTER_GL(); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *) &(This->mat.u.diffuse)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *) &(This->mat.u1.ambient)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float *) &(This->mat.u2.specular)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float *) &(This->mat.u3.emissive)); LEAVE_GL(); Index: dlls/ddraw/d3dtexture.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/d3dtexture.c,v retrieving revision 1.45 diff -u -r1.45 d3dtexture.c --- dlls/ddraw/d3dtexture.c 12 May 2003 03:09:17 -0000 1.45 +++ dlls/ddraw/d3dtexture.c 15 May 2003 04:10:45 -0000 @@ -94,7 +94,7 @@ GLuint tex_name = glThis->tex_name; TRACE(" activating OpenGL texture id %d.\n", tex_name); - glBindTexture(GL_TEXTURE_2D, tex_name); + pglBindTexture(GL_TEXTURE_2D, tex_name); if (This->mipmap_level != 0) { WARN(" application activating a sub-level of the mipmapping chain (level %d) !\n", This->mipmap_level); @@ -164,7 +164,7 @@ GL_UNSIGNED_BYTE, /* table type */ table); /* the color table */ - glTexImage2D(GL_TEXTURE_2D, /* target */ + pglTexImage2D(GL_TEXTURE_2D, /* target */ surf_ptr->mipmap_level, /* level */ GL_COLOR_INDEX8_EXT, /* internal format */ src_d->dwWidth, src_d->dwHeight, /* width, height */ @@ -517,7 +517,7 @@ if ((upload_done == FALSE) && (error == FALSE)) { if (gl_surf_ptr->initial_upload_done == FALSE) { - glTexImage2D(GL_TEXTURE_2D, + pglTexImage2D(GL_TEXTURE_2D, surf_ptr->mipmap_level, format, src_d->dwWidth, src_d->dwHeight, @@ -527,7 +527,7 @@ surface == NULL ? src_d->lpSurface : surface); gl_surf_ptr->initial_upload_done = TRUE; } else { - glTexSubImage2D(GL_TEXTURE_2D, + pglTexSubImage2D(GL_TEXTURE_2D, surf_ptr->mipmap_level, 0, 0, src_d->dwWidth, src_d->dwHeight, @@ -646,7 +646,7 @@ /* And delete texture handle */ ENTER_GL(); if (glThis->tex_name != 0) - glDeleteTextures(1, &(glThis->tex_name)); + pglDeleteTextures(1, &(glThis->tex_name)); LEAVE_GL(); /* And if this texture was the current one, remove it at the device level */ @@ -945,7 +945,7 @@ ENTER_GL(); if (surf->mipmap_level == 0) { - glGenTextures(1, &(private->tex_name)); + pglGenTextures(1, &(private->tex_name)); if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n"); TRACE(" GL texture created for surface %p (private data at %p and GL id %d).\n", surf, private, private->tex_name); } else { Index: dlls/ddraw/ddraw_private.h =================================================================== RCS file: /home/wine/wine/dlls/ddraw/ddraw_private.h,v retrieving revision 1.35 diff -u -r1.35 ddraw_private.h --- dlls/ddraw/ddraw_private.h 2 Jan 2003 19:51:25 -0000 1.35 +++ dlls/ddraw/ddraw_private.h 15 May 2003 04:10:45 -0000 @@ -353,6 +353,7 @@ extern Convert ModeEmulations[8]; extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw); +extern BOOL opengl_initialized; /****************************************************************************** * Structure conversion (for thunks) Index: dlls/ddraw/main.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/main.c,v retrieving revision 1.31 diff -u -r1.31 main.c --- dlls/ddraw/main.c 15 Mar 2003 00:12:43 -0000 1.31 +++ dlls/ddraw/main.c 15 May 2003 04:10:45 -0000 @@ -37,6 +37,10 @@ /* This for all the enumeration and creation of D3D-related objects */ #include "ddraw_private.h" #include "wine/debug.h" +#include "wine/library.h" +#include "wine/port.h" + +#include "gl_private.h" #define MAX_DDRAW_DRIVERS 3 static const ddraw_driver* DDRAW_drivers[MAX_DDRAW_DRIVERS]; @@ -48,6 +52,83 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); +static void *gl_handle = NULL; +BOOL opengl_initialized = 0; + +#define MAKE_FUNCPTR(f) typeof(f) * p##f = NULL; + +MAKE_FUNCPTR(glAlphaFunc) +MAKE_FUNCPTR(glBegin) +MAKE_FUNCPTR(glBindTexture) +MAKE_FUNCPTR(glBlendFunc) +MAKE_FUNCPTR(glClear) +MAKE_FUNCPTR(glClearColor) +MAKE_FUNCPTR(glClearDepth) +MAKE_FUNCPTR(glClearStencil) +MAKE_FUNCPTR(glClipPlane) +MAKE_FUNCPTR(glColor3f) +MAKE_FUNCPTR(glColor3ub) +MAKE_FUNCPTR(glColor4ub) +MAKE_FUNCPTR(glColorMaterial) +MAKE_FUNCPTR(glCullFace) +MAKE_FUNCPTR(glDeleteTextures) +MAKE_FUNCPTR(glDepthFunc) +MAKE_FUNCPTR(glDepthMask) +MAKE_FUNCPTR(glDisable) +MAKE_FUNCPTR(glDrawBuffer) +MAKE_FUNCPTR(glDrawPixels) +MAKE_FUNCPTR(glEnable) +MAKE_FUNCPTR(glEnd) +MAKE_FUNCPTR(glFlush) +MAKE_FUNCPTR(glFogf) +MAKE_FUNCPTR(glFogfv) +MAKE_FUNCPTR(glFogi) +MAKE_FUNCPTR(glFrontFace) +MAKE_FUNCPTR(glGenTextures) +MAKE_FUNCPTR(glGetBooleanv) +MAKE_FUNCPTR(glGetFloatv) +MAKE_FUNCPTR(glGetIntegerv) +MAKE_FUNCPTR(glHint) +MAKE_FUNCPTR(glLightModelfv) +MAKE_FUNCPTR(glLightModeli) +MAKE_FUNCPTR(glLightfv) +MAKE_FUNCPTR(glLoadIdentity) +MAKE_FUNCPTR(glLoadMatrixf) +MAKE_FUNCPTR(glMaterialf) +MAKE_FUNCPTR(glMaterialfv) +MAKE_FUNCPTR(glMatrixMode) +MAKE_FUNCPTR(glMultMatrixf) +MAKE_FUNCPTR(glNormal3f) +MAKE_FUNCPTR(glNormal3fv) +MAKE_FUNCPTR(glPolygonMode) +MAKE_FUNCPTR(glPolygonOffset) +MAKE_FUNCPTR(glPopMatrix) +MAKE_FUNCPTR(glPushMatrix) +MAKE_FUNCPTR(glRasterPos2f) +MAKE_FUNCPTR(glReadBuffer) +MAKE_FUNCPTR(glReadPixels) +MAKE_FUNCPTR(glShadeModel) +MAKE_FUNCPTR(glStencilFunc) +MAKE_FUNCPTR(glStencilMask) +MAKE_FUNCPTR(glStencilOp) +MAKE_FUNCPTR(glTexCoord2f) +MAKE_FUNCPTR(glTexCoord2fv) +MAKE_FUNCPTR(glTexEnvi) +MAKE_FUNCPTR(glTexImage2D) +MAKE_FUNCPTR(glTexParameteri) +MAKE_FUNCPTR(glTexParameterfv) +MAKE_FUNCPTR(glTexSubImage2D) +MAKE_FUNCPTR(glTranslatef) +MAKE_FUNCPTR(glVertex3f) +MAKE_FUNCPTR(glVertex3fv) +MAKE_FUNCPTR(glVertex4f) +MAKE_FUNCPTR(glXCreateContext) +MAKE_FUNCPTR(glXDestroyContext) +MAKE_FUNCPTR(glXMakeCurrent) +MAKE_FUNCPTR(glXSwapBuffers) + +#undef MAKE_FUNCPTR + /**********************************************************************/ typedef struct { @@ -55,6 +136,100 @@ LPVOID lpContext; } DirectDrawEnumerateProcData; +static BOOL DDRAW_bind_to_opengl( void ) +{ + char *glname = "libGL.so"; + + gl_handle = wine_dlopen(glname, RTLD_NOW, NULL, 0); + if(!gl_handle) { + WINE_MESSAGE("Wine cannot find the OpenGL graphics library (%s).\n",glname); + return FALSE; + } + +#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(gl_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;} + + LOAD_FUNCPTR(glAlphaFunc) + LOAD_FUNCPTR(glBegin) + LOAD_FUNCPTR(glBindTexture) + LOAD_FUNCPTR(glBlendFunc) + LOAD_FUNCPTR(glClear) + LOAD_FUNCPTR(glClearColor) + LOAD_FUNCPTR(glClearDepth) + LOAD_FUNCPTR(glClearStencil) + LOAD_FUNCPTR(glClipPlane) + LOAD_FUNCPTR(glColor3f) + LOAD_FUNCPTR(glColor3ub) + LOAD_FUNCPTR(glColor4ub) + LOAD_FUNCPTR(glColorMaterial) + LOAD_FUNCPTR(glCullFace) + LOAD_FUNCPTR(glDeleteTextures) + LOAD_FUNCPTR(glDepthFunc) + LOAD_FUNCPTR(glDepthMask) + LOAD_FUNCPTR(glDisable) + LOAD_FUNCPTR(glDrawBuffer) + LOAD_FUNCPTR(glDrawPixels) + LOAD_FUNCPTR(glEnable) + LOAD_FUNCPTR(glEnd) + LOAD_FUNCPTR(glFlush) + LOAD_FUNCPTR(glFogf) + LOAD_FUNCPTR(glFogfv) + LOAD_FUNCPTR(glFogi) + LOAD_FUNCPTR(glFrontFace) + LOAD_FUNCPTR(glGenTextures) + LOAD_FUNCPTR(glGetBooleanv) + LOAD_FUNCPTR(glGetFloatv) + LOAD_FUNCPTR(glGetIntegerv) + LOAD_FUNCPTR(glHint) + LOAD_FUNCPTR(glLightModelfv) + LOAD_FUNCPTR(glLightModeli) + LOAD_FUNCPTR(glLightfv) + LOAD_FUNCPTR(glLoadIdentity) + LOAD_FUNCPTR(glLoadMatrixf) + LOAD_FUNCPTR(glMaterialf) + LOAD_FUNCPTR(glMaterialfv) + LOAD_FUNCPTR(glMatrixMode) + LOAD_FUNCPTR(glMultMatrixf) + LOAD_FUNCPTR(glNormal3f) + LOAD_FUNCPTR(glNormal3fv) + LOAD_FUNCPTR(glPolygonMode) + LOAD_FUNCPTR(glPolygonOffset) + LOAD_FUNCPTR(glPopMatrix) + LOAD_FUNCPTR(glPushMatrix) + LOAD_FUNCPTR(glRasterPos2f) + LOAD_FUNCPTR(glReadBuffer) + LOAD_FUNCPTR(glReadPixels) + LOAD_FUNCPTR(glShadeModel) + LOAD_FUNCPTR(glStencilFunc) + LOAD_FUNCPTR(glStencilMask) + LOAD_FUNCPTR(glStencilOp) + LOAD_FUNCPTR(glTexCoord2f) + LOAD_FUNCPTR(glTexCoord2fv) + LOAD_FUNCPTR(glTexEnvi) + LOAD_FUNCPTR(glTexImage2D) + LOAD_FUNCPTR(glTexParameteri) + LOAD_FUNCPTR(glTexSubImage2D) + LOAD_FUNCPTR(glTranslatef) + LOAD_FUNCPTR(glVertex3f) + LOAD_FUNCPTR(glVertex3fv) + LOAD_FUNCPTR(glVertex4f) + LOAD_FUNCPTR(glXCreateContext) + LOAD_FUNCPTR(glXDestroyContext) + LOAD_FUNCPTR(glXMakeCurrent) + LOAD_FUNCPTR(glXSwapBuffers) +#undef LOAD_FUNCPTR + + return TRUE; + +sym_not_found: + WINE_MESSAGE( + "Wine cannot find certain functions that it needs inside the OpenGL\n" + "graphics library. To enable Wine to use OpenGL please upgrade\n" + "your OpenGL libraries\n"); + wine_dlclose(gl_handle, NULL, 0); + gl_handle = NULL; + return FALSE; +} + /*********************************************************************** * DirectDrawEnumerateExA (DDRAW.@) */ @@ -531,6 +706,7 @@ wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); } + opengl_initialized = DDRAW_bind_to_opengl(); } if (DDRAW_num_drivers > 0) Index: dlls/ddraw/mesa.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/mesa.c,v retrieving revision 1.37 diff -u -r1.37 mesa.c --- dlls/ddraw/mesa.c 12 May 2003 03:09:17 -0000 1.37 +++ dlls/ddraw/mesa.c 15 May 2003 04:10:46 -0000 @@ -125,9 +125,9 @@ case D3DRENDERSTATE_TEXTUREPERSPECTIVE: /* 4 */ if (dwRenderState) - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + pglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); else - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + pglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); break; case D3DRENDERSTATE_WRAPU: /* 5 */ @@ -146,11 +146,11 @@ Maybe replacing the Z function by ALWAYS would be a better idea. */ if (dwRenderState == D3DZB_TRUE) - glEnable(GL_DEPTH_TEST); + pglEnable(GL_DEPTH_TEST); else if (dwRenderState == D3DZB_FALSE) - glDisable(GL_DEPTH_TEST); + pglDisable(GL_DEPTH_TEST); else { - glEnable(GL_DEPTH_TEST); + pglEnable(GL_DEPTH_TEST); WARN(" w-buffering not supported.\n"); } break; @@ -158,13 +158,13 @@ case D3DRENDERSTATE_FILLMODE: /* 8 */ switch ((D3DFILLMODE) dwRenderState) { case D3DFILL_POINT: - glPolygonMode(GL_FRONT_AND_BACK,GL_POINT); + pglPolygonMode(GL_FRONT_AND_BACK,GL_POINT); break; case D3DFILL_WIREFRAME: - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + pglPolygonMode(GL_FRONT_AND_BACK,GL_LINE); break; case D3DFILL_SOLID: - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); + pglPolygonMode(GL_FRONT_AND_BACK,GL_FILL); break; default: ERR("Unhandled fill mode %ld !\n",dwRenderState); @@ -174,10 +174,10 @@ case D3DRENDERSTATE_SHADEMODE: /* 9 */ switch ((D3DSHADEMODE) dwRenderState) { case D3DSHADE_FLAT: - glShadeModel(GL_FLAT); + pglShadeModel(GL_FLAT); break; case D3DSHADE_GOURAUD: - glShadeModel(GL_SMOOTH); + pglShadeModel(GL_SMOOTH); break; default: ERR("Unhandled shade mode %ld !\n",dwRenderState); @@ -186,16 +186,16 @@ case D3DRENDERSTATE_ZWRITEENABLE: /* 14 */ if (dwRenderState) - glDepthMask(GL_TRUE); + pglDepthMask(GL_TRUE); else - glDepthMask(GL_FALSE); + pglDepthMask(GL_FALSE); break; case D3DRENDERSTATE_ALPHATESTENABLE: /* 15 */ if (dwRenderState) - glEnable(GL_ALPHA_TEST); + pglEnable(GL_ALPHA_TEST); else - glDisable(GL_ALPHA_TEST); + pglDisable(GL_ALPHA_TEST); break; case D3DRENDERSTATE_TEXTUREMAG: { /* 17 */ @@ -242,7 +242,7 @@ case D3DRENDERSTATE_SRCBLEND: /* 19 */ case D3DRENDERSTATE_DESTBLEND: /* 20 */ - glBlendFunc(convert_D3D_blendop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_SRCBLEND - 1]), + pglBlendFunc(convert_D3D_blendop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_SRCBLEND - 1]), convert_D3D_blendop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_DESTBLEND - 1])); break; @@ -250,7 +250,7 @@ switch ((D3DTEXTUREBLEND) dwRenderState) { case D3DTBLEND_MODULATE: case D3DTBLEND_MODULATEALPHA: - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); break; default: ERR("Unhandled texture environment %ld !\n",dwRenderState); @@ -260,17 +260,17 @@ case D3DRENDERSTATE_CULLMODE: /* 22 */ switch ((D3DCULL) dwRenderState) { case D3DCULL_NONE: - glDisable(GL_CULL_FACE); + pglDisable(GL_CULL_FACE); break; case D3DCULL_CW: - glEnable(GL_CULL_FACE); - glFrontFace(GL_CCW); - glCullFace(GL_BACK); + pglEnable(GL_CULL_FACE); + pglFrontFace(GL_CCW); + pglCullFace(GL_BACK); break; case D3DCULL_CCW: - glEnable(GL_CULL_FACE); - glFrontFace(GL_CW); - glCullFace(GL_BACK); + pglEnable(GL_CULL_FACE); + pglFrontFace(GL_CW); + pglCullFace(GL_BACK); break; default: ERR("Unhandled cull mode %ld !\n",dwRenderState); @@ -278,27 +278,27 @@ break; case D3DRENDERSTATE_ZFUNC: /* 23 */ - glDepthFunc(convert_D3D_compare_to_GL(dwRenderState)); + pglDepthFunc(convert_D3D_compare_to_GL(dwRenderState)); break; case D3DRENDERSTATE_ALPHAREF: /* 24 */ case D3DRENDERSTATE_ALPHAFUNC: /* 25 */ - glAlphaFunc(convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_ALPHAFUNC - 1]), + pglAlphaFunc(convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_ALPHAFUNC - 1]), (lpStateBlock->render_state[D3DRENDERSTATE_ALPHAREF - 1] & 0x000000FF) / 255.0); break; case D3DRENDERSTATE_DITHERENABLE: /* 26 */ if (dwRenderState) - glEnable(GL_DITHER); + pglEnable(GL_DITHER); else - glDisable(GL_DITHER); + pglDisable(GL_DITHER); break; case D3DRENDERSTATE_ALPHABLENDENABLE: /* 27 */ if (dwRenderState) { - glEnable(GL_BLEND); + pglEnable(GL_BLEND); } else { - glDisable(GL_BLEND); + pglDisable(GL_BLEND); } break; @@ -327,7 +327,7 @@ color[1] = ((dwRenderState >> 8) & 0xFF)/255.0f; color[2] = ((dwRenderState >> 0) & 0xFF)/255.0f; color[3] = ((dwRenderState >> 24) & 0xFF)/255.0f; - glFogfv(GL_FOG_COLOR,color); + pglFogfv(GL_FOG_COLOR,color); /* Note: glFogiv does not seem to work */ } break; @@ -339,28 +339,28 @@ break; case D3DRENDERSTATE_FOGDENSITY: /* 38 */ - glFogi(GL_FOG_DENSITY,*(float*)&dwRenderState); + pglFogi(GL_FOG_DENSITY,*(float*)&dwRenderState); break; case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */ /* This needs to be fixed. */ if (dwRenderState) - glEnable(GL_BLEND); + pglEnable(GL_BLEND); else - glDisable(GL_BLEND); + pglDisable(GL_BLEND); break; case D3DRENDERSTATE_ZBIAS: /* 47 */ /* This is a tad bit hacky.. But well, no idea how to do it better in OpenGL :-/ */ if (dwRenderState == 0) { - glDisable(GL_POLYGON_OFFSET_FILL); - glDisable(GL_POLYGON_OFFSET_LINE); - glDisable(GL_POLYGON_OFFSET_POINT); + pglDisable(GL_POLYGON_OFFSET_FILL); + pglDisable(GL_POLYGON_OFFSET_LINE); + pglDisable(GL_POLYGON_OFFSET_POINT); } else { - glEnable(GL_POLYGON_OFFSET_FILL); - glEnable(GL_POLYGON_OFFSET_LINE); - glEnable(GL_POLYGON_OFFSET_POINT); - glPolygonOffset(1.0, dwRenderState * 1.0); + pglEnable(GL_POLYGON_OFFSET_FILL); + pglEnable(GL_POLYGON_OFFSET_LINE); + pglEnable(GL_POLYGON_OFFSET_POINT); + pglPolygonOffset(1.0, dwRenderState * 1.0); } break; @@ -369,15 +369,15 @@ case D3DRENDERSTATE_STENCILENABLE: /* 52 */ if (dwRenderState) - glEnable(GL_STENCIL_TEST); + pglEnable(GL_STENCIL_TEST); else - glDisable(GL_STENCIL_TEST); + pglDisable(GL_STENCIL_TEST); break; case D3DRENDERSTATE_STENCILFAIL: /* 53 */ case D3DRENDERSTATE_STENCILZFAIL: /* 54 */ case D3DRENDERSTATE_STENCILPASS: /* 55 */ - glStencilOp(convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFAIL - 1]), + pglStencilOp(convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFAIL - 1]), convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILZFAIL - 1]), convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILPASS - 1])); break; @@ -385,13 +385,13 @@ case D3DRENDERSTATE_STENCILFUNC: /* 56 */ case D3DRENDERSTATE_STENCILREF: /* 57 */ case D3DRENDERSTATE_STENCILMASK: /* 58 */ - glStencilFunc(convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFUNC - 1]), + pglStencilFunc(convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFUNC - 1]), lpStateBlock->render_state[D3DRENDERSTATE_STENCILREF - 1], lpStateBlock->render_state[D3DRENDERSTATE_STENCILMASK - 1]); break; case D3DRENDERSTATE_STENCILWRITEMASK: /* 59 */ - glStencilMask(dwRenderState); + pglStencilMask(dwRenderState); break; case D3DRENDERSTATE_CLIPPING: /* 136 */ @@ -407,9 +407,9 @@ } for (i = 0, runner = 0x00000001; i < This->max_clipping_planes; i++, runner = (runner << 1)) { if (mask & runner) { - glEnable(GL_CLIP_PLANE0 + i); + pglEnable(GL_CLIP_PLANE0 + i); } else { - glDisable(GL_CLIP_PLANE0 + i); + pglDisable(GL_CLIP_PLANE0 + i); } } } @@ -417,9 +417,9 @@ case D3DRENDERSTATE_LIGHTING: /* 137 */ if (dwRenderState) - glEnable(GL_LIGHTING); + pglEnable(GL_LIGHTING); else - glDisable(GL_LIGHTING); + pglDisable(GL_LIGHTING); break; case D3DRENDERSTATE_AMBIENT: { /* 139 */ @@ -429,7 +429,7 @@ light[1] = ((dwRenderState >> 8) & 0xFF) / 255.0; light[2] = ((dwRenderState >> 0) & 0xFF) / 255.0; light[3] = ((dwRenderState >> 24) & 0xFF) / 255.0; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light); + pglLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light); } break; case D3DRENDERSTATE_COLORVERTEX: /* 141 */ @@ -438,18 +438,18 @@ case D3DRENDERSTATE_LOCALVIEWER: /* 142 */ if (dwRenderState) - glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); + pglLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); else - glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); + pglLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); break; case D3DRENDERSTATE_NORMALIZENORMALS: /* 143 */ if (dwRenderState) { - glEnable(GL_NORMALIZE); - glEnable(GL_RESCALE_NORMAL); + pglEnable(GL_NORMALIZE); + pglEnable(GL_RESCALE_NORMAL); } else { - glDisable(GL_NORMALIZE); - glDisable(GL_RESCALE_NORMAL); + pglDisable(GL_NORMALIZE); + pglDisable(GL_RESCALE_NORMAL); } break; Index: dlls/ddraw/mesa_private.h =================================================================== RCS file: /home/wine/wine/dlls/ddraw/mesa_private.h,v retrieving revision 1.42 diff -u -r1.42 mesa_private.h --- dlls/ddraw/mesa_private.h 12 May 2003 03:09:17 -0000 1.42 +++ dlls/ddraw/mesa_private.h 15 May 2003 04:10:46 -0000 @@ -26,26 +26,7 @@ #ifdef HAVE_OPENGL -#undef APIENTRY -#undef CALLBACK -#undef WINAPI - -#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */ -#include <GL/gl.h> -#include <GL/glx.h> -#ifdef HAVE_GL_GLEXT_H -# include <GL/glext.h> -#endif -#undef XMD_H - -#undef APIENTRY -#undef CALLBACK -#undef WINAPI - -/* Redefines the constants */ -#define CALLBACK __stdcall -#define WINAPI __stdcall -#define APIENTRY WINAPI +#include "gl_private.h" /* X11 locking */ Index: dlls/ddraw/d3ddevice/mesa.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/mesa.c,v retrieving revision 1.97 diff -u -r1.97 mesa.c --- dlls/ddraw/d3ddevice/mesa.c 13 May 2003 00:41:58 -0000 1.97 +++ dlls/ddraw/d3ddevice/mesa.c 15 May 2003 04:10:47 -0000 @@ -109,7 +109,7 @@ { TRACE("(%p, %ld)\n",(Display*)display,(Drawable)drawable); ENTER_GL(); - glXSwapBuffers((Display*)display,(Drawable)drawable); + pglXSwapBuffers((Display*)display,(Drawable)drawable); LEAVE_GL(); return TRUE; } @@ -124,7 +124,7 @@ ENTER_GL(); TRACE("glxMakeCurrent %p, %ld, %p\n",glThis->display,glThis->drawable, glThis->gl_context); - if (glXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) { + if (pglXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) { ERR("Error in setting current context (context %p drawable %ld)!\n", glThis->gl_context, glThis->drawable); } @@ -265,10 +265,10 @@ devcap = (Mesa_DeviceCapabilities *) private->device_capabilities; ENTER_GL(); - ext_string = glGetString(GL_EXTENSIONS); + ext_string = pglGetString(GL_EXTENSIONS); /* Query for the ColorTable Extension */ if (strstr(ext_string, "GL_EXT_paletted_texture")) { - devcap->ptr_ColorTableEXT = (PFNGLCOLORTABLEEXTPROC) glXGetProcAddressARB("glColorTableEXT"); + devcap->ptr_ColorTableEXT = (PFNGLCOLORTABLEEXTPROC) pglXGetProcAddressARB("glColorTableEXT"); TRACE("Color table extension supported (function at %p)\n", devcap->ptr_ColorTableEXT); } else { TRACE("Color table extension not found.\n"); @@ -348,7 +348,7 @@ DeleteCriticalSection(&(This->crit)); ENTER_GL(); - glXDestroyContext(glThis->display, glThis->gl_context); + pglXDestroyContext(glThis->display, glThis->gl_context); LEAVE_GL(); HeapFree(GetProcessHeap(), 0, This->clipping_planes); @@ -694,32 +694,32 @@ switch (d3dpt) { case D3DPT_POINTLIST: TRACE("Start POINTS\n"); - glBegin(GL_POINTS); + pglBegin(GL_POINTS); break; case D3DPT_LINELIST: TRACE("Start LINES\n"); - glBegin(GL_LINES); + pglBegin(GL_LINES); break; case D3DPT_LINESTRIP: TRACE("Start LINE_STRIP\n"); - glBegin(GL_LINE_STRIP); + pglBegin(GL_LINE_STRIP); break; case D3DPT_TRIANGLELIST: TRACE("Start TRIANGLES\n"); - glBegin(GL_TRIANGLES); + pglBegin(GL_TRIANGLES); break; case D3DPT_TRIANGLESTRIP: TRACE("Start TRIANGLE_STRIP\n"); - glBegin(GL_TRIANGLE_STRIP); + pglBegin(GL_TRIANGLE_STRIP); break; case D3DPT_TRIANGLEFAN: TRACE("Start TRIANGLE_FAN\n"); - glBegin(GL_TRIANGLE_FAN); + pglBegin(GL_TRIANGLE_FAN); break; default: @@ -787,7 +787,7 @@ if no fogging state change occured */ if (This->state_block.render_state[D3DRENDERSTATE_FOGENABLE - 1] == TRUE) { if (vertex_transformed == TRUE) { - glDisable(GL_FOG); + pglDisable(GL_FOG); /* Now check if our fog_table still corresponds to the current vertex color. Element '0x..00' is always the fog color as it corresponds to maximum fog intensity */ if ((glThis->fog_table[0 * 0x10000 + 0x0000] != ((This->state_block.render_state[D3DRENDERSTATE_FOGCOLOR - 1] >> 0) & 0xFF)) || @@ -799,32 +799,32 @@ } else { if (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE - 1] != D3DFOG_NONE) { switch (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE - 1]) { - case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); break; - case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); break; - case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); break; + case D3DFOG_LINEAR: pglFogi(GL_FOG_MODE, GL_LINEAR); break; + case D3DFOG_EXP: pglFogi(GL_FOG_MODE, GL_EXP); break; + case D3DFOG_EXP2: pglFogi(GL_FOG_MODE, GL_EXP2); break; } if (vertex_lit == FALSE) { - glFogf(GL_FOG_START, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1]); - glFogf(GL_FOG_END, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1]); + pglFogf(GL_FOG_START, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1]); + pglFogf(GL_FOG_END, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1]); } else { /* Special case of 'pixel fog' */ - glFogf(GL_FOG_START, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1])); - glFogf(GL_FOG_END, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1])); + pglFogf(GL_FOG_START, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1])); + pglFogf(GL_FOG_END, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1])); } - glEnable(GL_FOG); + pglEnable(GL_FOG); } else { - glDisable(GL_FOG); + pglDisable(GL_FOG); } } } else { - glDisable(GL_FOG); + pglDisable(GL_FOG); } /* Handle the 'no-normal' case */ if ((vertex_lit == FALSE) && (This->state_block.render_state[D3DRENDERSTATE_LIGHTING - 1] == TRUE)) - glEnable(GL_LIGHTING); + pglEnable(GL_LIGHTING); else - glDisable(GL_LIGHTING); + pglDisable(GL_LIGHTING); /* Handle the code for pre-vertex material properties */ if (vertex_transformed == FALSE) { @@ -834,7 +834,7 @@ (This->state_block.render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] != D3DMCS_MATERIAL) || (This->state_block.render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] != D3DMCS_MATERIAL) || (This->state_block.render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] != D3DMCS_MATERIAL)) { - glEnable(GL_COLOR_MATERIAL); + pglEnable(GL_COLOR_MATERIAL); } } } @@ -950,40 +950,40 @@ /* These are the various handler used in the generic path */ inline static void handle_xyz(D3DVALUE *coords) { - glVertex3fv(coords); + pglVertex3fv(coords); } inline static void handle_xyzrhw(D3DVALUE *coords) { if (coords[3] < 1e-8) - glVertex3fv(coords); + pglVertex3fv(coords); else { GLfloat w = 1.0 / coords[3]; - glVertex4f(coords[0] * w, + pglVertex4f(coords[0] * w, coords[1] * w, coords[2] * w, w); } } inline static void handle_normal(D3DVALUE *coords) { - glNormal3fv(coords); + pglNormal3fv(coords); } inline static void handle_diffuse_base(STATEBLOCK *sb, DWORD *color) { if ((sb->render_state[D3DRENDERSTATE_ALPHATESTENABLE - 1] == TRUE) || (sb->render_state[D3DRENDERSTATE_ALPHABLENDENABLE - 1] == TRUE)) { - glColor4ub((*color >> 16) & 0xFF, + pglColor4ub((*color >> 16) & 0xFF, (*color >> 8) & 0xFF, (*color >> 0) & 0xFF, (*color >> 24) & 0xFF); } else { - glColor3ub((*color >> 16) & 0xFF, + pglColor3ub((*color >> 16) & 0xFF, (*color >> 8) & 0xFF, (*color >> 0) & 0xFF); } } inline static void handle_specular_base(STATEBLOCK *sb, DWORD *color) { - glColor4ub((*color >> 16) & 0xFF, + pglColor4ub((*color >> 16) & 0xFF, (*color >> 8) & 0xFF, (*color >> 0) & 0xFF, (*color >> 24) & 0xFF); /* No idea if the alpha field is really used.. */ @@ -994,20 +994,20 @@ (sb->render_state[D3DRENDERSTATE_LIGHTING - 1] == TRUE) && (sb->render_state[D3DRENDERSTATE_COLORVERTEX - 1] == TRUE)) { if (sb->render_state[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + pglColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); handle_diffuse_base(sb, color); } if (sb->render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); + pglColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); handle_diffuse_base(sb, color); } if ((sb->render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] == D3DMCS_COLOR1) && (sb->render_state[D3DRENDERSTATE_SPECULARENABLE - 1] == TRUE)) { - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + pglColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); handle_diffuse_base(sb, color); } if (sb->render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); + pglColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); handle_diffuse_base(sb, color); } } else { @@ -1020,20 +1020,20 @@ (sb->render_state[D3DRENDERSTATE_LIGHTING - 1] == TRUE) && (sb->render_state[D3DRENDERSTATE_COLORVERTEX - 1] == TRUE)) { if (sb->render_state[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + pglColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); handle_specular_base(sb, color); } if (sb->render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); + pglColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); handle_specular_base(sb, color); } if ((sb->render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] == D3DMCS_COLOR2) && (sb->render_state[D3DRENDERSTATE_SPECULARENABLE - 1] == TRUE)) { - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + pglColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); handle_specular_base(sb, color); } if (sb->render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); + pglColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); handle_specular_base(sb, color); } } @@ -1067,11 +1067,11 @@ } inline static void handle_texture(D3DVALUE *coords) { - glTexCoord2fv(coords); + pglTexCoord2fv(coords); } inline static void handle_textures(D3DVALUE *coords, int tex_index) { /* For the moment, draw only the first texture.. */ - if (tex_index == 0) glTexCoord2fv(coords); + if (tex_index == 0) pglTexCoord2fv(coords); } static void draw_primitive_strided(IDirect3DDeviceImpl *This, @@ -1104,7 +1104,7 @@ if ((d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) { vertex_lighted = TRUE; } else { - if ((d3dvtVertexType & D3DFVF_NORMAL) == 0) glNormal3f(0.0, 0.0, 0.0); + if ((d3dvtVertexType & D3DFVF_NORMAL) == 0) pglNormal3f(0.0, 0.0, 0.0); } draw_primitive_handle_GL_state(This, @@ -1270,10 +1270,10 @@ ERR(" matrix weighting not handled yet....\n"); } - glEnd(); + pglEnd(); /* Whatever the case, disable the color material stuff */ - glDisable(GL_COLOR_MATERIAL); + pglDisable(GL_COLOR_MATERIAL); LEAVE_GL(); TRACE("End\n"); @@ -1541,15 +1541,15 @@ } if (is_color) { - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT + num, src); + pglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT + num, src); if (is_alpha_replicate) { - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); + pglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); } else { - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_COLOR : GL_SRC_COLOR); + pglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_COLOR : GL_SRC_COLOR); } } else { - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT + num, src); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); + pglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT + num, src); + pglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); } return handled; @@ -1628,7 +1628,7 @@ } } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, convert_min_filter_to_GL(This->state_block.texture_stage_state[dwStage][D3DTSS_MINFILTER - 1], This->state_block.texture_stage_state[dwStage][D3DTSS_MIPFILTER - 1])); break; @@ -1641,7 +1641,7 @@ default: FIXME(" Unhandled stage type : D3DTSS_MAGFILTER => %08lx\n", dwState); break; } } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, convert_mag_filter_to_GL(dwState)); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, convert_mag_filter_to_GL(dwState)); break; case D3DTSS_ADDRESS: @@ -1661,10 +1661,10 @@ } if ((d3dTexStageStateType == D3DTSS_ADDRESS) || (d3dTexStageStateType == D3DTSS_ADDRESSU)) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, arg); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, arg); if ((d3dTexStageStateType == D3DTSS_ADDRESS) || (d3dTexStageStateType == D3DTSS_ADDRESSV)) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, arg); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, arg); } break; case D3DTSS_ALPHAOP: @@ -1706,18 +1706,18 @@ } if ((d3dTexStageStateType == D3DTSS_COLOROP) && (dwState == D3DTOP_DISABLE) && (dwStage == 0)) { - glDisable(GL_TEXTURE_2D); + pglDisable(GL_TEXTURE_2D); TRACE(" disabling 2D texturing.\n"); } else { /* Re-enable texturing */ if ((dwStage == 0) && (This->current_texture[0] != NULL)) { - glEnable(GL_TEXTURE_2D); + pglEnable(GL_TEXTURE_2D); TRACE(" enabling 2D texturing.\n"); } /* Re-Enable GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT */ if (dwState != D3DTOP_DISABLE) { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); } /* Now set up the operand correctly */ @@ -1730,7 +1730,7 @@ case D3DTOP_SELECTARG1: case D3DTOP_SELECTARG2: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_REPLACE); + pglTexEnvi(GL_TEXTURE_ENV, parm, GL_REPLACE); break; case D3DTOP_MODULATE4X: @@ -1738,17 +1738,17 @@ case D3DTOP_MODULATE2X: scale = scale * 2; /* Drop through */ case D3DTOP_MODULATE: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_MODULATE); + pglTexEnvi(GL_TEXTURE_ENV, parm, GL_MODULATE); break; case D3DTOP_ADD: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD); + pglTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD); break; case D3DTOP_ADDSIGNED2X: scale = scale * 2; /* Drop through */ case D3DTOP_ADDSIGNED: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD_SIGNED_EXT); + pglTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD_SIGNED_EXT); break; default: @@ -1779,9 +1779,9 @@ if (handled) { if (d3dTexStageStateType == D3DTSS_ALPHAOP) { - glTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale); + pglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale); } else { - glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, scale); + pglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, scale); } TRACE(" Stage type is : %s => %s\n", type, value); } else { @@ -1859,7 +1859,7 @@ color[2] = ((dwState >> 0) & 0xFF) / 255.0; color[3] = ((dwState >> 24) & 0xFF) / 255.0; - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); + pglTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); } break; case D3DTSS_TEXCOORDINDEX: { @@ -1939,8 +1939,8 @@ This->current_texture[dwStage] = NULL; TRACE(" disabling 2D texturing.\n"); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); + pglBindTexture(GL_TEXTURE_2D, 0); + pglDisable(GL_TEXTURE_2D); } else { IDirectDrawSurfaceImpl *tex_impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpTexture2); GLint max_mip_level; @@ -1950,7 +1950,7 @@ if (This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE) { /* Do not re-enable texturing if it was disabled due to the COLOROP code */ - glEnable(GL_TEXTURE_2D); + pglEnable(GL_TEXTURE_2D); TRACE(" enabling 2D texturing.\n"); } gltex_upload_texture(tex_impl); @@ -1961,12 +1961,12 @@ max_mip_level = tex_impl->surface_desc.u2.dwMipMapCount - 1; } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, convert_mag_filter_to_GL(This->state_block.texture_stage_state[dwStage][D3DTSS_MAGFILTER - 1])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, convert_min_filter_to_GL(This->state_block.texture_stage_state[dwStage][D3DTSS_MINFILTER - 1], This->state_block.texture_stage_state[dwStage][D3DTSS_MIPFILTER - 1])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_mip_level); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_mip_level); } LEAVE_GL(); @@ -2001,19 +2001,19 @@ This->current_material = *lpMat; - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *) &(This->current_material.u.diffuse)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *) &(This->current_material.u1.ambient)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float *) &(This->current_material.u2.specular)); - glMaterialfv(GL_FRONT_AND_BACK, + pglMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float *) &(This->current_material.u3.emissive)); - glMaterialf(GL_FRONT_AND_BACK, + pglMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, This->current_material.u4.power); /* Not sure about this... */ @@ -2043,34 +2043,34 @@ float direction[4]; float cut_off = 180.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); direction[0] = lpLight->dvDirection.u1.x; direction[1] = lpLight->dvDirection.u2.y; direction[2] = lpLight->dvDirection.u3.z; direction[3] = 0.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) direction); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) direction); } break; case D3DLIGHT_POINT: { float position[4]; float cut_off = 180.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); position[0] = lpLight->dvPosition.u1.x; position[1] = lpLight->dvPosition.u2.y; position[2] = lpLight->dvPosition.u3.z; position[3] = 1.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) position); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_CONSTANT_ATTENUATION, &(lpLight->dvAttenuation0)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_LINEAR_ATTENUATION, &(lpLight->dvAttenuation1)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_QUADRATIC_ATTENUATION, &(lpLight->dvAttenuation2)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) position); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_CONSTANT_ATTENUATION, &(lpLight->dvAttenuation0)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_LINEAR_ATTENUATION, &(lpLight->dvAttenuation1)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_QUADRATIC_ATTENUATION, &(lpLight->dvAttenuation2)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); } break; case D3DLIGHT_SPOT: { @@ -2078,25 +2078,25 @@ float position[4]; float cut_off = 90.0 * (lpLight->dvPhi / M_PI); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_AMBIENT, (float *) &(lpLight->dcvAmbient)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_DIFFUSE, (float *) &(lpLight->dcvDiffuse)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPECULAR, (float *) &(lpLight->dcvSpecular)); direction[0] = lpLight->dvDirection.u1.x; direction[1] = lpLight->dvDirection.u2.y; direction[2] = lpLight->dvDirection.u3.z; direction[3] = 0.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_DIRECTION, (float *) direction); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_DIRECTION, (float *) direction); position[0] = lpLight->dvPosition.u1.x; position[1] = lpLight->dvPosition.u2.y; position[2] = lpLight->dvPosition.u3.z; position[3] = 1.0; - glLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) position); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_CONSTANT_ATTENUATION, &(lpLight->dvAttenuation0)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_LINEAR_ATTENUATION, &(lpLight->dvAttenuation1)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_QUADRATIC_ATTENUATION, &(lpLight->dvAttenuation2)); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); - glLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_EXPONENT, &(lpLight->dvFalloff)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_POSITION, (float *) position); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_CONSTANT_ATTENUATION, &(lpLight->dvAttenuation0)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_LINEAR_ATTENUATION, &(lpLight->dvAttenuation1)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_QUADRATIC_ATTENUATION, &(lpLight->dvAttenuation2)); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_CUTOFF, &cut_off); + pglLightfv(GL_LIGHT0 + dwLightIndex, GL_SPOT_EXPONENT, &(lpLight->dvFalloff)); if ((lpLight->dvTheta != 0.0) || (lpLight->dvTheta != lpLight->dvPhi)) { WARN("dvTheta not fully supported yet !\n"); } @@ -2124,9 +2124,9 @@ TRACE(" setting default light parameters...\n"); GL_IDirect3DDeviceImpl_7_SetLight(iface, dwLightIndex, &(This->light_parameters[dwLightIndex])); } - glEnable(GL_LIGHT0 + dwLightIndex); + pglEnable(GL_LIGHT0 + dwLightIndex); } else { - glDisable(GL_LIGHT0 + dwLightIndex); + pglDisable(GL_LIGHT0 + dwLightIndex); } return DD_OK; @@ -2153,7 +2153,7 @@ plane[3] = pPlaneEquation[3]; /* XXX: is here also code needed to handle the transformation of the world? */ - glClipPlane( GL_CLIP_PLANE0+dwIndex, (const GLdouble*)(&plane) ); + pglClipPlane( GL_CLIP_PLANE0+dwIndex, (const GLdouble*)(&plane) ); return D3D_OK; } @@ -2400,41 +2400,41 @@ ENTER_GL(); if (dwFlags & D3DCLEAR_ZBUFFER) { bitfield |= GL_DEPTH_BUFFER_BIT; - glGetBooleanv(GL_DEPTH_WRITEMASK, &ztest); - glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */ - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value); - glClearDepth(dvZ); + pglGetBooleanv(GL_DEPTH_WRITEMASK, &ztest); + pglDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */ + pglGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value); + pglClearDepth(dvZ); TRACE(" depth value : %f\n", dvZ); } if (dwFlags & D3DCLEAR_STENCIL) { bitfield |= GL_STENCIL_BUFFER_BIT; - glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value); - glClearStencil(dwStencil); + pglGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value); + pglClearStencil(dwStencil); TRACE(" stencil value : %ld\n", dwStencil); } if (dwFlags & D3DCLEAR_TARGET) { bitfield |= GL_COLOR_BUFFER_BIT; - glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value); - glClearColor(((dwColor >> 16) & 0xFF) / 255.0, + pglGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value); + pglClearColor(((dwColor >> 16) & 0xFF) / 255.0, ((dwColor >> 8) & 0xFF) / 255.0, ((dwColor >> 0) & 0xFF) / 255.0, ((dwColor >> 24) & 0xFF) / 255.0); TRACE(" color value (ARGB) : %08lx\n", dwColor); } - glClear(bitfield); + pglClear(bitfield); if (dwFlags & D3DCLEAR_ZBUFFER) { - glDepthMask(ztest); - glClearDepth(old_z_clear_value); + pglDepthMask(ztest); + pglClearDepth(old_z_clear_value); } if (dwFlags & D3DCLEAR_STENCIL) { bitfield |= GL_STENCIL_BUFFER_BIT; - glClearStencil(old_stencil_clear_value); + pglClearStencil(old_stencil_clear_value); } if (dwFlags & D3DCLEAR_TARGET) { bitfield |= GL_COLOR_BUFFER_BIT; - glClearColor(old_color_clear_value[0], + pglClearColor(old_color_clear_value[0], old_color_clear_value[1], old_color_clear_value[2], old_color_clear_value[3]); @@ -2486,8 +2486,8 @@ trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0; trans_mat[14] = -1.0; trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0; trans_mat[15] = 1.0; - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); /* See the OpenGL Red Book for an explanation of the following translation (in the OpenGL Correctness Tips section). @@ -2496,9 +2496,9 @@ one and we will have strange artifacts (as the rounding and stuff may give different results for different pixels, ie sometimes take the left pixel, sometimes the right). */ - glTranslatef(0.375, 0.375, 0); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(trans_mat); + pglTranslatef(0.375, 0.375, 0); + pglMatrixMode(GL_PROJECTION); + pglLoadMatrixf(trans_mat); } void @@ -2506,13 +2506,13 @@ D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat) { if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED)) != 0) { - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf((float *) view_mat); - glMultMatrixf((float *) world_mat); + pglMatrixMode(GL_MODELVIEW); + pglLoadMatrixf((float *) view_mat); + pglMultMatrixf((float *) world_mat); } if ((matrices & PROJMAT_CHANGED) != 0) { - glMatrixMode(GL_PROJECTION); - glLoadMatrixf((float *) proj_mat); + pglMatrixMode(GL_PROJECTION); + pglLoadMatrixf((float *) proj_mat); } } @@ -2548,15 +2548,15 @@ ENTER_GL(); - glGetIntegerv(GL_READ_BUFFER, &prev_read); - glFlush(); + pglGetIntegerv(GL_READ_BUFFER, &prev_read); + pglFlush(); if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER|DDSCAPS_PRIMARYSURFACE)) != 0) { /* Application wants to lock the front buffer */ - glReadBuffer(GL_FRONT); + pglReadBuffer(GL_FRONT); } else if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER)) == (DDSCAPS_BACKBUFFER)) { /* Application wants to lock the back buffer */ - glReadBuffer(GL_BACK); + pglReadBuffer(GL_BACK); } else { WARN(" do not support 3D surface locking for this surface type - trying to use default buffer.\n"); } @@ -2577,12 +2577,12 @@ loc_rect = *pRect; } #if 0 - glReadPixels(loc_rect.left, loc_rect.top, loc_rect.right, loc_rect.bottom, + pglReadPixels(loc_rect.left, loc_rect.top, loc_rect.right, loc_rect.bottom, GL_RGB, buffer_type, ((char *)This->surface_desc.lpSurface + loc_rect.top * This->surface_desc.u1.lPitch + loc_rect.left * GET_BPP(This->surface_desc))); #endif - glReadBuffer(prev_read); + pglReadBuffer(prev_read); LEAVE_GL(); } } @@ -2598,14 +2598,14 @@ ENTER_GL(); - glGetIntegerv(GL_DRAW_BUFFER, &prev_draw); + pglGetIntegerv(GL_DRAW_BUFFER, &prev_draw); if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER|DDSCAPS_PRIMARYSURFACE)) != 0) { /* Application wants to lock the front buffer */ - glDrawBuffer(GL_FRONT); + pglDrawBuffer(GL_FRONT); } else if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER)) == (DDSCAPS_BACKBUFFER)) { /* Application wants to lock the back buffer */ - glDrawBuffer(GL_BACK); + pglDrawBuffer(GL_BACK); } else { WARN(" do not support 3D surface unlocking for this surface type - trying to use default buffer.\n"); } @@ -2620,12 +2620,12 @@ LeaveCriticalSection(&(This->d3ddevice->crit)); return; } - glRasterPos2f(0.0, 0.0); + pglRasterPos2f(0.0, 0.0); #if 0 - glDrawPixels(This->surface_desc.dwWidth, This->surface_desc.dwHeight, + pglDrawPixels(This->surface_desc.dwWidth, This->surface_desc.dwHeight, GL_RGB, buffer_type, This->surface_desc.lpSurface); #endif - glDrawBuffer(prev_draw); + pglDrawBuffer(prev_draw); LEAVE_GL(); } @@ -2698,7 +2698,7 @@ TRACE(" visual found\n"); } - gl_object->gl_context = glXCreateContext(gl_object->display, vis, + gl_object->gl_context = pglXCreateContext(gl_object->display, vis, NULL, GL_TRUE); if (gl_object->gl_context == NULL) { @@ -2774,7 +2774,7 @@ TRACE(" current context set\n"); /* allocate the clipping planes */ - glGetIntegerv(GL_MAX_CLIP_PLANES,&max_clipping_planes); + pglGetIntegerv(GL_MAX_CLIP_PLANES,&max_clipping_planes); if (max_clipping_planes>32) { object->max_clipping_planes=32; } else { @@ -2783,13 +2783,13 @@ TRACE(" capable of %d clipping planes\n", (int)object->max_clipping_planes ); object->clipping_planes = (d3d7clippingplane*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->max_clipping_planes * sizeof(d3d7clippingplane)); - glHint(GL_FOG_HINT,GL_NICEST); + pglHint(GL_FOG_HINT,GL_NICEST); - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glDrawBuffer(buffer); - glReadBuffer(buffer); - /* glDisable(GL_DEPTH_TEST); Need here to check for the presence of a ZBuffer and to reenable it when the ZBuffer is attached */ + pglClearColor(0.0, 0.0, 0.0, 0.0); + pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + pglDrawBuffer(buffer); + pglReadBuffer(buffer); + /* pglDisable(GL_DEPTH_TEST); Need here to check for the presence of a ZBuffer and to reenable it when the ZBuffer is attached */ LEAVE_GL(); /* fill_device_capabilities(d3d->ddraw); */ Index: dlls/ddraw/ddraw/hal.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/ddraw/hal.c,v retrieving revision 1.9 diff -u -r1.9 hal.c --- dlls/ddraw/ddraw/hal.c 13 Jan 2003 18:30:47 -0000 1.9 +++ dlls/ddraw/ddraw/hal.c 15 May 2003 04:10:48 -0000 @@ -139,8 +139,10 @@ } #ifdef HAVE_OPENGL - if (d3d_hal_data.hwCaps.dwFlags & D3DDD_WINE_OPENGL_DEVICE) { - /*GL_DirectDraw_Init(&dd_gbl);*/ + if( opengl_initialized ) { + if (d3d_hal_data.hwCaps.dwFlags & D3DDD_WINE_OPENGL_DEVICE) { + /*GL_DirectDraw_Init(&dd_gbl);*/ + } } #endif Index: dlls/ddraw/ddraw/main.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/ddraw/main.c,v retrieving revision 1.40 diff -u -r1.40 main.c --- dlls/ddraw/ddraw/main.c 11 May 2003 03:46:53 -0000 1.40 +++ dlls/ddraw/ddraw/main.c 15 May 2003 04:10:48 -0000 @@ -179,10 +179,11 @@ *obj = ICOM_INTERFACE(This, IDirectDraw4); } #ifdef HAVE_OPENGL - else if ( IsEqualGUID( &IID_IDirect3D , refiid ) || + else if ( opengl_initialized && + ( IsEqualGUID( &IID_IDirect3D , refiid ) || IsEqualGUID( &IID_IDirect3D2 , refiid ) || IsEqualGUID( &IID_IDirect3D3 , refiid ) || - IsEqualGUID( &IID_IDirect3D7 , refiid ) ) + IsEqualGUID( &IID_IDirect3D7 , refiid ) ) ) { IDirect3DImpl *d3d_impl; HRESULT ret_value; Index: dlls/ddraw/ddraw/user.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/ddraw/user.c,v retrieving revision 1.15 diff -u -r1.15 user.c --- dlls/ddraw/ddraw/user.c 7 Mar 2003 20:34:34 -0000 1.15 +++ dlls/ddraw/ddraw/user.c 15 May 2003 04:10:49 -0000 @@ -174,8 +174,11 @@ | DDFXCAPS_BLTSTRETCHY | DDFXCAPS_BLTSTRETCHYN) This->caps.dwCaps |= DDCAPS_GDI | DDCAPS_PALETTE | BLIT_CAPS; #ifdef HAVE_OPENGL - /* Hack for D3D code */ - This->caps.dwCaps |= DDCAPS_3D; + if( opengl_initialized ) + { + /* Hack for D3D code */ + This->caps.dwCaps |= DDCAPS_3D; + } #endif /* HAVE_OPENGL */ This->caps.dwCaps2 |= DDCAPS2_CERTIFIED | DDCAPS2_NOPAGELOCKREQUIRED | DDCAPS2_PRIMARYGAMMA | DDCAPS2_WIDESURFACES; @@ -199,8 +202,11 @@ DDSCAPS_PRIMARYSURFACE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY | DDSCAPS_VISIBLE; #ifdef HAVE_OPENGL - /* Hacks for D3D code */ - This->caps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER; + if( opengl_initialized ) + { + /* Hacks for D3D code */ + This->caps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER; + } #endif /* HAVE_OPENGL */ This->caps.ddsOldCaps.dwCaps = This->caps.ddsCaps.dwCaps; Index: dlls/ddraw/dsurface/main.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/dsurface/main.c,v retrieving revision 1.46 diff -u -r1.46 main.c --- dlls/ddraw/dsurface/main.c 15 Mar 2003 01:11:14 -0000 1.46 +++ dlls/ddraw/dsurface/main.c 15 May 2003 04:10:49 -0000 @@ -179,48 +179,51 @@ return S_OK; } #ifdef HAVE_OPENGL - else if ( IsEqualGUID( &IID_D3DDEVICE_OpenGL, riid ) || - IsEqualGUID( &IID_IDirect3DHALDevice, riid) ) + else if( opengl_initialized ) { - IDirect3DDeviceImpl *d3ddevimpl; - HRESULT ret_value; + if ( IsEqualGUID( &IID_D3DDEVICE_OpenGL, riid ) || + IsEqualGUID( &IID_IDirect3DHALDevice, riid) ) + { + IDirect3DDeviceImpl *d3ddevimpl; + HRESULT ret_value; - ret_value = d3ddevice_create(&d3ddevimpl, This->ddraw_owner->d3d, This); - if (FAILED(ret_value)) return ret_value; + ret_value = d3ddevice_create(&d3ddevimpl, This->ddraw_owner->d3d, This); + if (FAILED(ret_value)) return ret_value; - *ppObj = ICOM_INTERFACE(d3ddevimpl, IDirect3DDevice); - TRACE(" returning Direct3DDevice interface at %p.\n", *ppObj); + *ppObj = ICOM_INTERFACE(d3ddevimpl, IDirect3DDevice); + TRACE(" returning Direct3DDevice interface at %p.\n", *ppObj); - This->ref++; /* No idea if this is correct.. Need to check using real Windows */ - return ret_value; - } - else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) || - IsEqualGUID( &IID_IDirect3DTexture2, riid )) - { - HRESULT ret_value = S_OK; + This->ref++; /* No idea if this is correct.. Need to check using real Windows */ + return ret_value; + } + else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) || + IsEqualGUID( &IID_IDirect3DTexture2, riid )) + { + HRESULT ret_value = S_OK; - if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) == 0) return E_NOINTERFACE; + if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) == 0) return E_NOINTERFACE; - /* In case the texture surface was created before the D3D creation */ - if (This->tex_private == NULL) { - if (This->ddraw_owner->d3d == NULL) { - ERR("Texture created with no D3D object yet.. Not supported !\n"); - return E_NOINTERFACE; - } + /* In case the texture surface was created before the D3D creation */ + if (This->tex_private == NULL) { + if (This->ddraw_owner->d3d == NULL) { + ERR("Texture created with no D3D object yet.. Not supported !\n"); + return E_NOINTERFACE; + } - ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, This->mip_main); - if (FAILED(ret_value)) return ret_value; - } - if (IsEqualGUID( &IID_IDirect3DTexture, riid )) { - *ppObj = ICOM_INTERFACE(This, IDirect3DTexture); - TRACE(" returning Direct3DTexture interface at %p.\n", *ppObj); - } else { - *ppObj = ICOM_INTERFACE(This, IDirect3DTexture2); - TRACE(" returning Direct3DTexture2 interface at %p.\n", *ppObj); - } - This->ref++; - return ret_value; - } + ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, This->mip_main); + if (FAILED(ret_value)) return ret_value; + } + if (IsEqualGUID( &IID_IDirect3DTexture, riid )) { + *ppObj = ICOM_INTERFACE(This, IDirect3DTexture); + TRACE(" returning Direct3DTexture interface at %p.\n", *ppObj); + } else { + *ppObj = ICOM_INTERFACE(This, IDirect3DTexture2); + TRACE(" returning Direct3DTexture2 interface at %p.\n", *ppObj); + } + This->ref++; + return ret_value; + } + } #endif return E_NOINTERFACE; --- /dev/null 1994-07-18 08:46:18.000000000 +0900 +++ dlls/ddraw/gl_private.h 2003-05-15 12:58:01.000000000 +0900 @@ -0,0 +1,105 @@ + +#ifndef __GRAPHICS_WINE_GL_PRIVATE_H +#define __GRAPHICS_WINE_GL_PRIVATE_H + +#ifdef HAVE_OPENGL + +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */ +#include <GL/gl.h> +#include <GL/glx.h> +#ifdef HAVE_GL_GLEXT_H +# include <GL/glext.h> +#endif +#undef XMD_H + +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +/* Redefines the constants */ +#define CALLBACK __stdcall +#define WINAPI __stdcall +#define APIENTRY WINAPI + +#define MAKE_FUNCPTR(f) extern typeof(f) * p##f; + +MAKE_FUNCPTR(glAlphaFunc) +MAKE_FUNCPTR(glBegin) +MAKE_FUNCPTR(glBindTexture) +MAKE_FUNCPTR(glBlendFunc) +MAKE_FUNCPTR(glClear) +MAKE_FUNCPTR(glClearColor) +MAKE_FUNCPTR(glClearDepth) +MAKE_FUNCPTR(glClearStencil) +MAKE_FUNCPTR(glClipPlane) +MAKE_FUNCPTR(glColor3f) +MAKE_FUNCPTR(glColor3ub) +MAKE_FUNCPTR(glColor4ub) +MAKE_FUNCPTR(glColorMaterial) +MAKE_FUNCPTR(glCullFace) +MAKE_FUNCPTR(glDeleteTextures) +MAKE_FUNCPTR(glDepthFunc) +MAKE_FUNCPTR(glDepthMask) +MAKE_FUNCPTR(glDisable) +MAKE_FUNCPTR(glDrawBuffer) +MAKE_FUNCPTR(glDrawPixels) +MAKE_FUNCPTR(glEnable) +MAKE_FUNCPTR(glEnd) +MAKE_FUNCPTR(glFlush) +MAKE_FUNCPTR(glFogf) +MAKE_FUNCPTR(glFogfv) +MAKE_FUNCPTR(glFogi) +MAKE_FUNCPTR(glFrontFace) +MAKE_FUNCPTR(glGenTextures) +MAKE_FUNCPTR(glGetBooleanv) +MAKE_FUNCPTR(glGetFloatv) +MAKE_FUNCPTR(glGetIntegerv) +MAKE_FUNCPTR(glHint) +MAKE_FUNCPTR(glLightModelfv) +MAKE_FUNCPTR(glLightModeli) +MAKE_FUNCPTR(glLightfv) +MAKE_FUNCPTR(glLoadIdentity) +MAKE_FUNCPTR(glLoadMatrixf) +MAKE_FUNCPTR(glMaterialf) +MAKE_FUNCPTR(glMaterialfv) +MAKE_FUNCPTR(glMatrixMode) +MAKE_FUNCPTR(glMultMatrixf) +MAKE_FUNCPTR(glNormal3f) +MAKE_FUNCPTR(glNormal3fv) +MAKE_FUNCPTR(glPolygonMode) +MAKE_FUNCPTR(glPolygonOffset) +MAKE_FUNCPTR(glPopMatrix) +MAKE_FUNCPTR(glPushMatrix) +MAKE_FUNCPTR(glRasterPos2f) +MAKE_FUNCPTR(glReadBuffer) +MAKE_FUNCPTR(glReadPixels) +MAKE_FUNCPTR(glShadeModel) +MAKE_FUNCPTR(glStencilFunc) +MAKE_FUNCPTR(glStencilMask) +MAKE_FUNCPTR(glStencilOp) +MAKE_FUNCPTR(glTexCoord2f) +MAKE_FUNCPTR(glTexCoord2fv) +MAKE_FUNCPTR(glTexEnvi) +MAKE_FUNCPTR(glTexImage2D) +MAKE_FUNCPTR(glTexParameteri) +MAKE_FUNCPTR(glTexParameterfv) +MAKE_FUNCPTR(glTexSubImage2D) +MAKE_FUNCPTR(glTranslatef) +MAKE_FUNCPTR(glVertex3f) +MAKE_FUNCPTR(glVertex3fv) +MAKE_FUNCPTR(glVertex4f) +MAKE_FUNCPTR(glXCreateContext) +MAKE_FUNCPTR(glXDestroyContext) +MAKE_FUNCPTR(glXMakeCurrent) +MAKE_FUNCPTR(glXSwapBuffers) + +#undef MAKE_FUNCPTR + +#endif /* HAVE_OPENGL */ + +#endif /* __GRAPHICS_WINE_GL_PRIVATE_H */ +