- try to fix bug with menu and OsgGraph

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5994 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 87b99d4520a3222e4f951f31eb8de78d545fbd39
Former-commit-id: 515b83b6c18f11995e2e73efe894e62af6639834
This commit is contained in:
torcs-ng 2015-04-25 20:10:48 +00:00
parent fb2626b855
commit 7a8d701368

View file

@ -22,7 +22,6 @@
@version $Id$ @version $Id$
@ingroup gui @ingroup gui
*/ */
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
@ -42,6 +41,11 @@
#include "guimenu.h" #include "guimenu.h"
#include "musicplayer.h" #include "musicplayer.h"
#ifdef WIN32
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgram = NULL;
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB ;
#endif
#if SDL_MAJOR_VERSION >= 2 #if SDL_MAJOR_VERSION >= 2
SDL_Window* GfuiWindow; SDL_Window* GfuiWindow;
@ -122,6 +126,10 @@ gfuiInit(void)
gfuiInitMenu(); gfuiInitMenu();
initMusic(); initMusic();
#ifdef WIN32
glUseProgram = (PFNGLUSEPROGRAMOBJECTARBPROC)wglGetProcAddress("glUseProgram");
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
#endif
//gfctrlJoyInit(); // Not here ; done later on the fly, when really needed. //gfctrlJoyInit(); // Not here ; done later on the fly, when really needed.
} }
@ -256,6 +264,8 @@ GfuiRedraw(void)
{ {
tGfuiObject *curObj; tGfuiObject *curObj;
glUseProgram(0);
glActiveTextureARB(GL_TEXTURE0);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -272,6 +282,10 @@ GfuiRedraw(void)
gluOrtho2D(0, GfuiScreen->width, 0, GfuiScreen->height); gluOrtho2D(0, GfuiScreen->width, 0, GfuiScreen->height);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
if (GfuiScreen->bgColor.alpha != 0.0) { if (GfuiScreen->bgColor.alpha != 0.0) {
glClearColor(GfuiScreen->bgColor.red, glClearColor(GfuiScreen->bgColor.red,
@ -280,7 +294,7 @@ GfuiRedraw(void)
GfuiScreen->bgColor.alpha); GfuiScreen->bgColor.alpha);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
// Display backround image if any. // Display backround image if any.
if (GfuiScreen->bgImage) { if (GfuiScreen->bgImage) {
@ -288,9 +302,12 @@ GfuiRedraw(void)
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
glColor3f(gfuiColors[GFUI_BASECOLORBGIMAGE][0], glColor3f(gfuiColors[GFUI_BASECOLORBGIMAGE][0],
gfuiColors[GFUI_BASECOLORBGIMAGE][1], gfuiColors[GFUI_BASECOLORBGIMAGE][1],
gfuiColors[GFUI_BASECOLORBGIMAGE][2]); gfuiColors[GFUI_BASECOLORBGIMAGE][2]);
glBindTexture(GL_TEXTURE_2D, GfuiScreen->bgImage); glBindTexture(GL_TEXTURE_2D, GfuiScreen->bgImage);
// Get real 2^N x 2^P texture size (may have been 0 padded at load time // Get real 2^N x 2^P texture size (may have been 0 padded at load time
@ -330,6 +347,7 @@ GfuiRedraw(void)
} }
// Display texture. // Display texture.
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(tx1, ty1); glVertex3f(0.0, 0.0, 0.0); glTexCoord2f(tx1, ty1); glVertex3f(0.0, 0.0, 0.0);
@ -339,6 +357,8 @@ GfuiRedraw(void)
glEnd(); glEnd();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
} }