diff --git a/SConstruct b/SConstruct index 9e97f04bbd..9b5065bba2 100644 --- a/SConstruct +++ b/SConstruct @@ -97,6 +97,7 @@ vars.AddVariables( BoolVariable('nowx', 'Set For Building with no WX libs (WIP)', False), BoolVariable('wxgl', 'Set For Building with WX GL libs (WIP)', False), BoolVariable('sdlgl', 'Set For Building with SDL GL libs (WIP)', False), + BoolVariable('gltext', 'temp don\'t use (WIP)', False), EnumVariable('flavor', 'Choose a build flavor', 'release', allowed_values = ('release', 'devel', 'debug', 'fastlog'), ignorecase = 2 @@ -232,6 +233,12 @@ if env['sdlgl']: env['HAVE_COCOA'] = 0 env['USE_WX'] = 0 +env['GLTEST'] = 0 +if env['gltext']: + env['GLTEST'] = 1 + +conf.Define('GLTEST', env['GLTEST']) + # Gui less build if env['nowx']: env['HAVE_WX'] = 0; diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index c4cea287ca..e58a6e1a6f 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -58,6 +58,7 @@ #else #define _stricmp strcasecmp #define _unlink unlink +#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) #endif #ifdef _WIN32 diff --git a/Source/Core/Common/Src/Timer.h b/Source/Core/Common/Src/Timer.h index 64791ab38a..632196939a 100644 --- a/Source/Core/Common/Src/Timer.h +++ b/Source/Core/Common/Src/Timer.h @@ -47,4 +47,7 @@ class Timer }; } // end of namespace Common +#ifdef __GNUC__ +u32 timeGetTime(); +#endif #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 917cd62e88..930ad8b45c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -18,6 +18,9 @@ #ifndef _GLINIT_H #define _GLINIT_H +#if defined GLTEST && GLTEST +#include "nGLUtil.h" +#else #include "Config.h" #include "pluginspecs_video.h" @@ -32,7 +35,6 @@ #else // linux basic definitions -#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) #if defined(USE_WX) && USE_WX #include #include "wx/wx.h" @@ -55,23 +57,6 @@ #include #endif -#define __inline inline - -#include // ftime(), struct timeb - -inline unsigned long timeGetTime() -{ -#ifdef _WIN32 - _timeb t; - _ftime(&t); -#else - timeb t; - ftime(&t); -#endif - - return (unsigned long)(t.time*1000+t.millitm); -} - #endif // linux basic definitions #ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils @@ -143,5 +128,5 @@ void OpenGL_SwapBuffers(); void OpenGL_SetWindowText(const char *text); void OpenGL_Shutdown(); void OpenGL_Update(); - +#endif #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h index 7ad54ebf64..f0d56cbf83 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h @@ -35,6 +35,7 @@ class GLWindow { u32 GetWidth() {return width;} u32 GetHeight() {return height;} + virtual bool valid() { return false; } // bool GLwindow(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) {}; // setResolution // resolution iter diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 932095d4af..4a69fc9370 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -42,6 +42,7 @@ #include "VertexLoaderManager.h" #include "VertexLoader.h" #include "XFB.h" +#include "Timer.h" #if defined(HAVE_WX) && HAVE_WX #include "Debugger/Debugger.h" // for the CDebugger class #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SConscript b/Source/Plugins/Plugin_VideoOGL/Src/SConscript index aa2aaa3d37..bb74cc943c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SConscript +++ b/Source/Plugins/Plugin_VideoOGL/Src/SConscript @@ -12,8 +12,6 @@ name = "Plugin_VideoOGL" files = [ 'BPStructs.cpp', 'Globals.cpp', - 'GLUtil.cpp', - 'main.cpp', 'Config.cpp', 'memcpy_amd.cpp', 'OpcodeDecoding.cpp', @@ -45,6 +43,16 @@ libs = [ gfxenv = env.Clone() +if gfxenv['GLTEST']: + files += [ + 'nmain.cpp', + 'nGLUtil.cpp', + ] +else: + files += [ + 'main.cpp', + 'GLUtil.cpp', + ] if gfxenv['HAVE_WX']: files += [ 'GUI/ConfigDlg.cpp', diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h index 274c1c885b..ad8dfd772f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h @@ -2,6 +2,7 @@ #define _SDLWINDOW_H #include "GLWindow.h" +#if defined HAVE_SDL && HAVE_SDL #include class SDLWindow : public GLWindow @@ -21,4 +22,11 @@ public: SDLWindow(int _iwidth, int _iheight); }; +#else +class SDLWindow : public GLWindow +{ + public: + SDLWindow(int _iwidth, int _iheight) {} +}; +#endif #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h index 7a972947db..b8cbdf8c07 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h @@ -2,6 +2,7 @@ #define _WXGLWINDOW_H #include "GLWindow.h" +#if defined USE_WX && USE_WX #include "wx/wx.h" #include "wx/glcanvas.h" @@ -28,4 +29,10 @@ public: WXGLWindow(int _iwidth, int _iheight); }; +#else +class WXGLWindow : public GLWindow +{ + WXGLWindow(int _iwidth, int _iheight) {} +}; +#endif #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h index 19c2708672..b1b241893b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h @@ -2,6 +2,7 @@ #define _X11WINDOW_H #include "GLWindow.h" +#if defined HAVE_X11 && HAVE_X11 #include #include @@ -36,5 +37,11 @@ public: ~X11Window(); X11Window(int _iwidth, int _iheight); }; - +#else +class X11Window : public GLWindow +{ +public: + X11Window(int _iwidth, int _iheight) {} +}; +#endif #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp new file mode 100644 index 0000000000..f40b419744 --- /dev/null +++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp @@ -0,0 +1,90 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Globals.h" +#include "IniFile.h" +#include "svnrev.h" + +#include "Render.h" +#include "nGLUtil.h" + +GLWindow *glWin = NULL; + +void OpenGL_SwapBuffers() +{ + glWin->SwapBuffers(); +} + +void OpenGL_SetWindowText(const char *text) +{ + glWin->SetWindowText(text); +} + +unsigned int Callback_PeekMessages() +{ + return glWin->PeekMessages(); +} + +void UpdateFPSDisplay(const char *text) +{ + char temp[512]; + sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text); + OpenGL_SetWindowText(temp); + +} + +// ======================================================================================= +// Create window. Called from main.cpp +bool OpenGL_Create(SVideoInitialize &_VideoInitialize, + int width, int height) +{ + g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; + g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; + + if (strncmp(iBackend, "sdl") == 0) + glWin = new SDLWindow(width, height); + else if (strncmp(iBackend, "x11") == 0) + glWin = new X11Window(width, height); + else if (strncmp(iBackend, "wxgl") == 0) + glWin = new WXGLWindow(width, height); + + return (glWin?true:false); +} + +bool OpenGL_MakeCurrent() +{ + return glWin->MakeCurrent(); +} + + +// ======================================================================================= +// Update window width, size and etc. Called from Render.cpp +// ---------------- +void OpenGL_Update() +{ + glWin->Update(); +} + + + +// ======================================================================================= +// Close plugin +// ---------------- +void OpenGL_Shutdown() +{ + glWin->Shutdown(); +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h new file mode 100644 index 0000000000..ce15a4c0fe --- /dev/null +++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h @@ -0,0 +1,50 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _NGLINIT_H +#define _NGLINIT_H + +#include "Config.h" +#include "pluginspecs_video.h" +#include "GLWindow.h" +// backends +#include "SDLWindow.h" +#include "X11Window.h" +#include "WXGLWindow.h" + +#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#define GL_REPORT_ERROR() { err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG("%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } } + +#if defined(_DEBUG) || defined(DEBUGFAST) +#define GL_REPORT_ERRORD() { GLenum err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG("%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } } +#else +#define GL_REPORT_ERRORD() +#endif +// OLD interface todo remove +bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); +bool OpenGL_MakeCurrent(); +void OpenGL_SwapBuffers(); +void OpenGL_SetWindowText(const char *text); +void OpenGL_Shutdown(); +void OpenGL_Update(); +#endif