Some code clean up, and take care of some compiler warnings.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5090 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2010-02-20 04:18:19 +00:00
parent f74b5463d5
commit 154bc956ad
11 changed files with 484 additions and 514 deletions

View File

@ -1,21 +1,21 @@
// Copyright (C) 2003 Dolphin Project. // Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif
@ -39,7 +39,7 @@
#include "CPUDetect.h" #include "CPUDetect.h"
#include "CoreTiming.h" #include "CoreTiming.h"
#include "Boot/Boot.h" #include "Boot/Boot.h"
#include "HW/Memmap.h" #include "HW/Memmap.h"
#include "HW/ProcessorInterface.h" #include "HW/ProcessorInterface.h"
#include "HW/GPFifo.h" #include "HW/GPFifo.h"
@ -50,31 +50,31 @@
#include "HW/AudioInterface.h" #include "HW/AudioInterface.h"
#include "HW/VideoInterface.h" #include "HW/VideoInterface.h"
#include "HW/SystemTimers.h" #include "HW/SystemTimers.h"
#include "PowerPC/PowerPC.h" #include "PowerPC/PowerPC.h"
#include "PowerPC/JitCommon/JitBase.h" #include "PowerPC/JitCommon/JitBase.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "ConfigManager.h" #include "ConfigManager.h"
#include "VolumeHandler.h" #include "VolumeHandler.h"
#include "FileMonitor.h" #include "FileMonitor.h"
#include "MemTools.h" #include "MemTools.h"
#include "Host.h" #include "Host.h"
#include "LogManager.h" #include "LogManager.h"
#include "State.h" #include "State.h"
#include "OnFrame.h" #include "OnFrame.h"
namespace Core namespace Core
{ {
// Declarations and definitions // Declarations and definitions
Common::Timer Timer; Common::Timer Timer;
volatile u32 DrawnFrame = 0; volatile u32 DrawnFrame = 0;
u32 DrawnVideo = 0; u32 DrawnVideo = 0;
// Function forwarding // Function forwarding
//void Callback_VideoRequestWindowSize(int _iWidth, int _iHeight, BOOL _bFullscreen); //void Callback_VideoRequestWindowSize(int _iWidth, int _iHeight, BOOL _bFullscreen);
void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak); void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak);
@ -85,17 +85,17 @@ void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage); void Callback_PADLog(const TCHAR* _szMessage);
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v); void Callback_WiimoteLog(const TCHAR* _szMessage, int _v);
void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size); void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
// For keyboard shortcuts. // For keyboard shortcuts.
void Callback_KeyPress(int key, bool shift, bool control); void Callback_KeyPress(int key, bool shift, bool control);
TPeekMessages Callback_PeekMessages = NULL; TPeekMessages Callback_PeekMessages = NULL;
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL; TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
// Function declarations // Function declarations
THREAD_RETURN EmuThread(void *pArg); THREAD_RETURN EmuThread(void *pArg);
void Stop(); void Stop();
bool g_bStopping = false; bool g_bStopping = false;
bool g_bHwInit = false; bool g_bHwInit = false;
bool g_bRealWiimote = false; bool g_bRealWiimote = false;
@ -126,39 +126,39 @@ bool PanicAlertToVideo(const char* text, bool yes_no)
DisplayMessage(text, 3000); DisplayMessage(text, 3000);
return true; return true;
} }
void DisplayMessage(const std::string &message, int time_in_ms) void DisplayMessage(const std::string &message, int time_in_ms)
{ {
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message.c_str(), CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message.c_str(),
time_in_ms); time_in_ms);
} }
void DisplayMessage(const char *message, int time_in_ms) void DisplayMessage(const char *message, int time_in_ms)
{ {
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message, CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message,
time_in_ms); time_in_ms);
} }
void Callback_DebuggerBreak() void Callback_DebuggerBreak()
{ {
CCPU::Break(); CCPU::Break();
} }
void *GetWindowHandle() void *GetWindowHandle()
{ {
return g_pWindowHandle; return g_pWindowHandle;
} }
#if defined HAVE_X11 && HAVE_X11 #if defined HAVE_X11 && HAVE_X11
void *GetXWindow() void *GetXWindow()
{ {
return g_pXWindow; return g_pXWindow;
} }
#endif #endif
bool GetRealWiimote() bool GetRealWiimote()
{ {
return g_bRealWiimote; return g_bRealWiimote;
} }
bool isRunning() bool isRunning()
@ -265,11 +265,6 @@ void ProcessXEvents(void)
{ {
XNextEvent(dpy, &event); XNextEvent(dpy, &event);
switch(event.type) { switch(event.type) {
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if(key == XK_F4 && ((event.xkey.state & Mod1Mask) == Mod1Mask))
Host_Message(WM_USER_STOP);
break;
case KeyPress: case KeyPress:
key = XLookupKeysym((XKeyEvent*)&event, 0); key = XLookupKeysym((XKeyEvent*)&event, 0);
if (key == XK_Escape) if (key == XK_Escape)
@ -312,10 +307,10 @@ THREAD_RETURN CpuThread(void *pArg)
CPluginManager::GetInstance().GetVideo()->Video_Prepare(); CPluginManager::GetInstance().GetVideo()->Video_Prepare();
Common::SetCurrentThreadName("CPU-GPU thread"); Common::SetCurrentThreadName("CPU-GPU thread");
} }
if (_CoreParameter.bLockThreads) if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(1); // Force to first core Common::Thread::SetCurrentThreadAffinity(1); // Force to first core
if (_CoreParameter.bUseFastMem) if (_CoreParameter.bUseFastMem)
{ {
#ifdef _M_X64 #ifdef _M_X64
@ -325,7 +320,7 @@ THREAD_RETURN CpuThread(void *pArg)
PanicAlert("32-bit platforms do not support fastmem yet. Report this bug."); PanicAlert("32-bit platforms do not support fastmem yet. Report this bug.");
#endif #endif
} }
// Enter CPU run loop. When we leave it - we are done. // Enter CPU run loop. When we leave it - we are done.
CCPU::Run(); CCPU::Run();
@ -337,7 +332,7 @@ THREAD_RETURN CpuThread(void *pArg)
} }
cpuRunloopQuit.Set(); cpuRunloopQuit.Set();
return 0; return 0;
} }
@ -355,21 +350,21 @@ THREAD_RETURN EmuThread(void *pArg)
CPluginManager &Plugins = CPluginManager::GetInstance(); CPluginManager &Plugins = CPluginManager::GetInstance();
if (_CoreParameter.bLockThreads) if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(2); // Force to second core Common::Thread::SetCurrentThreadAffinity(2); // Force to second core
INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "Gamecube"); INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "Gamecube");
INFO_LOG(OSREPORT, "CPU Thread separate = %s", _CoreParameter.bCPUThread ? "Yes" : "No"); INFO_LOG(OSREPORT, "CPU Thread separate = %s", _CoreParameter.bCPUThread ? "Yes" : "No");
HW::Init(); HW::Init();
emuThreadGoing.Set(); emuThreadGoing.Set();
// Load the VideoPlugin // Load the VideoPlugin
SVideoInitialize VideoInitialize; SVideoInitialize VideoInitialize;
VideoInitialize.pGetMemoryPointer = Memory::GetPointer; VideoInitialize.pGetMemoryPointer = Memory::GetPointer;
VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt; VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt;
VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent; VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent;
VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe; VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe;
// This is first the m_Panel handle, then it is updated to have the new window handle // This is first the m_Panel handle, then it is updated to have the new window handle
VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow; VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow;
VideoInitialize.pLog = Callback_VideoLog; VideoInitialize.pLog = Callback_VideoLog;
VideoInitialize.pSysMessage = Host_SysMessage; VideoInitialize.pSysMessage = Host_SysMessage;
@ -381,13 +376,13 @@ THREAD_RETURN EmuThread(void *pArg)
VideoInitialize.pKeyPress = Callback_KeyPress; VideoInitialize.pKeyPress = Callback_KeyPress;
VideoInitialize.bWii = _CoreParameter.bWii; VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bOnThread = _CoreParameter.bCPUThread; VideoInitialize.bOnThread = _CoreParameter.bCPUThread;
VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase; VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase;
VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd; VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd;
VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer; VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer;
VideoInitialize.bAutoAspectIs16_9 = _CoreParameter.bWii ? (SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR") ? true : false) : false; VideoInitialize.bAutoAspectIs16_9 = _CoreParameter.bWii ? (SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR") ? true : false) : false;
Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll
// Under linux, this is an X11 Display, not a HWND! // Under linux, this is an X11 Display, not a HWND!
g_pWindowHandle = (HWND)VideoInitialize.pWindowHandle; g_pWindowHandle = (HWND)VideoInitialize.pWindowHandle;
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
@ -396,7 +391,7 @@ THREAD_RETURN EmuThread(void *pArg)
Callback_PeekMessages = VideoInitialize.pPeekMessages; Callback_PeekMessages = VideoInitialize.pPeekMessages;
g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay; g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay;
// Load and init DSPPlugin // Load and init DSPPlugin
DSPInitialize dspInit; DSPInitialize dspInit;
dspInit.hWnd = g_pWindowHandle; dspInit.hWnd = g_pWindowHandle;
dspInit.pARAM_Read_U8 = (u8 (__cdecl *)(const u32))DSP::ReadARAM; dspInit.pARAM_Read_U8 = (u8 (__cdecl *)(const u32))DSP::ReadARAM;
@ -440,20 +435,20 @@ THREAD_RETURN EmuThread(void *pArg)
// Wait for Wiiuse to find the number of connected Wiimotes // Wait for Wiiuse to find the number of connected Wiimotes
Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize); Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize);
} }
// The hardware is initialized. // The hardware is initialized.
g_bHwInit = true; g_bHwInit = true;
DisplayMessage("CPU: " + cpu_info.Summarize(), 8000); DisplayMessage("CPU: " + cpu_info.Summarize(), 8000);
DisplayMessage(_CoreParameter.m_strFilename, 3000); DisplayMessage(_CoreParameter.m_strFilename, 3000);
// Load GCM/DOL/ELF whatever ... we boot with the interpreter core // Load GCM/DOL/ELF whatever ... we boot with the interpreter core
PowerPC::SetMode(PowerPC::MODE_INTERPRETER); PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
CBoot::BootUp(); CBoot::BootUp();
if (g_pUpdateFPSDisplay != NULL) if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay(("Loading " + _CoreParameter.m_strFilename).c_str()); g_pUpdateFPSDisplay(("Loading " + _CoreParameter.m_strFilename).c_str());
// Setup our core, but can't use dynarec if we are compare server // Setup our core, but can't use dynarec if we are compare server
if (_CoreParameter.iCPUCore && (!_CoreParameter.bRunCompareServer || _CoreParameter.bRunCompareClient)) if (_CoreParameter.iCPUCore && (!_CoreParameter.bRunCompareServer || _CoreParameter.bRunCompareClient))
PowerPC::SetMode(PowerPC::MODE_JIT); PowerPC::SetMode(PowerPC::MODE_JIT);
@ -465,7 +460,7 @@ THREAD_RETURN EmuThread(void *pArg)
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
Common::Thread *xEventThread = NULL; Common::Thread *xEventThread = NULL;
#endif #endif
// ENTER THE VIDEO THREAD LOOP // ENTER THE VIDEO THREAD LOOP
if (_CoreParameter.bCPUThread) if (_CoreParameter.bCPUThread)
{ {
@ -569,8 +564,6 @@ THREAD_RETURN EmuThread(void *pArg)
g_bStopping = false; g_bStopping = false;
return 0; return 0;
} }
// Set or get the running state // Set or get the running state
@ -579,7 +572,7 @@ void SetState(EState _State)
switch (_State) switch (_State)
{ {
case CORE_UNINITIALIZED: case CORE_UNINITIALIZED:
Stop(); Stop();
break; break;
case CORE_PAUSE: case CORE_PAUSE:
CCPU::EnableStepping(true); // Break CCPU::EnableStepping(true); // Break
@ -592,7 +585,7 @@ void SetState(EState _State)
break; break;
} }
} }
EState GetState() EState GetState()
{ {
if (g_bHwInit) if (g_bHwInit)
@ -606,7 +599,7 @@ EState GetState()
} }
return CORE_UNINITIALIZED; return CORE_UNINITIALIZED;
} }
static inline std::string GenerateScreenshotName() static inline std::string GenerateScreenshotName()
{ {
int index = 1; int index = 1;
@ -718,7 +711,7 @@ void VideoThrottle()
Host_UpdateStatusBar(SMessage.c_str()); Host_UpdateStatusBar(SMessage.c_str());
// Reset counter // Reset counter
Timer.Update(); Timer.Update();
Common::AtomicStore(DrawnFrame, 0); Common::AtomicStore(DrawnFrame, 0);
DrawnVideo = 0; DrawnVideo = 0;
} }
@ -761,7 +754,7 @@ void Callback_VideoCopiedToXFB(bool video_update)
{ {
GENERIC_LOG(LogTypes::AUDIO, (LogTypes::LOG_LEVELS)_v, _szMessage); GENERIC_LOG(LogTypes::AUDIO, (LogTypes::LOG_LEVELS)_v, _szMessage);
} }
// Callback_DSPInterrupt // Callback_DSPInterrupt
// WARNING - THIS MAY BE EXECUTED FROM DSP THREAD // WARNING - THIS MAY BE EXECUTED FROM DSP THREAD
@ -769,7 +762,7 @@ void Callback_DSPInterrupt()
{ {
DSP::GenerateDSPInterruptFromPlugin(DSP::INT_DSP); DSP::GenerateDSPInterruptFromPlugin(DSP::INT_DSP);
} }
// Callback_PADLog // Callback_PADLog
// //
@ -778,17 +771,17 @@ void Callback_PADLog(const TCHAR* _szMessage)
// FIXME add levels // FIXME add levels
INFO_LOG(SERIALINTERFACE, _szMessage); INFO_LOG(SERIALINTERFACE, _szMessage);
} }
// Callback_ISOName: Let the DSP plugin get the game name // Callback_ISOName: Let the DSP plugin get the game name
// //
const char *Callback_ISOName() const char *Callback_ISOName()
{ {
SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (params.m_strName.length() > 0) if (params.m_strName.length() > 0)
return params.m_strName.c_str(); return params.m_strName.c_str();
else else
return ""; return "";
} }
// Called from ANY thread! // Called from ANY thread!
@ -829,12 +822,12 @@ void Callback_KeyPress(int key, bool shift, bool control)
Host_Message(WM_USER_PAUSE); Host_Message(WM_USER_PAUSE);
#endif #endif
} }
// Callback_WiimoteLog // Callback_WiimoteLog
// //
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v) void Callback_WiimoteLog(const TCHAR* _szMessage, int _v)
{ {
GENERIC_LOG(LogTypes::WIIMOTE, (LogTypes::LOG_LEVELS)_v, _szMessage); GENERIC_LOG(LogTypes::WIIMOTE, (LogTypes::LOG_LEVELS)_v, _szMessage);
} }
} // Core } // Core

View File

@ -23,11 +23,12 @@
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#ifdef __linux__ #include "Common.h" // Common
#if defined HAVE_X11 && HAVE_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif #endif
#include "Common.h" // Common
#include "CPUDetect.h" #include "CPUDetect.h"
#include "IniFile.h" #include "IniFile.h"
#include "FileUtil.h" #include "FileUtil.h"
@ -475,7 +476,7 @@ bool DolphinApp::OnInit()
// Set main parent window // Set main parent window
SetTopWindow(main_frame); SetTopWindow(main_frame);
#if defined __linux__ #if defined HAVE_X11 && HAVE_X11
XInitThreads(); XInitThreads();
#endif #endif
return true; return true;

View File

@ -36,8 +36,6 @@
extern int frameCount; extern int frameCount;
extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
static int s_fps=0;
// Renderer really isn't a very good name for this class - it's more like "Misc". // Renderer really isn't a very good name for this class - it's more like "Misc".
// The long term goal is to get rid of this class and replace it with others that make // The long term goal is to get rid of this class and replace it with others that make
// more sense. // more sense.

View File

@ -50,6 +50,8 @@
#include "debugger/debugger.h" #include "debugger/debugger.h"
int s_fps=0;
static int s_target_width; static int s_target_width;
static int s_target_height; static int s_target_height;

View File

@ -28,8 +28,8 @@
#else #else
struct RECT struct RECT
{ {
int left, top; int left, top;
int right, bottom; int right, bottom;
}; };
#endif #endif
@ -54,41 +54,39 @@ extern HINSTANCE g_hInstance;
void OpenGL_SwapBuffers() void OpenGL_SwapBuffers()
{ {
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
GLWin.glCanvas->SwapBuffers(); GLWin.glCanvas->SwapBuffers();
#elif defined(HAVE_COCOA) && HAVE_COCOA #elif defined(HAVE_COCOA) && HAVE_COCOA
cocoaGLSwap(GLWin.cocoaCtx,GLWin.cocoaWin); cocoaGLSwap(GLWin.cocoaCtx,GLWin.cocoaWin);
#elif defined(_WIN32) #elif defined(_WIN32)
SwapBuffers(hDC); SwapBuffers(hDC);
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
glXSwapBuffers(GLWin.dpy, GLWin.win); glXSwapBuffers(GLWin.dpy, GLWin.win);
#endif #endif
} }
u32 OpenGL_GetBackbufferWidth() u32 OpenGL_GetBackbufferWidth()
{ {
return s_backbuffer_width; return s_backbuffer_width;
} }
u32 OpenGL_GetBackbufferHeight() u32 OpenGL_GetBackbufferHeight()
{ {
return s_backbuffer_height; return s_backbuffer_height;
} }
void OpenGL_SetWindowText(const char *text) void OpenGL_SetWindowText(const char *text)
{ {
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
GLWin.frame->SetTitle(wxString::FromAscii(text)); GLWin.frame->SetTitle(wxString::FromAscii(text));
#elif defined(HAVE_COCOA) && HAVE_COCOA #elif defined(HAVE_COCOA) && HAVE_COCOA
cocoaGLSetTitle(GLWin.cocoaWin, text); cocoaGLSetTitle(GLWin.cocoaWin, text);
#elif defined(_WIN32) #elif defined(_WIN32)
// TODO convert text to unicode and change SetWindowTextA to SetWindowText // TODO convert text to unicode and change SetWindowTextA to SetWindowText
SetWindowTextA(EmuWindow::GetWnd(), text); SetWindowTextA(EmuWindow::GetWnd(), text);
#elif defined(HAVE_X11) && HAVE_X11 // GLX #elif defined(HAVE_X11) && HAVE_X11 // GLX
/** // Tell X to ask the window manager to set the window title. (X
* Tell X to ask the window manager to set the window title. (X // itself doesn't provide window title functionality.)
* itself doesn't provide window title functionality.) XStoreName(GLWin.dpy, GLWin.win, text);
*/
XStoreName(GLWin.dpy, GLWin.win, text);
#endif #endif
} }
@ -96,110 +94,110 @@ void OpenGL_SetWindowText(const char *text)
unsigned int Callback_PeekMessages() unsigned int Callback_PeekMessages()
{ {
#ifdef _WIN32 #ifdef _WIN32
// TODO: peekmessage // TODO: peekmessage
MSG msg; MSG msg;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{ {
if (msg.message == WM_QUIT) if (msg.message == WM_QUIT)
return FALSE; return FALSE;
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
return TRUE; return TRUE;
#else #else
return FALSE; return FALSE;
#endif #endif
} }
// Show the current FPS // Show the current FPS
void UpdateFPSDisplay(const char *text) void UpdateFPSDisplay(const char *text)
{ {
char temp[512]; char temp[512];
sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text); sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text);
OpenGL_SetWindowText(temp); OpenGL_SetWindowText(temp);
} }
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
void CreateXWindow (void) void CreateXWindow (void)
{ {
Atom wmProtocols[3]; Atom wmProtocols[3];
int width, height; int width, height;
if (GLWin.fs) if (GLWin.fs)
{ {
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fullSize >= 0) if (GLWin.fullSize >= 0)
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
GLWin.fullSize, GLWin.screenRotation, CurrentTime); GLWin.fullSize, GLWin.screenRotation, CurrentTime);
#endif #endif
GLWin.attr.override_redirect = True; GLWin.attr.override_redirect = True;
width = GLWin.fullWidth; width = GLWin.fullWidth;
height = GLWin.fullHeight; height = GLWin.fullHeight;
} }
else else
{ {
GLWin.attr.override_redirect = False; GLWin.attr.override_redirect = False;
width = GLWin.winWidth; width = GLWin.winWidth;
height = GLWin.winHeight; height = GLWin.winHeight;
} }
// Control window size and picture scaling // Control window size and picture scaling
s_backbuffer_width = width; s_backbuffer_width = width;
s_backbuffer_height = height; s_backbuffer_height = height;
// create the window // create the window
GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | ResizeRedirectMask; StructureNotifyMask | ResizeRedirectMask;
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen), GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen),
0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual, 0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr); CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr);
wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
wmProtocols[1] = XInternAtom(GLWin.dpy, "WM_TAKE_FOCUS", True); wmProtocols[1] = XInternAtom(GLWin.dpy, "WM_TAKE_FOCUS", True);
wmProtocols[2] = XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False); wmProtocols[2] = XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False);
XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3); XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3);
XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL); XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
XMapRaised(GLWin.dpy, GLWin.win); XMapRaised(GLWin.dpy, GLWin.win);
if (GLWin.fs) if (GLWin.fs)
{ {
XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
XGrabPointer(GLWin.dpy, GLWin.win, True, NULL, XGrabPointer(GLWin.dpy, GLWin.win, True, NULL,
GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime);
XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime); XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime);
} }
XSync(GLWin.dpy, True); XSync(GLWin.dpy, True);
} }
void DestroyXWindow(void) void DestroyXWindow(void)
{ {
if( GLWin.ctx ) if( GLWin.ctx )
{ {
if( !glXMakeCurrent(GLWin.dpy, None, NULL)) if( !glXMakeCurrent(GLWin.dpy, None, NULL))
{ {
printf("Could not release drawing context.\n"); printf("Could not release drawing context.\n");
} }
} }
/* switch back to original desktop resolution if we were in fullscreen */ /* switch back to original desktop resolution if we were in fullscreen */
if( GLWin.fs ) if( GLWin.fs )
{ {
XUngrabKeyboard (GLWin.dpy, CurrentTime); XUngrabKeyboard (GLWin.dpy, CurrentTime);
XUngrabPointer (GLWin.dpy, CurrentTime); XUngrabPointer (GLWin.dpy, CurrentTime);
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fullSize >= 0) if (GLWin.fullSize >= 0)
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
GLWin.deskSize, GLWin.screenRotation, CurrentTime); GLWin.deskSize, GLWin.screenRotation, CurrentTime);
#endif #endif
} }
XUndefineCursor(GLWin.dpy, GLWin.win); XUndefineCursor(GLWin.dpy, GLWin.win);
XUnmapWindow(GLWin.dpy, GLWin.win); XUnmapWindow(GLWin.dpy, GLWin.win);
XSync(GLWin.dpy, True); XSync(GLWin.dpy, True);
} }
void ToggleFullscreenMode (void) void ToggleFullscreenMode (void)
{ {
DestroyXWindow(); DestroyXWindow();
GLWin.fs = !GLWin.fs; GLWin.fs = !GLWin.fs;
CreateXWindow(); CreateXWindow();
OpenGL_MakeCurrent(); OpenGL_MakeCurrent();
} }
#endif #endif
@ -209,66 +207,66 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
{ {
#if !defined(HAVE_X11) || !HAVE_X11 #if !defined(HAVE_X11) || !HAVE_X11
// Check for fullscreen mode // Check for fullscreen mode
int _twidth, _theight; int _twidth, _theight;
if (g_Config.bFullscreen) if (g_Config.bFullscreen)
{ {
if (strlen(g_Config.cFSResolution) > 1) if (strlen(g_Config.cFSResolution) > 1)
{ {
sscanf(g_Config.cFSResolution, "%dx%d", &_twidth, &_theight); sscanf(g_Config.cFSResolution, "%dx%d", &_twidth, &_theight);
} }
else // No full screen reso set, fall back to default reso else // No full screen reso set, fall back to default reso
{ {
_twidth = _iwidth; _twidth = _iwidth;
_theight = _iheight; _theight = _iheight;
} }
} }
else // Going Windowed else // Going Windowed
{ {
if (strlen(g_Config.cInternalRes) > 1) if (strlen(g_Config.cInternalRes) > 1)
{ {
sscanf(g_Config.cInternalRes, "%dx%d", &_twidth, &_theight); sscanf(g_Config.cInternalRes, "%dx%d", &_twidth, &_theight);
} }
else // No Window resolution set, fall back to default else // No Window resolution set, fall back to default
{ {
_twidth = _iwidth; _twidth = _iwidth;
_theight = _iheight; _theight = _iheight;
} }
} }
// Control window size and picture scaling // Control window size and picture scaling
s_backbuffer_width = _twidth; s_backbuffer_width = _twidth;
s_backbuffer_height = _theight; s_backbuffer_height = _theight;
#endif #endif
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0}; int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
wxSize size(_iwidth, _iheight); wxSize size(_iwidth, _iheight);
if (!g_Config.RenderToMainframe || if (!g_Config.RenderToMainframe ||
g_VideoInitialize.pWindowHandle == NULL) { g_VideoInitialize.pWindowHandle == NULL) {
GLWin.frame = new wxFrame((wxWindow *)NULL, GLWin.frame = new wxFrame((wxWindow *)NULL,
-1, _("Dolphin"), wxPoint(50,50), size); -1, _("Dolphin"), wxPoint(50,50), size);
} else { } else {
GLWin.frame = new wxFrame((wxWindow *)g_VideoInitialize.pWindowHandle, GLWin.frame = new wxFrame((wxWindow *)g_VideoInitialize.pWindowHandle,
-1, _("Dolphin"), wxPoint(50,50), size); -1, _("Dolphin"), wxPoint(50,50), size);
} }
GLWin.glCanvas = new wxGLCanvas(GLWin.frame, wxID_ANY, args, GLWin.glCanvas = new wxGLCanvas(GLWin.frame, wxID_ANY, args,
wxPoint(0,0), size, wxSUNKEN_BORDER); wxPoint(0,0), size, wxSUNKEN_BORDER);
GLWin.glCtxt = new wxGLContext(GLWin.glCanvas); GLWin.glCtxt = new wxGLContext(GLWin.glCanvas);
GLWin.frame->Show(TRUE); GLWin.frame->Show(TRUE);
GLWin.glCanvas->Show(TRUE); GLWin.glCanvas->Show(TRUE);
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt); GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
#elif defined(HAVE_COCOA) && HAVE_COCOA #elif defined(HAVE_COCOA) && HAVE_COCOA
GLWin.width = s_backbuffer_width; GLWin.width = s_backbuffer_width;
GLWin.height = s_backbuffer_height; GLWin.height = s_backbuffer_height;
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height); GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode); GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
#elif defined(_WIN32) #elif defined(_WIN32)
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait...")); g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait..."));
@ -277,123 +275,123 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
g_VideoInitialize.pSysMessage("failed to create window"); g_VideoInitialize.pSysMessage("failed to create window");
return false; return false;
} }
if (g_Config.bFullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = s_backbuffer_width;
dmScreenSettings.dmPelsHeight = s_backbuffer_height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (g_Config.bFullscreen)
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
{ DEVMODE dmScreenSettings;
if (MessageBox(NULL, _T("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"), _T("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES) memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = s_backbuffer_width;
dmScreenSettings.dmPelsHeight = s_backbuffer_height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL, _T("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"), _T("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
EmuWindow::ToggleFullscreen(EmuWindow::GetWnd()); EmuWindow::ToggleFullscreen(EmuWindow::GetWnd());
else else
return false; return false;
} }
else else
{ {
// SetWindowPos to the upper-left corner of the screen // SetWindowPos to the upper-left corner of the screen
SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, 0, 0, _twidth, _theight, SWP_NOREPOSITION | SWP_NOZORDER); SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, 0, 0, _twidth, _theight, SWP_NOREPOSITION | SWP_NOZORDER);
} }
} }
else else
{ {
// Change to default resolution // Change to default resolution
ChangeDisplaySettings(NULL, 0); ChangeDisplaySettings(NULL, 0);
} }
// Show the window // Show the window
EmuWindow::Show(); EmuWindow::Show();
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{ {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number 1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth 32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer 0, // 8bit Alpha Buffer
0, // Shift Bit Ignored 0, // Shift Bit Ignored
0, // No Accumulation Buffer 0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored 0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer) 24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer 8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer 0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved 0, // Reserved
0, 0, 0 // Layer Masks Ignored 0, 0, 0 // Layer Masks Ignored
}; };
GLuint PixelFormat; // Holds The Results After Searching For A Match GLuint PixelFormat; // Holds The Results After Searching For A Match
if (!(hDC=GetDC(EmuWindow::GetWnd()))) { if (!(hDC=GetDC(EmuWindow::GetWnd()))) {
PanicAlert("(1) Can't create an OpenGL Device context. Fail."); PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
return false; return false;
} }
if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) { if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) {
PanicAlert("(2) Can't find a suitable PixelFormat."); PanicAlert("(2) Can't find a suitable PixelFormat.");
return false; return false;
} }
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) { if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {
PanicAlert("(3) Can't set the PixelFormat."); PanicAlert("(3) Can't set the PixelFormat.");
return false; return false;
} }
if (!(hRC = wglCreateContext(hDC))) { if (!(hRC = wglCreateContext(hDC))) {
PanicAlert("(4) Can't create an OpenGL rendering context."); PanicAlert("(4) Can't create an OpenGL rendering context.");
return false; return false;
} }
// -------------------------------------- // --------------------------------------
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
Colormap cmap; Colormap cmap;
int glxMajorVersion, glxMinorVersion; int glxMajorVersion, glxMinorVersion;
int vidModeMajorVersion, vidModeMinorVersion; int vidModeMajorVersion, vidModeMinorVersion;
// attributes for a single buffered visual in RGBA format with at least // attributes for a single buffered visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer // 8 bits per color and a 24 bit depth buffer
int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 8, int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8, GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8, GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24, GLX_DEPTH_SIZE, 24,
None}; None};
// attributes for a double buffered visual in RGBA format with at least // attributes for a double buffered visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer // 8 bits per color and a 24 bit depth buffer
int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8, GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8, GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8, GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24, GLX_DEPTH_SIZE, 24,
GLX_SAMPLE_BUFFERS_ARB, g_Config.iMultisampleMode, GLX_SAMPLES_ARB, 1, None }; GLX_SAMPLE_BUFFERS_ARB, g_Config.iMultisampleMode, GLX_SAMPLES_ARB, 1, None };
GLWin.dpy = XOpenDisplay(0); GLWin.dpy = XOpenDisplay(0);
g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy; g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy;
GLWin.screen = DefaultScreen(GLWin.dpy); GLWin.screen = DefaultScreen(GLWin.dpy);
// Fullscreen option. // Fullscreen option.
GLWin.fs = g_Config.bFullscreen; //Set to setting in Options GLWin.fs = g_Config.bFullscreen; //Set to setting in Options
/* get an appropriate visual */ /* get an appropriate visual */
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl); GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl);
if (GLWin.vi == NULL) { if (GLWin.vi == NULL) {
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl); GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
GLWin.doubleBuffered = False; GLWin.doubleBuffered = False;
ERROR_LOG(VIDEO, "Only Singlebuffered Visual!"); ERROR_LOG(VIDEO, "Only Singlebuffered Visual!");
} }
else { else {
GLWin.doubleBuffered = True; GLWin.doubleBuffered = True;
NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!"); NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!");
} }
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion); NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
@ -410,70 +408,70 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
GLWin.attr.border_pixel = 0; GLWin.attr.border_pixel = 0;
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL); XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
// Get the resolution setings for both fullscreen and windowed modes // Get the resolution setings for both fullscreen and windowed modes
if (strlen(g_Config.cFSResolution) > 1) if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &GLWin.fullWidth, &GLWin.fullHeight); sscanf(g_Config.cFSResolution, "%dx%d", &GLWin.fullWidth, &GLWin.fullHeight);
else // No full screen reso set, fall back to desktop resolution else // No full screen reso set, fall back to desktop resolution
{ {
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen); GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen); GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
} }
if (strlen(g_Config.cInternalRes) > 1) if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &GLWin.winWidth, &GLWin.winHeight); sscanf(g_Config.cInternalRes, "%dx%d", &GLWin.winWidth, &GLWin.winHeight);
else // No Window resolution set, fall back to default else // No Window resolution set, fall back to default
{ {
GLWin.winWidth = _iwidth; GLWin.winWidth = _iwidth;
GLWin.winHeight = _iheight; GLWin.winHeight = _iheight;
} }
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion); XRRQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
XRRScreenSize *sizes; XRRScreenSize *sizes;
int numSizes; int numSizes;
NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion); NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion);
GLWin.screenConfig = XRRGetScreenInfo(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.screen)); GLWin.screenConfig = XRRGetScreenInfo(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.screen));
/* save desktop resolution */ /* save desktop resolution */
GLWin.deskSize = XRRConfigCurrentConfiguration(GLWin.screenConfig, &GLWin.screenRotation); GLWin.deskSize = XRRConfigCurrentConfiguration(GLWin.screenConfig, &GLWin.screenRotation);
/* Set the desktop resolution as the default */ /* Set the desktop resolution as the default */
GLWin.fullSize = -1; GLWin.fullSize = -1;
/* Find the index of the fullscreen resolution from config */ /* Find the index of the fullscreen resolution from config */
sizes = XRRConfigSizes(GLWin.screenConfig, &numSizes); sizes = XRRConfigSizes(GLWin.screenConfig, &numSizes);
if (numSizes > 0 && sizes != NULL) { if (numSizes > 0 && sizes != NULL) {
for (int i = 0; i < numSizes; i++) { for (int i = 0; i < numSizes; i++) {
if ((sizes[i].width == GLWin.fullWidth) && (sizes[i].height == GLWin.fullHeight)) { if ((sizes[i].width == GLWin.fullWidth) && (sizes[i].height == GLWin.fullHeight)) {
GLWin.fullSize = i; GLWin.fullSize = i;
} }
} }
NOTICE_LOG(VIDEO, "Fullscreen Resolution %dx%d", sizes[GLWin.fullSize].width, sizes[GLWin.fullSize].height); NOTICE_LOG(VIDEO, "Fullscreen Resolution %dx%d", sizes[GLWin.fullSize].width, sizes[GLWin.fullSize].height);
} }
else { else {
ERROR_LOG(VIDEO, "Failed to obtain fullscreen sizes.\n" ERROR_LOG(VIDEO, "Failed to obtain fullscreen sizes.\n"
"Using current desktop resolution for fullscreen.\n"); "Using current desktop resolution for fullscreen.\n");
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen); GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen); GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
} }
#else #else
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen); GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen); GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
#endif #endif
CreateXWindow(); CreateXWindow();
g_VideoInitialize.pXWindow = (Window *) &GLWin.win; g_VideoInitialize.pXWindow = (Window *) &GLWin.win;
if (g_Config.bHideCursor) if (g_Config.bHideCursor)
{ {
// make a blank cursor // make a blank cursor
Pixmap Blank; Pixmap Blank;
XColor DummyColor; XColor DummyColor;
char ZeroData[1] = {0}; char ZeroData[1] = {0};
Blank = XCreateBitmapFromData (GLWin.dpy, GLWin.win, ZeroData, 1, 1); Blank = XCreateBitmapFromData (GLWin.dpy, GLWin.win, ZeroData, 1, 1);
GLWin.blankCursor = XCreatePixmapCursor(GLWin.dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0); GLWin.blankCursor = XCreatePixmapCursor(GLWin.dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0);
XFreePixmap (GLWin.dpy, Blank); XFreePixmap (GLWin.dpy, Blank);
} }
#endif #endif
return true; return true;
} }
@ -481,35 +479,35 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
bool OpenGL_MakeCurrent() bool OpenGL_MakeCurrent()
{ {
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt); GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
#elif defined(HAVE_COCOA) && HAVE_COCOA #elif defined(HAVE_COCOA) && HAVE_COCOA
cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin); cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin);
#elif defined(_WIN32) #elif defined(_WIN32)
if (!wglMakeCurrent(hDC,hRC)) { if (!wglMakeCurrent(hDC,hRC)) {
PanicAlert("(5) Can't Activate The GL Rendering Context."); PanicAlert("(5) Can't Activate The GL Rendering Context.");
return false; return false;
} }
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
Window winDummy; Window winDummy;
unsigned int borderDummy; unsigned int borderDummy;
// connect the glx-context to the window // connect the glx-context to the window
glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
NOTICE_LOG(VIDEO, "GLWin Depth %d", GLWin.depth) NOTICE_LOG(VIDEO, "GLWin Depth %d", GLWin.depth)
if (glXIsDirect(GLWin.dpy, GLWin.ctx)) { if (glXIsDirect(GLWin.dpy, GLWin.ctx)) {
NOTICE_LOG(VIDEO, "detected direct rendering"); NOTICE_LOG(VIDEO, "detected direct rendering");
} else { } else {
ERROR_LOG(VIDEO, "no Direct Rendering possible!"); ERROR_LOG(VIDEO, "no Direct Rendering possible!");
} }
// Hide the cursor now // Hide the cursor now
if (g_Config.bHideCursor) if (g_Config.bHideCursor)
XDefineCursor (GLWin.dpy, GLWin.win, GLWin.blankCursor); XDefineCursor (GLWin.dpy, GLWin.win, GLWin.blankCursor);
// better for pad plugin key input (thc) // better for pad plugin key input (thc)
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask | XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask ); StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask );
#endif #endif
return true; return true;
} }
@ -519,16 +517,16 @@ bool OpenGL_MakeCurrent()
void OpenGL_Update() void OpenGL_Update()
{ {
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
RECT rcWindow = {0}; RECT rcWindow = {0};
rcWindow.right = GLWin.width; rcWindow.right = GLWin.width;
rcWindow.bottom = GLWin.height; rcWindow.bottom = GLWin.height;
// TODO fill in // TODO fill in
#elif defined(HAVE_COCOA) && HAVE_COCOA #elif defined(HAVE_COCOA) && HAVE_COCOA
RECT rcWindow = {0}; RECT rcWindow = {0};
rcWindow.right = GLWin.width; rcWindow.right = GLWin.width;
rcWindow.bottom = GLWin.height; rcWindow.bottom = GLWin.height;
#elif defined(_WIN32) #elif defined(_WIN32)
RECT rcWindow; RECT rcWindow;
@ -548,104 +546,82 @@ void OpenGL_Update()
// ------------------ // ------------------
// See below for documentation // See below for documentation
// ------------------ // ------------------
int width = rcWindow.right - rcWindow.left; int width = rcWindow.right - rcWindow.left;
int height = rcWindow.bottom - rcWindow.top; int height = rcWindow.bottom - rcWindow.top;
// If we are rendering to a child window // If we are rendering to a child window
if (EmuWindow::GetParentWnd() != 0) if (EmuWindow::GetParentWnd() != 0)
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE); ::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
s_backbuffer_width = width; s_backbuffer_width = width;
s_backbuffer_height = height; s_backbuffer_height = height;
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
// We just check all of our events here // We just check all of our events here
XEvent event; XEvent event;
KeySym key; KeySym key;
static bool ShiftPressed = false; int num_events;
static bool ControlPressed = false; for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) {
static int FKeyPressed = -1; XNextEvent(GLWin.dpy, &event);
int num_events; switch(event.type) {
for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) { case KeyPress:
XNextEvent(GLWin.dpy, &event); key = XLookupKeysym((XKeyEvent*)&event, 0);
switch(event.type) { if(key >= XK_F1 && key <= XK_F9)
case KeyRelease: {
key = XLookupKeysym((XKeyEvent*)&event, 0); if(key == XK_F4 && ((event.xkey.state & Mod1Mask) == Mod1Mask))
if(key >= XK_F1 && key <= XK_F9) { g_VideoInitialize.pKeyPress(0x1b, False, False);
g_VideoInitialize.pKeyPress(FKeyPressed, ShiftPressed, ControlPressed); else
FKeyPressed = -1; g_VideoInitialize.pKeyPress(key - 0xff4e,
} else { (event.xkey.state & ShiftMask) == ShiftMask,
if(key == XK_Shift_L || key == XK_Shift_R) (event.xkey.state & ControlMask) == ControlMask);
ShiftPressed = false; }
else if(key == XK_Control_L || key == XK_Control_R) else if (key == XK_Escape)
ControlPressed = false; {
} if (GLWin.fs)
break; {
case KeyPress: ToggleFullscreenMode();
key = XLookupKeysym((XKeyEvent*)&event, 0); XEvent mapevent;
if(key >= XK_F1 && key <= XK_F9) do {
{ XMaskEvent(GLWin.dpy, StructureNotifyMask, &mapevent);
if(key == XK_F4 && ((event.xkey.state & Mod1Mask) == Mod1Mask)) } while ( (mapevent.type != MapNotify) || (mapevent.xmap.event != GLWin.win) );
FKeyPressed = 0x1b; }
else g_VideoInitialize.pKeyPress(0x1c, False, False);
FKeyPressed = key - 0xff4e; }
} else if (key == XK_Return && ((event.xkey.state & Mod1Mask) == Mod1Mask))
else if (key == XK_Escape) ToggleFullscreenMode();
{ break;
if (GLWin.fs) case FocusIn:
{ if (g_Config.bHideCursor)
ToggleFullscreenMode(); XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor);
XEvent event; break;
do { case FocusOut:
XMaskEvent(GLWin.dpy, StructureNotifyMask, &event); if (g_Config.bHideCursor && !GLWin.fs)
} while ( (event.type != MapNotify) || (event.xmap.event != GLWin.win) ); XUndefineCursor(GLWin.dpy, GLWin.win);
} break;
g_VideoInitialize.pKeyPress(0x1c, ShiftPressed, ControlPressed); case ConfigureNotify:
} Window winDummy;
else if (key == XK_Return && ((event.xkey.state & Mod1Mask) == Mod1Mask)) unsigned int borderDummy;
ToggleFullscreenMode(); XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
else { &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
if(key == XK_Shift_L || key == XK_Shift_R) s_backbuffer_width = GLWin.width;
ShiftPressed = true; s_backbuffer_height = GLWin.height;
else if(key == XK_Control_L || key == XK_Control_R) // Save windowed mode size for return from fullscreen
ControlPressed = true; if (!GLWin.fs)
} {
break; GLWin.winWidth = GLWin.width;
case ButtonPress: GLWin.winHeight = GLWin.height;
case ButtonRelease: }
break; break;
case FocusIn: case ClientMessage:
if (g_Config.bHideCursor) if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor); g_VideoInitialize.pKeyPress(0x1b, False, False);
break; if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False))
case FocusOut: ToggleFullscreenMode();
if (g_Config.bHideCursor && !GLWin.fs) return;
XUndefineCursor(GLWin.dpy, GLWin.win); break;
break; default:
case ConfigureNotify: break;
Window winDummy; }
unsigned int borderDummy;
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
s_backbuffer_width = GLWin.width;
s_backbuffer_height = GLWin.height;
// Save windowed mode size for return from fullscreen
if (!GLWin.fs)
{
GLWin.winWidth = GLWin.width;
GLWin.winHeight = GLWin.height;
}
break;
case ClientMessage:
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
g_VideoInitialize.pKeyPress(0x1b, False, False);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False))
ToggleFullscreenMode();
return;
break;
default:
break;
}
} }
return; return;
#endif #endif
@ -686,13 +662,13 @@ void OpenGL_Shutdown()
hDC = NULL; // Set DC To NULL hDC = NULL; // Set DC To NULL
} }
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
DestroyXWindow(); DestroyXWindow();
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fullSize >= 0) if (GLWin.fullSize >= 0)
XRRFreeScreenConfigInfo(GLWin.screenConfig); XRRFreeScreenConfigInfo(GLWin.screenConfig);
#endif #endif
if (g_Config.bHideCursor) if (g_Config.bHideCursor)
XFreeCursor(GLWin.dpy, GLWin.blankCursor); XFreeCursor(GLWin.dpy, GLWin.blankCursor);
if (GLWin.ctx) if (GLWin.ctx)
{ {
glXDestroyContext(GLWin.dpy, GLWin.ctx); glXDestroyContext(GLWin.dpy, GLWin.ctx);

View File

@ -79,21 +79,21 @@
#include <sys/types.h> #include <sys/types.h>
typedef struct { typedef struct {
int screen; int screen;
#if defined(HAVE_COCOA) && HAVE_COCOA #if defined(HAVE_COCOA) && HAVE_COCOA
NSWindow *cocoaWin; NSWindow *cocoaWin;
NSOpenGLContext *cocoaCtx; NSOpenGLContext *cocoaCtx;
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
Window win; Window win;
Display *dpy; Display *dpy;
XVisualInfo *vi; XVisualInfo *vi;
GLXContext ctx; GLXContext ctx;
Cursor blankCursor; Cursor blankCursor;
XSetWindowAttributes attr; XSetWindowAttributes attr;
Bool fs; Bool fs;
Bool doubleBuffered; Bool doubleBuffered;
int fullWidth, fullHeight; int fullWidth, fullHeight;
int winWidth, winHeight; int winWidth, winHeight;
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRScreenConfiguration *screenConfig; XRRScreenConfiguration *screenConfig;
Rotation screenRotation; Rotation screenRotation;
@ -101,13 +101,13 @@ typedef struct {
#endif // XRANDR #endif // XRANDR
#endif // X11 #endif // X11
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
wxGLCanvas *glCanvas; wxGLCanvas *glCanvas;
wxFrame *frame; wxFrame *frame;
wxGLContext *glCtxt; wxGLContext *glCtxt;
#endif #endif
int x, y; int x, y;
unsigned int width, height; unsigned int width, height;
unsigned int depth; unsigned int depth;
} GLWindow; } GLWindow;
extern GLWindow GLWin; extern GLWindow GLWin;

View File

@ -53,7 +53,6 @@ void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 || if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 ||
lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4) lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4)
{ {
const float f[4] = {f1, f2, f3, f4};
glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f1, f2, f3, f4); glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f1, f2, f3, f4);
lastPSconstants[const_number][0] = f1; lastPSconstants[const_number][0] = f1;
lastPSconstants[const_number][1] = f2; lastPSconstants[const_number][1] = f2;

View File

@ -74,6 +74,8 @@
// Declarations and definitions // Declarations and definitions
// ---------------------------- // ----------------------------
int s_fps=0;
CGcontext g_cgcontext; CGcontext g_cgcontext;
CGprofile g_cgvProf; CGprofile g_cgvProf;
CGprofile g_cgfProf; CGprofile g_cgfProf;

View File

@ -361,7 +361,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
// TODO: make this less slow. (How?) // TODO: make this less slow. (How?)
if(s_srcTextureWidth == (GLsizei)srcFmtWidth && s_srcTextureHeight == (GLsizei)srcHeight) if((GLsizei)s_srcTextureWidth == (GLsizei)srcFmtWidth && (GLsizei)s_srcTextureHeight == (GLsizei)srcHeight)
{ {
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0,0,0,s_srcTextureWidth, s_srcTextureHeight, GL_BGRA, GL_UNSIGNED_BYTE, srcAddr); glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0,0,0,s_srcTextureWidth, s_srcTextureHeight, GL_BGRA, GL_UNSIGNED_BYTE, srcAddr);
} }

View File

@ -262,7 +262,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u64 texHash; u64 texHash;
u32 FullFormat = tex_format; u32 FullFormat = tex_format;
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
u32 FullFormat = (tex_format | (tlutfmt << 16)); FullFormat = (tex_format | (tlutfmt << 16));
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
{ {
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
@ -299,7 +299,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
if (!g_ActiveConfig.bSafeTextureCache) if (!g_ActiveConfig.bSafeTextureCache)
hash_value = ((u32 *)ptr)[0]; hash_value = ((u32 *)ptr)[0];
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt)) if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && (int) FullFormat == entry.fmt))
{ {
entry.frameCount = frameCount; entry.frameCount = frameCount;
glEnable(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D); glEnable(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D);
@ -317,7 +317,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
// Let's reload the new texture data into the same texture, // Let's reload the new texture data into the same texture,
// instead of destroying it and having to create a new one. // instead of destroying it and having to create a new one.
// Might speed up movie playback very, very slightly. // Might speed up movie playback very, very slightly.
if (width == entry.w && height == entry.h && FullFormat == entry.fmt) if (width == entry.w && height == entry.h && (int) FullFormat == entry.fmt)
{ {
glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture); glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
@ -344,7 +344,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
int oldWidth = width; int oldWidth = width;
int oldHeight = height; int oldHeight = height;
sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, texHash, tex_format); sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, (unsigned int) texHash, tex_format);
dfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp); dfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp);
if (dfmt != PC_TEX_FMT_NONE) if (dfmt != PC_TEX_FMT_NONE)
@ -492,7 +492,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
bCheckedDumpDir = true; bCheckedDumpDir = true;
} }
sprintf(szTemp, "%s/%s_%08x_%i.tga",szDir, uniqueId, texHash, tex_format); sprintf(szTemp, "%s/%s_%08x_%i.tga",szDir, uniqueId, (unsigned int) texHash, tex_format);
if (!File::Exists(szTemp)) if (!File::Exists(szTemp))
{ {
SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight); SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight);
@ -648,7 +648,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
{ {
_assert_(entry.texture); _assert_(entry.texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
if (entry.w == w && entry.h == h && entry.isRectangle && entry.fmt == copyfmt) if (entry.w == w && entry.h == h && entry.isRectangle && entry.fmt == (int) copyfmt)
{ {
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
// for some reason mario sunshine errors here... // for some reason mario sunshine errors here...

View File

@ -299,7 +299,6 @@ void Flush()
// finally bind // finally bind
int groupStart = 0;
if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid); if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid);
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); // Lego Star Wars crashes here. if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); // Lego Star Wars crashes here.