Changed Fixed some apple stuff glGenTextures is still generating a bus error because we don't have a gl context yet.
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</item>
|
</item>
|
||||||
<item id="org.eclipse.cdt.core.pathentry">
|
<item id="org.eclipse.cdt.core.pathentry">
|
||||||
|
<pathentry include="/usr/X11R6/include" kind="inc" path="" system="true"/>
|
||||||
<pathentry kind="src" path=""/>
|
<pathentry kind="src" path=""/>
|
||||||
<pathentry kind="out" path=""/>
|
<pathentry kind="out" path=""/>
|
||||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||||
|
|||||||
24
.project
24
.project
@@ -11,40 +11,44 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
||||||
<value></value>
|
<value>-f Makefile.macosx</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
||||||
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
|
||||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
|
||||||
<value>false</value>
|
|
||||||
</dictionary>
|
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.environment</key>
|
<key>org.eclipse.cdt.make.core.environment</key>
|
||||||
<value></value>
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||||
<value>true</value>
|
<value>false</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
||||||
<value>all</value>
|
<value>all</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
<dictionary>
|
||||||
|
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||||
|
<value>true</value>
|
||||||
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
<key>org.eclipse.cdt.make.core.build.location</key>
|
||||||
<value>clean</value>
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.command</key>
|
<key>org.eclipse.cdt.make.core.build.command</key>
|
||||||
<value>make</value>
|
<value>make</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
<dictionary>
|
||||||
|
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
||||||
|
<value>clean</value>
|
||||||
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
@@ -59,7 +63,7 @@
|
|||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||||
<value>true</value>
|
<value>false</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ EXECUTABLES = OpenArena/OA
|
|||||||
LIBRARIES =
|
LIBRARIES =
|
||||||
BUILDROOT = /usr/local
|
BUILDROOT = /usr/local
|
||||||
PREFIX =
|
PREFIX =
|
||||||
INCLUDE_DIRS = /System/Library/Frameworks/OpenGL.framework/Headers
|
|
||||||
LIBRARY_DIRS = /System/Library/Frameworks/OpenGL.framework/Libraries
|
|
||||||
|
|
||||||
.Phony: all clean install
|
.Phony: all clean install
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#include <GL/glu.h> // Header file for Glu32 library
|
#include <GL/glu.h> // Header file for Glu32 library
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <gl.h> // Header file for OpenGL32 library
|
#include <GL/gl.h> // Header file for OpenGL32 library
|
||||||
#include <glu.h> // Header file for Glu32 library
|
#include <GL/glu.h> // Header file for Glu32 library
|
||||||
#endif
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#pragma warning(disable: 4786)
|
#pragma warning(disable: 4786)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Variables
|
// Variables
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <gl.h>
|
#include <GL/gl.h>
|
||||||
#include <glu.h>
|
#include <GL/glu.h>
|
||||||
#endif
|
#endif
|
||||||
//#include <gl/glaux.h> //Hopefully nothing needs this remove if it works in windows
|
//#include <gl/glaux.h> //Hopefully nothing needs this remove if it works in windows
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -34,7 +34,7 @@ extern OpenArena::Window g_Screen;
|
|||||||
//int InitGL(GLvoid);
|
//int InitGL(GLvoid);
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
bool LoadGLTexture(string , GLuint, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
||||||
void FreeGLTexture(GLuint&);
|
void FreeGLTexture(GLuint);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -10,8 +10,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <gl.h>
|
#include <GL/gl.h>
|
||||||
#include <glu.h>
|
#include <GL/glu.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>
|
||||||
@@ -55,7 +56,21 @@ namespace OpenArena
|
|||||||
Vec2i GetMousePosition();
|
Vec2i GetMousePosition();
|
||||||
void SetMousePosition(Vec2i pos);
|
void SetMousePosition(Vec2i pos);
|
||||||
|
|
||||||
// #ifdef __linux
|
#ifdef __linux
|
||||||
|
Display* GetDisplay();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Cursor CreateWindowedCursor();
|
||||||
|
Cursor CreateFullscreenCursor();
|
||||||
|
int screen;
|
||||||
|
::Window window;
|
||||||
|
GLXContext hRC;
|
||||||
|
XSetWindowAttributes attributes;
|
||||||
|
bool doubleBuffered;
|
||||||
|
XF86VidModeModeInfo vidMode;
|
||||||
|
int x, y;
|
||||||
|
Display* display;
|
||||||
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
Display* GetDisplay();
|
Display* GetDisplay();
|
||||||
|
|
||||||
@@ -90,5 +105,9 @@ LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|||||||
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
|
static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,29 +3,30 @@ CPP = g++ -g
|
|||||||
INCLUDES =
|
INCLUDES =
|
||||||
LD = g++
|
LD = g++
|
||||||
INCLUDEPATH = ../include
|
INCLUDEPATH = ../include
|
||||||
INCLUDE_DIRS = -I/System/Library/Frameworks/OpenGL.framework/Headers
|
X11INCLUDEDIR = /usr/X11R6/include
|
||||||
LIBRARY_DIRS = -L/System/Library/Frameworks/OpenGL.framework/Libraries -L/usr/X11R6/lib
|
X11LIBDIR = /usr/X11R6/lib
|
||||||
|
INCLUDE_DIRS = -I$(X11INCLUDEDIR)
|
||||||
|
LIBRARY_DIRS = -L$(X11LIBDIR)
|
||||||
OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o physics.o player.o strmanip.o tga.o vector.o window.o keys.o main.o
|
OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o physics.o player.o strmanip.o tga.o vector.o window.o keys.o main.o
|
||||||
LIBS = -L/usr/X11R6/lib -lGL -lGLU -lXxf86vm $(INCLUDE_DIRS)
|
LIBS = $(LIBRARY_DIRS) -lGL -lGLU -lXxf86vm -lX11
|
||||||
LIBRARIES =
|
LIBRARIES =
|
||||||
SO_LIBS =
|
SO_LIBS =
|
||||||
SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so
|
SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so
|
||||||
FRAMEWORK_DIR = /System/Library/Frameworks/
|
CPPFLAGS = $(INCLUDE_DIRS)
|
||||||
CPPFLAGS =
|
|
||||||
LDFLAGS = $(LIBS)
|
LDFLAGS = $(LIBS)
|
||||||
.Phony: all clean install
|
.Phony: all clean install
|
||||||
|
|
||||||
all: ../OpenArena/OA
|
all: ../OpenArena/OpenArena
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
rm -f ../OpenArena/OA
|
if [ -f ../OpenArena/OpenArena ]; then rm ../OpenArena/OpenArena; fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
||||||
#Executables
|
#Executables
|
||||||
../OpenArena/OA: $(OBJECTS)
|
../OpenArena/OpenArena: $(OBJECTS)
|
||||||
$(LD) $(LDFLAGS) $(INCLUDE_DIRS) -o ../OpenArena/OA $(OBJECTS)
|
$(LD) $(LDFLAGS) $(INCLUDE_DIRS) -o ../OpenArena/OpenArena $(OBJECTS)
|
||||||
|
|
||||||
#Dynamic Libraries
|
#Dynamic Libraries
|
||||||
oa_game.so:
|
oa_game.so:
|
||||||
@@ -84,5 +85,5 @@ window.o: window.cpp $(INCLUDEPATH)/window.h
|
|||||||
keys.o: keys.cpp $(INCLUDEPATH)/keys.h
|
keys.o: keys.cpp $(INCLUDEPATH)/keys.h
|
||||||
$(CPP) -c $(INCLUDE_DIRS) -o keys.o keys.cpp
|
$(CPP) -c $(INCLUDE_DIRS) -o keys.o keys.cpp
|
||||||
|
|
||||||
main.o: linux.cpp $(INCLUDEPATH)/main.h
|
main.o: macosx.cpp $(INCLUDEPATH)/main.h
|
||||||
$(CPP) -c $(INCLUDE_DIRS) -o main.o linux.cpp
|
$(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp
|
||||||
|
|||||||
@@ -35,9 +35,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//void InitControls();
|
//void InitControls();
|
||||||
//unsigned char TranslateKey(int keyCode);
|
unsigned char TranslateKey(int keyCode);
|
||||||
//unsigned char TranslateButton(int keyCode);
|
unsigned char TranslateButton(int keyCode);
|
||||||
//void HandleConsoleKeyPress(OpenArena::Keys key);
|
void HandleConsoleKeyPress(OpenArena::Keys key);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Function Definitions
|
// Function Definitions
|
||||||
@@ -224,7 +224,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCursorPos(g_Screen.width/2, g_Screen.height/2);//Shit this may be windows specific
|
// SetMousePosition(g_Screen.width/2, g_Screen.height/2);//Shit this may be windows specific
|
||||||
}
|
}
|
||||||
|
|
||||||
//Maybe some of these if not almost all should be moved into Level
|
//Maybe some of these if not almost all should be moved into Level
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
|
|
||||||
#include "../include/mygl.h"
|
#include "../include/mygl.h"
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
void FreeGLTexture(GLuint& texture)
|
void FreeGLTexture(GLuint texture)
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
bool LoadGLTexture(string fn, GLuint texture, GLuint mag, GLuint min)
|
||||||
{
|
{
|
||||||
if(Right(tolower(fn), 4) == ".bmp")
|
if(Right(tolower(fn), 4) == ".bmp")
|
||||||
{
|
{
|
||||||
|
|||||||
190
src/window.cpp
190
src/window.cpp
@@ -9,6 +9,15 @@ void OpenArena::Window::SwapBuffers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
void OpenArena::Window::SwapBuffers()
|
||||||
|
{
|
||||||
|
if(doubleBuffered)
|
||||||
|
{
|
||||||
|
glXSwapBuffers(display, window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void OpenArena::Window::SwapBuffers()
|
void OpenArena::Window::SwapBuffers()
|
||||||
{
|
{
|
||||||
@@ -37,6 +46,27 @@ void OpenArena::Window::Close()
|
|||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
void OpenArena::Window::Close()
|
||||||
|
{
|
||||||
|
if(hRC)
|
||||||
|
{
|
||||||
|
if(!glXMakeCurrent(display, None, NULL))
|
||||||
|
{
|
||||||
|
printf("Could not release drawing context.\n");
|
||||||
|
}
|
||||||
|
glXDestroyContext(display, hRC);
|
||||||
|
hRC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_fullscreen)
|
||||||
|
{
|
||||||
|
XF86VidModeSwitchToMode(display, screen, &vidMode);
|
||||||
|
XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||||
|
}
|
||||||
|
XCloseDisplay(display);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void OpenArena::Window::Close()
|
void OpenArena::Window::Close()
|
||||||
{
|
{
|
||||||
@@ -111,6 +141,110 @@ bool OpenArena::Window::Open()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vi = glXChooseVisual(display, screen, attrListDbl);
|
||||||
|
if(vi == NULL)
|
||||||
|
vi = glXChooseVisual(display, screen, attrListSgl);
|
||||||
|
doubleBuffered = false;
|
||||||
|
printf("Only Singlebuffered Visual!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doubleBuffered = true;
|
||||||
|
printf("Got Doublebuffered Visual!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
glXQueryVersion(display, &glxMajorVersion, & glxMinorVersion);
|
||||||
|
printf("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
|
||||||
|
|
||||||
|
hRC = glXCreateContext(display, vi, 0, GL_TRUE);
|
||||||
|
cmap = XCreateColormap(display, RootWindow(display, vi->screen), vi->visual, AllocNone);
|
||||||
|
attributes.colormap = cmap;
|
||||||
|
attributes.border_pixel = 0;
|
||||||
|
|
||||||
|
attributes.event_mask = ExposureMask |
|
||||||
|
KeyPressMask | KeyReleaseMask |
|
||||||
|
ButtonPressMask | ButtonReleaseMask |
|
||||||
|
// PointerMotionMask | ButtonMotionMask |
|
||||||
|
StructureNotifyMask;
|
||||||
|
|
||||||
|
if(_fullscreen)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
|
||||||
|
XMapRaised(display, window);
|
||||||
|
XGrabKeyboard(display, window, true, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
|
XGrabPointer(display, window, true, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
|
||||||
|
XDefineCursor(display, window, CreateFullscreenCursor());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attributes);
|
||||||
|
wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", true);
|
||||||
|
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||||
|
XSetStandardProperties(display, window, GetName(), GetName(), None, NULL, 0, NULL);
|
||||||
|
XMapRaised(display, window);
|
||||||
|
XDefineCursor(display, window, CreateWindowedCursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
glXMakeCurrent(display, window, hRC);
|
||||||
|
unsigned int twidth, theight, depth;
|
||||||
|
XGetGeometry(display, window, &winDummy, &x, &y, &twidth, &theight, &borderDummy, &depth);
|
||||||
|
_colorDepth = (char)depth;
|
||||||
|
_height = (short)twidth;
|
||||||
|
_width = (short)theight;
|
||||||
|
printf("Resolution %dx%d\n", twidth, theight);
|
||||||
|
printf("Depth %d\n", depth);
|
||||||
|
if(glXIsDirect(display, hRC))
|
||||||
|
{
|
||||||
|
printf("Congrats, you have Direct Rendering!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Sorry, no Direct Rendering possible!\n");
|
||||||
|
}
|
||||||
|
_initializer->Initialize();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
bool OpenArena::Window::Open()
|
||||||
|
{
|
||||||
|
XVisualInfo* vi;
|
||||||
|
Colormap cmap;
|
||||||
|
int bestMode = 0;
|
||||||
|
int vidModeMajorVersion;
|
||||||
|
int vidModeMinorVersion;
|
||||||
|
int glxMajorVersion;
|
||||||
|
int glxMinorVersion;
|
||||||
|
int modeNum;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vi = glXChooseVisual(display, screen, attrListDbl);
|
vi = glXChooseVisual(display, screen, attrListDbl);
|
||||||
if(vi == NULL)
|
if(vi == NULL)
|
||||||
{
|
{
|
||||||
@@ -178,7 +312,7 @@ bool OpenArena::Window::Open()
|
|||||||
{
|
{
|
||||||
printf("Sorry, no Direct Rendering possible!\n");
|
printf("Sorry, no Direct Rendering possible!\n");
|
||||||
}
|
}
|
||||||
OnInit();
|
_initializer->Initialize();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -301,7 +435,7 @@ bool OpenArena::Window::Open()
|
|||||||
SetFocus(window);
|
SetFocus(window);
|
||||||
OnResize(_width, _height);
|
OnResize(_width, _height);
|
||||||
|
|
||||||
if (!OnInit())
|
if (!_initializer->Initialize())
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||||
@@ -385,6 +519,13 @@ Display* OpenArena::Window::GetDisplay()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
Display* OpenArena::Window::GetDisplay()
|
||||||
|
{
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
Vec2i OpenArena::Window::GetMousePosition()
|
Vec2i OpenArena::Window::GetMousePosition()
|
||||||
{
|
{
|
||||||
@@ -405,6 +546,26 @@ Vec2i OpenArena::Window::GetMousePosition()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
OpenArena::Vec2i OpenArena::Window::GetMousePosition()
|
||||||
|
{
|
||||||
|
::Window rootWindow;
|
||||||
|
::Window childWindow;
|
||||||
|
int rootX;
|
||||||
|
int rootY;
|
||||||
|
int mouseX;
|
||||||
|
int mouseY;
|
||||||
|
unsigned int mask;
|
||||||
|
if(!XQueryPointer(display, window, &rootWindow, &childWindow, &rootX, &rootY, &mouseX, &mouseY, &mask))
|
||||||
|
{
|
||||||
|
return Vec2i(-1,-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Vec2i(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OpenArena::Vec2i OpenArena::Window::GetMousePosition()
|
OpenArena::Vec2i OpenArena::Window::GetMousePosition()
|
||||||
{
|
{
|
||||||
@@ -421,6 +582,13 @@ void OpenArena::Window::SetMousePosition(Vec2i pos)
|
|||||||
XWarpPointer(display, None, window, 0, 0, 0, 0, middle.x, middle.y);
|
XWarpPointer(display, None, window, 0, 0, 0, 0, middle.x, middle.y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
void OpenArena::Window::SetMousePosition(Vec2i pos)
|
||||||
|
{
|
||||||
|
Vec2i middle = Vec2i(_width, _height)/2;
|
||||||
|
XWarpPointer(display, None, window, 0, 0, 0, 0, middle.x, middle.y);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void OpenArena::Window::SetMousePosition(Vec2i pos)
|
void OpenArena::Window::SetMousePosition(Vec2i pos)
|
||||||
{
|
{
|
||||||
@@ -446,4 +614,22 @@ Cursor OpenArena::Window::CreateFullscreenCursor()
|
|||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
Cursor OpenArena::Window::CreateWindowedCursor()
|
||||||
|
{
|
||||||
|
return CreateFullscreenCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
Cursor OpenArena::Window::CreateFullscreenCursor()
|
||||||
|
{
|
||||||
|
Pixmap pixmap = XCreatePixmap(display, window, 1, 1, 1);
|
||||||
|
XColor color;
|
||||||
|
color.pixel = 0;
|
||||||
|
color.red = 0;
|
||||||
|
color.flags = DoRed;
|
||||||
|
Cursor cur = XCreatePixmapCursor(display, pixmap, pixmap, &color, &color, 0, 0);
|
||||||
|
XFreePixmap(display, pixmap);
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user