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.
// 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/
#ifdef _WIN32
#include <windows.h>
#endif
@ -39,7 +39,7 @@
#include "CPUDetect.h"
#include "CoreTiming.h"
#include "Boot/Boot.h"
#include "HW/Memmap.h"
#include "HW/ProcessorInterface.h"
#include "HW/GPFifo.h"
@ -50,31 +50,31 @@
#include "HW/AudioInterface.h"
#include "HW/VideoInterface.h"
#include "HW/SystemTimers.h"
#include "PowerPC/PowerPC.h"
#include "PowerPC/JitCommon/JitBase.h"
#include "PluginManager.h"
#include "ConfigManager.h"
#include "VolumeHandler.h"
#include "FileMonitor.h"
#include "MemTools.h"
#include "Host.h"
#include "LogManager.h"
#include "State.h"
#include "OnFrame.h"
namespace Core
{
// Declarations and definitions
Common::Timer Timer;
volatile u32 DrawnFrame = 0;
u32 DrawnVideo = 0;
// Function forwarding
//void Callback_VideoRequestWindowSize(int _iWidth, int _iHeight, BOOL _bFullscreen);
void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak);
@ -85,17 +85,17 @@ void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage);
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v);
void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
// For keyboard shortcuts.
void Callback_KeyPress(int key, bool shift, bool control);
TPeekMessages Callback_PeekMessages = NULL;
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
// Function declarations
THREAD_RETURN EmuThread(void *pArg);
void Stop();
bool g_bStopping = false;
bool g_bHwInit = false;
bool g_bRealWiimote = false;
@ -126,39 +126,39 @@ bool PanicAlertToVideo(const char* text, bool yes_no)
DisplayMessage(text, 3000);
return true;
}
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);
}
void DisplayMessage(const char *message, int time_in_ms)
{
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message,
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message,
time_in_ms);
}
void Callback_DebuggerBreak()
{
CCPU::Break();
}
void *GetWindowHandle()
{
return g_pWindowHandle;
return g_pWindowHandle;
}
#if defined HAVE_X11 && HAVE_X11
void *GetXWindow()
{
return g_pXWindow;
}
{
return g_pXWindow;
}
#endif
bool GetRealWiimote()
{
return g_bRealWiimote;
return g_bRealWiimote;
}
bool isRunning()
@ -265,11 +265,6 @@ void ProcessXEvents(void)
{
XNextEvent(dpy, &event);
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:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if (key == XK_Escape)
@ -312,10 +307,10 @@ THREAD_RETURN CpuThread(void *pArg)
CPluginManager::GetInstance().GetVideo()->Video_Prepare();
Common::SetCurrentThreadName("CPU-GPU thread");
}
if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(1); // Force to first core
if (_CoreParameter.bUseFastMem)
{
#ifdef _M_X64
@ -325,7 +320,7 @@ THREAD_RETURN CpuThread(void *pArg)
PanicAlert("32-bit platforms do not support fastmem yet. Report this bug.");
#endif
}
// Enter CPU run loop. When we leave it - we are done.
CCPU::Run();
@ -337,7 +332,7 @@ THREAD_RETURN CpuThread(void *pArg)
}
cpuRunloopQuit.Set();
return 0;
return 0;
}
@ -355,21 +350,21 @@ THREAD_RETURN EmuThread(void *pArg)
CPluginManager &Plugins = CPluginManager::GetInstance();
if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(2); // Force to second core
INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "Gamecube");
INFO_LOG(OSREPORT, "CPU Thread separate = %s", _CoreParameter.bCPUThread ? "Yes" : "No");
HW::Init();
emuThreadGoing.Set();
// Load the VideoPlugin
SVideoInitialize VideoInitialize;
SVideoInitialize VideoInitialize;
VideoInitialize.pGetMemoryPointer = Memory::GetPointer;
VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt;
VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent;
VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe;
// This is first the m_Panel handle, then it is updated to have the new window handle
VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt;
VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent;
VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe;
// This is first the m_Panel handle, then it is updated to have the new window handle
VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow;
VideoInitialize.pLog = Callback_VideoLog;
VideoInitialize.pSysMessage = Host_SysMessage;
@ -381,13 +376,13 @@ THREAD_RETURN EmuThread(void *pArg)
VideoInitialize.pKeyPress = Callback_KeyPress;
VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bOnThread = _CoreParameter.bCPUThread;
VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase;
VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd;
VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer;
VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase;
VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd;
VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer;
VideoInitialize.bAutoAspectIs16_9 = _CoreParameter.bWii ? (SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR") ? true : false) : false;
Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll
// Under linux, this is an X11 Display, not a HWND!
g_pWindowHandle = (HWND)VideoInitialize.pWindowHandle;
#if defined(HAVE_X11) && HAVE_X11
@ -396,7 +391,7 @@ THREAD_RETURN EmuThread(void *pArg)
Callback_PeekMessages = VideoInitialize.pPeekMessages;
g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay;
// Load and init DSPPlugin
// Load and init DSPPlugin
DSPInitialize dspInit;
dspInit.hWnd = g_pWindowHandle;
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
Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize);
}
// The hardware is initialized.
g_bHwInit = true;
DisplayMessage("CPU: " + cpu_info.Summarize(), 8000);
DisplayMessage(_CoreParameter.m_strFilename, 3000);
// Load GCM/DOL/ELF whatever ... we boot with the interpreter core
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
CBoot::BootUp();
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
if (_CoreParameter.iCPUCore && (!_CoreParameter.bRunCompareServer || _CoreParameter.bRunCompareClient))
PowerPC::SetMode(PowerPC::MODE_JIT);
@ -465,7 +460,7 @@ THREAD_RETURN EmuThread(void *pArg)
#if defined(HAVE_X11) && HAVE_X11
Common::Thread *xEventThread = NULL;
#endif
// ENTER THE VIDEO THREAD LOOP
if (_CoreParameter.bCPUThread)
{
@ -569,8 +564,6 @@ THREAD_RETURN EmuThread(void *pArg)
g_bStopping = false;
return 0;
}
// Set or get the running state
@ -579,7 +572,7 @@ void SetState(EState _State)
switch (_State)
{
case CORE_UNINITIALIZED:
Stop();
Stop();
break;
case CORE_PAUSE:
CCPU::EnableStepping(true); // Break
@ -592,7 +585,7 @@ void SetState(EState _State)
break;
}
}
EState GetState()
{
if (g_bHwInit)
@ -606,7 +599,7 @@ EState GetState()
}
return CORE_UNINITIALIZED;
}
static inline std::string GenerateScreenshotName()
{
int index = 1;
@ -718,7 +711,7 @@ void VideoThrottle()
Host_UpdateStatusBar(SMessage.c_str());
// Reset counter
Timer.Update();
Timer.Update();
Common::AtomicStore(DrawnFrame, 0);
DrawnVideo = 0;
}
@ -761,7 +754,7 @@ void Callback_VideoCopiedToXFB(bool video_update)
{
GENERIC_LOG(LogTypes::AUDIO, (LogTypes::LOG_LEVELS)_v, _szMessage);
}
// Callback_DSPInterrupt
// WARNING - THIS MAY BE EXECUTED FROM DSP THREAD
@ -769,7 +762,7 @@ void Callback_DSPInterrupt()
{
DSP::GenerateDSPInterruptFromPlugin(DSP::INT_DSP);
}
// Callback_PADLog
//
@ -778,17 +771,17 @@ void Callback_PADLog(const TCHAR* _szMessage)
// FIXME add levels
INFO_LOG(SERIALINTERFACE, _szMessage);
}
// Callback_ISOName: Let the DSP plugin get the game name
//
const char *Callback_ISOName()
{
SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter;
SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (params.m_strName.length() > 0)
return params.m_strName.c_str();
else
return "";
return "";
}
// Called from ANY thread!
@ -829,12 +822,12 @@ void Callback_KeyPress(int key, bool shift, bool control)
Host_Message(WM_USER_PAUSE);
#endif
}
// Callback_WiimoteLog
//
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v)
{
GENERIC_LOG(LogTypes::WIIMOTE, (LogTypes::LOG_LEVELS)_v, _szMessage);
}
} // Core

View File

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

View File

@ -36,8 +36,6 @@
extern int frameCount;
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".
// The long term goal is to get rid of this class and replace it with others that make
// more sense.

View File

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

View File

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

View File

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

View File

@ -74,6 +74,8 @@
// Declarations and definitions
// ----------------------------
int s_fps=0;
CGcontext g_cgcontext;
CGprofile g_cgvProf;
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);
// 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);
}

View File

@ -262,7 +262,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u64 texHash;
u32 FullFormat = tex_format;
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 ((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)
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;
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,
// instead of destroying it and having to create a new one.
// 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);
GL_REPORT_ERRORD();
@ -344,7 +344,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
int oldWidth = width;
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);
if (dfmt != PC_TEX_FMT_NONE)
@ -492,7 +492,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
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))
{
SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight);
@ -648,7 +648,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
{
_assert_(entry.texture);
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);
// for some reason mario sunshine errors here...

View File

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