1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Massive refactoring: move API or OS dependent code to separate files.

Include/enable necessary source files in project files.
This commit is contained in:
Sergey Lipskiy 2014-09-11 14:38:56 +07:00
parent 8afec13cb9
commit f6ebb311a1
39 changed files with 1820 additions and 1324 deletions

View File

@ -6,7 +6,6 @@ set(GLideN64_SOURCES
3DMath.cpp
Combiner.cpp
CRC.cpp
Debug.cpp
DepthBuffer.cpp
F3D.cpp
F3DDKR.cpp
@ -31,6 +30,7 @@ set(GLideN64_SOURCES
S2DEX.cpp
Textures.cpp
VI.cpp
common/CommonAPIImpl_common.cpp
)
if(MUPENPLUSAPI)
@ -38,20 +38,40 @@ if(MUPENPLUSAPI)
-DMUPENPLUSAPI
)
include_directories( inc )
set(GLideN64_SOURCES_WIN
Config_mupen.cpp
)
set(GLideN64_SOURCES_LINUX
Config_mupen.cpp
Debug_linux.cpp
MupenPlusPluginAPI.cpp
mupenplus/Config.cpp
mupenplus/CommonAPIImpl_mupenplus.cpp
mupenplus/GLideN64_mupenplus.cpp
mupenplus/MicrocodeDialog.cpp
mupenplus/MupenPlusAPIImpl.cpp
mupenplus/OpenGL_mupenplus.cpp
)
set(GLideN64_SOURCES_WIN ${GLideN64_SOURCES_LINUX}
windows/GLFunctions.cpp
)
else(MUPENPLUSAPI)
set(GLideN64_SOURCES_WIN
Config.cpp
ZilmarPluginAPI.cpp
common/ZilmarAPIImpl_common.cpp
windows/Config.cpp
windows/Debug.cpp
windows/CommonAPIImpl_windows.cpp
windows/GLideN64_windows.cpp
windows/GLFunctions.cpp
windows/MicrocodeDialog.cpp
windows/OpenGL_windows.cpp
windows/ZilmarAPIImpl_windows.cpp
)
set(GLideN64_SOURCES_LINUX
Config_linux.cpp
Debug_linux.cpp
ZilmarPluginAPI.cpp
common/ZilmarAPIImpl_common.cpp
posix/Config.cpp
posix/Debug.cpp
posix/CommonAPIImpl_posix.cpp
posix/MicrocodeDialog.cpp
posix/OpenGL_posix.cpp
posix/ZilmarAPIImpl_posix.cpp
)
endif(MUPENPLUSAPI)
@ -73,6 +93,7 @@ if(WIN32)
add_definitions(
-D_WINDOWS
-D__WIN32__
-DWIN32
-D_WIN32_
-D_CRT_SECURE_NO_WARNINGS
-D__MSC__
@ -119,10 +140,12 @@ if(NOT OPENGL_FOUND)
message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)
add_library( GLideN64 SHARED ${GLideN64_SOURCES})
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x")
SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x -static-libgcc -static-libstdc++")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CPP11_COMPILE_FLAGS}" )
SET(GCC_STATIC_LINK_FLAGS "-static-libgcc -static-libstdc++")
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_STATIC_LINK_FLAGS}" )
add_library( GLideN64 SHARED ${GLideN64_SOURCES})
SET_TARGET_PROPERTIES(
GLideN64

66
CommonPluginAPI.cpp Normal file
View File

@ -0,0 +1,66 @@
#ifdef _WINDOWS
# include <windows.h>
#else
# include "winlnxdefs.h"
#endif // _WINDOWS
#include "PluginAPI.h"
extern "C" {
EXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info)
{
return api().InitiateGFX(Gfx_Info);
}
EXPORT void CALL MoveScreen (int xpos, int ypos)
{
api().MoveScreen(xpos, ypos);
}
EXPORT void CALL ProcessDList(void)
{
api().ProcessDList();
}
EXPORT void CALL ProcessRDPList(void)
{
api().ProcessRDPList();
}
EXPORT void CALL RomClosed (void)
{
api().RomClosed();
}
EXPORT void CALL RomOpen (void)
{
api().RomOpen();
}
EXPORT void CALL ShowCFB (void)
{
api().ShowCFB();
}
EXPORT void CALL UpdateScreen (void)
{
api().UpdateScreen();
}
EXPORT void CALL ViStatusChanged (void)
{
api().ViStatusChanged();
}
EXPORT void CALL ViWidthChanged (void)
{
api().ViWidthChanged();
}
EXPORT void CALL ChangeWindow(void)
{
api().ChangeWindow();
}
}

View File

@ -520,8 +520,10 @@ void FrameBufferToRDRAM::Destroy() {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &m_FBO);
m_FBO = 0;
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
if (m_pTexture != NULL) {
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
}
glDeleteBuffers(2, m_aPBO);
m_aPBO[0] = m_aPBO[1] = 0;
}
@ -654,8 +656,10 @@ void DepthBufferToRDRAM::Destroy() {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &m_FBO);
m_FBO = 0;
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
if (m_pTexture != NULL) {
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
}
glDeleteBuffers(2, m_aPBO);
m_aPBO[0] = m_aPBO[1] = 0;
}
@ -746,8 +750,10 @@ void RDRAMtoFrameBuffer::Init()
void RDRAMtoFrameBuffer::Destroy()
{
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
if (m_pTexture != NULL) {
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = NULL;
}
#ifndef GLES2
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;

203
GBI.cpp
View File

@ -19,20 +19,10 @@
#include "F3DDKR.h"
#include "F3DWRUS.h"
#include "F3DPD.h"
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
# include "Resource.h"
#else // _WINDOWS
#include <glib.h>
#include <gtk/gtk.h>
#endif // _WINDOWS
#endif // MUPENPLUSAPI
#include "CRC.h"
#include "Log.h"
#include "Debug.h"
u32 uc_crc, uc_dcrc;
char uc_str[256];
u32 last_good_ucode = (u32) -1;
SpecialMicrocodeInfo specialMicrocodes[] =
@ -111,178 +101,6 @@ void GBI_Unknown( u32 w0, u32 w1 )
#endif
}
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
INT_PTR CALLBACK MicrocodeDlgProc( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch (uMsg)
{
case WM_INITDIALOG:
for (int i = 0; i < numMicrocodeTypes; i++)
{
SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_ADDSTRING, 0, (LPARAM)MicrocodeTypes[i] );
}
SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_SETCURSEL, 0, 0 );
char text[1024];
sprintf( text, "Microcode CRC:\t\t0x%08x\r\nMicrocode Data CRC:\t0x%08x\r\nMicrocode Text:\t\t%s", uc_crc, uc_dcrc, uc_str );
SendDlgItemMessage( hWndDlg, IDC_TEXTBOX, WM_SETTEXT, NULL, (LPARAM)text );
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
EndDialog( hWndDlg, SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_GETCURSEL, 0, 0 ) );
return TRUE;
case IDCANCEL:
EndDialog( hWndDlg, NONE );
return TRUE;
}
break;
}
return FALSE;
}
#else // _WINDOWS
static int selectedMicrocode = -1;
static GtkWidget *microcodeWindow = 0;
static GtkWidget *microcodeList = 0;
static void okButton_clicked( GtkWidget *widget, void *data )
{
gtk_widget_hide( microcodeWindow );
if (GTK_LIST(microcodeList)->selection != 0)
{
char *text = 0;
GtkListItem *item = GTK_LIST_ITEM(GTK_LIST(microcodeList)->selection->data);
GtkLabel *label = GTK_LABEL(GTK_BIN(item)->child);
gtk_label_get( label, &text );
if (text != 0)
for (int i = 0; i < numMicrocodeTypes; i++)
if (!strcmp( text, MicrocodeTypes[i] ))
{
selectedMicrocode = i;
return;
}
}
selectedMicrocode = NONE;
}
static void stopButton_clicked( GtkWidget *widget, void *data )
{
gtk_widget_hide( microcodeWindow );
selectedMicrocode = NONE;
}
static gint
delete_question_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
return TRUE; // undeleteable
}
static int MicrocodeDialog()
{
GtkWidget *infoLabel;
GtkWidget *infoFrame, *infoTable;
GtkWidget *crcInfoLabel, *crcDataInfoLabel, *textInfoLabel;
GtkWidget *crcLabel, *crcDataLabel, *textLabel;
GtkWidget *selectUcodeLabel;
GtkWidget *microcodeLabel;
GtkWidget *okButton, *stopButton;
GList *ucodeList = 0;
char buf[1024];
if (!g_thread_supported())
g_thread_init( NULL );
gdk_threads_enter();
// create dialog
if (microcodeWindow == 0)
{
microcodeWindow = gtk_dialog_new();
gtk_signal_connect( GTK_OBJECT(microcodeWindow), "delete_event",
GTK_SIGNAL_FUNC(delete_question_event), (gpointer)NULL );
sprintf( buf, "%s - unknown microcode", pluginName );
gtk_window_set_title( GTK_WINDOW(microcodeWindow), buf );
gtk_container_set_border_width( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->vbox), 11 );
// ok button
okButton = gtk_button_new_with_label( "Ok" );
gtk_signal_connect_object( GTK_OBJECT(okButton), "clicked",
GTK_SIGNAL_FUNC(okButton_clicked), NULL );
gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), okButton );
// stop button
stopButton = gtk_button_new_with_label( "Stop" );
gtk_signal_connect_object( GTK_OBJECT(stopButton), "clicked",
GTK_SIGNAL_FUNC(stopButton_clicked), NULL );
gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), stopButton );
// info label
infoLabel = gtk_label_new( "Unknown microcode. Please notify Orkin, including the following information:" );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoLabel );
// info frame
infoFrame = gtk_frame_new( "Microcode info" );
gtk_container_set_border_width( GTK_CONTAINER(infoFrame), 7 );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoFrame );
infoTable = gtk_table_new( 3, 2, FALSE );
gtk_container_set_border_width( GTK_CONTAINER(infoTable), 7 );
gtk_table_set_col_spacings( GTK_TABLE(infoTable), 3 );
gtk_table_set_row_spacings( GTK_TABLE(infoTable), 3 );
gtk_container_add( GTK_CONTAINER(infoFrame), infoTable );
crcInfoLabel = gtk_label_new( "Microcode CRC:" );
crcDataInfoLabel = gtk_label_new( "Microcode Data CRC:" );
textInfoLabel = gtk_label_new( "Microcode Text:" );
crcLabel = gtk_label_new( "" );
crcDataLabel = gtk_label_new( "" );
textLabel = gtk_label_new( "" );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcInfoLabel, 0, 1, 0, 1 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcLabel, 1, 2, 0, 1 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataInfoLabel, 0, 1, 1, 2 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataLabel, 1, 2, 1, 2 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), textInfoLabel, 0, 1, 2, 3 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), textLabel, 1, 2, 2, 3 );
selectUcodeLabel = gtk_label_new( "You can manually select the closest matching microcode." );
for (int i = 0; i < numMicrocodeTypes; i++)
ucodeList = g_list_append( ucodeList, gtk_list_item_new_with_label( MicrocodeTypes[i] ) );
microcodeList = gtk_list_new();
gtk_list_set_selection_mode( GTK_LIST(microcodeList), GTK_SELECTION_SINGLE );
gtk_list_append_items( GTK_LIST(microcodeList), ucodeList );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), selectUcodeLabel );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), microcodeList );
}
snprintf( buf, 1024, "0x%8.8X", uc_crc );
gtk_label_set_text( GTK_LABEL(crcLabel), buf );
snprintf( buf, 1024, "0x%8.8X", uc_dcrc );
gtk_label_set_text( GTK_LABEL(crcDataLabel), buf );
gtk_label_set_text( GTK_LABEL(textLabel), uc_str );
selectedMicrocode = -1;
gtk_widget_show_all( microcodeWindow );
while (selectedMicrocode == -1)
{
// if( gtk_main_iteration() )
// break;
usleep( 10000 );
}
gdk_threads_leave();
return selectedMicrocode;
}
#endif // _WINDOWS
#endif // MUPENPLUSAPI
MicrocodeInfo *GBI_AddMicrocode()
{
MicrocodeInfo *newtop = (MicrocodeInfo*)malloc( sizeof( MicrocodeInfo ) );
@ -296,7 +114,7 @@ MicrocodeInfo *GBI_AddMicrocode()
if (!GBI.bottom)
GBI.bottom = newtop;
GBI.top = newtop;
GBI.top = newtop;
GBI.numMicrocodes++;
@ -334,6 +152,8 @@ void GBI_Destroy()
}
}
int MicrocodeDialog(u32 _crc, const char * _str);
MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
{
MicrocodeInfo *current;
@ -360,7 +180,7 @@ MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
current->type = NONE;
// See if we can identify it by CRC
uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 );
u32 uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 );
for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
{
if (uc_crc == specialMicrocodes[i].crc)
@ -373,6 +193,7 @@ MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
// See if we can identify it by text
char uc_data[2048];
UnswapCopy( &RDRAM[uc_dstart & 0x1FFFFFFF], uc_data, 2048 );
char uc_str[256];
strcpy( uc_str, "Not Found" );
for (u32 i = 0; i < 2048; i++)
@ -440,21 +261,9 @@ MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
}
}
#ifndef MUPENPLUSAPI
// Let the user choose the microcode
#ifdef _WINDOWS
current->type = (u32)DialogBox( hInstance, MAKEINTRESOURCE( IDD_MICROCODEDLG ), hWnd, MicrocodeDlgProc );
#else // _WINDOWS
printf( "GLideN64: Warning - unknown ucode!!!\n" );
current->type = MicrocodeDialog();
#endif // _WINDOWS
#else // MUPENPLUSAPI
LOG(LOG_ERROR, "[GLideN64]: Warning - unknown ucode!!!\n");
if (last_good_ucode != (u32)-1)
current->type=last_good_ucode;
else
assert(false && "Unknown microcode!");
#endif // MUPENPLUSAPI
current->type = MicrocodeDialog(uc_crc, uc_str);
return current;
}

3
GBI.h
View File

@ -32,9 +32,6 @@ static const char *MicrocodeTypes[] =
"None"
};
static const int numMicrocodeTypes = 11;
// Fixed point conversion factors
#define FIXED2FLOATRECIP1 0.5f
#define FIXED2FLOATRECIP2 0.25f

View File

@ -1,394 +1,3 @@
#ifdef _WINDOWS
# include <windows.h>
# include <commctrl.h>
#else
# include "winlnxdefs.h"
#include <dlfcn.h>
#endif // _WINDOWS
#include "GLideN64.h"
#include "Debug.h"
#include "OpenGL.h"
#include "N64.h"
#include "RSP.h"
#include "RDP.h"
#include "VI.h"
#include "Config.h"
#include "Textures.h"
#include "Combiner.h"
char pluginName[] = "GLideN64 alpha";
#ifdef _WINDOWS
HWND hWnd;
HWND hStatusBar;
//HWND hFullscreen;
HWND hToolBar;
HINSTANCE hInstance;
#define DLSYM(a, b) GetProcAddress(a, b)
#else
#define DLSYM(a, b) dlsym(a, b)
#endif // _WINDOWS
#ifndef MUPENPLUSAPI
#include "ZilmarGFX_1_3.h"
char *screenDirectory;
char * screenDirectory;
void (*CheckInterrupts)( void );
#ifdef _WINDOWS
LONG windowedStyle;
LONG windowedExStyle;
RECT windowedRect;
HMENU windowedMenu;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
hInstance = hinstDLL;
if (dwReason == DLL_PROCESS_ATTACH)
{
Config_LoadConfig();
OGL.hRC = NULL;
OGL.hDC = NULL;
// hFullscreen = NULL;
}
return TRUE;
}
#else
void
_init( void )
{
Config_LoadConfig();
OGL.hScreen = NULL;
}
#endif // _WINDOWS
EXPORT void CALL CaptureScreen ( char * Directory )
{
screenDirectory = Directory;
OGL.captureScreen = true;
}
EXPORT void CALL CloseDLL (void)
{
}
EXPORT void CALL DllAbout ( HWND hParent )
{
#ifdef _WINDOWS
MessageBox( hParent, "GLideN64 alpha. Based on Orkin's glN64 v0.4", pluginName, MB_OK | MB_ICONINFORMATION );
#else
puts( "GLideN64 alpha. Based on Orkin's glN64 v0.4" );
#endif
}
EXPORT void CALL DllConfig ( HWND hParent )
{
Config_DoConfig(hParent);
}
EXPORT void CALL DllTest ( HWND hParent )
{
}
EXPORT void CALL DrawScreen (void)
{
}
EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo )
{
PluginInfo->Version = 0x103;
PluginInfo->Type = PLUGIN_TYPE_GFX;
strcpy( PluginInfo->Name, pluginName );
PluginInfo->NormalMemory = FALSE;
PluginInfo->MemoryBswaped = TRUE;
}
#ifdef _WINDOWS
BOOL CALLBACK FindToolBarProc( HWND hWnd, LPARAM lParam )
{
if (GetWindowLong( hWnd, GWL_STYLE ) & RBS_VARHEIGHT)
{
hToolBar = hWnd;
return FALSE;
}
return TRUE;
}
#endif // _WINDOWS
EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
{
OGL_ReadScreen( dest, width, height );
}
#else // MUPENPLUSAPI
#include "m64p_plugin.h"
#include "Log.h"
#ifdef ANDROID
#include "ae_bridge.h"
#endif
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
/* definitions of pointers to Core video extension functions */
ptr_VidExt_Init CoreVideo_Init = NULL;
ptr_VidExt_Quit CoreVideo_Quit = NULL;
ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes = NULL;
ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode = NULL;
ptr_VidExt_SetCaption CoreVideo_SetCaption = NULL;
ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen = NULL;
ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow = NULL;
ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress = NULL;
ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute = NULL;
ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;
void (*CheckInterrupts)( void );
void (*renderCallback)() = NULL;
extern "C" {
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context, void (*DebugCallback)(void *, int, const char *))
{
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(CoreLibHandle, "ConfigGetSharedDataFilepath");
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(CoreLibHandle, "ConfigGetUserConfigPath");
/* Get the core Video Extension function pointers from the library handle */
CoreVideo_Init = (ptr_VidExt_Init) DLSYM(CoreLibHandle, "VidExt_Init");
CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(CoreLibHandle, "VidExt_Quit");
CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) DLSYM(CoreLibHandle, "VidExt_ListFullscreenModes");
CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) DLSYM(CoreLibHandle, "VidExt_SetVideoMode");
CoreVideo_SetCaption = (ptr_VidExt_SetCaption) DLSYM(CoreLibHandle, "VidExt_SetCaption");
CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) DLSYM(CoreLibHandle, "VidExt_ToggleFullScreen");
CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) DLSYM(CoreLibHandle, "VidExt_ResizeWindow");
CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) DLSYM(CoreLibHandle, "VidExt_GL_GetProcAddress");
CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) DLSYM(CoreLibHandle, "VidExt_GL_SetAttribute");
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(CoreLibHandle, "VidExt_GL_SwapBuffers");
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginShutdown(void)
{
OGL_Stop();
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType,
int *PluginVersion, int *APIVersion, const char **PluginNamePtr,
int *Capabilities)
{
/* set version info */
if (PluginType != NULL)
*PluginType = M64PLUGIN_GFX;
if (PluginVersion != NULL)
*PluginVersion = PLUGIN_VERSION;
if (APIVersion != NULL)
*APIVersion = VIDEO_PLUGIN_API_VERSION;
if (PluginNamePtr != NULL)
*PluginNamePtr = pluginName;
if (Capabilities != NULL)
{
*Capabilities = 0;
}
return M64ERR_SUCCESS;
}
EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
{
//OGL_ReadScreen( dest, width, height );
}
EXPORT void CALL SetRenderingCallback(void (*callback)(int))
{
static void (*renderCallback)(int) = NULL;
renderCallback = callback;
}
EXPORT void CALL FBRead(u32 addr)
{
}
EXPORT void CALL FBWrite(u32 addr, u32 size) {
}
EXPORT void CALL FBGetFrameBufferInfo(void *p)
{
}
EXPORT void CALL ResizeVideoOutput(int Width, int Height)
{
}
EXPORT void CALL SetFrameSkipping(bool autoSkip, int maxSkips)
{
}
EXPORT void CALL SetStretchVideo(bool stretch)
{
}
EXPORT void CALL StartGL()
{
OGL_Start();
}
EXPORT void CALL StopGL()
{
OGL_Stop();
}
EXPORT void CALL ResizeGL(int width, int height)
{
/*
int videoWidth = width;
int videoHeight = height;
if (!config.stretchVideo) {
const float ratio = (config.romPAL ? 9.0f/11.0f : 0.75f);
videoWidth = (int) (height / ratio);
if (videoWidth > width) {
videoWidth = width;
videoHeight = (int) (width * ratio);
}
}
int x = (width - videoWidth) / 2;
int y = (height - videoHeight) / 2;
OGL_ResizeWindow(x, y, videoWidth, videoHeight);
*/
}
} // extern "C"
#endif // MUPENPLUSAPI
//----------Common-------------------//
extern "C" {
EXPORT void CALL ChangeWindow (void)
{
# ifdef __LINUX__
SDL_WM_ToggleFullScreen( OGL.hScreen );
# endif // __LINUX__
}
EXPORT void CALL MoveScreen (int xpos, int ypos)
{
}
EXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info)
{
DMEM = Gfx_Info.DMEM;
IMEM = Gfx_Info.IMEM;
RDRAM = Gfx_Info.RDRAM;
REG.MI_INTR = Gfx_Info.MI_INTR_REG;
REG.DPC_START = Gfx_Info.DPC_START_REG;
REG.DPC_END = Gfx_Info.DPC_END_REG;
REG.DPC_CURRENT = Gfx_Info.DPC_CURRENT_REG;
REG.DPC_STATUS = Gfx_Info.DPC_STATUS_REG;
REG.DPC_CLOCK = Gfx_Info.DPC_CLOCK_REG;
REG.DPC_BUFBUSY = Gfx_Info.DPC_BUFBUSY_REG;
REG.DPC_PIPEBUSY = Gfx_Info.DPC_PIPEBUSY_REG;
REG.DPC_TMEM = Gfx_Info.DPC_TMEM_REG;
REG.VI_STATUS = Gfx_Info.VI_STATUS_REG;
REG.VI_ORIGIN = Gfx_Info.VI_ORIGIN_REG;
REG.VI_WIDTH = Gfx_Info.VI_WIDTH_REG;
REG.VI_INTR = Gfx_Info.VI_INTR_REG;
REG.VI_V_CURRENT_LINE = Gfx_Info.VI_V_CURRENT_LINE_REG;
REG.VI_TIMING = Gfx_Info.VI_TIMING_REG;
REG.VI_V_SYNC = Gfx_Info.VI_V_SYNC_REG;
REG.VI_H_SYNC = Gfx_Info.VI_H_SYNC_REG;
REG.VI_LEAP = Gfx_Info.VI_LEAP_REG;
REG.VI_H_START = Gfx_Info.VI_H_START_REG;
REG.VI_V_START = Gfx_Info.VI_V_START_REG;
REG.VI_V_BURST = Gfx_Info.VI_V_BURST_REG;
REG.VI_X_SCALE = Gfx_Info.VI_X_SCALE_REG;
REG.VI_Y_SCALE = Gfx_Info.VI_Y_SCALE_REG;
CheckInterrupts = Gfx_Info.CheckInterrupts;
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
hWnd = Gfx_Info.hWnd;
hStatusBar = Gfx_Info.hStatusBar;
hToolBar = NULL;
EnumChildWindows( hWnd, FindToolBarProc,0 );
#else // _WINDOWS
Config_LoadConfig();
OGL.hScreen = NULL;
#endif // _WINDOWS
#else // MUPENPLUSAPI
Config_LoadConfig();
// Config_LoadRomConfig(Gfx_Info.HEADER);
#endif // MUPENPLUSAPI
//OGL_Start();
return TRUE;
}
EXPORT void CALL ProcessDList(void)
{
RSP_ProcessDList();
}
EXPORT void CALL ProcessRDPList(void)
{
}
EXPORT void CALL RomClosed (void)
{
OGL_Stop();
#ifdef DEBUG
CloseDebugDlg();
#endif
}
EXPORT void CALL RomOpen (void)
{
RSP_Init();
OGL_ResizeWindow();
#ifdef DEBUG
OpenDebugDlg();
#endif
}
EXPORT void CALL RomResumed(void)
{
}
EXPORT void CALL ShowCFB (void)
{
gSP.changed |= CHANGED_CPU_FB_WRITE;
}
EXPORT void CALL UpdateScreen (void)
{
VI_UpdateScreen();
}
EXPORT void CALL ViStatusChanged (void)
{
}
EXPORT void CALL ViWidthChanged (void)
{
}
}

View File

@ -2,74 +2,7 @@
#define GLIDEN64_H
extern char pluginName[];
#ifdef _WINDOWS
#include <windows.h>
extern HWND hWnd;
extern HWND hStatusBar;
//HWND hFullscreen;
extern HWND hToolBar;
extern HINSTANCE hInstance;
#endif
#ifndef MUPENPLUSAPI
//#define DEBUG
extern void (*CheckInterrupts)( void );
extern char *screenDirectory;
#else // MUPENPLUSAPI
#include <stdio.h>
#include "m64p_config.h"
#include "m64p_vidext.h"
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
//#define DEBUG
#define PLUGIN_VERSION 0x020000
#define VIDEO_PLUGIN_API_VERSION 0x020200
#define CONFIG_API_VERSION 0x020000
#define VIDEXT_API_VERSION 0x030000
/* definitions of pointers to Core config functions */
extern ptr_ConfigOpenSection ConfigOpenSection;
extern ptr_ConfigSetParameter ConfigSetParameter;
extern ptr_ConfigGetParameter ConfigGetParameter;
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
extern ptr_ConfigGetParamInt ConfigGetParamInt;
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
extern ptr_ConfigGetParamBool ConfigGetParamBool;
extern ptr_ConfigGetParamString ConfigGetParamString;
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
extern ptr_VidExt_Init CoreVideo_Init;
extern ptr_VidExt_Quit CoreVideo_Quit;
extern ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes;
extern ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode;
extern ptr_VidExt_SetCaption CoreVideo_SetCaption;
extern ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen;
extern ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow;
extern ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress;
extern ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute;
extern ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers;
extern void (*CheckInterrupts)( void );
extern void (*renderCallback)();
#endif // MUPENPLUSAPI
#endif // GLIDEN64_H

View File

@ -194,7 +194,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>MUPENPLUSAPI;WIN32_ASM;_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MUPENPLUSAPI;WIN32;WIN32_ASM;_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -241,22 +241,47 @@
<ItemGroup>
<ClCompile Include="3DMath.cpp" />
<ClCompile Include="Combiner.cpp" />
<ClCompile Include="Config.cpp">
<ClCompile Include="CommonPluginAPI.cpp" />
<ClCompile Include="common\CommonAPIImpl_common.cpp" />
<ClCompile Include="common\ZilmarAPIImpl_common.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Config_mupen.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="CRC.cpp" />
<ClCompile Include="Debug.cpp" />
<ClCompile Include="DepthBuffer.cpp" />
<ClCompile Include="FrameBuffer.cpp" />
<ClCompile Include="GBI.cpp" />
<ClCompile Include="gDP.cpp" />
<ClCompile Include="GLideN64.cpp" />
<ClCompile Include="gSP.cpp" />
<ClCompile Include="MupenPlusPluginAPI.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\CommonAPIImpl_mupenplus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\Config.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\GLideN64_mupenplus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\MicrocodeDialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\MupenPlusAPIImpl.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mupenplus\OpenGL_mupenplus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="N64.cpp" />
<ClCompile Include="OpenGL.cpp" />
<ClCompile Include="RDP.CPP" />
@ -275,6 +300,39 @@
<ClCompile Include="S2DEX.cpp" />
<ClCompile Include="S2DEX2.cpp" />
<ClCompile Include="GLSLCombiner.cpp" />
<ClCompile Include="windows\CommonAPIImpl_windows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\Config.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\Debug.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\GLFunctions.cpp" />
<ClCompile Include="windows\GLideN64_windows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\MicrocodeDialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\OpenGL_windows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="windows\ZilmarAPIImpl_windows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="ZilmarPluginAPI.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="3DMath.h" />
@ -290,9 +348,14 @@
<ClInclude Include="glext.h" />
<ClInclude Include="GLideN64.h" />
<ClInclude Include="gSP.h" />
<ClInclude Include="mupenplus\GLideN64_mupenplus.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="N64.h" />
<ClInclude Include="Noise_shader.h" />
<ClInclude Include="OpenGL.h" />
<ClInclude Include="PluginAPI.h" />
<ClInclude Include="RDP.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="RSP.h" />
@ -312,7 +375,12 @@
<ClInclude Include="S2DEX.h" />
<ClInclude Include="S2DEX2.h" />
<ClInclude Include="GLSLCombiner.h" />
<ClInclude Include="ZilmarGFX_1_3.h" />
<ClInclude Include="windows\GLFunctions.h" />
<ClInclude Include="windows\GLideN64_windows.h" />
<ClInclude Include="ZilmarGFX_1_3.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />

View File

@ -25,6 +25,21 @@
<UniqueIdentifier>{ceb7e29d-3bc2-453c-a043-ef450103c3f0}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
<Filter Include="Header Files\windows">
<UniqueIdentifier>{384c65a8-5096-4ef9-bdec-3256fcd337f2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\common">
<UniqueIdentifier>{7c6de76c-0fca-47cf-99b1-0ee0fd845d7e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\windows">
<UniqueIdentifier>{cad4dfbc-6dba-4d7c-805b-b2ba719da383}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\mupenplus">
<UniqueIdentifier>{5481df48-dd50-42c8-89e5-670b337403e2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\mupenplus">
<UniqueIdentifier>{b10a85f0-0fbb-4f8e-b6d8-78ee2a6394bf}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Combiner.cpp">
@ -33,9 +48,6 @@
<ClCompile Include="CRC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Debug.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DepthBuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -111,12 +123,63 @@
<ClCompile Include="3DMath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Config.cpp">
<ClCompile Include="MupenPlusPluginAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Config_mupen.cpp">
<ClCompile Include="CommonPluginAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ZilmarPluginAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="common\CommonAPIImpl_common.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
<ClCompile Include="common\ZilmarAPIImpl_common.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
<ClCompile Include="mupenplus\CommonAPIImpl_mupenplus.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="mupenplus\Config.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="mupenplus\GLideN64_mupenplus.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="mupenplus\MicrocodeDialog.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="mupenplus\MupenPlusAPIImpl.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="mupenplus\OpenGL_mupenplus.cpp">
<Filter>Source Files\mupenplus</Filter>
</ClCompile>
<ClCompile Include="windows\CommonAPIImpl_windows.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\Config.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\Debug.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\GLFunctions.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\GLideN64_windows.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\MicrocodeDialog.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\OpenGL_windows.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
<ClCompile Include="windows\ZilmarAPIImpl_windows.cpp">
<Filter>Source Files\windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="3DMath.h">
@ -227,6 +290,18 @@
<ClInclude Include="Shaders.h">
<Filter>Header Files\Combiners</Filter>
</ClInclude>
<ClInclude Include="windows\GLFunctions.h">
<Filter>Header Files\windows</Filter>
</ClInclude>
<ClInclude Include="mupenplus\GLideN64_mupenplus.h">
<Filter>Header Files\mupenplus</Filter>
</ClInclude>
<ClInclude Include="windows\GLideN64_windows.h">
<Filter>Header Files\windows</Filter>
</ClInclude>
<ClInclude Include="PluginAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">

86
MupenPlusPluginAPI.cpp Normal file
View File

@ -0,0 +1,86 @@
#include "PluginAPI.h"
#include "Types.h"
extern "C" {
EXPORT m64p_error CALL PluginGetVersion(
m64p_plugin_type * _PluginType,
int * _PluginVersion,
int * _APIVersion,
const char ** _PluginNamePtr,
int * _Capabilities
)
{
return api().PluginGetVersion(_PluginType, _PluginVersion, _APIVersion, _PluginNamePtr, _Capabilities);
}
EXPORT m64p_error CALL PluginStartup(
m64p_dynlib_handle CoreLibHandle,
void *Context,
void (*DebugCallback)(void *, int, const char *)
)
{
return api().PluginStartup(CoreLibHandle);
}
EXPORT m64p_error CALL PluginShutdown(void)
{
return api().PluginShutdown();
}
EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
{
api().ReadScreen2(dest, width, height, front);
}
EXPORT void CALL SetRenderingCallback(void (*callback)(int))
{
api().SetRenderingCallback(callback);
}
EXPORT void CALL FBRead(u32 addr)
{
api().FBRead(addr);
}
EXPORT void CALL FBWrite(u32 addr, u32 size)
{
api().FBWrite(addr, size);
}
EXPORT void CALL FBGetFrameBufferInfo(void *p)
{
api().FBGetFrameBufferInfo(p);
}
EXPORT void CALL ResizeVideoOutput(int Width, int Height)
{
api().ResizeVideoOutput(Width, Height);
}
EXPORT void CALL SetFrameSkipping(bool autoSkip, int maxSkips)
{
api().SetFrameSkipping(autoSkip, maxSkips);
}
EXPORT void CALL SetStretchVideo(bool stretch)
{
api().SetStretchVideo(stretch);
}
EXPORT void CALL StartGL()
{
api().StartGL();
}
EXPORT void CALL StopGL()
{
api().StopGL();
}
EXPORT void CALL ResizeGL(int width, int height)
{
api().ResizeGL(width, height);
}
} // extern "C"

View File

@ -1,8 +1,8 @@
#include "OpenGL.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <time.h> /* time_t, struct tm, difftime, time, mktime */
#include "OpenGL.h"
//// paulscode, added for SDL linkage:
#if defined(GLES2)
@ -33,73 +33,6 @@
GLInfo OGL;
#ifdef _WINDOWS
// GLSL functions
PFNGLCREATESHADERPROC glCreateShader;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
PFNGLUNIFORM1IPROC glUniform1i;
PFNGLUNIFORM1FPROC glUniform1f;
PFNGLUNIFORM2FPROC glUniform2f;
PFNGLUNIFORM2IPROC glUniform2i;
PFNGLUNIFORM4FPROC glUniform4f;
PFNGLUNIFORM3FVPROC glUniform3fv;
PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLDETACHSHADERPROC glDetachShader;
PFNGLDELETESHADERPROC glDeleteShader;
PFNGLDELETEPROGRAMPROC glDeleteProgram;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETPROGRAMIVPROC glGetProgramiv;
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
// multitexture functions
PFNGLACTIVETEXTUREPROC glActiveTexture;
PFNGLDEPTHRANGEFPROC glDepthRangef;
PFNGLCLEARDEPTHFPROC glClearDepthf;
// EXT_fog_coord functions
PFNGLFOGCOORDFEXTPROC glFogCoordfEXT;
PFNGLFOGCOORDFVEXTPROC glFogCoordfvEXT;
PFNGLFOGCOORDDEXTPROC glFogCoorddEXT;
PFNGLFOGCOORDDVEXTPROC glFogCoorddvEXT;
PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT;
PFNGLDRAWBUFFERSPROC glDrawBuffers;
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGENBUFFERSPROC glGenBuffers;
PFNGLBINDBUFFERPROC glBindBuffer;
PFNGLBUFFERDATAPROC glBufferData;
PFNGLMAPBUFFERPROC glMapBuffer;
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLDELETEBUFFERSPROC glDeleteBuffers;
PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
PFNGLMEMORYBARRIERPROC glMemoryBarrier;
#endif // _WINDOWS
BOOL isExtensionSupported( const char *extension )
{
const GLubyte *extensions = NULL;
@ -135,63 +68,6 @@ void OGL_InitExtensions()
const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
u32 uVersion = atol(version);
#ifdef _WINDOWS
glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f");
glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress( "glActiveTexture" );
glDepthRangef = (PFNGLDEPTHRANGEFPROC)wglGetProcAddress( "glDepthRangef" );
glClearDepthf = (PFNGLCLEARDEPTHFPROC)wglGetProcAddress( "glClearDepthf" );
glDrawBuffers = (PFNGLDRAWBUFFERSPROC)wglGetProcAddress( "glDrawBuffers" );
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress( "glBindFramebuffer" );
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress( "glDeleteFramebuffers" );
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress( "glGenFramebuffers" );
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress( "glFramebufferTexture2D" );
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress( "glGenRenderbuffers" );
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress( "glBindRenderbuffer" );
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress( "glRenderbufferStorage" );
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress( "glFramebufferRenderbuffer" );
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress( "glDeleteRenderbuffers" );
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress( "glCheckFramebufferStatus" );
glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)wglGetProcAddress( "glBlitFramebuffer" );
glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress( "glGenBuffers" );
glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress( "glBindBuffer" );
glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress( "glBufferData" );
glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress( "glMapBuffer" );
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress( "glUnmapBuffer" );
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress( "glDeleteBuffers" );
glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)wglGetProcAddress( "glBindImageTexture" );
glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)wglGetProcAddress( "glMemoryBarrier" );
#endif // _WINDOWS
if (glGenFramebuffers != NULL)
OGL.framebufferMode = GLInfo::fbFBO;
@ -238,278 +114,9 @@ void OGL_UpdateScale()
OGL.scaleY = OGL.height / (float)VI.height;
}
void OGL_ResizeWindow()
void OGL_InitData()
{
#if defined(_WINDOWS) && !defined(MUPENPLUSAPI)
RECT windowRect, statusRect, toolRect;
if (OGL.fullscreen)
{
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
OGL.heightOffset = 0;
SetWindowPos( hWnd, NULL, 0, 0, OGL.width, OGL.height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
}
else
{
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
GetClientRect( hWnd, &windowRect );
GetWindowRect( hStatusBar, &statusRect );
if (hToolBar)
GetWindowRect( hToolBar, &toolRect );
else
toolRect.bottom = toolRect.top = 0;
OGL.heightOffset = (statusRect.bottom - statusRect.top);
windowRect.right = windowRect.left + config.video.windowedWidth - 1;
windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + OGL.heightOffset;
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE );
}
#endif // _WINDOWS
}
////// paulscode, added for SDL linkage
#if defined(GLES2) && defined (USE_SDL)
//#if defined (USE_SDL)
bool OGL_SDL_Start()
{
/* Initialize SDL */
LOG(LOG_MINIMAL, "Initializing SDL video subsystem...\n" );
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
{
LOG(LOG_ERROR, "Error initializing SDL video subsystem: %s\n", SDL_GetError() );
return FALSE;
}
int current_w = config.video.windowedWidth;
int current_h = config.video.windowedHeight;
/* Set the video mode */
LOG(LOG_MINIMAL, "Setting video mode %dx%d...\n", current_w, current_h );
// TODO: I should actually check what the pixelformat is, rather than assuming 16 bpp (RGB_565) or 32 bpp (RGBA_8888):
//// paulscode, added for switching between modes RGBA8888 and RGB565
// (part of the color banding fix)
int bitsPP;
if( Android_JNI_UseRGBA8888() )
bitsPP = 32;
else
bitsPP = 16;
////
// TODO: Replace SDL_SetVideoMode with something that is SDL 2.0 compatible
// Better yet, eliminate all SDL calls by using the Mupen64Plus core api
if (!(OGL.hScreen = SDL_SetVideoMode( current_w, current_h, bitsPP, SDL_HWSURFACE )))
{
LOG(LOG_ERROR, "Problem setting videomode %dx%d: %s\n", current_w, current_h, SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return FALSE;
}
/*
//// paulscode, fixes the screen-size problem
int videoWidth = current_w;
int videoHeight = current_h;
int x = 0;
int y = 0;
//re-scale width and height on per-rom basis
float width = (float)videoWidth * (float)config.window.refwidth / 800.f;
float height = (float)videoHeight * (float)config.window.refheight / 480.f;
//re-center video if it was re-scaled per-rom
x -= (width - (float)videoWidth) / 2.f;
y -= (height - (float)videoHeight) / 2.f;
//set xpos and ypos
config.window.xpos = x;
config.window.ypos = y;
config.framebuffer.xpos = x;
config.framebuffer.ypos = y;
//set width and height
config.window.width = (int)width;
config.window.height = (int)height;
config.framebuffer.width = (int)width;
config.framebuffer.height = (int)height;
////
*/
return true;
}
#endif
//////
bool OGL_Start()
{
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
32, // color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
if ((HWND)hWnd == NULL)
hWnd = GetActiveWindow();
if ((OGL.hDC = GetDC( hWnd )) == NULL)
{
MessageBox( hWnd, "Error while getting a device context!", pluginName, MB_ICONERROR | MB_OK );
return FALSE;
}
if ((pixelFormat = ChoosePixelFormat( OGL.hDC, &pfd )) == 0)
{
MessageBox( hWnd, "Unable to find a suitable pixel format!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return FALSE;
}
if ((SetPixelFormat( OGL.hDC, pixelFormat, &pfd )) == FALSE)
{
MessageBox( hWnd, "Error while setting pixel format!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return FALSE;
}
if ((OGL.hRC = wglCreateContext( OGL.hDC )) == NULL)
{
MessageBox( hWnd, "Error while creating OpenGL context!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return FALSE;
}
if ((wglMakeCurrent( OGL.hDC, OGL.hRC )) == FALSE)
{
MessageBox( hWnd, "Error while making OpenGL context current!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return FALSE;
}
#endif // _WINDOWS
#ifdef USE_SDL
// init sdl & gl
Uint32 videoFlags = 0;
if (OGL.fullscreen)
{
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
}
else
{
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
}
/* Initialize SDL */
printf( "[glN64]: (II) Initializing SDL video subsystem...\n" );
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
{
printf( "[glN64]: (EE) Error initializing SDL video subsystem: %s\n", SDL_GetError() );
return FALSE;
}
/* Video Info */
const SDL_VideoInfo *videoInfo;
printf( "[glN64]: (II) Getting video info...\n" );
if (!(videoInfo = SDL_GetVideoInfo()))
{
printf( "[glN64]: (EE) Video query failed: %s\n", SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return FALSE;
}
/* Set the video mode */
videoFlags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
if (videoInfo->hw_available)
videoFlags |= SDL_HWSURFACE;
else
videoFlags |= SDL_SWSURFACE;
if (videoInfo->blit_hw)
videoFlags |= SDL_HWACCEL;
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
/* SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );*/
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // 32 bit z-buffer
printf( "[glN64]: (II) Setting video mode %dx%d...\n", OGL.width, OGL.height );
if (!(OGL.hScreen = SDL_SetVideoMode( OGL.width, OGL.height, 0, videoFlags )))
{
printf( "[glN64]: (EE) Error setting videomode %dx%d: %s\n", OGL.width, OGL.height, SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return FALSE;
}
SDL_WM_SetCaption( pluginName, pluginName );
#endif // USE_SDL
#else // MUPENPLUSAPI
if (OGL.fullscreen){
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
} else {
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
}
#ifndef GLES2
CoreVideo_Init();
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, 1);
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
printf("(II) Setting video mode %dx%d...\n", OGL.width, OGL.height);
if (CoreVideo_SetVideoMode(OGL.width, OGL.height, 0, OGL.fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags) 0) != M64ERR_SUCCESS) {
printf("(EE) Error setting videomode %dx%d\n", OGL.width, OGL.height);
CoreVideo_Quit();
return false;
}
char caption[500];
# ifdef _DEBUG
sprintf(caption, "GLideN64 debug");
# else // _DEBUG
sprintf(caption, "GLideN64");
# endif // _DEBUG
CoreVideo_SetCaption(caption);
#else // GLES2
if (!OGL_SDL_Start())
return false;
#endif // GLES2
#endif // MUPENPLUSAPI
OGL_InitGLFunctions();
OGL_InitExtensions();
OGL_InitStates();
@ -529,47 +136,15 @@ bool OGL_Start()
#ifdef __TRIBUFFER_OPT
__indexmap_init();
#endif
return TRUE;
}
void OGL_Stop()
void OGL_DestroyData()
{
OGL.renderState = GLInfo::rsNone;
Combiner_Destroy();
FrameBuffer_Destroy();
DepthBuffer_Destroy();
textureCache().destroy();
OGL.renderState = GLInfo::rsNone;
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
wglMakeCurrent( NULL, NULL );
if (OGL.hRC)
{
wglDeleteContext( OGL.hRC );
OGL.hRC = NULL;
}
if (OGL.hDC)
{
ReleaseDC( hWnd, OGL.hDC );
OGL.hDC = NULL;
}
#elif defined(USE_SDL)
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif // _WINDOWS
#else // MUPENPLUSAPI
#ifndef GLES2
CoreVideo_Quit();
#else
#if defined(USE_SDL)
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif
#endif // GLES2
#endif // MUPENPLUSAPI
}
void OGL_UpdateCullFace()
@ -1235,67 +810,6 @@ void OGL_ClearColorBuffer( float *color )
glEnable( GL_SCISSOR_TEST );
}
void OGL_SaveScreenshot()
{
#if defined(_WINDOWS) && !defined(MUPENPLUSAPI)
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
HANDLE hBitmapFile;
char *pixelData = (char*)malloc( OGL.width * OGL.height * 3 );
GLint oldMode;
glGetIntegerv( GL_READ_BUFFER, &oldMode );
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glReadBuffer( GL_FRONT );
glReadPixels( 0, OGL.heightOffset, OGL.width, OGL.height, GL_BGR_EXT, GL_UNSIGNED_BYTE, pixelData );
glReadBuffer( oldMode );
infoHeader.biSize = sizeof( BITMAPINFOHEADER );
infoHeader.biWidth = OGL.width;
infoHeader.biHeight = OGL.height;
infoHeader.biPlanes = 1;
infoHeader.biBitCount = 24;
infoHeader.biCompression = BI_RGB;
infoHeader.biSizeImage = OGL.width * OGL.height * 3;
infoHeader.biXPelsPerMeter = 0;
infoHeader.biYPelsPerMeter = 0;
infoHeader.biClrUsed = 0;
infoHeader.biClrImportant = 0;
fileHeader.bfType = 19778;
fileHeader.bfSize = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) + infoHeader.biSizeImage;
fileHeader.bfReserved1 = fileHeader.bfReserved2 = 0;
fileHeader.bfOffBits = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER );
char filename[256];
CreateDirectory( screenDirectory, NULL );
int i = 0;
do
{
sprintf( filename, "%sscreen%02i.bmp", screenDirectory, i );
i++;
if (i > 99)
return;
hBitmapFile = CreateFile( filename, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
}
while (hBitmapFile == INVALID_HANDLE_VALUE);
DWORD written;
WriteFile( hBitmapFile, &fileHeader, sizeof( BITMAPFILEHEADER ), &written, NULL );
WriteFile( hBitmapFile, &infoHeader, sizeof( BITMAPINFOHEADER ), &written, NULL );
WriteFile( hBitmapFile, pixelData, infoHeader.biSizeImage, &written, NULL );
CloseHandle( hBitmapFile );
free( pixelData );
#endif // _WINDOWS
}
void OGL_ReadScreen( void **dest, long *width, long *height )
{
*width = OGL.width;
@ -1314,46 +828,6 @@ void OGL_ReadScreen( void **dest, long *width, long *height )
glReadPixels( 0, OGL.heightOffset, OGL.width, OGL.height, format, GL_UNSIGNED_BYTE, *dest );
}
void OGL_SwapBuffers()
{
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
if (OGL.hDC == NULL)
SwapBuffers( wglGetCurrentDC() );
else
SwapBuffers( OGL.hDC );
#endif // _WINDOWS
#if defined(USE_SDL)
static int frames[5] = { 0, 0, 0, 0, 0 };
static int framesIndex = 0;
static Uint32 lastTicks = 0;
Uint32 ticks = SDL_GetTicks();
frames[framesIndex]++;
if (ticks >= (lastTicks + 1000))
{
char caption[500];
float fps = 0.0;
for (int i = 0; i < 5; i++)
fps += frames[i];
fps /= 5.0;
snprintf( caption, 500, "%s - %.2f fps", pluginName, fps );
SDL_WM_SetCaption( caption, pluginName );
framesIndex = (framesIndex + 1) % 5;
frames[framesIndex] = 0;
lastTicks = ticks;
}
SDL_GL_SwapBuffers();
#endif // USE_SDL
#else // MUPENPLUSAPI
#ifndef GLES2
CoreVideo_GL_SwapBuffers();
#else
Android_JNI_SwapWindow(); // paulscode, fix for black-screen bug
#endif // GLES2
#endif // MUPENPLUSAPI
}
bool checkFBO() {
GLenum e = glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch (e) {

View File

@ -5,6 +5,7 @@
#include <windows.h>
#include <GL/gl.h>
#include "glext.h"
#include "windows/GLFunctions.h"
#else
#include "winlnxdefs.h"
#ifdef GLES2
@ -42,6 +43,7 @@ struct GLInfo
#endif // _WINDOWS
BOOL fullscreen;
unsigned int fullscreenWidth, fullscreenHeight, fullscreenBits, fullscreenRefresh;
unsigned int width, height, heightOffset;
float scaleX, scaleY;
@ -87,6 +89,9 @@ struct GLInfo
extern GLInfo OGL;
void OGL_InitGLFunctions();
void OGL_InitData();
void OGL_DestroyData();
bool OGL_Start();
void OGL_Stop();
@ -106,61 +111,4 @@ void OGL_ReadScreen( void **dest, long *width, long *height );
bool checkFBO();
#ifdef _WINDOWS
extern PFNGLCREATESHADERPROC glCreateShader;
extern PFNGLCOMPILESHADERPROC glCompileShader;
extern PFNGLSHADERSOURCEPROC glShaderSource;
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
extern PFNGLATTACHSHADERPROC glAttachShader;
extern PFNGLLINKPROGRAMPROC glLinkProgram;
extern PFNGLUSEPROGRAMPROC glUseProgram;
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
extern PFNGLUNIFORM1IPROC glUniform1i;
extern PFNGLUNIFORM1FPROC glUniform1f;
extern PFNGLUNIFORM2FPROC glUniform2f;
extern PFNGLUNIFORM2IPROC glUniform2i;
extern PFNGLUNIFORM4FPROC glUniform4f;
extern PFNGLUNIFORM3FVPROC glUniform3fv;
extern PFNGLUNIFORM4FVPROC glUniform4fv;
extern PFNGLDETACHSHADERPROC glDetachShader;
extern PFNGLDELETESHADERPROC glDeleteShader;
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
extern PFNGLGETSHADERIVPROC glGetShaderiv;
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
extern PFNGLDEPTHRANGEFPROC glDepthRangef;
extern PFNGLCLEARDEPTHFPROC glClearDepthf;
extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGENBUFFERSPROC glGenBuffers;
extern PFNGLBINDBUFFERPROC glBindBuffer;
extern PFNGLBUFFERDATAPROC glBufferData;
extern PFNGLMAPBUFFERPROC glMapBuffer;
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
#endif // !_WINDOWS
#endif

82
PluginAPI.h Normal file
View File

@ -0,0 +1,82 @@
#ifndef COMMONPLUGINAPI_H
#define COMMONPLUGINAPI_H
#ifdef MUPENPLUSAPI
#include "m64p_plugin.h"
#else
#include "ZilmarGFX_1_3.h"
#endif
class PluginAPI
{
public:
// Common
void MoveScreen(int /*_xpos*/, int /*_ypos*/) {}
void ProcessRDPList() {}
void ViStatusChanged() {}
void ViWidthChanged() {}
void ProcessDList();
void RomClosed();
void RomOpen();
void ShowCFB();
void UpdateScreen();
int InitiateGFX(const GFX_INFO & _gfxInfo);
void ChangeWindow();
#ifndef MUPENPLUSAPI
// Zilmar
void DllTest(HWND /*_hParent*/) {}
void DrawScreen() {}
void CloseDLL(void) {}
void CaptureScreen(char * _Directory);
void DllConfig(HWND _hParent);
void GetDllInfo (PLUGIN_INFO * PluginInfo);
void ReadScreen(void **_dest, long *_width, long *_height);
void DllAbout(HWND _hParent);
#else
// MupenPlus
void ReadScreen2(void * _dest, int * _width, int * _height, int _front) {}
void FBRead(unsigned int _addr) {}
void FBWrite(unsigned int addr, unsigned int size) {}
void FBGetFrameBufferInfo(void * _p) {}
void ResizeVideoOutput(int _Width, int _Height) {}
void SetFrameSkipping(bool _autoSkip, int _maxSkips) {}
void SetStretchVideo(bool _stretch) {}
m64p_error PluginStartup(m64p_dynlib_handle _CoreLibHandle);
m64p_error PluginShutdown();
m64p_error PluginGetVersion(
m64p_plugin_type * _PluginType,
int * _PluginVersion,
int * _APIVersion,
const char ** _PluginNamePtr,
int * _Capabilities
);
void SetRenderingCallback(void (*callback)(int));
void StartGL();
void StopGL();
void ResizeGL(int _width, int _height);
#endif
static PluginAPI & get()
{
static PluginAPI api;
return api;
}
private:
PluginAPI() {}
PluginAPI(const PluginAPI &);
void _initiateGFX(const GFX_INFO & _gfxInfo);
};
inline PluginAPI & api()
{
return PluginAPI::get();
}
#endif // COMMONPLUGINAPI_H

51
ZilmarPluginAPI.cpp Normal file
View File

@ -0,0 +1,51 @@
#ifdef _WINDOWS
# include <windows.h>
#else
# include "winlnxdefs.h"
#endif // _WINDOWS
#include "PluginAPI.h"
extern "C" {
EXPORT void CALL CaptureScreen ( char * Directory )
{
api().CaptureScreen(Directory);
}
EXPORT void CALL CloseDLL (void)
{
api().CloseDLL();
}
EXPORT void CALL DllAbout ( HWND hParent )
{
api().DllAbout(hParent);
}
EXPORT void CALL DllConfig ( HWND hParent )
{
api().DllConfig(hParent);
}
EXPORT void CALL DllTest ( HWND hParent )
{
api().DllTest(hParent);
}
EXPORT void CALL DrawScreen (void)
{
api().DrawScreen();
}
EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo )
{
api().GetDllInfo(PluginInfo);
}
EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
{
api().ReadScreen(dest, width, height);
}
}

View File

@ -0,0 +1,82 @@
#ifdef _WINDOWS
# include <windows.h>
#else
# include "../winlnxdefs.h"
#endif // _WINDOWS
#include "../PluginAPI.h"
#include "../N64.h"
#include "../GLideN64.h"
#include "../OpenGL.h"
#include "../RSP.h"
#include "../VI.h"
#include "../Debug.h"
void PluginAPI::ProcessDList()
{
RSP_ProcessDList();
}
void PluginAPI::RomClosed()
{
OGL_Stop();
#ifdef DEBUG
CloseDebugDlg();
#endif
}
void PluginAPI::RomOpen()
{
RSP_Init();
OGL_ResizeWindow();
#ifdef DEBUG
OpenDebugDlg();
#endif
}
void PluginAPI::ShowCFB()
{
gSP.changed |= CHANGED_CPU_FB_WRITE;
}
void PluginAPI::UpdateScreen()
{
VI_UpdateScreen();
}
void PluginAPI::_initiateGFX(const GFX_INFO & _gfxInfo) {
DMEM = _gfxInfo.DMEM;
IMEM = _gfxInfo.IMEM;
RDRAM = _gfxInfo.RDRAM;
REG.MI_INTR = _gfxInfo.MI_INTR_REG;
REG.DPC_START = _gfxInfo.DPC_START_REG;
REG.DPC_END = _gfxInfo.DPC_END_REG;
REG.DPC_CURRENT = _gfxInfo.DPC_CURRENT_REG;
REG.DPC_STATUS = _gfxInfo.DPC_STATUS_REG;
REG.DPC_CLOCK = _gfxInfo.DPC_CLOCK_REG;
REG.DPC_BUFBUSY = _gfxInfo.DPC_BUFBUSY_REG;
REG.DPC_PIPEBUSY = _gfxInfo.DPC_PIPEBUSY_REG;
REG.DPC_TMEM = _gfxInfo.DPC_TMEM_REG;
REG.VI_STATUS = _gfxInfo.VI_STATUS_REG;
REG.VI_ORIGIN = _gfxInfo.VI_ORIGIN_REG;
REG.VI_WIDTH = _gfxInfo.VI_WIDTH_REG;
REG.VI_INTR = _gfxInfo.VI_INTR_REG;
REG.VI_V_CURRENT_LINE = _gfxInfo.VI_V_CURRENT_LINE_REG;
REG.VI_TIMING = _gfxInfo.VI_TIMING_REG;
REG.VI_V_SYNC = _gfxInfo.VI_V_SYNC_REG;
REG.VI_H_SYNC = _gfxInfo.VI_H_SYNC_REG;
REG.VI_LEAP = _gfxInfo.VI_LEAP_REG;
REG.VI_H_START = _gfxInfo.VI_H_START_REG;
REG.VI_V_START = _gfxInfo.VI_V_START_REG;
REG.VI_V_BURST = _gfxInfo.VI_V_BURST_REG;
REG.VI_X_SCALE = _gfxInfo.VI_X_SCALE_REG;
REG.VI_Y_SCALE = _gfxInfo.VI_Y_SCALE_REG;
CheckInterrupts = _gfxInfo.CheckInterrupts;
}

View File

@ -0,0 +1,37 @@
#ifdef _WINDOWS
# include <windows.h>
#else
# include "../winlnxdefs.h"
#endif // _WINDOWS
#include "../PluginAPI.h"
#include "../GLideN64.h"
#include "../OpenGL.h"
#include "../Config.h"
#include "../RSP.h"
void PluginAPI::CaptureScreen(char * _Directory)
{
screenDirectory = _Directory;
OGL.captureScreen = true;
}
void PluginAPI::DllConfig(HWND _hParent)
{
Config_DoConfig(_hParent);
}
void PluginAPI::GetDllInfo(PLUGIN_INFO * PluginInfo)
{
PluginInfo->Version = 0x103;
PluginInfo->Type = PLUGIN_TYPE_GFX;
strcpy( PluginInfo->Name, pluginName );
PluginInfo->NormalMemory = FALSE;
PluginInfo->MemoryBswaped = TRUE;
}
void PluginAPI::ReadScreen(void **_dest, long *_width, long *_height)
{
OGL_ReadScreen(_dest, _width, _height);
}

View File

@ -0,0 +1,12 @@
#include "../PluginAPI.h"
#include "../OpenGL.h"
#include "../Config.h"
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
_initiateGFX(_gfxInfo);
Config_LoadConfig();
return TRUE;
}

View File

@ -1,12 +1,13 @@
#include "GLideN64_MupenPlus.h"
#include <errno.h>
#include <string.h>
#include "Config.h"
#include "GLideN64.h"
#include "RSP.h"
#include "Textures.h"
#include "OpenGL.h"
#include "Log.h"
#include "../Config.h"
#include "../GLideN64.h"
#include "../RSP.h"
#include "../Textures.h"
#include "../OpenGL.h"
#include "../Log.h"
Config config;

View File

@ -0,0 +1,19 @@
#include "GLideN64_MupenPlus.h"
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
/* definitions of pointers to Core video extension functions */
ptr_VidExt_Init CoreVideo_Init = NULL;
ptr_VidExt_Quit CoreVideo_Quit = NULL;
ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes = NULL;
ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode = NULL;
ptr_VidExt_SetCaption CoreVideo_SetCaption = NULL;
ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen = NULL;
ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow = NULL;
ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress = NULL;
ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute = NULL;
ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;
void (*renderCallback)() = NULL;

View File

@ -0,0 +1,46 @@
#ifndef GLIDEN64_MUPENPLUS_H
#define GLIDEN64_MUPENPLUS_H
#include "m64p_config.h"
#include "m64p_vidext.h"
#define PLUGIN_VERSION 0x020000
#define VIDEO_PLUGIN_API_VERSION 0x020200
#define CONFIG_API_VERSION 0x020000
#define VIDEXT_API_VERSION 0x030000
/* definitions of pointers to Core config functions */
extern ptr_ConfigOpenSection ConfigOpenSection;
extern ptr_ConfigSetParameter ConfigSetParameter;
extern ptr_ConfigGetParameter ConfigGetParameter;
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
extern ptr_ConfigGetParamInt ConfigGetParamInt;
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
extern ptr_ConfigGetParamBool ConfigGetParamBool;
extern ptr_ConfigGetParamString ConfigGetParamString;
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
extern ptr_VidExt_Init CoreVideo_Init;
extern ptr_VidExt_Quit CoreVideo_Quit;
extern ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes;
extern ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode;
extern ptr_VidExt_SetCaption CoreVideo_SetCaption;
extern ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen;
extern ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow;
extern ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress;
extern ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute;
extern ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute;
extern ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers;
extern void (*renderCallback)();
#endif // GLIDEN64_MUPENPLUS_H

View File

@ -0,0 +1,8 @@
#include <assert.h>
#include "../GBI.h"
int MicrocodeDialog(unsigned int /*_crc*/, const char * /*_str*/)
{
assert(last_good_ucode != (unsigned int)-1 && "Unknown microcode!");
return last_good_ucode;
}

View File

@ -0,0 +1,90 @@
#include "GLideN64_MupenPlus.h"
#include "../PluginAPI.h"
#include "../GLideN64.h"
#include "../OpenGL.h"
#ifdef _WINDOWS
#define DLSYM(a, b) GetProcAddress(a, b)
#else
#define DLSYM(a, b) dlsym(a, b)
#endif // _WINDOWS
m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
{
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(_CoreLibHandle, "ConfigGetSharedDataFilepath");
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(_CoreLibHandle, "ConfigGetUserConfigPath");
/* Get the core Video Extension function pointers from the library handle */
CoreVideo_Init = (ptr_VidExt_Init) DLSYM(_CoreLibHandle, "VidExt_Init");
CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(_CoreLibHandle, "VidExt_Quit");
CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) DLSYM(_CoreLibHandle, "VidExt_ListFullscreenModes");
CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) DLSYM(_CoreLibHandle, "VidExt_SetVideoMode");
CoreVideo_SetCaption = (ptr_VidExt_SetCaption) DLSYM(_CoreLibHandle, "VidExt_SetCaption");
CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) DLSYM(_CoreLibHandle, "VidExt_ToggleFullScreen");
CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) DLSYM(_CoreLibHandle, "VidExt_ResizeWindow");
CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) DLSYM(_CoreLibHandle, "VidExt_GL_GetProcAddress");
CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) DLSYM(_CoreLibHandle, "VidExt_GL_SetAttribute");
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(_CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(_CoreLibHandle, "VidExt_GL_SwapBuffers");
return M64ERR_SUCCESS;
}
m64p_error PluginAPI::PluginShutdown()
{
OGL_Stop();
return M64ERR_SUCCESS;
}
m64p_error PluginAPI::PluginGetVersion(
m64p_plugin_type * _PluginType,
int * _PluginVersion,
int * _APIVersion,
const char ** _PluginNamePtr,
int * _Capabilities
)
{
/* set version info */
if (_PluginType != NULL)
*_PluginType = M64PLUGIN_GFX;
if (_PluginVersion != NULL)
*_PluginVersion = PLUGIN_VERSION;
if (_APIVersion != NULL)
*_APIVersion = VIDEO_PLUGIN_API_VERSION;
if (_PluginNamePtr != NULL)
*_PluginNamePtr = pluginName;
if (_Capabilities != NULL)
{
*_Capabilities = 0;
}
return M64ERR_SUCCESS;
}
void PluginAPI::SetRenderingCallback(void (*callback)(int))
{
static void (*renderCallback)(int) = NULL;
renderCallback = callback;
}
void PluginAPI::StartGL()
{
OGL_Start();
}
void PluginAPI::StopGL()
{
OGL_Stop();
}
void PluginAPI::ResizeGL(int _width, int _height)
{
}
void PluginAPI::ChangeWindow()
{
}

View File

@ -0,0 +1,155 @@
#include "GLideN64_MupenPlus.h"
#include <stdio.h>
#include "../OpenGL.h"
#include "../Config.h"
#ifndef _WINDOWS
void OGL_InitGLFunctions()
{
}
#endif
void OGL_ResizeWindow()
{
}
////// paulscode, added for SDL linkage
#if defined(GLES2) && defined (USE_SDL)
//#if defined (USE_SDL)
bool OGL_SDL_Start()
{
/* Initialize SDL */
LOG(LOG_MINIMAL, "Initializing SDL video subsystem...\n" );
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
{
LOG(LOG_ERROR, "Error initializing SDL video subsystem: %s\n", SDL_GetError() );
return FALSE;
}
int current_w = config.video.windowedWidth;
int current_h = config.video.windowedHeight;
/* Set the video mode */
LOG(LOG_MINIMAL, "Setting video mode %dx%d...\n", current_w, current_h );
// TODO: I should actually check what the pixelformat is, rather than assuming 16 bpp (RGB_565) or 32 bpp (RGBA_8888):
//// paulscode, added for switching between modes RGBA8888 and RGB565
// (part of the color banding fix)
int bitsPP;
if( Android_JNI_UseRGBA8888() )
bitsPP = 32;
else
bitsPP = 16;
////
// TODO: Replace SDL_SetVideoMode with something that is SDL 2.0 compatible
// Better yet, eliminate all SDL calls by using the Mupen64Plus core api
if (!(OGL.hScreen = SDL_SetVideoMode( current_w, current_h, bitsPP, SDL_HWSURFACE )))
{
LOG(LOG_ERROR, "Problem setting videomode %dx%d: %s\n", current_w, current_h, SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return FALSE;
}
/*
//// paulscode, fixes the screen-size problem
int videoWidth = current_w;
int videoHeight = current_h;
int x = 0;
int y = 0;
//re-scale width and height on per-rom basis
float width = (float)videoWidth * (float)config.window.refwidth / 800.f;
float height = (float)videoHeight * (float)config.window.refheight / 480.f;
//re-center video if it was re-scaled per-rom
x -= (width - (float)videoWidth) / 2.f;
y -= (height - (float)videoHeight) / 2.f;
//set xpos and ypos
config.window.xpos = x;
config.window.ypos = y;
config.framebuffer.xpos = x;
config.framebuffer.ypos = y;
//set width and height
config.window.width = (int)width;
config.window.height = (int)height;
config.framebuffer.width = (int)width;
config.framebuffer.height = (int)height;
////
*/
return true;
}
#endif
//////
bool OGL_Start()
{
if (OGL.fullscreen){
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
} else {
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
}
#ifndef GLES2
CoreVideo_Init();
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, 1);
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
printf("(II) Setting video mode %dx%d...\n", OGL.width, OGL.height);
if (CoreVideo_SetVideoMode(OGL.width, OGL.height, 0, OGL.fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags) 0) != M64ERR_SUCCESS) {
printf("(EE) Error setting videomode %dx%d\n", OGL.width, OGL.height);
CoreVideo_Quit();
return false;
}
char caption[500];
# ifdef _DEBUG
sprintf(caption, "GLideN64 debug");
# else // _DEBUG
sprintf(caption, "GLideN64");
# endif // _DEBUG
CoreVideo_SetCaption(caption);
#else // GLES2
if (!OGL_SDL_Start())
return false;
#endif // GLES2
OGL_InitData();
return true;
}
void OGL_Stop()
{
OGL_DestroyData();
#ifndef GLES2
CoreVideo_Quit();
#else
#if defined(USE_SDL)
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif
#endif // GLES2
}
void OGL_SwapBuffers()
{
#ifndef GLES2
CoreVideo_GL_SwapBuffers();
#else
Android_JNI_SwapWindow(); // paulscode, fix for black-screen bug
#endif // GLES2
}
void OGL_SaveScreenshot()
{
}

View File

@ -0,0 +1,13 @@
#include "../CommonPluginAPI.h"
#include "../OpenGL.h"
#include "../Config.h"
int CommonPluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
_initiateGFX(_gfxInfo);
Config_LoadConfig();
OGL.hScreen = NULL;
return TRUE;
}

View File

@ -1,10 +1,8 @@
#include "Debug.h"
#ifdef DEBUG
#include <stdarg.h>
#include <stdio.h>
#include "../Debug.h"
DebugInfo Debug;
static bool dumpMessages = FALSE;

137
posix/MicrocodeDialog.cpp Normal file
View File

@ -0,0 +1,137 @@
#include <glib.h>
#include <gtk/gtk.h>
static int selectedMicrocode = -1;
static GtkWidget *microcodeWindow = 0;
static GtkWidget *microcodeList = 0;
static void okButton_clicked( GtkWidget *widget, void *data )
{
gtk_widget_hide( microcodeWindow );
if (GTK_LIST(microcodeList)->selection != 0)
{
char *text = 0;
GtkListItem *item = GTK_LIST_ITEM(GTK_LIST(microcodeList)->selection->data);
GtkLabel *label = GTK_LABEL(GTK_BIN(item)->child);
gtk_label_get( label, &text );
if (text != 0)
for (int i = 0; i < numMicrocodeTypes; i++)
if (!strcmp( text, MicrocodeTypes[i] ))
{
selectedMicrocode = i;
return;
}
}
selectedMicrocode = NONE;
}
static void stopButton_clicked( GtkWidget *widget, void *data )
{
gtk_widget_hide( microcodeWindow );
selectedMicrocode = NONE;
}
static gint
delete_question_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
return TRUE; // undeleteable
}
int MicrocodeDialog(u32 _crc, const char * _str)
{
GtkWidget *infoLabel;
GtkWidget *infoFrame, *infoTable;
GtkWidget *crcInfoLabel, *crcDataInfoLabel, *textInfoLabel;
GtkWidget *crcLabel, *crcDataLabel, *textLabel;
GtkWidget *selectUcodeLabel;
GtkWidget *microcodeLabel;
GtkWidget *okButton, *stopButton;
GList *ucodeList = 0;
char buf[1024];
if (!g_thread_supported())
g_thread_init( NULL );
gdk_threads_enter();
// create dialog
if (microcodeWindow == 0)
{
microcodeWindow = gtk_dialog_new();
gtk_signal_connect( GTK_OBJECT(microcodeWindow), "delete_event",
GTK_SIGNAL_FUNC(delete_question_event), (gpointer)NULL );
sprintf( buf, "%s - unknown microcode", pluginName );
gtk_window_set_title( GTK_WINDOW(microcodeWindow), buf );
gtk_container_set_border_width( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->vbox), 11 );
// ok button
okButton = gtk_button_new_with_label( "Ok" );
gtk_signal_connect_object( GTK_OBJECT(okButton), "clicked",
GTK_SIGNAL_FUNC(okButton_clicked), NULL );
gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), okButton );
// stop button
stopButton = gtk_button_new_with_label( "Stop" );
gtk_signal_connect_object( GTK_OBJECT(stopButton), "clicked",
GTK_SIGNAL_FUNC(stopButton_clicked), NULL );
gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), stopButton );
// info label
infoLabel = gtk_label_new( "Unknown microcode. Please notify Orkin, including the following information:" );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoLabel );
// info frame
infoFrame = gtk_frame_new( "Microcode info" );
gtk_container_set_border_width( GTK_CONTAINER(infoFrame), 7 );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoFrame );
infoTable = gtk_table_new( 3, 2, FALSE );
gtk_container_set_border_width( GTK_CONTAINER(infoTable), 7 );
gtk_table_set_col_spacings( GTK_TABLE(infoTable), 3 );
gtk_table_set_row_spacings( GTK_TABLE(infoTable), 3 );
gtk_container_add( GTK_CONTAINER(infoFrame), infoTable );
crcInfoLabel = gtk_label_new( "Microcode CRC:" );
crcDataInfoLabel = gtk_label_new( "Microcode Data CRC:" );
textInfoLabel = gtk_label_new( "Microcode Text:" );
crcLabel = gtk_label_new( "" );
crcDataLabel = gtk_label_new( "" );
textLabel = gtk_label_new( "" );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcInfoLabel, 0, 1, 0, 1 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcLabel, 1, 2, 0, 1 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataInfoLabel, 0, 1, 1, 2 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataLabel, 1, 2, 1, 2 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), textInfoLabel, 0, 1, 2, 3 );
gtk_table_attach_defaults( GTK_TABLE(infoTable), textLabel, 1, 2, 2, 3 );
selectUcodeLabel = gtk_label_new( "You can manually select the closest matching microcode." );
for (int i = 0; i < numMicrocodeTypes; i++)
ucodeList = g_list_append( ucodeList, gtk_list_item_new_with_label( MicrocodeTypes[i] ) );
microcodeList = gtk_list_new();
gtk_list_set_selection_mode( GTK_LIST(microcodeList), GTK_SELECTION_SINGLE );
gtk_list_append_items( GTK_LIST(microcodeList), ucodeList );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), selectUcodeLabel );
gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), microcodeList );
}
snprintf( buf, 1024, "0x%8.8X", _crc );
gtk_label_set_text( GTK_LABEL(crcLabel), buf );
snprintf( buf, 1024, "0x%8.8X", 0 );
gtk_label_set_text( GTK_LABEL(crcDataLabel), buf );
gtk_label_set_text( GTK_LABEL(textLabel), _str );
selectedMicrocode = -1;
gtk_widget_show_all( microcodeWindow );
while (selectedMicrocode == -1)
{
// if( gtk_main_iteration() )
// break;
usleep( 10000 );
}
gdk_threads_leave();
return selectedMicrocode;
}

117
posix/OpenGL_posix.cpp Normal file
View File

@ -0,0 +1,117 @@
#include "../OpenGL.h"
void OGL_InitGLFunctions()
{
}
void OGL_ResizeWindow()
{
}
bool OGL_Start()
{
#ifdef USE_SDL
// init sdl & gl
Uint32 videoFlags = 0;
if (OGL.fullscreen)
{
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
}
else
{
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
}
/* Initialize SDL */
printf( "[glN64]: (II) Initializing SDL video subsystem...\n" );
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
{
printf( "[glN64]: (EE) Error initializing SDL video subsystem: %s\n", SDL_GetError() );
return false;
}
/* Video Info */
const SDL_VideoInfo *videoInfo;
printf( "[glN64]: (II) Getting video info...\n" );
if (!(videoInfo = SDL_GetVideoInfo()))
{
printf( "[glN64]: (EE) Video query failed: %s\n", SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return false;
}
/* Set the video mode */
videoFlags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
if (videoInfo->hw_available)
videoFlags |= SDL_HWSURFACE;
else
videoFlags |= SDL_SWSURFACE;
if (videoInfo->blit_hw)
videoFlags |= SDL_HWACCEL;
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
/* SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );*/
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // 32 bit z-buffer
printf( "[glN64]: (II) Setting video mode %dx%d...\n", OGL.width, OGL.height );
if (!(OGL.hScreen = SDL_SetVideoMode( OGL.width, OGL.height, 0, videoFlags )))
{
printf( "[glN64]: (EE) Error setting videomode %dx%d: %s\n", OGL.width, OGL.height, SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
return false;
}
SDL_WM_SetCaption( pluginName, pluginName );
#endif // USE_SDL
OGL_InitData();
return true;
}
void OGL_Stop()
{
OGL_DestroyData();
#if defined(USE_SDL)
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif // _WINDOWS
}
void OGL_SwapBuffers()
{
#if defined(USE_SDL)
static int frames[5] = { 0, 0, 0, 0, 0 };
static int framesIndex = 0;
static Uint32 lastTicks = 0;
Uint32 ticks = SDL_GetTicks();
frames[framesIndex]++;
if (ticks >= (lastTicks + 1000))
{
char caption[500];
float fps = 0.0;
for (int i = 0; i < 5; i++)
fps += frames[i];
fps /= 5.0;
snprintf( caption, 500, "%s - %.2f fps", pluginName, fps );
SDL_WM_SetCaption( caption, pluginName );
framesIndex = (framesIndex + 1) % 5;
frames[framesIndex] = 0;
lastTicks = ticks;
}
SDL_GL_SwapBuffers();
#endif // USE_SDL
}
void OGL_SaveScreenshot()
{
}

View File

@ -0,0 +1,15 @@
#include "../PluginAPI.h"
#include "../GLideN64.h"
#include "../OpenGL.h"
void PluginAPI::ChangeWindow()
{
#if defined(USE_SDL)
SDL_WM_ToggleFullScreen( OGL.hScreen );
#endif
}
void PluginAPI::DllAbout(HWND _hParent)
{
puts( "GLideN64 alpha. Based on Orkin's glN64 v0.4" );
}

View File

@ -0,0 +1,25 @@
#include "GLideN64_Windows.h"
#include <commctrl.h>
#include "../PluginAPI.h"
#include "../OpenGL.h"
BOOL CALLBACK FindToolBarProc( HWND hWnd, LPARAM lParam )
{
if (GetWindowLong( hWnd, GWL_STYLE ) & RBS_VARHEIGHT) {
hToolBar = hWnd;
return FALSE;
}
return TRUE;
}
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
_initiateGFX(_gfxInfo);
hWnd = _gfxInfo.hWnd;
hStatusBar = _gfxInfo.hStatusBar;
hToolBar = NULL;
EnumChildWindows( hWnd, FindToolBarProc, 0 );
return TRUE;
}

View File

@ -1,13 +1,14 @@
#include <windows.h>
#include "GLideN64_Windows.h"
#include <stdio.h>
#include "Config.h"
#include "GLideN64.h"
#include "Resource.h"
#include "RSP.h"
#include "Textures.h"
#include "OpenGL.h"
#include <commctrl.h>
#include "../Config.h"
#include "../GLideN64.h"
#include "../Resource.h"
#include "../RSP.h"
#include "../Textures.h"
#include "../OpenGL.h"
Config config;
HWND hConfigDlg;

View File

@ -1,19 +1,20 @@
#if defined(_DEBUG) && defined(_WINDOWS)
#include <windows.h>
#include "GLideN64_Windows.h"
#include <stdio.h>
#include <process.h>
#include "GLideN64.h"
#include "Debug.h"
#include "resource.h"
#include "RDP.h"
#include "RSP.h"
#include "RichEdit.h"
#include <RichEdit.h>
#include "../GLideN64.h"
#include "../Debug.h"
#include "../resource.h"
#include "../RDP.h"
#include "../RSP.h"
DebugInfo Debug;
CHARFORMAT handledFormat =
{
CHARFORMAT handledFormat =
{
sizeof( CHARFORMAT ),
CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE,
NULL,
@ -25,8 +26,8 @@ CHARFORMAT handledFormat =
(TCHAR*)"Courier New"
};
CHARFORMAT unknownFormat =
{
CHARFORMAT unknownFormat =
{
sizeof( CHARFORMAT ),
CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE,
NULL,
@ -38,8 +39,8 @@ CHARFORMAT unknownFormat =
(TCHAR*)"Courier New"
};
CHARFORMAT errorFormat =
{
CHARFORMAT errorFormat =
{
sizeof( CHARFORMAT ),
CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE,
NULL,
@ -51,8 +52,8 @@ CHARFORMAT errorFormat =
(TCHAR*)"Courier New"
};
CHARFORMAT detailFormat =
{
CHARFORMAT detailFormat =
{
sizeof( CHARFORMAT ),
CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE,
NULL,
@ -71,18 +72,18 @@ char dumpFilename[256];
BOOL CALLBACK DebugDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch (uMsg)
{
switch (uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage( hDlg, IDC_DEBUGEDIT, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&handledFormat );
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
/* case IDC_DUMP:
case WM_COMMAND:
switch (LOWORD(wParam))
{
/* case IDC_DUMP:
RSP.dumpNextDL = TRUE;
return TRUE;
return TRUE;
case IDC_VERIFYCACHE:
if (!TextureCache_Verify())
MessageBox( NULL, "Texture cache chain is currupted!", "glNintendo64()", MB_OK );
@ -184,7 +185,7 @@ BOOL CALLBACK DebugDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}
}
return FALSE;
}
@ -197,10 +198,10 @@ void DebugDlgThreadFunc( void* )
MSG msg;
while (GetMessage( &msg, hDebugDlg, 0, 0 ) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
void OpenDebugDlg()
@ -252,11 +253,11 @@ void DebugMsg( u16 type, const char * format, ... )
char text[256];
va_list va;
va_start( va, format );
va_start( va, format );
if (DumpMessages)
{
dumpFile = fopen( dumpFilename, "a+" );
dumpFile = fopen( dumpFilename, "a+" );
vfprintf( dumpFile, format, va );
fclose( dumpFile );
}
@ -310,4 +311,4 @@ void DebugMsg( u16 type, const char * format, ... )
va_end( va );
}
#endif
#endif

117
windows/GLFunctions.cpp Normal file
View File

@ -0,0 +1,117 @@
#include "GLideN64_Windows.h"
#include "../OpenGL.h"
// GLSL functions
PFNGLCREATESHADERPROC glCreateShader;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
PFNGLUNIFORM1IPROC glUniform1i;
PFNGLUNIFORM1FPROC glUniform1f;
PFNGLUNIFORM2FPROC glUniform2f;
PFNGLUNIFORM2IPROC glUniform2i;
PFNGLUNIFORM4FPROC glUniform4f;
PFNGLUNIFORM3FVPROC glUniform3fv;
PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLDETACHSHADERPROC glDetachShader;
PFNGLDELETESHADERPROC glDeleteShader;
PFNGLDELETEPROGRAMPROC glDeleteProgram;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETPROGRAMIVPROC glGetProgramiv;
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
// multitexture functions
PFNGLACTIVETEXTUREPROC glActiveTexture;
PFNGLDEPTHRANGEFPROC glDepthRangef;
PFNGLCLEARDEPTHFPROC glClearDepthf;
PFNGLDRAWBUFFERSPROC glDrawBuffers;
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGENBUFFERSPROC glGenBuffers;
PFNGLBINDBUFFERPROC glBindBuffer;
PFNGLBUFFERDATAPROC glBufferData;
PFNGLMAPBUFFERPROC glMapBuffer;
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLDELETEBUFFERSPROC glDeleteBuffers;
PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
PFNGLMEMORYBARRIERPROC glMemoryBarrier;
void OGL_InitGLFunctions()
{
glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f");
glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress( "glActiveTexture" );
glDepthRangef = (PFNGLDEPTHRANGEFPROC)wglGetProcAddress( "glDepthRangef" );
glClearDepthf = (PFNGLCLEARDEPTHFPROC)wglGetProcAddress( "glClearDepthf" );
glDrawBuffers = (PFNGLDRAWBUFFERSPROC)wglGetProcAddress( "glDrawBuffers" );
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress( "glBindFramebuffer" );
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress( "glDeleteFramebuffers" );
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress( "glGenFramebuffers" );
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress( "glFramebufferTexture2D" );
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress( "glGenRenderbuffers" );
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress( "glBindRenderbuffer" );
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress( "glRenderbufferStorage" );
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress( "glFramebufferRenderbuffer" );
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress( "glDeleteRenderbuffers" );
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress( "glCheckFramebufferStatus" );
glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)wglGetProcAddress( "glBlitFramebuffer" );
glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress( "glGenBuffers" );
glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress( "glBindBuffer" );
glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress( "glBufferData" );
glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress( "glMapBuffer" );
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress( "glUnmapBuffer" );
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress( "glDeleteBuffers" );
glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)wglGetProcAddress( "glBindImageTexture" );
glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)wglGetProcAddress( "glMemoryBarrier" );
}

59
windows/GLFunctions.h Normal file
View File

@ -0,0 +1,59 @@
#ifndef GLFUNCTIONS_H
#define GLFUNCTIONS_H
extern PFNGLCREATESHADERPROC glCreateShader;
extern PFNGLCOMPILESHADERPROC glCompileShader;
extern PFNGLSHADERSOURCEPROC glShaderSource;
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
extern PFNGLATTACHSHADERPROC glAttachShader;
extern PFNGLLINKPROGRAMPROC glLinkProgram;
extern PFNGLUSEPROGRAMPROC glUseProgram;
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
extern PFNGLUNIFORM1IPROC glUniform1i;
extern PFNGLUNIFORM1FPROC glUniform1f;
extern PFNGLUNIFORM2FPROC glUniform2f;
extern PFNGLUNIFORM2IPROC glUniform2i;
extern PFNGLUNIFORM4FPROC glUniform4f;
extern PFNGLUNIFORM3FVPROC glUniform3fv;
extern PFNGLUNIFORM4FVPROC glUniform4fv;
extern PFNGLDETACHSHADERPROC glDetachShader;
extern PFNGLDELETESHADERPROC glDeleteShader;
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
extern PFNGLGETSHADERIVPROC glGetShaderiv;
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
extern PFNGLDEPTHRANGEFPROC glDepthRangef;
extern PFNGLCLEARDEPTHFPROC glClearDepthf;
extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGENBUFFERSPROC glGenBuffers;
extern PFNGLBINDBUFFERPROC glBindBuffer;
extern PFNGLBUFFERDATAPROC glBufferData;
extern PFNGLMAPBUFFERPROC glMapBuffer;
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
#endif // GLFUNCTIONS_H

View File

@ -0,0 +1,20 @@
#include "GLideN64_Windows.h"
#include "../OpenGL.h"
#include "../Config.h"
HWND hWnd;
HWND hStatusBar;
HWND hToolBar;
HINSTANCE hInstance;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID /*lpvReserved*/)
{
hInstance = hinstDLL;
if (dwReason == DLL_PROCESS_ATTACH) {
Config_LoadConfig();
OGL.hRC = NULL;
OGL.hDC = NULL;
}
return TRUE;
}

View File

@ -0,0 +1,11 @@
#ifndef GLIDEN64_WINDOWS_H
#define GLIDEN64_WINDOWS_H
#include <windows.h>
extern HWND hWnd;
extern HWND hStatusBar;
extern HWND hToolBar;
extern HINSTANCE hInstance;
#endif // GLIDEN64_WINDOWS_H

View File

@ -0,0 +1,48 @@
#include "GLideN64_Windows.h"
#include <commctrl.h>
#include <stdio.h>
#include "../GBI.h"
#include "../Resource.h"
static const int numMicrocodeTypes = 11;
static unsigned int uc_crc;
static const char * uc_str;
INT_PTR CALLBACK MicrocodeDlgProc( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch (uMsg)
{
case WM_INITDIALOG:
for (int i = 0; i < numMicrocodeTypes; i++) {
SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_ADDSTRING, 0, (LPARAM)MicrocodeTypes[i] );
}
SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_SETCURSEL, 0, 0 );
char text[1024];
sprintf( text, "Microcode CRC:\t\t0x%08x\r\nMicrocode Text:\t\t%s", uc_crc, uc_str );
SendDlgItemMessage( hWndDlg, IDC_TEXTBOX, WM_SETTEXT, NULL, (LPARAM)text );
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog( hWndDlg, SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_GETCURSEL, 0, 0 ) );
return TRUE;
case IDCANCEL:
EndDialog( hWndDlg, NONE );
return TRUE;
}
break;
}
return FALSE;
}
int MicrocodeDialog(unsigned int _crc, const char * _str)
{
uc_crc = _crc;
uc_str = _str;
return DialogBox( hInstance, MAKEINTRESOURCE( IDD_MICROCODEDLG ), hWnd, MicrocodeDlgProc );
}

186
windows/OpenGL_windows.cpp Normal file
View File

@ -0,0 +1,186 @@
#include "GLideN64_Windows.h"
#include <stdio.h>
#include "../GLideN64.h"
#include "../Config.h"
#include "../OpenGL.h"
void OGL_ResizeWindow()
{
RECT windowRect, statusRect, toolRect;
if (OGL.fullscreen)
{
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
OGL.heightOffset = 0;
SetWindowPos( hWnd, NULL, 0, 0, OGL.width, OGL.height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
}
else
{
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
GetClientRect( hWnd, &windowRect );
GetWindowRect( hStatusBar, &statusRect );
if (hToolBar)
GetWindowRect( hToolBar, &toolRect );
else
toolRect.bottom = toolRect.top = 0;
OGL.heightOffset = (statusRect.bottom - statusRect.top);
windowRect.right = windowRect.left + config.video.windowedWidth - 1;
windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + OGL.heightOffset;
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE );
}
}
bool OGL_Start()
{
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
32, // color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
if (hWnd == NULL)
hWnd = GetActiveWindow();
if ((OGL.hDC = GetDC( hWnd )) == NULL) {
MessageBox( hWnd, "Error while getting a device context!", pluginName, MB_ICONERROR | MB_OK );
return false;
}
if ((pixelFormat = ChoosePixelFormat( OGL.hDC, &pfd )) == 0) {
MessageBox( hWnd, "Unable to find a suitable pixel format!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return false;
}
if ((SetPixelFormat( OGL.hDC, pixelFormat, &pfd )) == FALSE) {
MessageBox( hWnd, "Error while setting pixel format!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return false;
}
if ((OGL.hRC = wglCreateContext( OGL.hDC )) == NULL) {
MessageBox( hWnd, "Error while creating OpenGL context!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return false;
}
if ((wglMakeCurrent( OGL.hDC, OGL.hRC )) == FALSE) {
MessageBox( hWnd, "Error while making OpenGL context current!", pluginName, MB_ICONERROR | MB_OK );
OGL_Stop();
return false;
}
OGL_InitData();
return true;
}
void OGL_Stop()
{
OGL_DestroyData();
wglMakeCurrent( NULL, NULL );
if (OGL.hRC) {
wglDeleteContext( OGL.hRC );
OGL.hRC = NULL;
}
if (OGL.hDC) {
ReleaseDC( hWnd, OGL.hDC );
OGL.hDC = NULL;
}
}
void OGL_SwapBuffers()
{
if (OGL.hDC == NULL)
SwapBuffers( wglGetCurrentDC() );
else
SwapBuffers( OGL.hDC );
}
void OGL_SaveScreenshot()
{
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
HANDLE hBitmapFile;
char *pixelData = (char*)malloc( OGL.width * OGL.height * 3 );
GLint oldMode;
glGetIntegerv( GL_READ_BUFFER, &oldMode );
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glReadBuffer( GL_FRONT );
glReadPixels( 0, OGL.heightOffset, OGL.width, OGL.height, GL_BGR_EXT, GL_UNSIGNED_BYTE, pixelData );
glReadBuffer( oldMode );
infoHeader.biSize = sizeof( BITMAPINFOHEADER );
infoHeader.biWidth = OGL.width;
infoHeader.biHeight = OGL.height;
infoHeader.biPlanes = 1;
infoHeader.biBitCount = 24;
infoHeader.biCompression = BI_RGB;
infoHeader.biSizeImage = OGL.width * OGL.height * 3;
infoHeader.biXPelsPerMeter = 0;
infoHeader.biYPelsPerMeter = 0;
infoHeader.biClrUsed = 0;
infoHeader.biClrImportant = 0;
fileHeader.bfType = 19778;
fileHeader.bfSize = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) + infoHeader.biSizeImage;
fileHeader.bfReserved1 = fileHeader.bfReserved2 = 0;
fileHeader.bfOffBits = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER );
char filename[256];
CreateDirectory( screenDirectory, NULL );
int i = 0;
do
{
sprintf( filename, "%sscreen%02i.bmp", screenDirectory, i );
i++;
if (i > 99)
return;
hBitmapFile = CreateFile( filename, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
}
while (hBitmapFile == INVALID_HANDLE_VALUE);
DWORD written;
WriteFile( hBitmapFile, &fileHeader, sizeof( BITMAPFILEHEADER ), &written, NULL );
WriteFile( hBitmapFile, &infoHeader, sizeof( BITMAPINFOHEADER ), &written, NULL );
WriteFile( hBitmapFile, pixelData, infoHeader.biSizeImage, &written, NULL );
CloseHandle( hBitmapFile );
free( pixelData );
}

View File

@ -0,0 +1,71 @@
#include "GLideN64_Windows.h"
#include "../PluginAPI.h"
#include "../GLideN64.h"
#include "../OpenGL.h"
LONG windowedStyle;
LONG windowedExStyle;
RECT windowedRect;
HMENU windowedMenu;
void PluginAPI::ChangeWindow()
{
if (!OGL.fullscreen) {
DEVMODE fullscreenMode;
memset( &fullscreenMode, 0, sizeof(DEVMODE) );
fullscreenMode.dmSize = sizeof(DEVMODE);
fullscreenMode.dmPelsWidth = OGL.fullscreenWidth;
fullscreenMode.dmPelsHeight = OGL.fullscreenHeight;
fullscreenMode.dmBitsPerPel = OGL.fullscreenBits;
fullscreenMode.dmDisplayFrequency = OGL.fullscreenRefresh;
fullscreenMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
if (ChangeDisplaySettings( &fullscreenMode, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL) {
MessageBox( NULL, "Failed to change display mode", pluginName, MB_ICONERROR | MB_OK );
return;
}
ShowCursor( FALSE );
windowedMenu = GetMenu( hWnd );
if (windowedMenu)
SetMenu( hWnd, NULL );
if (hStatusBar)
ShowWindow( hStatusBar, SW_HIDE );
windowedExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );
windowedStyle = GetWindowLong( hWnd, GWL_STYLE );
SetWindowLong( hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST );
SetWindowLong( hWnd, GWL_STYLE, WS_POPUP );
GetWindowRect( hWnd, &windowedRect );
OGL.fullscreen = TRUE;
OGL_ResizeWindow();
} else {
ChangeDisplaySettings( NULL, 0 );
ShowCursor( TRUE );
if (windowedMenu)
SetMenu( hWnd, windowedMenu );
if (hStatusBar)
ShowWindow( hStatusBar, SW_SHOW );
SetWindowLong( hWnd, GWL_STYLE, windowedStyle );
SetWindowLong( hWnd, GWL_EXSTYLE, windowedExStyle );
SetWindowPos( hWnd, NULL, windowedRect.left, windowedRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
OGL.fullscreen = FALSE;
OGL_ResizeWindow();
}
}
void PluginAPI::DllAbout(HWND _hParent)
{
MessageBox(_hParent, "GLideN64 alpha. Based on Orkin's glN64 v0.4", pluginName, MB_OK | MB_ICONINFORMATION );
}