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

@@ -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;
}
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);
}
/*
GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
*/
if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str()))
glFont.BuildFont("oa/textures/menu/font.bmp");
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");
//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;
}
};

View File

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

View File

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

View File

@@ -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 = "";

View File

@@ -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);

View File

@@ -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))