mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-11 10:54:15 +02:00
OpenGL UI fixes for on OS X/all platforms
- Reinitialise textures after SDL_SetVideoMode - Fix header includes and remove GLEW setup on OSX
This commit is contained in:
@@ -1043,7 +1043,7 @@ int main(int argc, char * argv[])
|
|||||||
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
|
||||||
//glScaled(2.0f, 2.0f, 1.0f);
|
//glScaled(2.0f, 2.0f, 1.0f);
|
||||||
#endif
|
#endif
|
||||||
#if defined(OGLI)
|
#if defined(OGLI) && !defined(MACOSX)
|
||||||
int status = glewInit();
|
int status = glewInit();
|
||||||
if(status != GLEW_OK)
|
if(status != GLEW_OK)
|
||||||
{
|
{
|
||||||
|
@@ -188,6 +188,9 @@ public:
|
|||||||
//OpenGL specific instance variables
|
//OpenGL specific instance variables
|
||||||
GLuint vidBuf, textTexture;
|
GLuint vidBuf, textTexture;
|
||||||
void Reset();
|
void Reset();
|
||||||
|
void LoadDefaults();
|
||||||
|
void InitialiseTextures();
|
||||||
|
void DestroyTextures();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Common graphics methods in Graphics.cpp
|
//Common graphics methods in Graphics.cpp
|
||||||
|
@@ -10,12 +10,36 @@ Graphics::Graphics():
|
|||||||
{
|
{
|
||||||
// if(gMutex == TMPMUT)
|
// if(gMutex == TMPMUT)
|
||||||
// pthread_mutex_init (&gMutex, NULL);
|
// pthread_mutex_init (&gMutex, NULL);
|
||||||
Reset();
|
LoadDefaults();
|
||||||
|
InitialiseTextures();
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
//Texture for main UI
|
//Texture for main UI
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::LoadDefaults()
|
||||||
|
{
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
//glOrtho(0, WINDOWW*sdl_scale, 0, WINDOWH*sdl_scale, -1, 1);
|
||||||
|
glOrtho(0, WINDOWW*sdl_scale, WINDOWH*sdl_scale, 0, -1, 1);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
//glRasterPos2i(0, WINDOWH);
|
||||||
|
glRasterPos2i(0, 0);
|
||||||
|
glPixelZoom(1, 1);
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::InitialiseTextures()
|
||||||
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glGenTextures(1, &vidBuf);
|
glGenTextures(1, &vidBuf);
|
||||||
@@ -39,6 +63,11 @@ Graphics::Graphics():
|
|||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::DestroyTextures()
|
||||||
|
{
|
||||||
|
//Todo...
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::Acquire()
|
void Graphics::Acquire()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&gMutex);
|
pthread_mutex_lock(&gMutex);
|
||||||
@@ -55,18 +84,9 @@ Graphics::~Graphics()
|
|||||||
|
|
||||||
void Graphics::Reset()
|
void Graphics::Reset()
|
||||||
{
|
{
|
||||||
glMatrixMode(GL_PROJECTION);
|
LoadDefaults();
|
||||||
glLoadIdentity();
|
DestroyTextures();
|
||||||
|
InitialiseTextures();
|
||||||
//glOrtho(0, WINDOWW*sdl_scale, 0, WINDOWH*sdl_scale, -1, 1);
|
|
||||||
glOrtho(0, WINDOWW*sdl_scale, WINDOWH*sdl_scale, 0, -1, 1);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
//glRasterPos2i(0, WINDOWH);
|
|
||||||
glRasterPos2i(0, 0);
|
|
||||||
glPixelZoom(1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Clear()
|
void Graphics::Clear()
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_OS_X_VERSION_10_9
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
#include <OpenGL/gl3.h>
|
#include <OpenGL/gl3.h>
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user