2008-07-12 17:40:22 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
2008-08-17 03:56:07 +00:00
|
|
|
#include <wx/aboutdlg.h>
|
2008-07-23 16:04:58 +00:00
|
|
|
#include "Globals.h"
|
2008-07-23 15:20:36 +00:00
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
#ifdef _WIN32
|
2008-08-26 23:32:54 +00:00
|
|
|
#include "OS/Win32.h"
|
2008-07-23 16:32:38 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-25 19:44:11 +00:00
|
|
|
#if defined(__APPLE__)
|
2008-08-26 23:32:54 +00:00
|
|
|
#include <SDL.h>
|
2008-08-12 23:17:29 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-23 15:20:36 +00:00
|
|
|
#include "GUI/ConfigDlg.h"
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
#include "Render.h"
|
|
|
|
#include "GLInit.h"
|
|
|
|
#include "Fifo.h"
|
|
|
|
#include "OpcodeDecoding.h"
|
|
|
|
#include "TextureMngr.h"
|
|
|
|
#include "BPStructs.h"
|
|
|
|
#include "VertexLoader.h"
|
2008-07-17 21:09:18 +00:00
|
|
|
#include "PixelShaderManager.h"
|
|
|
|
#include "VertexShaderManager.h"
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
SVideoInitialize g_VideoInitialize;
|
|
|
|
#define VERSION_STRING "0.1"
|
|
|
|
|
|
|
|
|
|
|
|
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
|
|
|
|
{
|
|
|
|
_PluginInfo->Version = 0x0100;
|
|
|
|
_PluginInfo->Type = PLUGIN_TYPE_VIDEO;
|
|
|
|
#ifdef DEBUGFAST
|
2008-07-16 12:17:20 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OGL (DebugFast) " VERSION_STRING);
|
2008-07-12 17:40:22 +00:00
|
|
|
#else
|
|
|
|
#ifndef _DEBUG
|
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OGL " VERSION_STRING);
|
|
|
|
#else
|
2008-07-16 12:17:20 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OGL (Debug) " VERSION_STRING);
|
2008-07-12 17:40:22 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void DllAbout(HWND _hParent)
|
|
|
|
{
|
2008-07-22 23:20:54 +00:00
|
|
|
wxAboutDialogInfo info;
|
|
|
|
info.AddDeveloper(_T("zerofrog(@gmail.com)"));
|
|
|
|
info.SetDescription(_T("Vertex/Pixel Shader 2.0 or higher, framebuffer objects, multiple render targets"));
|
|
|
|
wxAboutBox(info);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DllConfig(HWND _hParent)
|
|
|
|
{
|
2008-08-13 00:00:39 +00:00
|
|
|
#if defined(_WIN32)
|
2008-07-23 15:20:36 +00:00
|
|
|
wxWindow win;
|
2008-08-05 08:49:27 +00:00
|
|
|
win.SetHWND(_hParent);
|
2008-08-06 09:48:54 +00:00
|
|
|
ConfigDialog frame(&win);
|
2008-08-05 08:49:27 +00:00
|
|
|
|
2008-08-06 09:48:54 +00:00
|
|
|
DWORD iModeNum = 0;
|
|
|
|
DEVMODE dmi;
|
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
|
|
|
dmi.dmSize = sizeof(dmi);
|
2008-08-26 13:15:25 +00:00
|
|
|
std::string resos[100];
|
|
|
|
int i = 0;
|
2008-08-06 09:48:54 +00:00
|
|
|
|
2008-08-26 13:15:25 +00:00
|
|
|
while(EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
|
2008-08-06 09:48:54 +00:00
|
|
|
{
|
|
|
|
char szBuffer[100];
|
|
|
|
sprintf(szBuffer,"%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
|
2008-08-26 13:15:25 +00:00
|
|
|
//making a string cause char*[] to char was a baaad idea
|
|
|
|
std::string strBuffer(szBuffer);
|
|
|
|
//create a check loop to check every pointer of resos to see if the res is added or not
|
|
|
|
int b = 0;
|
|
|
|
bool resFound = false;
|
|
|
|
while(b < i && !resFound)
|
|
|
|
{
|
|
|
|
//is the res already added?
|
|
|
|
resFound = (resos[b] == strBuffer);
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
if(!resFound)
|
|
|
|
//and add the res
|
2008-08-26 23:32:54 +00:00
|
|
|
{
|
|
|
|
resos[i] = strBuffer;
|
|
|
|
i++;
|
|
|
|
frame.AddFSReso(szBuffer);
|
|
|
|
frame.AddWindowReso(szBuffer);
|
|
|
|
}
|
2008-08-06 09:48:54 +00:00
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
|
|
|
}
|
2008-07-23 15:20:36 +00:00
|
|
|
frame.ShowModal();
|
2008-08-05 08:49:27 +00:00
|
|
|
win.SetHWND(0);
|
2008-07-23 15:20:36 +00:00
|
|
|
|
2008-08-13 00:00:39 +00:00
|
|
|
#elif defined(__linux__)
|
2008-07-23 16:32:38 +00:00
|
|
|
ConfigDialog frame(NULL);
|
2008-07-30 04:23:43 +00:00
|
|
|
g_Config.Load();
|
|
|
|
XVisualInfo *vi;
|
|
|
|
Colormap cmap;
|
|
|
|
int dpyWidth, dpyHeight;
|
|
|
|
int glxMajorVersion, glxMinorVersion;
|
|
|
|
int vidModeMajorVersion, vidModeMinorVersion;
|
|
|
|
GLWin.dpy = XOpenDisplay(0);
|
|
|
|
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
|
|
|
XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
|
|
|
|
//Get all full screen resos for the config dialog
|
|
|
|
XF86VidModeModeInfo **modes = NULL;
|
|
|
|
int modeNum = 0;
|
|
|
|
int bestMode = 0;
|
|
|
|
|
2008-08-06 09:48:54 +00:00
|
|
|
//set best mode to current
|
2008-07-30 04:23:43 +00:00
|
|
|
bestMode = 0;
|
|
|
|
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
|
|
|
|
int px = 0, py = 0;
|
|
|
|
if (modeNum > 0 && modes != NULL)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < modeNum; i++)
|
|
|
|
{
|
|
|
|
if(px != modes[i]->hdisplay && py != modes[i]->vdisplay)
|
|
|
|
{
|
|
|
|
char temp[32];
|
|
|
|
sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
|
|
|
|
frame.AddFSReso(temp);
|
2008-08-06 09:48:54 +00:00
|
|
|
frame.AddWindowReso(temp);//Add same to Window ones, since they should be nearly all that's needed
|
2008-07-30 04:23:43 +00:00
|
|
|
px = modes[i]->hdisplay;//Used to remove repeating from different screen depths
|
|
|
|
py = modes[i]->vdisplay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-23 15:20:36 +00:00
|
|
|
frame.ShowModal();
|
2008-08-12 23:17:29 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
#endif
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void Video_Initialize(SVideoInitialize* _pVideoInitialize)
|
|
|
|
{
|
|
|
|
if (_pVideoInitialize == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
// OpenConsole();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
frameCount = 0;
|
|
|
|
g_VideoInitialize = *_pVideoInitialize;
|
|
|
|
InitLUTs();
|
|
|
|
g_Config.Load();
|
2008-07-30 04:23:43 +00:00
|
|
|
|
|
|
|
if (!OpenGL_Create(g_VideoInitialize, 640, 480)) { //640x480 will be the default if all else fails//
|
2008-07-12 17:40:22 +00:00
|
|
|
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
|
|
|
|
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
|
|
|
|
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
|
2008-08-10 21:06:03 +00:00
|
|
|
|
|
|
|
Renderer::AddMessage("Dolphin OpenGL Video Plugin v" VERSION_STRING ,5000);
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Video_Prepare(void)
|
|
|
|
{
|
|
|
|
OpenGL_MakeCurrent();
|
|
|
|
if (!Renderer::Create2()) {
|
|
|
|
g_VideoInitialize.pLog("Renderer::Create2 failed\n", TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureMngr::Init();
|
|
|
|
|
|
|
|
BPInit();
|
|
|
|
VertexManager::Init();
|
|
|
|
OpcodeDecoder_Init();
|
|
|
|
Fifo_Init();
|
|
|
|
VertexShaderMngr::Init();
|
|
|
|
PixelShaderMngr::Init();
|
|
|
|
GL_REPORT_ERRORD();
|
|
|
|
}
|
2008-08-05 08:49:27 +00:00
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void Video_Shutdown(void)
|
|
|
|
{
|
|
|
|
VertexShaderMngr::Shutdown();
|
|
|
|
PixelShaderMngr::Shutdown();
|
|
|
|
Fifo_Shutdown();
|
|
|
|
VertexManager::Destroy();
|
|
|
|
TextureMngr::Shutdown();
|
|
|
|
OpcodeDecoder_Shutdown();
|
|
|
|
Renderer::Shutdown();
|
|
|
|
OpenGL_Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-21 17:49:06 +00:00
|
|
|
void Video_EnterLoop()
|
|
|
|
{
|
|
|
|
Fifo_EnterLoop(g_VideoInitialize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void DebugLog(const char* _fmt, ...)
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
char* Msg = (char*)alloca(strlen(_fmt)+512);
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start( ap, _fmt );
|
|
|
|
vsnprintf( Msg, strlen(_fmt)+512, _fmt, ap );
|
|
|
|
va_end( ap );
|
|
|
|
|
|
|
|
g_VideoInitialize.pLog(Msg, FALSE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
bool ScreenShot(TCHAR *File)
|
|
|
|
{
|
|
|
|
char str[64];
|
|
|
|
int left = 200, top = 15;
|
|
|
|
sprintf(str, "Dolphin OGL " VERSION_STRING);
|
|
|
|
|
|
|
|
Renderer::ResetGLState();
|
2008-08-10 21:06:03 +00:00
|
|
|
Renderer::RenderText(str, left+1, top+1, 0xff000000);
|
|
|
|
Renderer::RenderText(str, left, top, 0xffc0ffff);
|
2008-07-12 17:40:22 +00:00
|
|
|
Renderer::RestoreGLState();
|
|
|
|
|
|
|
|
if (Renderer::SaveRenderTarget(File, 0)) {
|
|
|
|
char str[255];
|
|
|
|
sprintf(str, "saved %s\n", File);
|
|
|
|
Renderer::AddMessage(str, 500);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
BOOL Video_Screenshot(TCHAR* _szFilename)
|
|
|
|
{
|
|
|
|
if (ScreenShot(_szFilename))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-07-23 16:32:38 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void Video_UpdateXFB(BYTE* _pXFB, DWORD _dwWidth, DWORD _dwHeight)
|
|
|
|
{
|
|
|
|
}
|
2008-08-10 21:34:22 +00:00
|
|
|
|
|
|
|
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
|
|
|
{
|
|
|
|
Renderer::AddMessage(pstr,milliseconds);
|
|
|
|
}
|