Fixes for Mac OS X (still no textures)

This commit is contained in:
2006-06-19 02:35:13 -04:00
parent d70d3ac4b6
commit e718408b0e
8 changed files with 70 additions and 41 deletions

View File

@@ -70,7 +70,9 @@ namespace OpenArena
uint32 FPS(); uint32 FPS();
void ParseCmds(const char*); void ParseCmds(const char*);
void Print(int x, int y, const char* string, unsigned int set); void Print(int x, int y, const char* string, unsigned int set);
void SetWindow(Window*);
Window* GetWindow();
/*Not Yet Implemented /*Not Yet Implemented
void PlayerConnect(); // implement later void PlayerConnect(); // implement later
void PlayerDisconnect(); // implement later void PlayerDisconnect(); // implement later
@@ -105,7 +107,7 @@ namespace OpenArena
//list<GL_MY_TEXTURE> textures; //list<GL_MY_TEXTURE> textures;
Texture* textures; Texture* textures;
Texture menuTextures[NUM_MENU_TEXTURES]; Texture menuTextures[NUM_MENU_TEXTURES];
Window* _window;
// private: // private:

View File

@@ -15,7 +15,7 @@
#include <GL/glx.h> #include <GL/glx.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/xf86vmode.h> //#include <X11/extensions/xf86vmode.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#endif #endif
@@ -82,7 +82,7 @@ namespace OpenArena
GLXContext hRC; GLXContext hRC;
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
bool doubleBuffered; bool doubleBuffered;
XF86VidModeModeInfo vidMode; //XF86VidModeModeInfo vidMode;
int x, y; int x, y;
Display* display; Display* display;
#endif #endif

View File

@@ -37,6 +37,7 @@ namespace OpenArena
{ {
Level::Level() Level::Level()
{ {
_window = NULL;
textureNames = NULL; textureNames = NULL;
numTextures = 0; numTextures = 0;
textures = NULL; textures = NULL;
@@ -432,31 +433,38 @@ namespace OpenArena
void Level::LoadGLTextures() void Level::LoadGLTextures()
{ {
printf("In LoadGLTextures: _window = %d\n", _window);
/*GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f}; if(_window != NULL)
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);*/
if(textures != NULL)
{ {
delete [] textures; /*
} GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
textures = new Texture[numTextures]; glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
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())) if(textures != NULL)
glFont.BuildFont("oa/textures/menu/font.bmp"); {
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 //Load the console background image
if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga")) 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"); {
menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load("oa/textures/menu/con_back.bmp");
}
}
} }
uint32 Level::FPS() uint32 Level::FPS()
@@ -1222,4 +1230,14 @@ namespace OpenArena
} }
consoleOutput[0] = line; consoleOutput[0] = line;
} }
void Level::SetWindow(Window* window)
{
_window = window;
}
Window* Level::GetWindow()
{
return _window;
}
}; };

View File

@@ -145,6 +145,8 @@ int main(int argc, char** argv)
return 1; return 1;
} }
level.SetWindow(g_Screen);
while(!done) while(!done)
{ {
while(XPending(g_Screen.GetDisplay()) > 0) while(XPending(g_Screen.GetDisplay()) > 0)

View File

@@ -144,6 +144,9 @@ int main(int argc, char** argv)
{ {
return 1; return 1;
} }
level.SetWindow(&g_Screen);
level.LoadGLTextures();
while(!done) while(!done)
{ {

View File

@@ -71,7 +71,9 @@ namespace OpenArena
{ {
if(Loaded()) 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; minFilter = GL_LINEAR;
magFilter = GL_LINEAR; magFilter = GL_LINEAR;
filename = ""; filename = "";

View File

@@ -61,8 +61,8 @@ void OpenArena::Window::Close()
if(_fullscreen) if(_fullscreen)
{ {
XF86VidModeSwitchToMode(display, screen, &vidMode); // XF86VidModeSwitchToMode(display, screen, &vidMode);
XF86VidModeSetViewPort(display, screen, 0, 0); // XF86VidModeSetViewPort(display, screen, 0, 0);
} }
XCloseDisplay(display); XCloseDisplay(display);
} }
@@ -222,27 +222,27 @@ bool OpenArena::Window::Open()
int glxMajorVersion; int glxMajorVersion;
int glxMinorVersion; int glxMinorVersion;
int modeNum; int modeNum;
XF86VidModeModeInfo** modes; // XF86VidModeModeInfo** modes;
Atom wmDelete; Atom wmDelete;
::Window winDummy; ::Window winDummy;
unsigned int borderDummy; unsigned int borderDummy;
display = XOpenDisplay(0); display = XOpenDisplay(0);
screen = DefaultScreen(display); screen = DefaultScreen(display);
XF86VidModeQueryVersion(display, &vidModeMajorVersion, &vidModeMinorVersion); //XF86VidModeQueryVersion(display, &vidModeMajorVersion, &vidModeMinorVersion);
printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion); //printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion);
XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes); //XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes);
vidMode = *modes[0]; //vidMode = *modes[0];
int i; int i;
for(i=0; i<modeNum; i++) for(i=0; i<modeNum; i++)
{ {
//Add a check for colordepth here //Add a check for colordepth here
if((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height)) // if((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height))
{ // {
bestMode = i; // bestMode = i;
} // }
} }
vi = glXChooseVisual(display, screen, attrListDbl); vi = glXChooseVisual(display, screen, attrListDbl);
@@ -274,9 +274,9 @@ bool OpenArena::Window::Open()
if(_fullscreen) if(_fullscreen)
{ {
XF86VidModeSwitchToMode(display, screen, modes[bestMode]); // XF86VidModeSwitchToMode(display, screen, modes[bestMode]);
XF86VidModeSetViewPort(display, screen, 0, 0); // XF86VidModeSetViewPort(display, screen, 0, 0);
XFree(modes); // XFree(modes);
attributes.override_redirect = true; 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); window = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attributes);

View File

@@ -257,6 +257,8 @@ int WINAPI WinMain( HINSTANCE hInstance,
return 0; return 0;
} }
level.SetWindow(g_Screen);
while(!done) while(!done)
{ {
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))