Fixes for Mac OS X (still no textures)
This commit is contained in:
@@ -70,6 +70,8 @@ namespace OpenArena
|
||||
uint32 FPS();
|
||||
void ParseCmds(const char*);
|
||||
void Print(int x, int y, const char* string, unsigned int set);
|
||||
void SetWindow(Window*);
|
||||
Window* GetWindow();
|
||||
|
||||
/*Not Yet Implemented
|
||||
void PlayerConnect(); // implement later
|
||||
@@ -105,7 +107,7 @@ namespace OpenArena
|
||||
//list<GL_MY_TEXTURE> textures;
|
||||
Texture* textures;
|
||||
Texture menuTextures[NUM_MENU_TEXTURES];
|
||||
|
||||
Window* _window;
|
||||
|
||||
|
||||
// private:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
//#include <X11/extensions/xf86vmode.h>
|
||||
#include <X11/keysym.h>
|
||||
#endif
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenArena
|
||||
GLXContext hRC;
|
||||
XSetWindowAttributes attributes;
|
||||
bool doubleBuffered;
|
||||
XF86VidModeModeInfo vidMode;
|
||||
//XF86VidModeModeInfo vidMode;
|
||||
int x, y;
|
||||
Display* display;
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace OpenArena
|
||||
{
|
||||
Level::Level()
|
||||
{
|
||||
_window = NULL;
|
||||
textureNames = NULL;
|
||||
numTextures = 0;
|
||||
textures = NULL;
|
||||
@@ -432,31 +433,38 @@ namespace OpenArena
|
||||
|
||||
void Level::LoadGLTextures()
|
||||
{
|
||||
|
||||
/*GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
||||
glEnable(GL_LIGHT1);
|
||||
glEnable(GL_LIGHTING);*/
|
||||
|
||||
if(textures != NULL)
|
||||
printf("In LoadGLTextures: _window = %d\n", _window);
|
||||
if(_window != NULL)
|
||||
{
|
||||
delete [] textures;
|
||||
/*
|
||||
GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
||||
glEnable(GL_LIGHT1);
|
||||
glEnable(GL_LIGHTING);
|
||||
*/
|
||||
|
||||
if(textures != NULL)
|
||||
{
|
||||
delete [] textures;
|
||||
}
|
||||
|
||||
textures = new Texture[numTextures];
|
||||
|
||||
for(uint32 i=0; i<numTextures; i++)
|
||||
{
|
||||
if(!textures[i].Load(gamedir + "textures/" + textureNames[i]))
|
||||
textures[i].Load(DEFAULT_TEXTURE_NAME);
|
||||
}
|
||||
|
||||
if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str()))
|
||||
glFont.BuildFont("oa/textures/menu/font.bmp");
|
||||
|
||||
//Load the console background image
|
||||
if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga"))
|
||||
{
|
||||
menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load("oa/textures/menu/con_back.bmp");
|
||||
}
|
||||
}
|
||||
|
||||
textures = new Texture[numTextures];
|
||||
|
||||
for(uint32 i=0; i<numTextures; i++)
|
||||
{
|
||||
if(!textures[i].Load(gamedir + "textures/" + textureNames[i]))
|
||||
textures[i].Load(DEFAULT_TEXTURE_NAME);
|
||||
}
|
||||
|
||||
if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str()))
|
||||
glFont.BuildFont("oa/textures/menu/font.bmp");
|
||||
|
||||
//Load the console background image
|
||||
if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga"))
|
||||
menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load("oa/textures/menu/con_back.bmp");
|
||||
}
|
||||
|
||||
uint32 Level::FPS()
|
||||
@@ -1222,4 +1230,14 @@ namespace OpenArena
|
||||
}
|
||||
consoleOutput[0] = line;
|
||||
}
|
||||
|
||||
void Level::SetWindow(Window* window)
|
||||
{
|
||||
_window = window;
|
||||
}
|
||||
|
||||
Window* Level::GetWindow()
|
||||
{
|
||||
return _window;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -145,6 +145,8 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
level.SetWindow(g_Screen);
|
||||
|
||||
while(!done)
|
||||
{
|
||||
while(XPending(g_Screen.GetDisplay()) > 0)
|
||||
|
||||
@@ -145,6 +145,9 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
level.SetWindow(&g_Screen);
|
||||
level.LoadGLTextures();
|
||||
|
||||
while(!done)
|
||||
{
|
||||
while(XPending(g_Screen.GetDisplay()) > 0)
|
||||
|
||||
@@ -71,7 +71,9 @@ namespace OpenArena
|
||||
{
|
||||
if(Loaded())
|
||||
{
|
||||
FreeGLTexture(id);
|
||||
//This is only temporarily removed for mac os x
|
||||
//TODO make this work on all operating systems
|
||||
//FreeGLTexture(id);
|
||||
minFilter = GL_LINEAR;
|
||||
magFilter = GL_LINEAR;
|
||||
filename = "";
|
||||
|
||||
@@ -61,8 +61,8 @@ void OpenArena::Window::Close()
|
||||
|
||||
if(_fullscreen)
|
||||
{
|
||||
XF86VidModeSwitchToMode(display, screen, &vidMode);
|
||||
XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||
// XF86VidModeSwitchToMode(display, screen, &vidMode);
|
||||
// XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||
}
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
@@ -222,27 +222,27 @@ bool OpenArena::Window::Open()
|
||||
int glxMajorVersion;
|
||||
int glxMinorVersion;
|
||||
int modeNum;
|
||||
XF86VidModeModeInfo** modes;
|
||||
// XF86VidModeModeInfo** modes;
|
||||
Atom wmDelete;
|
||||
::Window winDummy;
|
||||
unsigned int borderDummy;
|
||||
|
||||
display = XOpenDisplay(0);
|
||||
screen = DefaultScreen(display);
|
||||
XF86VidModeQueryVersion(display, &vidModeMajorVersion, &vidModeMinorVersion);
|
||||
printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion);
|
||||
//XF86VidModeQueryVersion(display, &vidModeMajorVersion, &vidModeMinorVersion);
|
||||
//printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion);
|
||||
|
||||
XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes);
|
||||
vidMode = *modes[0];
|
||||
//XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes);
|
||||
//vidMode = *modes[0];
|
||||
|
||||
int i;
|
||||
for(i=0; i<modeNum; i++)
|
||||
{
|
||||
//Add a check for colordepth here
|
||||
if((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height))
|
||||
{
|
||||
bestMode = i;
|
||||
}
|
||||
// if((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height))
|
||||
// {
|
||||
// bestMode = i;
|
||||
// }
|
||||
}
|
||||
|
||||
vi = glXChooseVisual(display, screen, attrListDbl);
|
||||
@@ -274,9 +274,9 @@ bool OpenArena::Window::Open()
|
||||
|
||||
if(_fullscreen)
|
||||
{
|
||||
XF86VidModeSwitchToMode(display, screen, modes[bestMode]);
|
||||
XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||
XFree(modes);
|
||||
// XF86VidModeSwitchToMode(display, screen, modes[bestMode]);
|
||||
// XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||
// XFree(modes);
|
||||
|
||||
attributes.override_redirect = true;
|
||||
window = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attributes);
|
||||
|
||||
@@ -257,6 +257,8 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
return 0;
|
||||
}
|
||||
|
||||
level.SetWindow(g_Screen);
|
||||
|
||||
while(!done)
|
||||
{
|
||||
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
|
||||
|
||||
Reference in New Issue
Block a user