More WIP OGL EventHandler work by shuffle2 and myself. Wiimote isn't implemented yet and OGL window is too small (should take window borders into account when creating window).

Not committing VideoOGL.vcproj so that project compiles with old OGL video window. In order to test just replace main.cpp/GLUtil.cpp/GLUtil.h with nmain.cpp/nGLUtil.cpp/nGLUtil.h in the project.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2038 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY 2009-01-29 23:35:31 +00:00
parent d3677a0247
commit cd658ac755
21 changed files with 1158 additions and 650 deletions

View File

@ -271,7 +271,7 @@ void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
case sf::Key::Divide: sprintf(keyStr, "/"); break;
case sf::Key::Left: sprintf(keyStr, "Left"); break;
case sf::Key::Right: sprintf(keyStr, "Right"); break;
case sf::Key::Up: sprintf(keyStr, "UP"); break;
case sf::Key::Up: sprintf(keyStr, "Up"); break;
case sf::Key::Down: sprintf(keyStr, "Down"); break;
case sf::Key::Numpad0: sprintf(keyStr, "NP 0"); break;
case sf::Key::Numpad1: sprintf(keyStr, "NP 1"); break;
@ -298,12 +298,12 @@ void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
case sf::Key::F13: sprintf(keyStr, "F13"); break;
case sf::Key::F14: sprintf(keyStr, "F14"); break;
case sf::Key::F15: sprintf(keyStr, "F15"); break;
case sf::Key::Pause: sprintf(keyStr, "Paues"); break;
case sf::Key::Pause: sprintf(keyStr, "Pause"); break;
default:
if (keycode > sf::Key::Escape)
sprintf(keyStr, "Invalid Key");
else
sprintf(keyStr, "%c", keycode);
sprintf(keyStr, "%c", toupper(keycode));
break;
}
}

View File

@ -587,7 +587,8 @@ void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
#endif
// Set buttons status from wxWidgets in the main application
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PAD_Input(u16 _Key, u8 _UpDown) {}
void PAD_Input(u16 _Key, u8 _UpDown) {
}
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)

View File

@ -163,7 +163,7 @@
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointModel="0"
UsePrecompiledHeader="0"
UsePrecompiledHeader="1"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
AssemblerListingLocation="$(IntDir)\"
@ -187,12 +187,13 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dxerr9.lib dinput8.lib xinput.lib comctl32.lib"
AdditionalDependencies="comctl32.lib"
OutputFile="..\..\..\Binary\x64\plugins\Plugin_PadSimpleEvnt.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateManifest="false"
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
LinkTimeCodeGeneration="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(TargetDir)$(TargetName).lib"
@ -642,6 +643,10 @@
RelativePath=".\Src\PadSimple.h"
>
</File>
<File
RelativePath="..\..\PluginSpecs\pluginspecs_pad.h"
>
</File>
<File
RelativePath=".\Src\SConscript"
>

View File

@ -20,6 +20,7 @@
#include "Common.h"
#include "pluginspecs_pad.h"
#include "PadSimple.h"
#include "IniFile.h"
@ -103,15 +104,7 @@ bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
return false;
}
if (!eventHandler->RegisterEventListener(ParseKeyEvent, key)) {
char codestr[100];
eventHandler->SFKeyToString(code, codestr);
PanicAlert("Failed to register %s, might be already in use", codestr);
return false;
}
// FIXME: unregister old event
// We need to handle mod change
// and double registers
if (pad[nPad].keyForControl[id] != 0) {
@ -125,6 +118,14 @@ bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
eventHandler->RemoveEventListener(oldKey);
}
if (!eventHandler->RegisterEventListener(ParseKeyEvent, key)) {
char codestr[100];
eventHandler->SFKeyToString(code, codestr);
PanicAlert("Failed to register %s, might be already in use", codestr);
return false;
}
pad[nPad].keyForControl[id] = code;
return true;
@ -264,6 +265,8 @@ bool ParseKeyEvent(sf::Event ev) {
}
void PAD_Input(u16 _Key, u8 _UpDown) {
}
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
@ -342,9 +345,6 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
#endif
}
void PAD_Input(u8 _Key, u8 _UpDown) {
}
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) {
}

View File

@ -9,7 +9,12 @@
#include "pluginspecs_video.h"
#ifdef _WIN32
#define GLEW_STATIC
#include <GLew/glew.h>
#include <GLew/wglew.h>
#include <GLew/gl.h>
#include <GLew/glext.h>
#else
#include <GL/glew.h>
#endif
@ -32,13 +37,13 @@ struct res {
};
class GLWindow {
private:
private:
// TODO: what is xmax and ymax? do we need [xy]render?
u32 xWin, yWin; // windows size
int xOffset, yOffset; // offset in window
u32 xWin, yWin; // Windows' size
int xOffset, yOffset; // Offset in window
float xMax, yMax; // ???
u32 xRender, yRender; // render area
u32 xRender, yRender; // Render area
bool properties[OGL_PROP_COUNT];
@ -75,7 +80,7 @@ public:
float FactorX = 640.0f / (float)GetXwin();
float FactorY = 480.0f / (float)GetYwin();
// float Max = (FactorX < FactorY) ? FactorX : FactorY;
//float Max = (FactorX < FactorY) ? FactorX : FactorY;
SetMax(1.0f / FactorX, 1.0f / FactorY);
SetOffset(0,0);

View File

@ -15,7 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "GLUtil.h"
#include "nGLUtil.h"
#include "Profiler.h"
#include "x64Emitter.h"
#include "ABI.h"

View File

@ -18,7 +18,7 @@
#include "Globals.h"
#include "Profiler.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include <Cg/cg.h>
#include <Cg/cgGL.h>

View File

@ -24,7 +24,7 @@
#include <vector>
#include <cmath>
#include "GLUtil.h"
#include "nGLUtil.h"
#include <Cg/cg.h>
#include <Cg/cgGL.h>
@ -56,7 +56,7 @@
#endif
#ifdef _WIN32
#include "OS/Win32.h"
#include "Win32Window.h" // warning: crapcode
#else
#endif
/////////////////////////////
@ -494,19 +494,19 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
if (oldscreen && !g_Config.bFullscreen) { // if transitioning from full screen
#ifdef _WIN32
RECT rc;
rc.left = 0; rc.top = 0;
rc.right = nNewWidth; rc.bottom = nNewHeight;
AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
//RECT rc;
//rc.left = 0; rc.top = 0;
//rc.right = nNewWidth; rc.bottom = nNewHeight;
//AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
//RECT rcdesktop;
//GetWindowRect(GetDesktopWindow(), &rcdesktop);
SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
UpdateWindow(EmuWindow::GetWnd());
//SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
//SetWindowPos(EmuWindow:GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
// ((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
// rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
//UpdateWindow(EmuWindow::GetWnd());
#else // linux
#endif
}

View File

@ -17,11 +17,11 @@ void SDLWindow::Update() {
SDL_Surface *surface = SDL_GetVideoSurface();
if (!surface) {
PanicAlert("Can't ge t surface to update");
PanicAlert("Can't get surface to update");
return;
}
// SetSize(surface->w, surface->h);
//SetSize(surface->w, surface->h);
updateDim();
}
@ -69,9 +69,9 @@ SDLWindow::SDLWindow() : GLWindow() {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
PanicAlert("Failed to init SDL: %s", SDL_GetError());
SDL_Quit();
// return NULL;
//return NULL;
}
//setup ogl to use double buffering
// Setup ogl to use double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}

View File

@ -22,7 +22,7 @@ public:
#else
class SDLWindow : public GLWindow
{
public:
public:
SDLWindow() {}
};
#endif

View File

@ -22,7 +22,7 @@
#include "Globals.h"
#include "Config.h"
#include "ImageWrite.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include "Render.h"
namespace TextureConverter

View File

@ -19,7 +19,7 @@
#define _TEXTURECONVERTER_H
#include "VideoCommon.h"
#include "GLUtil.h"
#include "nGLUtil.h"
// Converts textures between formats
// TODO: support multiple texture formats

View File

@ -21,7 +21,7 @@
#include <map>
#include "VideoCommon.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include "BPStructs.h"
class TextureMngr

View File

@ -22,7 +22,7 @@
#include "Config.h"
#include "Statistics.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include <Cg/cg.h>
#include <Cg/cgGL.h>

File diff suppressed because it is too large Load Diff

View File

@ -6,24 +6,65 @@
#ifdef _WIN32
class Win32Window : public GLWindow
{
public:
virtual void SwapBuffers();
virtual void SetWindowText(const char *text);
virtual bool PeekMessages();
virtual void Update();
virtual bool MakeCurrent();
HWND GetWnd(){return myHandle;};
HWND GetParentWnd(){return myParent;};
static bool valid() { return true; }
~Win32Window();
Win32Window();
static sf::Key::Code KeysymToSF(KeySym Sym);
static sf::Key::Code VirtualKeyCodeToSF(WPARAM VirtualKey, LPARAM Flags);
static sf::Key::Code GetShiftState(bool KeyDown);
private:
struct VideoMode
{
unsigned int Width;
unsigned int Height;
unsigned int BitsPerPixel;
unsigned int DepthBits;
unsigned int StencilBits;
unsigned int AntialiasingLevel;
};
virtual void ShowMouseCursor(bool Show);
void RegisterWindowClass();
void SwitchToFullscreen(const VideoMode& Mode);
void CreateContext(VideoMode& Mode);
void Cleanup();
void ProcessEvent(UINT Message, WPARAM WParam, LPARAM LParam);
static LRESULT CALLBACK GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam);
// Static member data
static unsigned int ourWindowCount;
static const char* ourClassName;
static Win32Window* ourFullscreenWindow;
// Member data
HWND myHandle;
HINSTANCE myhInstance;
HWND myParent; // Possibly not wanted here
long myCallback;
HCURSOR myCursor;
HICON myIcon;
bool myKeyRepeatEnabled;
bool myIsCursorIn;
HDC myDeviceContext;
HGLRC myGLContext;
};
#else
class Win32Window : public GLWindow
{
public:
public:
Win32Window {}
};
#endif
#endif //_WIN32
#endif //_WIN32WINDOW_H

View File

@ -19,7 +19,7 @@
// Preliminary non-working code.
#include "Globals.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include "MemoryUtil.h"
#include "Render.h"
#include "TextureMngr.h"

View File

@ -49,8 +49,7 @@ void UpdateFPSDisplay(const char *text)
// =======================================================================================
// Create window. Called from main.cpp
bool OpenGL_Create(SVideoInitialize &_VideoInitialize,
int width, int height)
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int width, int height)
{
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
@ -61,6 +60,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize,
glWin = new X11Window();
else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0)
glWin = new WXGLWindow();
else if (strncasecmp(g_Config.iBackend, "windows", 10) == 0)
glWin = new Win32Window();
else
PanicAlert("Invalid backend %s", g_Config.iBackend);
@ -78,7 +79,7 @@ bool OpenGL_MakeCurrent()
// =======================================================================================
// Update window width, size and etc. Called from Render.cpp
// Update window width, size and etc. Called from Render.cpp and XFB.cpp
// ----------------
void OpenGL_Update()
{
@ -86,7 +87,6 @@ void OpenGL_Update()
}
// =======================================================================================
// Close plugin
// ----------------
@ -130,6 +130,8 @@ void OpenGL_AddBackends(ConfigDialog *frame) {
frame->AddRenderBackend("X11");
if(WXGLWindow::valid())
frame->AddRenderBackend("WXGL");
if(Win32Window::valid())
frame->AddRenderBackend("Windows"); // Not "Win32" because retarded people will ask where "win64" is...
}
void OpenGL_AddResolutions(ConfigDialog *frame) {

View File

@ -26,6 +26,7 @@
#include "SDLWindow.h"
#include "X11Window.h"
#include "WXGLWindow.h"
#include "Win32Window.h"
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
#define GL_DEPTH_STENCIL_EXT 0x84F9

View File

@ -26,7 +26,7 @@
#include "LookUpTables.h"
#include "ImageWrite.h"
#include "Render.h"
#include "GLUtil.h"
#include "nGLUtil.h"
#include "Fifo.h"
#include "OpcodeDecoding.h"
#include "TextureMngr.h"
@ -47,6 +47,53 @@
SVideoInitialize g_VideoInitialize;
PLUGIN_GLOBALS* globals;
//////////////////////////////////////////////////////////////////////////
// Nasty stuff which win32 needs for wxw
//////////////////////////////////////////////////////////////////////////
#if defined(_WIN32) && defined(HAVE_WX) && HAVE_WX
HINSTANCE g_hInstance;
class wxDLLApp : public wxApp
{
bool OnInit()
{
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{ // Use wxInitialize() if you don't want GUI instead of the following 12 lines
wxSetInstance((HINSTANCE)hinstDLL);
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if ( !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
wxEntryCleanup(); // Use wxUninitialize() if you don't want GUI
break;
default:
break;
}
g_hInstance = hinstDLL;
return TRUE;
}
#endif
//////////////////////////////////////////////////////////////////////////
/* Create debugging window. There's currently a strange crash that occurs whe a game is loaded
if the OpenGL plugin was loaded before. I'll try to fix that. Currently you may have to
clsoe the window if it has auto started, and then restart it after the dll has loaded
@ -102,11 +149,15 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
void DllConfig(HWND _hParent)
{
ConfigDialog frame(NULL);
wxWindow * win = new wxWindow();
win->SetHWND((WXHWND)_hParent);
win->AdoptAttributesFromHWND();
//win->Reparent(wxGetApp().GetTopWindow());
ConfigDialog *frame = new ConfigDialog(win);
g_Config.Load();
OpenGL_AddBackends(&frame);
OpenGL_AddResolutions(&frame);
frame.ShowModal();
OpenGL_AddBackends(frame);
OpenGL_AddResolutions(frame);
frame->ShowModal();
}
void Initialize(void *init)
@ -242,14 +293,6 @@ unsigned int Video_Screenshot(TCHAR* _szFilename)
return FALSE;
}
void Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset)
{
if(g_Config.bUseXFB)
{
XFB_Draw(_pXFB, _dwWidth, _dwHeight, _dwYOffset);
}
}
void Video_AddMessage(const char* pstr, u32 milliseconds)
{
Renderer::AddMessage(pstr,milliseconds);