[Glide64] Fix up to work on android
This commit is contained in:
parent
a7a0974b88
commit
52aea8738f
|
@ -261,6 +261,9 @@ extern "C" {
|
||||||
uint32_t * VI_Y_SCALE_REG;
|
uint32_t * VI_Y_SCALE_REG;
|
||||||
|
|
||||||
void(*CheckInterrupts)(void);
|
void(*CheckInterrupts)(void);
|
||||||
|
#ifdef ANDROID
|
||||||
|
void(CALL *SwapBuffers)(void);
|
||||||
|
#endif
|
||||||
} GFX_INFO;
|
} GFX_INFO;
|
||||||
|
|
||||||
extern GFX_INFO gfx;
|
extern GFX_INFO gfx;
|
||||||
|
@ -490,6 +493,22 @@ extern "C" {
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
EXPORT void CALL ViWidthChanged(void);
|
EXPORT void CALL ViWidthChanged(void);
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
/******************************************************************
|
||||||
|
Function: SurfaceCreated
|
||||||
|
Purpose: this function is called when the surface is created.
|
||||||
|
input: none
|
||||||
|
output: none
|
||||||
|
*******************************************************************/
|
||||||
|
EXPORT void CALL SurfaceCreated(void);
|
||||||
|
/******************************************************************
|
||||||
|
Function: SurfaceChanged
|
||||||
|
Purpose: this function is called when the surface is has changed.
|
||||||
|
input: none
|
||||||
|
output: none
|
||||||
|
*******************************************************************/
|
||||||
|
EXPORT void CALL SurfaceChanged(int width, int height);
|
||||||
|
#endif
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
Function: FrameBufferWrite
|
Function: FrameBufferWrite
|
||||||
Purpose: This function is called to notify the dll that the
|
Purpose: This function is called to notify the dll that the
|
||||||
|
|
|
@ -44,22 +44,21 @@ typedef FxU32 GrCombineMode_t;
|
||||||
|
|
||||||
#define GR_TEXTURE_UMA_EXT 0x06
|
#define GR_TEXTURE_UMA_EXT 0x06
|
||||||
//wrapper specific
|
//wrapper specific
|
||||||
|
#ifdef _WIN32
|
||||||
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
|
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
|
||||||
|
#else
|
||||||
|
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxBool, FxBool);
|
||||||
|
#endif
|
||||||
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
|
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
|
||||||
FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*);
|
FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*);
|
||||||
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
|
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
|
||||||
FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*);
|
FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*);
|
||||||
|
|
||||||
FX_ENTRY GrContext_t FX_CALL
|
#ifdef _WIN32
|
||||||
grSstWinOpenExt(
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(HWND hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers);
|
||||||
HWND hWnd,
|
#else
|
||||||
GrScreenResolution_t screen_resolution,
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers);
|
||||||
GrScreenRefresh_t refresh_rate,
|
#endif
|
||||||
GrColorFormat_t color_format,
|
|
||||||
GrOriginLocation_t origin_location,
|
|
||||||
GrPixelFormat_t pixelformat,
|
|
||||||
int nColBuffers,
|
|
||||||
int nAuxBuffers);
|
|
||||||
|
|
||||||
//color combiner
|
//color combiner
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
|
|
@ -281,7 +281,11 @@ void ChangeSize()
|
||||||
|
|
||||||
void ConfigWrapper()
|
void ConfigWrapper()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
grConfigWrapperExt(g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
grConfigWrapperExt(g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
||||||
|
#else
|
||||||
|
grConfigWrapperExt(g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UseUnregisteredSetting(int /*SettingID*/)
|
void UseUnregisteredSetting(int /*SettingID*/)
|
||||||
|
@ -290,20 +294,31 @@ void UseUnregisteredSetting(int /*SettingID*/)
|
||||||
DebugBreak();
|
DebugBreak();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef ANDROID
|
||||||
|
extern int g_width, g_height;
|
||||||
|
#endif
|
||||||
|
|
||||||
void ReadSettings()
|
void ReadSettings()
|
||||||
{
|
{
|
||||||
g_settings->card_id = GetSetting(Set_CardId);
|
g_settings->card_id = GetSetting(Set_CardId);
|
||||||
|
#ifdef ANDROID
|
||||||
|
g_settings->scr_res_x = g_settings->res_x = g_width;
|
||||||
|
g_settings->scr_res_y = g_settings->res_y = g_height;
|
||||||
|
#else
|
||||||
g_settings->res_data = (uint32_t)GetSetting(Set_Resolution);
|
g_settings->res_data = (uint32_t)GetSetting(Set_Resolution);
|
||||||
if (g_settings->res_data >= 24) g_settings->res_data = 12;
|
if (g_settings->res_data >= 24) g_settings->res_data = 12;
|
||||||
g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0];
|
g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0];
|
||||||
g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1];
|
g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1];
|
||||||
g_settings->wrpResolution = GetSetting(Set_wrpResolution);
|
g_settings->wrpResolution = GetSetting(Set_wrpResolution);
|
||||||
|
#endif
|
||||||
g_settings->vsync = GetSetting(Set_vsync);
|
g_settings->vsync = GetSetting(Set_vsync);
|
||||||
g_settings->ssformat = (uint8_t)GetSetting(Set_ssformat);
|
g_settings->ssformat = (uint8_t)GetSetting(Set_ssformat);
|
||||||
g_settings->show_fps = (uint8_t)GetSetting(Set_ShowFps);
|
g_settings->show_fps = (uint8_t)GetSetting(Set_ShowFps);
|
||||||
g_settings->clock = GetSetting(Set_clock);
|
g_settings->clock = GetSetting(Set_clock);
|
||||||
g_settings->clock_24_hr = GetSetting(Set_clock_24_hr);
|
g_settings->clock_24_hr = GetSetting(Set_clock_24_hr);
|
||||||
|
#ifdef ANDROID
|
||||||
|
g_settings->rotate = GetSetting(Set_Rotate);
|
||||||
|
#endif
|
||||||
g_settings->advanced_options = Set_basic_mode ? !GetSystemSetting(Set_basic_mode) : 0;
|
g_settings->advanced_options = Set_basic_mode ? !GetSystemSetting(Set_basic_mode) : 0;
|
||||||
g_settings->texenh_options = GetSetting(Set_texenh_options);
|
g_settings->texenh_options = GetSetting(Set_texenh_options);
|
||||||
g_settings->use_hotkeys = GetSetting(Set_hotkeys);
|
g_settings->use_hotkeys = GetSetting(Set_hotkeys);
|
||||||
|
@ -532,6 +547,9 @@ void WriteSettings(bool saveEmulationSettings)
|
||||||
SetSetting(Set_ShowFps, g_settings->show_fps);
|
SetSetting(Set_ShowFps, g_settings->show_fps);
|
||||||
SetSetting(Set_clock, g_settings->clock);
|
SetSetting(Set_clock, g_settings->clock);
|
||||||
SetSetting(Set_clock_24_hr, g_settings->clock_24_hr);
|
SetSetting(Set_clock_24_hr, g_settings->clock_24_hr);
|
||||||
|
#ifdef ANDROID
|
||||||
|
SetSetting(Set_Rotate, g_settings->rotate);
|
||||||
|
#endif
|
||||||
//SetSetting(Set_advanced_options,g_settings->advanced_options);
|
//SetSetting(Set_advanced_options,g_settings->advanced_options);
|
||||||
SetSetting(Set_texenh_options, g_settings->texenh_options);
|
SetSetting(Set_texenh_options, g_settings->texenh_options);
|
||||||
|
|
||||||
|
@ -866,6 +884,10 @@ int InitGfx()
|
||||||
grGlideShutdown();
|
grGlideShutdown();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
gfx_context = grSstWinOpen(GR_REFRESH_60Hz, GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1);
|
||||||
|
g_settings->scr_res_x = g_settings->res_x = g_width;
|
||||||
|
g_settings->scr_res_y = g_settings->res_y = g_height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GfxInitDone = TRUE;
|
GfxInitDone = TRUE;
|
||||||
|
@ -1379,7 +1401,9 @@ int CALL InitiateGFX(GFX_INFO Gfx_Info)
|
||||||
ReadSettings();
|
ReadSettings();
|
||||||
char name[21] = "DEFAULT";
|
char name[21] = "DEFAULT";
|
||||||
ReadSpecialSettings(name);
|
ReadSpecialSettings(name);
|
||||||
|
#ifdef _WIN32
|
||||||
g_settings->res_data_org = g_settings->res_data;
|
g_settings->res_data_org = g_settings->res_data;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FPS
|
#ifdef FPS
|
||||||
fps_last.SetToNow();
|
fps_last.SetToNow();
|
||||||
|
@ -1406,7 +1430,11 @@ int CALL InitiateGFX(GFX_INFO Gfx_Info)
|
||||||
if (fb_depth_render_enabled)
|
if (fb_depth_render_enabled)
|
||||||
ZLUT_init();
|
ZLUT_init();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
grConfigWrapperExt(g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
grConfigWrapperExt(g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
||||||
|
#else
|
||||||
|
grConfigWrapperExt(g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic);
|
||||||
|
#endif
|
||||||
|
|
||||||
grGlideInit();
|
grGlideInit();
|
||||||
grSstSelect(0);
|
grSstSelect(0);
|
||||||
|
@ -1473,7 +1501,12 @@ void CALL PluginLoaded(void)
|
||||||
general_setting(Set_texenh_options, "texenh_options", 0);
|
general_setting(Set_texenh_options, "texenh_options", 0);
|
||||||
general_setting(Set_hotkeys, "hotkeys", 1);
|
general_setting(Set_hotkeys, "hotkeys", 1);
|
||||||
general_setting(Set_wrpVRAM, "wrpVRAM", 0);
|
general_setting(Set_wrpVRAM, "wrpVRAM", 0);
|
||||||
|
#ifndef ANDROID
|
||||||
general_setting(Set_wrpFBO, "wrpFBO", 0);
|
general_setting(Set_wrpFBO, "wrpFBO", 0);
|
||||||
|
#else
|
||||||
|
general_setting(Set_Rotate, "rotate", 0);
|
||||||
|
general_setting(Set_wrpFBO, "wrpFBO", 1);
|
||||||
|
#endif
|
||||||
general_setting(Set_wrpAnisotropic, "wrpAnisotropic", 0);
|
general_setting(Set_wrpAnisotropic, "wrpAnisotropic", 0);
|
||||||
general_setting(Set_autodetect_ucode, "autodetect_ucode", 1);
|
general_setting(Set_autodetect_ucode, "autodetect_ucode", 1);
|
||||||
general_setting(Set_ucode, "ucode", 2);
|
general_setting(Set_ucode, "ucode", 2);
|
||||||
|
@ -2322,6 +2355,33 @@ void CALL ViWidthChanged(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
/******************************************************************
|
||||||
|
Function: SurfaceCreated
|
||||||
|
Purpose: this function is called when the surface is created.
|
||||||
|
input: none
|
||||||
|
output: none
|
||||||
|
*******************************************************************/
|
||||||
|
void CALL SurfaceCreated(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
Function: SurfaceChanged
|
||||||
|
Purpose: this function is called when the surface is has changed.
|
||||||
|
input: none
|
||||||
|
output: none
|
||||||
|
*******************************************************************/
|
||||||
|
void init_combiner();
|
||||||
|
|
||||||
|
void CALL SurfaceChanged(int width, int height)
|
||||||
|
{
|
||||||
|
g_width = width;
|
||||||
|
g_height = height;
|
||||||
|
init_combiner();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WINPROC_OVERRIDE
|
#ifdef WINPROC_OVERRIDE
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -2408,3 +2468,10 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
|
||||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
void Android_JNI_SwapWindow()
|
||||||
|
{
|
||||||
|
gfx.SwapBuffers();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -6,8 +6,10 @@ CSettings::CSettings() :
|
||||||
scr_res_x(640),
|
scr_res_x(640),
|
||||||
res_y(480),
|
res_y(480),
|
||||||
scr_res_y(480),
|
scr_res_y(480),
|
||||||
|
#ifdef _WIN32
|
||||||
res_data(GR_RESOLUTION_640x480),
|
res_data(GR_RESOLUTION_640x480),
|
||||||
res_data_org(GR_RESOLUTION_640x480),
|
res_data_org(GR_RESOLUTION_640x480),
|
||||||
|
#endif
|
||||||
advanced_options(0),
|
advanced_options(0),
|
||||||
texenh_options(0),
|
texenh_options(0),
|
||||||
ssformat(0),
|
ssformat(0),
|
||||||
|
@ -16,6 +18,9 @@ CSettings::CSettings() :
|
||||||
show_fps(0),
|
show_fps(0),
|
||||||
clock(0),
|
clock(0),
|
||||||
clock_24_hr(0),
|
clock_24_hr(0),
|
||||||
|
#ifdef ANDROID
|
||||||
|
rotate(0),
|
||||||
|
#endif
|
||||||
|
|
||||||
filtering(0),
|
filtering(0),
|
||||||
fog(0),
|
fog(0),
|
||||||
|
@ -89,7 +94,9 @@ CSettings::CSettings() :
|
||||||
hacks(0),
|
hacks(0),
|
||||||
|
|
||||||
//wrapper settings
|
//wrapper settings
|
||||||
|
#ifdef _WIN32
|
||||||
wrpResolution(0),
|
wrpResolution(0),
|
||||||
|
#endif
|
||||||
wrpVRAM(0),
|
wrpVRAM(0),
|
||||||
wrpFBO(0),
|
wrpFBO(0),
|
||||||
wrpAnisotropic(0)
|
wrpAnisotropic(0)
|
||||||
|
|
|
@ -9,7 +9,9 @@ public:
|
||||||
|
|
||||||
uint32_t res_x, scr_res_x;
|
uint32_t res_x, scr_res_x;
|
||||||
uint32_t res_y, scr_res_y;
|
uint32_t res_y, scr_res_y;
|
||||||
|
#ifdef _WIN32
|
||||||
uint32_t res_data, res_data_org;
|
uint32_t res_data, res_data_org;
|
||||||
|
#endif
|
||||||
|
|
||||||
int advanced_options;
|
int advanced_options;
|
||||||
int texenh_options;
|
int texenh_options;
|
||||||
|
@ -19,6 +21,9 @@ public:
|
||||||
int show_fps;
|
int show_fps;
|
||||||
int clock;
|
int clock;
|
||||||
int clock_24_hr;
|
int clock_24_hr;
|
||||||
|
#ifdef ANDROID
|
||||||
|
int rotate;
|
||||||
|
#endif
|
||||||
|
|
||||||
int filtering;
|
int filtering;
|
||||||
int fog;
|
int fog;
|
||||||
|
@ -152,7 +157,9 @@ public:
|
||||||
uint32_t hacks;
|
uint32_t hacks;
|
||||||
|
|
||||||
//wrapper settings
|
//wrapper settings
|
||||||
|
#ifdef _WIN32
|
||||||
int wrpResolution;
|
int wrpResolution;
|
||||||
|
#endif
|
||||||
int wrpVRAM;
|
int wrpVRAM;
|
||||||
int wrpFBO;
|
int wrpFBO;
|
||||||
int wrpAnisotropic;
|
int wrpAnisotropic;
|
||||||
|
|
|
@ -44,15 +44,13 @@ void SetupTrace(void)
|
||||||
g_AndroidLogger = new AndroidLogger();
|
g_AndroidLogger = new AndroidLogger();
|
||||||
}
|
}
|
||||||
TraceAddModule(g_AndroidLogger);
|
TraceAddModule(g_AndroidLogger);
|
||||||
|
#endif
|
||||||
TraceSetMaxModule(MaxTraceModuleGlide64, TraceVerbose);
|
|
||||||
#else
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
TraceSetMaxModule(MaxTraceModuleGlide64, TraceInfo);
|
TraceSetMaxModule(MaxTraceModuleGlide64, TraceInfo);
|
||||||
#else
|
#else
|
||||||
TraceSetMaxModule(MaxTraceModuleGlide64, TraceError);
|
TraceSetMaxModule(MaxTraceModuleGlide64, TraceError);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
TraceSetModuleName(TraceMD5, "MD5");
|
TraceSetModuleName(TraceMD5, "MD5");
|
||||||
TraceSetModuleName(TraceSettings, "Settings");
|
TraceSetModuleName(TraceSettings, "Settings");
|
||||||
|
@ -64,6 +62,7 @@ void SetupTrace(void)
|
||||||
TraceSetModuleName(TraceRDP, "RDP");
|
TraceSetModuleName(TraceRDP, "RDP");
|
||||||
TraceSetModuleName(TraceTLUT, "TLUT");
|
TraceSetModuleName(TraceTLUT, "TLUT");
|
||||||
TraceSetModuleName(TracePNG, "PNG");
|
TraceSetModuleName(TracePNG, "PNG");
|
||||||
|
TraceSetModuleName(TraceOGLWrapper, "OGL Wrapper");
|
||||||
|
|
||||||
char log_dir[260];
|
char log_dir[260];
|
||||||
memset(log_dir, 0, sizeof(log_dir));
|
memset(log_dir, 0, sizeof(log_dir));
|
||||||
|
|
|
@ -13,6 +13,7 @@ enum TraceModuleGlide64
|
||||||
TraceRDP,
|
TraceRDP,
|
||||||
TraceTLUT,
|
TraceTLUT,
|
||||||
TracePNG,
|
TracePNG,
|
||||||
|
TraceOGLWrapper,
|
||||||
MaxTraceModuleGlide64,
|
MaxTraceModuleGlide64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,18 @@
|
||||||
<ClCompile Include="OGLEStextures.cpp">
|
<ClCompile Include="OGLEStextures.cpp">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="OGLESwrappers.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="OGLgeometry.cpp" />
|
<ClCompile Include="OGLgeometry.cpp" />
|
||||||
<ClCompile Include="OGLglitchmain.cpp" />
|
<ClCompile Include="OGLglitchmain.cpp" />
|
||||||
<ClCompile Include="OGLtextures.cpp" />
|
<ClCompile Include="OGLtextures.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="glitchmain.h" />
|
<ClInclude Include="glitchmain.h" />
|
||||||
|
<ClInclude Include="OGLESwrappers.h">
|
||||||
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="opengl.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -35,10 +35,19 @@
|
||||||
<ClCompile Include="OGLEStextures.cpp">
|
<ClCompile Include="OGLEStextures.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="OGLESwrappers.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="glitchmain.h">
|
<ClInclude Include="glitchmain.h">
|
||||||
<Filter>Headers</Filter>
|
<Filter>Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="OGLESwrappers.h">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="opengl.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -26,8 +26,11 @@
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "glide.h"
|
#include "glide.h"
|
||||||
#include "glitchmain.h"
|
#include "glitchmain.h"
|
||||||
|
#include <Glide64/trace.h>
|
||||||
|
#include <Glide64/Settings.h>
|
||||||
|
|
||||||
void vbo_draw();
|
void vbo_draw();
|
||||||
|
|
||||||
|
@ -68,6 +71,7 @@ static GLuint vertex_shader_object;
|
||||||
static GLuint program_object_default;
|
static GLuint program_object_default;
|
||||||
static GLuint program_object_depth;
|
static GLuint program_object_depth;
|
||||||
static GLuint program_object;
|
static GLuint program_object;
|
||||||
|
static GLuint rotation_matrix_location;
|
||||||
static int constant_color_location;
|
static int constant_color_location;
|
||||||
static int ccolor0_location;
|
static int ccolor0_location;
|
||||||
static int ccolor1_location;
|
static int ccolor1_location;
|
||||||
|
@ -176,6 +180,7 @@ SHADER_HEADER
|
||||||
"uniform vec3 vertexOffset; \n" //Moved some calculations from grDrawXXX to shader
|
"uniform vec3 vertexOffset; \n" //Moved some calculations from grDrawXXX to shader
|
||||||
"uniform vec4 textureSizes; \n"
|
"uniform vec4 textureSizes; \n"
|
||||||
"uniform vec3 fogModeEndScale; \n" //0 = Mode, 1 = gl_Fog.end, 2 = gl_Fog.scale
|
"uniform vec3 fogModeEndScale; \n" //0 = Mode, 1 = gl_Fog.end, 2 = gl_Fog.scale
|
||||||
|
"uniform mat4 rotation_matrix; \n"
|
||||||
SHADER_VARYING
|
SHADER_VARYING
|
||||||
" \n"
|
" \n"
|
||||||
"void main() \n"
|
"void main() \n"
|
||||||
|
@ -187,6 +192,7 @@ SHADER_VARYING
|
||||||
" gl_Position.z = aVertex.z / Z_MAX; \n"
|
" gl_Position.z = aVertex.z / Z_MAX; \n"
|
||||||
" gl_Position.w = 1.0; \n"
|
" gl_Position.w = 1.0; \n"
|
||||||
" gl_Position /= q; \n"
|
" gl_Position /= q; \n"
|
||||||
|
" gl_Position = rotation_matrix * gl_Position; \n"
|
||||||
" gl_FrontColor = aColor.bgra; \n"
|
" gl_FrontColor = aColor.bgra; \n"
|
||||||
" \n"
|
" \n"
|
||||||
" gl_TexCoord[0] = vec4(aMultiTexCoord0.xy / q / textureSizes.xy,0,1); \n"
|
" gl_TexCoord[0] = vec4(aMultiTexCoord0.xy / q / textureSizes.xy,0,1); \n"
|
||||||
|
@ -220,7 +226,7 @@ void check_compile(GLuint shader)
|
||||||
{
|
{
|
||||||
char log[1024];
|
char log[1024];
|
||||||
glGetShaderInfoLog(shader, 1024, NULL, log);
|
glGetShaderInfoLog(shader, 1024, NULL, log);
|
||||||
LOGINFO(log);
|
//LOGINFO(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,16 +238,79 @@ void check_link(GLuint program)
|
||||||
{
|
{
|
||||||
char log[1024];
|
char log[1024];
|
||||||
glGetProgramInfoLog(program, 1024, NULL, log);
|
glGetProgramInfoLog(program, 1024, NULL, log);
|
||||||
LOGINFO(log);
|
//LOGINFO(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_rotation_matrix(GLuint loc, int rotate)
|
||||||
|
{
|
||||||
|
GLfloat mat[16];
|
||||||
|
|
||||||
|
/* first setup everything which is the same everytime */
|
||||||
|
/* (X, X, 0, 0)
|
||||||
|
* (X, X, 0, 0)
|
||||||
|
* (0, 0, 1, 0)
|
||||||
|
* (0, 0, 0, 1)
|
||||||
|
*/
|
||||||
|
|
||||||
|
//mat[0] = cos(angle);
|
||||||
|
//mat[1] = sin(angle);
|
||||||
|
mat[2] = 0;
|
||||||
|
mat[3] = 0;
|
||||||
|
|
||||||
|
//mat[4] = -sin(angle);
|
||||||
|
//mat[5] = cos(angle);
|
||||||
|
mat[6] = 0;
|
||||||
|
mat[7] = 0;
|
||||||
|
|
||||||
|
mat[8] = 0;
|
||||||
|
mat[9] = 0;
|
||||||
|
mat[10] = 1;
|
||||||
|
mat[11] = 0;
|
||||||
|
|
||||||
|
mat[12] = 0;
|
||||||
|
mat[13] = 0;
|
||||||
|
mat[14] = 0;
|
||||||
|
mat[15] = 1;
|
||||||
|
|
||||||
|
/* now set the actual rotation */
|
||||||
|
if (1 == rotate) // 90 degree
|
||||||
|
{
|
||||||
|
mat[0] = 0;
|
||||||
|
mat[1] = 1;
|
||||||
|
mat[4] = -1;
|
||||||
|
mat[5] = 0;
|
||||||
|
}
|
||||||
|
else if (2 == rotate) // 180 degree
|
||||||
|
{
|
||||||
|
mat[0] = -1;
|
||||||
|
mat[1] = 0;
|
||||||
|
mat[4] = 0;
|
||||||
|
mat[5] = -1;
|
||||||
|
}
|
||||||
|
else if (3 == rotate) // 270 degree
|
||||||
|
{
|
||||||
|
mat[0] = 0;
|
||||||
|
mat[1] = -1;
|
||||||
|
mat[4] = 1;
|
||||||
|
mat[5] = 0;
|
||||||
|
}
|
||||||
|
else /* 0 degree, also fallback if input is wrong) */
|
||||||
|
{
|
||||||
|
mat[0] = 1;
|
||||||
|
mat[1] = 0;
|
||||||
|
mat[4] = 0;
|
||||||
|
mat[5] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
glUniformMatrix4fv(loc, 1, GL_FALSE, mat);
|
||||||
|
}
|
||||||
|
|
||||||
void init_combiner()
|
void init_combiner()
|
||||||
{
|
{
|
||||||
int texture[4] = { 0, 0, 0, 0 };
|
int texture[4] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
// creating a fake texture
|
// creating a fake texture
|
||||||
glBindTexture(GL_TEXTURE_2D, default_texture);
|
glBindTexture(GL_TEXTURE_2D, default_texture);
|
||||||
|
@ -251,8 +320,8 @@ void init_combiner()
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, default_texture);
|
glBindTexture(GL_TEXTURE_2D, default_texture);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
|
int rotation_matrix_location;
|
||||||
int texture0_location;
|
int texture0_location;
|
||||||
int texture1_location;
|
int texture1_location;
|
||||||
char *fragment_shader;
|
char *fragment_shader;
|
||||||
|
@ -299,6 +368,7 @@ void init_combiner()
|
||||||
check_compile(vertex_shader_object);
|
check_compile(vertex_shader_object);
|
||||||
|
|
||||||
// depth program
|
// depth program
|
||||||
|
#ifndef ANDROID
|
||||||
program_object = glCreateProgram();
|
program_object = glCreateProgram();
|
||||||
program_object_depth = program_object;
|
program_object_depth = program_object;
|
||||||
glAttachShader(program_object, fragment_depth_shader_object);
|
glAttachShader(program_object, fragment_depth_shader_object);
|
||||||
|
@ -314,10 +384,14 @@ void init_combiner()
|
||||||
check_link(program_object);
|
check_link(program_object);
|
||||||
glUseProgram(program_object);
|
glUseProgram(program_object);
|
||||||
|
|
||||||
|
rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix");
|
||||||
|
set_rotation_matrix(rotation_matrix_location, g_settings->rotate);
|
||||||
|
|
||||||
texture0_location = glGetUniformLocation(program_object, "texture0");
|
texture0_location = glGetUniformLocation(program_object, "texture0");
|
||||||
texture1_location = glGetUniformLocation(program_object, "texture1");
|
texture1_location = glGetUniformLocation(program_object, "texture1");
|
||||||
glUniform1i(texture0_location, 0);
|
glUniform1i(texture0_location, 0);
|
||||||
glUniform1i(texture1_location, 1);
|
glUniform1i(texture1_location, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
// default program
|
// default program
|
||||||
program_object = glCreateProgram();
|
program_object = glCreateProgram();
|
||||||
|
@ -334,6 +408,8 @@ void init_combiner()
|
||||||
glLinkProgram(program_object);
|
glLinkProgram(program_object);
|
||||||
check_link(program_object);
|
check_link(program_object);
|
||||||
glUseProgram(program_object);
|
glUseProgram(program_object);
|
||||||
|
rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix");
|
||||||
|
set_rotation_matrix(rotation_matrix_location, g_settings->rotate);
|
||||||
|
|
||||||
texture0_location = glGetUniformLocation(program_object, "texture0");
|
texture0_location = glGetUniformLocation(program_object, "texture0");
|
||||||
texture1_location = glGetUniformLocation(program_object, "texture1");
|
texture1_location = glGetUniformLocation(program_object, "texture1");
|
||||||
|
@ -410,6 +486,7 @@ typedef struct _shader_program_key
|
||||||
int blackandwhite1;
|
int blackandwhite1;
|
||||||
GLuint fragment_shader_object;
|
GLuint fragment_shader_object;
|
||||||
GLuint program_object;
|
GLuint program_object;
|
||||||
|
int rotation_matrix_location;
|
||||||
int texture0_location;
|
int texture0_location;
|
||||||
int texture1_location;
|
int texture1_location;
|
||||||
int vertexOffset_location;
|
int vertexOffset_location;
|
||||||
|
@ -469,6 +546,11 @@ void update_uniforms(shader_program_key prog)
|
||||||
glUniform1i(prog.ditherTex_location, 2);
|
glUniform1i(prog.ditherTex_location, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix");
|
||||||
|
set_rotation_matrix(rotation_matrix_location, g_settings->rotate);
|
||||||
|
rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix");
|
||||||
|
set_rotation_matrix(rotation_matrix_location, g_settings->rotate);
|
||||||
|
|
||||||
set_lambda();
|
set_lambda();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,6 +562,7 @@ void disable_textureSizes()
|
||||||
|
|
||||||
void compile_shader()
|
void compile_shader()
|
||||||
{
|
{
|
||||||
|
int rotation_matrix_location;
|
||||||
int texture0_location;
|
int texture0_location;
|
||||||
int texture1_location;
|
int texture1_location;
|
||||||
int ditherTex_location;
|
int ditherTex_location;
|
||||||
|
@ -582,6 +665,7 @@ void compile_shader()
|
||||||
check_link(program_object);
|
check_link(program_object);
|
||||||
glUseProgram(program_object);
|
glUseProgram(program_object);
|
||||||
|
|
||||||
|
shader_programs[number_of_programs].rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix");
|
||||||
shader_programs[number_of_programs].texture0_location = glGetUniformLocation(program_object, "texture0");
|
shader_programs[number_of_programs].texture0_location = glGetUniformLocation(program_object, "texture0");
|
||||||
shader_programs[number_of_programs].texture1_location = glGetUniformLocation(program_object, "texture1");
|
shader_programs[number_of_programs].texture1_location = glGetUniformLocation(program_object, "texture1");
|
||||||
shader_programs[number_of_programs].vertexOffset_location = glGetUniformLocation(program_object, "vertexOffset");
|
shader_programs[number_of_programs].vertexOffset_location = glGetUniformLocation(program_object, "vertexOffset");
|
||||||
|
@ -589,6 +673,7 @@ void compile_shader()
|
||||||
shader_programs[number_of_programs].fogModeEndScale_location = glGetUniformLocation(program_object, "fogModeEndScale");
|
shader_programs[number_of_programs].fogModeEndScale_location = glGetUniformLocation(program_object, "fogModeEndScale");
|
||||||
shader_programs[number_of_programs].fogColor_location = glGetUniformLocation(program_object, "fogColor");
|
shader_programs[number_of_programs].fogColor_location = glGetUniformLocation(program_object, "fogColor");
|
||||||
shader_programs[number_of_programs].alphaRef_location = glGetUniformLocation(program_object, "alphaRef");
|
shader_programs[number_of_programs].alphaRef_location = glGetUniformLocation(program_object, "alphaRef");
|
||||||
|
shader_programs[number_of_programs].chroma_color_location = glGetUniformLocation(program_object, "chroma_color");
|
||||||
|
|
||||||
update_uniforms(shader_programs[number_of_programs]);
|
update_uniforms(shader_programs[number_of_programs]);
|
||||||
|
|
||||||
|
@ -639,7 +724,7 @@ void set_lambda()
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grConstantColorValue(GrColor_t value)
|
grConstantColorValue(GrColor_t value)
|
||||||
{
|
{
|
||||||
LOG("grConstantColorValue(%d)\r\n", value);
|
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
|
||||||
switch (lfb_color_fmt)
|
switch (lfb_color_fmt)
|
||||||
{
|
{
|
||||||
case GR_COLORFORMAT_ARGB:
|
case GR_COLORFORMAT_ARGB:
|
||||||
|
@ -752,7 +837,7 @@ GrCombineFunction_t function, GrCombineFactor_t factor,
|
||||||
GrCombineLocal_t local, GrCombineOther_t other,
|
GrCombineLocal_t local, GrCombineOther_t other,
|
||||||
FxBool invert)
|
FxBool invert)
|
||||||
{
|
{
|
||||||
LOG("grColorCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
|
WriteTrace(TraceResolution, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert);
|
||||||
static int last_function = 0;
|
static int last_function = 0;
|
||||||
static int last_factor = 0;
|
static int last_factor = 0;
|
||||||
static int last_local = 0;
|
static int last_local = 0;
|
||||||
|
@ -962,7 +1047,7 @@ GrCombineLocal_t local, GrCombineOther_t other,
|
||||||
FxBool invert
|
FxBool invert
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LOG("grAlphaCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
|
WriteTrace(TraceResolution, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert);
|
||||||
static int last_function = 0;
|
static int last_function = 0;
|
||||||
static int last_factor = 0;
|
static int last_factor = 0;
|
||||||
static int last_local = 0;
|
static int last_local = 0;
|
||||||
|
@ -1200,7 +1285,7 @@ FxBool rgb_invert,
|
||||||
FxBool alpha_invert
|
FxBool alpha_invert
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LOG("grTexCombine(%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
|
WriteTrace(TraceResolution, TraceDebug, "tmu: %d rgb_function: %d rgb_factor: %d alpha_function: %d alpha_factor: %d rgb_invert: %d alpha_invert: %d", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
|
||||||
int num_tex;
|
int num_tex;
|
||||||
|
|
||||||
if (tmu == GR_TMU0) num_tex = 1;
|
if (tmu == GR_TMU0) num_tex = 1;
|
||||||
|
@ -1451,7 +1536,7 @@ GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int sfactorRGB = 0, dfactorRGB = 0, sfactorAlpha = 0, dfactorAlpha = 0;
|
int sfactorRGB = 0, dfactorRGB = 0, sfactorAlpha = 0, dfactorAlpha = 0;
|
||||||
LOG("grAlphaBlendFunction(%d,%d,%d,%d)\r\n", rgb_sf, rgb_df, alpha_sf, alpha_df);
|
WriteTrace(TraceResolution, TraceDebug, "rgb_sf: %d rgb_df: %d alpha_sf: %d alpha_df: %d", rgb_sf, rgb_df, alpha_sf, alpha_df);
|
||||||
|
|
||||||
switch (rgb_sf)
|
switch (rgb_sf)
|
||||||
{
|
{
|
||||||
|
@ -1525,7 +1610,7 @@ GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAlphaTestReferenceValue(GrAlpha_t value)
|
grAlphaTestReferenceValue(GrAlpha_t value)
|
||||||
{
|
{
|
||||||
LOG("grAlphaTestReferenceValue(%d)\r\n", value);
|
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
|
||||||
alpha_ref = value;
|
alpha_ref = value;
|
||||||
grAlphaTestFunction(alpha_func);
|
grAlphaTestFunction(alpha_func);
|
||||||
}
|
}
|
||||||
|
@ -1533,7 +1618,7 @@ grAlphaTestReferenceValue(GrAlpha_t value)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAlphaTestFunction(GrCmpFnc_t function)
|
grAlphaTestFunction(GrCmpFnc_t function)
|
||||||
{
|
{
|
||||||
LOG("grAlphaTestFunction(%d)\r\n", function);
|
WriteTrace(TraceResolution, TraceDebug, "function: %d", function);
|
||||||
alpha_func = function;
|
alpha_func = function;
|
||||||
switch (function)
|
switch (function)
|
||||||
{
|
{
|
||||||
|
@ -1561,7 +1646,7 @@ grAlphaTestFunction(GrCmpFnc_t function)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grFogMode(GrFogMode_t mode)
|
grFogMode(GrFogMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grFogMode(%d)\r\n", mode);
|
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GR_FOG_DISABLE:
|
case GR_FOG_DISABLE:
|
||||||
|
@ -1587,7 +1672,7 @@ grFogMode(GrFogMode_t mode)
|
||||||
FX_ENTRY float FX_CALL
|
FX_ENTRY float FX_CALL
|
||||||
guFogTableIndexToW(int i)
|
guFogTableIndexToW(int i)
|
||||||
{
|
{
|
||||||
LOG("guFogTableIndexToW(%d)\r\n", i);
|
WriteTrace(TraceResolution, TraceDebug, "i: %d", i);
|
||||||
return (float)(pow(2.0, 3.0 + (double)(i >> 2)) / (8 - (i & 3)));
|
return (float)(pow(2.0, 3.0 + (double)(i >> 2)) / (8 - (i & 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1595,7 +1680,7 @@ FX_ENTRY void FX_CALL
|
||||||
guFogGenerateLinear(GrFog_t *fogtable,
|
guFogGenerateLinear(GrFog_t *fogtable,
|
||||||
float nearZ, float farZ)
|
float nearZ, float farZ)
|
||||||
{
|
{
|
||||||
LOG("guFogGenerateLinear(%f,%f)\r\n", nearZ, farZ);
|
WriteTrace(TraceResolution, TraceDebug, "nearZ: %f farZ: %f", nearZ, farZ);
|
||||||
/*
|
/*
|
||||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||||
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
|
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
|
||||||
|
@ -1607,15 +1692,15 @@ float nearZ, float farZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grFogTable(const GrFog_t ft[])
|
grFogTable(const GrFog_t /*ft */[])
|
||||||
{
|
{
|
||||||
LOG("grFogTable()\r\n");
|
WriteTrace(TraceResolution, TraceDebug, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grFogColorValue(GrColor_t fogcolor)
|
grFogColorValue(GrColor_t fogcolor)
|
||||||
{
|
{
|
||||||
LOG("grFogColorValue(%x)\r\n", fogcolor);
|
WriteTrace(TraceResolution, TraceDebug, "fogcolor: %x", fogcolor);
|
||||||
|
|
||||||
switch (lfb_color_fmt)
|
switch (lfb_color_fmt)
|
||||||
{
|
{
|
||||||
|
@ -1643,7 +1728,7 @@ grFogColorValue(GrColor_t fogcolor)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grChromakeyMode(GrChromakeyMode_t mode)
|
grChromakeyMode(GrChromakeyMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grChromakeyMode(%d)\r\n", mode);
|
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GR_CHROMAKEY_DISABLE:
|
case GR_CHROMAKEY_DISABLE:
|
||||||
|
@ -1661,7 +1746,7 @@ grChromakeyMode(GrChromakeyMode_t mode)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grChromakeyValue(GrColor_t value)
|
grChromakeyValue(GrColor_t value)
|
||||||
{
|
{
|
||||||
LOG("grChromakeyValue(%x)\r\n", value);
|
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
|
||||||
int chroma_color_location;
|
int chroma_color_location;
|
||||||
|
|
||||||
switch (lfb_color_fmt)
|
switch (lfb_color_fmt)
|
||||||
|
@ -1716,19 +1801,17 @@ static void setPattern()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 33 * 1024 * 1024);
|
glBindTexture(GL_TEXTURE_2D, 33 * 1024 * 1024);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
|
glTexImage2D(GL_TEXTURE_2D, 0, 4, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grStipplePattern(
|
grStipplePattern(
|
||||||
GrStipplePattern_t stipple)
|
GrStipplePattern_t stipple)
|
||||||
{
|
{
|
||||||
LOG("grStipplePattern(%x)\r\n", stipple);
|
WriteTrace(TraceResolution, TraceDebug, "value: %x", stipple);
|
||||||
srand(stipple);
|
srand(stipple);
|
||||||
setPattern();
|
setPattern();
|
||||||
}
|
}
|
||||||
|
@ -1736,25 +1819,22 @@ GrStipplePattern_t stipple)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grStippleMode(GrStippleMode_t mode)
|
grStippleMode(GrStippleMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grStippleMode(%d)\r\n", mode);
|
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GR_STIPPLE_DISABLE:
|
case GR_STIPPLE_DISABLE:
|
||||||
dither_enabled = 0;
|
dither_enabled = 0;
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
break;
|
break;
|
||||||
case GR_STIPPLE_PATTERN:
|
case GR_STIPPLE_PATTERN:
|
||||||
setPattern();
|
setPattern();
|
||||||
dither_enabled = 1;
|
dither_enabled = 1;
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
break;
|
break;
|
||||||
case GR_STIPPLE_ROTATE:
|
case GR_STIPPLE_ROTATE:
|
||||||
setPattern();
|
setPattern();
|
||||||
dither_enabled = 1;
|
dither_enabled = 1;
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grStippleMode:%x", mode);
|
WriteTrace(TraceGlitch, TraceWarning, "grStippleMode:%x", mode);
|
||||||
|
@ -1769,7 +1849,7 @@ GrCCUColor_t c, FxBool c_invert,
|
||||||
GrCCUColor_t d, FxBool d_invert,
|
GrCCUColor_t d, FxBool d_invert,
|
||||||
FxU32 shift, FxBool invert)
|
FxU32 shift, FxBool invert)
|
||||||
{
|
{
|
||||||
LOG("grColorCombineExt(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
WriteTrace(TraceResolution, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
||||||
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grColorCombineExt : inverted result");
|
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grColorCombineExt : inverted result");
|
||||||
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grColorCombineExt : shift = %d", shift);
|
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grColorCombineExt : shift = %d", shift);
|
||||||
|
|
||||||
|
@ -1951,7 +2031,7 @@ GrACUColor_t c, FxBool c_invert,
|
||||||
GrACUColor_t d, FxBool d_invert,
|
GrACUColor_t d, FxBool d_invert,
|
||||||
FxU32 shift, FxBool invert)
|
FxU32 shift, FxBool invert)
|
||||||
{
|
{
|
||||||
LOG("grAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
WriteTrace(TraceResolution, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
||||||
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grAlphaCombineExt : inverted result");
|
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grAlphaCombineExt : inverted result");
|
||||||
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grAlphaCombineExt : shift = %d", shift);
|
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grAlphaCombineExt : shift = %d", shift);
|
||||||
|
|
||||||
|
@ -2105,7 +2185,7 @@ GrTCCUColor_t d, FxBool d_invert,
|
||||||
FxU32 shift, FxBool invert)
|
FxU32 shift, FxBool invert)
|
||||||
{
|
{
|
||||||
int num_tex;
|
int num_tex;
|
||||||
LOG("grTexColorCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
WriteTrace(TraceResolution, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
||||||
|
|
||||||
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grTexColorCombineExt : inverted result");
|
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grTexColorCombineExt : inverted result");
|
||||||
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grTexColorCombineExt : shift = %d", shift);
|
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grTexColorCombineExt : shift = %d", shift);
|
||||||
|
@ -2470,7 +2550,7 @@ GrTACUColor_t d, FxBool d_invert,
|
||||||
FxU32 shift, FxBool invert)
|
FxU32 shift, FxBool invert)
|
||||||
{
|
{
|
||||||
int num_tex;
|
int num_tex;
|
||||||
LOG("grTexAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
WriteTrace(TraceResolution, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
|
||||||
|
|
||||||
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grTexAlphaCombineExt : inverted result");
|
if (invert) WriteTrace(TraceGlitch, TraceWarning, "grTexAlphaCombineExt : inverted result");
|
||||||
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grTexAlphaCombineExt : shift = %d", shift);
|
if (shift) WriteTrace(TraceGlitch, TraceWarning, "grTexAlphaCombineExt : shift = %d", shift);
|
||||||
|
@ -2750,7 +2830,7 @@ grConstantColorValueExt(GrChipID_t tmu,
|
||||||
GrColor_t value)
|
GrColor_t value)
|
||||||
{
|
{
|
||||||
int num_tex;
|
int num_tex;
|
||||||
LOG("grConstantColorValueExt(%d,%d)\r\n", tmu, value);
|
WriteTrace(TraceResolution, TraceDebug, "tmu: %d value: %d", tmu, value);
|
||||||
|
|
||||||
if (tmu == GR_TMU0) num_tex = 1;
|
if (tmu == GR_TMU0) num_tex = 1;
|
||||||
else num_tex = 0;
|
else num_tex = 0;
|
||||||
|
|
|
@ -27,16 +27,11 @@
|
||||||
#include "glitchmain.h"
|
#include "glitchmain.h"
|
||||||
#include "../Glide64/winlnxdefs.h"
|
#include "../Glide64/winlnxdefs.h"
|
||||||
#include "../Glide64/rdp.h"
|
#include "../Glide64/rdp.h"
|
||||||
|
#include <Glide64/trace.h>
|
||||||
|
|
||||||
#define Z_MAX (65536.0f)
|
#define Z_MAX (65536.0f)
|
||||||
#define VERTEX_SIZE sizeof(VERTEX) //Size of vertex struct
|
#define VERTEX_SIZE sizeof(VERTEX) //Size of vertex struct
|
||||||
|
|
||||||
#ifdef ANDROID_EDITION
|
|
||||||
#include "ae_imports.h"
|
|
||||||
static float polygonOffsetFactor;
|
|
||||||
static float polygonOffsetUnits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int xy_off;
|
static int xy_off;
|
||||||
static int xy_en;
|
static int xy_en;
|
||||||
static int z_en;
|
static int z_en;
|
||||||
|
@ -64,15 +59,16 @@ static bool vertex_buffer_enabled = false;
|
||||||
|
|
||||||
void vbo_init()
|
void vbo_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vbo_draw()
|
void vbo_draw()
|
||||||
{
|
{
|
||||||
if (vertex_buffer_count)
|
if (vertex_buffer_count)
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlide64, TraceDebug, "vertex_draw_mode: %d vertex_buffer_count: %d", vertex_draw_mode, vertex_buffer_count);
|
||||||
glDrawArrays(vertex_draw_mode, 0, vertex_buffer_count);
|
glDrawArrays(vertex_draw_mode, 0, vertex_buffer_count);
|
||||||
vertex_buffer_count = 0;
|
vertex_buffer_count = 0;
|
||||||
|
WriteTrace(TraceGlide64, TraceDebug, "done (glGetError() = %X)", glGetError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +92,6 @@ void vbo_buffer(GLenum mode,GLint first,GLsizei count,void* pointers)
|
||||||
vertex_draw_mode = mode;
|
vertex_draw_mode = mode;
|
||||||
vbo_draw(); //Triangle fans and strips can't be joined as easily, just draw them straight away.
|
vbo_draw(); //Triangle fans and strips can't be joined as easily, just draw them straight away.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vbo_enable()
|
void vbo_enable()
|
||||||
|
@ -128,7 +122,6 @@ void vbo_disable()
|
||||||
vertex_buffer_enabled = false;
|
vertex_buffer_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float ZCALC(const float & z, const float & q) {
|
inline float ZCALC(const float & z, const float & q) {
|
||||||
float res = z_en ? ((z) / Z_MAX) / (q) : 1.0f;
|
float res = z_en ? ((z) / Z_MAX) / (q) : 1.0f;
|
||||||
return res;
|
return res;
|
||||||
|
@ -144,7 +137,6 @@ static inline void zclamp_glVertex4f(float a, float b, float c, float d)
|
||||||
#define glVertex4f(a,b,c,d) zclamp_glVertex4f(a,b,c,d)
|
#define glVertex4f(a,b,c,d) zclamp_glVertex4f(a,b,c,d)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static inline float ytex(int tmu, float y) {
|
static inline float ytex(int tmu, float y) {
|
||||||
if (invtex[tmu])
|
if (invtex[tmu])
|
||||||
return invtex[tmu] - y;
|
return invtex[tmu] - y;
|
||||||
|
@ -167,7 +159,7 @@ void init_geometry()
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grCoordinateSpace(GrCoordinateSpaceMode_t mode)
|
grCoordinateSpace(GrCoordinateSpaceMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grCoordinateSpace(%d)\r\n", mode);
|
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GR_WINDOW_COORDS:
|
case GR_WINDOW_COORDS:
|
||||||
|
@ -180,7 +172,7 @@ grCoordinateSpace( GrCoordinateSpaceMode_t mode )
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
|
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
|
||||||
{
|
{
|
||||||
LOG("grVertexLayout(%d,%d,%d)\r\n", param, offset, mode);
|
WriteTrace(TraceGlitch, TraceDebug, "param: %d offset: %d mode: %d", param, offset, mode);
|
||||||
switch (param)
|
switch (param)
|
||||||
{
|
{
|
||||||
case GR_PARAM_XY:
|
case GR_PARAM_XY:
|
||||||
|
@ -219,7 +211,7 @@ grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grCullMode(GrCullMode_t mode)
|
grCullMode(GrCullMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grCullMode(%d)\r\n", mode);
|
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
|
||||||
static int oldmode = -1, oldinv = -1;
|
static int oldmode = -1, oldinv = -1;
|
||||||
culling_mode = mode;
|
culling_mode = mode;
|
||||||
if (inverted_culling == oldinv && oldmode == mode)
|
if (inverted_culling == oldinv && oldmode == mode)
|
||||||
|
@ -255,7 +247,7 @@ grCullMode( GrCullMode_t mode )
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDepthBufferMode(GrDepthBufferMode_t mode)
|
grDepthBufferMode(GrDepthBufferMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grDepthBufferMode(%d)\r\n", mode);
|
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GR_DEPTHBUFFER_DISABLE:
|
case GR_DEPTHBUFFER_DISABLE:
|
||||||
|
@ -280,7 +272,7 @@ grDepthBufferMode( GrDepthBufferMode_t mode )
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDepthBufferFunction(GrCmpFnc_t function)
|
grDepthBufferFunction(GrCmpFnc_t function)
|
||||||
{
|
{
|
||||||
LOG("grDepthBufferFunction(%d)\r\n", function);
|
WriteTrace(TraceGlitch, TraceDebug, "function: %d", function);
|
||||||
switch (function)
|
switch (function)
|
||||||
{
|
{
|
||||||
case GR_CMP_GEQUAL:
|
case GR_CMP_GEQUAL:
|
||||||
|
@ -328,17 +320,13 @@ grDepthBufferFunction( GrCmpFnc_t function )
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDepthMask(FxBool mask)
|
grDepthMask(FxBool mask)
|
||||||
{
|
{
|
||||||
LOG("grDepthMask(%d)\r\n", mask);
|
WriteTrace(TraceGlitch, TraceDebug, "mask: %d", mask);
|
||||||
glDepthMask(mask);
|
glDepthMask(mask);
|
||||||
}
|
}
|
||||||
float biasFactor = 0;
|
float biasFactor = 0;
|
||||||
#if 0
|
#if 0
|
||||||
void FindBestDepthBias()
|
void FindBestDepthBias()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_EDITION
|
|
||||||
int hardwareType = Android_JNI_GetHardwareType();
|
|
||||||
Android_JNI_GetPolygonOffset(hardwareType, 1, &polygonOffsetFactor, &polygonOffsetUnits);
|
|
||||||
#else
|
|
||||||
float f, bestz = 0.25f;
|
float f, bestz = 0.25f;
|
||||||
int x;
|
int x;
|
||||||
if (biasFactor) return;
|
if (biasFactor) return;
|
||||||
|
@ -374,24 +362,23 @@ void FindBestDepthBias()
|
||||||
}
|
}
|
||||||
//printf(" --> bias factor %g\n", biasFactor);
|
//printf(" --> bias factor %g\n", biasFactor);
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDepthBiasLevel(FxI32 level)
|
grDepthBiasLevel(FxI32 level)
|
||||||
{
|
{
|
||||||
LOG("grDepthBiasLevel(%d)\r\n", level);
|
WriteTrace(TraceGlitch, TraceDebug, "level: %d", level);
|
||||||
if (level)
|
if (level)
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_EDITION
|
|
||||||
glPolygonOffset(polygonOffsetFactor, polygonOffsetUnits);
|
|
||||||
#else
|
|
||||||
if (w_buffer_mode)
|
if (w_buffer_mode)
|
||||||
|
{
|
||||||
glPolygonOffset(1.0f, -(float)level*zscale / 255.0f);
|
glPolygonOffset(1.0f, -(float)level*zscale / 255.0f);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glPolygonOffset(0, (float)level*biasFactor);
|
glPolygonOffset(0, (float)level*biasFactor);
|
||||||
#endif
|
}
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -406,7 +393,7 @@ grDepthBiasLevel( FxI32 level )
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDrawTriangle(const void *a, const void *b, const void *c)
|
grDrawTriangle(const void *a, const void *b, const void *c)
|
||||||
{
|
{
|
||||||
LOG("grDrawTriangle()\r\n\t");
|
WriteTrace(TraceGlitch, TraceDebug, "start");
|
||||||
|
|
||||||
if (nvidia_viewport_hack && !render_to_texture)
|
if (nvidia_viewport_hack && !render_to_texture)
|
||||||
{
|
{
|
||||||
|
@ -427,6 +414,8 @@ grDrawTriangle( const void *a, const void *b, const void *c )
|
||||||
memcpy(&vertex_buffer[vertex_buffer_count + 1], b, VERTEX_SIZE);
|
memcpy(&vertex_buffer[vertex_buffer_count + 1], b, VERTEX_SIZE);
|
||||||
memcpy(&vertex_buffer[vertex_buffer_count + 2], c, VERTEX_SIZE);
|
memcpy(&vertex_buffer[vertex_buffer_count + 2], c, VERTEX_SIZE);
|
||||||
vertex_buffer_count += 3;
|
vertex_buffer_count += 3;
|
||||||
|
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -443,7 +432,7 @@ grDrawPoint( const void *pt )
|
||||||
float *s1 = (float*)pt + st1_off/sizeof(float);
|
float *s1 = (float*)pt + st1_off/sizeof(float);
|
||||||
float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
|
float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
|
||||||
float *fog = (float*)pt + fog_ext_off/sizeof(float);
|
float *fog = (float*)pt + fog_ext_off/sizeof(float);
|
||||||
LOG("grDrawPoint()\r\n");
|
WriteTrace(TraceGlitch, TraceDebug,"grDrawPoint()\r\n");
|
||||||
|
|
||||||
if(nvidia_viewport_hack && !render_to_texture)
|
if(nvidia_viewport_hack && !render_to_texture)
|
||||||
{
|
{
|
||||||
|
@ -513,7 +502,7 @@ grDrawLine( const void *a, const void *b )
|
||||||
float *b_s1 = (float*)b + st1_off/sizeof(float);
|
float *b_s1 = (float*)b + st1_off/sizeof(float);
|
||||||
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
|
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
|
||||||
float *b_fog = (float*)b + fog_ext_off/sizeof(float);
|
float *b_fog = (float*)b + fog_ext_off/sizeof(float);
|
||||||
LOG("grDrawLine()\r\n");
|
WriteTrace(TraceGlitch, TraceDebug,"grDrawLine()\r\n");
|
||||||
|
|
||||||
if(nvidia_viewport_hack && !render_to_texture)
|
if(nvidia_viewport_hack && !render_to_texture)
|
||||||
{
|
{
|
||||||
|
@ -586,7 +575,7 @@ FX_ENTRY void FX_CALL
|
||||||
grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
|
grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
|
||||||
{
|
{
|
||||||
void **pointers = (void**)pointers2;
|
void **pointers = (void**)pointers2;
|
||||||
LOG("grDrawVertexArray(%d,%d)\r\n", mode, Count);
|
WriteTrace(TraceGlitch, TraceDebug, "grDrawVertexArray(%d,%d)\r\n", mode, Count);
|
||||||
|
|
||||||
if (nvidia_viewport_hack && !render_to_texture)
|
if (nvidia_viewport_hack && !render_to_texture)
|
||||||
{
|
{
|
||||||
|
@ -610,7 +599,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride)
|
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride)
|
||||||
{
|
{
|
||||||
LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);
|
WriteTrace(TraceGlitch, TraceDebug, "grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);
|
||||||
|
|
||||||
if (nvidia_viewport_hack && !render_to_texture)
|
if (nvidia_viewport_hack && !render_to_texture)
|
||||||
{
|
{
|
||||||
|
@ -620,7 +609,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
|
||||||
|
|
||||||
if (stride != 156)
|
if (stride != 156)
|
||||||
{
|
{
|
||||||
LOGINFO("Incompatible stride\n");
|
//LOGINFO("Incompatible stride\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadTexture();
|
reloadTexture();
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <SDL.h>
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -37,10 +36,7 @@
|
||||||
#include "glide.h"
|
#include "glide.h"
|
||||||
#include "g3ext.h"
|
#include "g3ext.h"
|
||||||
#include "glitchmain.h"
|
#include "glitchmain.h"
|
||||||
#include "m64p.h"
|
#include <Glide64/trace.h>
|
||||||
|
|
||||||
#include <SDL_opengles.h>
|
|
||||||
//#include <GL/glext.h>
|
|
||||||
|
|
||||||
#define OPENGL_CHECK_ERRORS { const GLenum errcode = glGetError(); if (errcode != GL_NO_ERROR) LOG("OpenGL Error code %i in '%s' line %i\n", errcode, __FILE__, __LINE__-1); }
|
#define OPENGL_CHECK_ERRORS { const GLenum errcode = glGetError(); if (errcode != GL_NO_ERROR) LOG("OpenGL Error code %i in '%s' line %i\n", errcode, __FILE__, __LINE__-1); }
|
||||||
|
|
||||||
|
@ -50,9 +46,11 @@
|
||||||
|
|
||||||
extern void(*renderCallback)(int);
|
extern void(*renderCallback)(int);
|
||||||
|
|
||||||
wrapper_config config = { 0, 0, 0, 0 };
|
wrapper_config config = { 0, 0, 0 };
|
||||||
int screen_width, screen_height;
|
int screen_width, screen_height;
|
||||||
|
|
||||||
|
void Android_JNI_SwapWindow(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static inline void opt_glCopyTexImage2D( GLenum target,
|
static inline void opt_glCopyTexImage2D( GLenum target,
|
||||||
GLint level,
|
GLint level,
|
||||||
|
@ -148,7 +146,7 @@ typedef struct
|
||||||
|
|
||||||
int nbTextureUnits;
|
int nbTextureUnits;
|
||||||
int nbAuxBuffers, current_buffer;
|
int nbAuxBuffers, current_buffer;
|
||||||
int width, widtho, heighto, height;
|
int g_width, widtho, heighto, g_height;
|
||||||
int saved_width, saved_height;
|
int saved_width, saved_height;
|
||||||
int blend_func_separate_support;
|
int blend_func_separate_support;
|
||||||
int npot_support;
|
int npot_support;
|
||||||
|
@ -203,11 +201,28 @@ struct texbuf_t {
|
||||||
static texbuf_t texbufs[NB_TEXBUFS];
|
static texbuf_t texbufs[NB_TEXBUFS];
|
||||||
static int texbuf_i;
|
static int texbuf_i;
|
||||||
|
|
||||||
unsigned short frameBuffer[2048 * 2048];
|
unsigned short frameBuffer[2048 * 2048 * 2]; // Support 2048x2048 screen resolution at 32 bits (RGBA) per pixel
|
||||||
unsigned short depthBuffer[2048 * 2048];
|
unsigned short depthBuffer[2048 * 2048]; // Support 2048x2048 screen resolution at 16 bits (depth) per pixel
|
||||||
|
|
||||||
//#define VOODOO1
|
//#define VOODOO1
|
||||||
|
|
||||||
|
void display_warning(const char *text, ...)
|
||||||
|
{
|
||||||
|
static int first_message = 100;
|
||||||
|
if (first_message)
|
||||||
|
{
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, text);
|
||||||
|
vsprintf(buf, text, ap);
|
||||||
|
va_end(ap);
|
||||||
|
first_message--;
|
||||||
|
//LOGINFO(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void display_error()
|
void display_error()
|
||||||
{
|
{
|
||||||
|
@ -236,66 +251,10 @@ void display_error()
|
||||||
}
|
}
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#ifdef LOGGING
|
|
||||||
char out_buf[256];
|
|
||||||
bool log_open = false;
|
|
||||||
std::ofstream log_file;
|
|
||||||
|
|
||||||
void OPEN_LOG()
|
|
||||||
{
|
|
||||||
if (!log_open)
|
|
||||||
{
|
|
||||||
log_file.open ("wrapper_log.txt", std::ios_base::out|std::ios_base::app);
|
|
||||||
log_open = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLOSE_LOG()
|
|
||||||
{
|
|
||||||
if (log_open)
|
|
||||||
{
|
|
||||||
log_file.close();
|
|
||||||
log_open = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LOG(const char *text, ...)
|
|
||||||
{
|
|
||||||
#ifdef VPDEBUG
|
|
||||||
if (!dumping) return;
|
|
||||||
#endif
|
|
||||||
if (!log_open)
|
|
||||||
return;
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, text);
|
|
||||||
vsprintf(out_buf, text, ap);
|
|
||||||
log_file << out_buf;
|
|
||||||
log_file.flush();
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
class LogManager {
|
|
||||||
public:
|
|
||||||
LogManager() {
|
|
||||||
OPEN_LOG();
|
|
||||||
}
|
|
||||||
~LogManager() {
|
|
||||||
CLOSE_LOG();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LogManager logManager;
|
|
||||||
|
|
||||||
#else // LOGGING
|
|
||||||
#define OPEN_LOG()
|
|
||||||
#define CLOSE_LOG()
|
|
||||||
//#define LOG
|
|
||||||
#endif // LOGGING
|
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grSstOrigin(GrOriginLocation_t origin)
|
grSstOrigin(GrOriginLocation_t origin)
|
||||||
{
|
{
|
||||||
LOG("grSstOrigin(%d)\r\n", origin);
|
WriteTrace(TraceGlitch, TraceDebug, "origin = %d", origin);
|
||||||
if (origin != GR_ORIGIN_UPPER_LEFT)
|
if (origin != GR_ORIGIN_UPPER_LEFT)
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grSstOrigin : %x", origin);
|
WriteTrace(TraceGlitch, TraceWarning, "grSstOrigin : %x", origin);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +262,7 @@ grSstOrigin(GrOriginLocation_t origin)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
|
grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
|
||||||
{
|
{
|
||||||
LOG("grClipWindow(%d,%d,%d,%d)\r\n", minx, miny, maxx, maxy);
|
WriteTrace(TraceGlitch, TraceDebug, "minx = %d, miny: %d maxy: %d", minx, miny, maxy);
|
||||||
|
|
||||||
if (use_fbo && render_to_texture) {
|
if (use_fbo && render_to_texture) {
|
||||||
if (int(minx) < 0) minx = 0;
|
if (int(minx) < 0) minx = 0;
|
||||||
|
@ -316,14 +275,14 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_fbo) {
|
if (!use_fbo) {
|
||||||
int th = height;
|
int th = g_height;
|
||||||
if (th > screen_height)
|
if (th > screen_height)
|
||||||
th = screen_height;
|
th = screen_height;
|
||||||
maxy = th - maxy;
|
maxy = th - maxy;
|
||||||
miny = th - miny;
|
miny = th - miny;
|
||||||
FxU32 tmp = maxy; maxy = miny; miny = tmp;
|
FxU32 tmp = maxy; maxy = miny; miny = tmp;
|
||||||
if (maxx > (FxU32)width) maxx = width;
|
if (maxx > (FxU32)g_width) maxx = g_width;
|
||||||
if (maxy > (FxU32)height) maxy = height;
|
if (maxy > (FxU32)g_height) maxy = g_height;
|
||||||
if (int(minx) < 0) minx = 0;
|
if (int(minx) < 0) minx = 0;
|
||||||
if (int(miny) < 0) miny = 0;
|
if (int(miny) < 0) miny = 0;
|
||||||
if (maxx < minx) maxx = minx;
|
if (maxx < minx) maxx = minx;
|
||||||
|
@ -332,7 +291,7 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
|
||||||
//printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy);
|
//printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glScissor(minx, (viewport_offset)+height - maxy, maxx - minx, maxy - miny);
|
glScissor(minx, (viewport_offset)+g_height - maxy, maxx - minx, maxy - miny);
|
||||||
}
|
}
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
@ -340,20 +299,20 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grColorMask(FxBool rgb, FxBool a)
|
grColorMask(FxBool rgb, FxBool a)
|
||||||
{
|
{
|
||||||
LOG("grColorMask(%d, %d)\r\n", rgb, a);
|
WriteTrace(TraceGlitch, TraceDebug, "rgb = %d, a: %d", rgb, a);
|
||||||
glColorMask(rgb, rgb, rgb, a);
|
glColorMask(rgb, rgb, rgb, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grGlideInit(void)
|
grGlideInit(void)
|
||||||
{
|
{
|
||||||
LOG("grGlideInit()\r\n");
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grSstSelect(int which_sst)
|
grSstSelect(int which_sst)
|
||||||
{
|
{
|
||||||
LOG("grSstSelect(%d)\r\n", which_sst);
|
WriteTrace(TraceGlitch, TraceDebug, "which_sst = %d", which_sst);
|
||||||
}
|
}
|
||||||
|
|
||||||
int isExtensionSupported(const char *extension)
|
int isExtensionSupported(const char *extension)
|
||||||
|
@ -421,38 +380,20 @@ int isWglExtensionSupported(const char *extension)
|
||||||
|
|
||||||
#define GrPixelFormat_t int
|
#define GrPixelFormat_t int
|
||||||
|
|
||||||
FX_ENTRY GrContext_t FX_CALL
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers)
|
||||||
grSstWinOpenExt(
|
|
||||||
HWND hWnd,
|
|
||||||
GrScreenResolution_t screen_resolution,
|
|
||||||
GrScreenRefresh_t refresh_rate,
|
|
||||||
GrColorFormat_t color_format,
|
|
||||||
GrOriginLocation_t origin_location,
|
|
||||||
GrPixelFormat_t pixelformat,
|
|
||||||
int nColBuffers,
|
|
||||||
int nAuxBuffers)
|
|
||||||
{
|
{
|
||||||
LOG("grSstWinOpenExt(%d, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
|
WriteTrace(TraceGlitch, TraceDebug, "refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
|
||||||
return grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format,
|
return grSstWinOpen(refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
|
||||||
origin_location, nColBuffers, nAuxBuffers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# ifndef ATTACH_PARENT_PROCESS
|
# ifndef ATTACH_PARENT_PROCESS
|
||||||
# define ATTACH_PARENT_PROCESS ((FxU32)-1)
|
# define ATTACH_PARENT_PROCESS ((FxU32)-1)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FX_ENTRY GrContext_t FX_CALL
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers)
|
||||||
grSstWinOpen(
|
|
||||||
HWND hWnd,
|
|
||||||
GrScreenResolution_t screen_resolution,
|
|
||||||
GrScreenRefresh_t refresh_rate,
|
|
||||||
GrColorFormat_t color_format,
|
|
||||||
GrOriginLocation_t origin_location,
|
|
||||||
int nColBuffers,
|
|
||||||
int nAuxBuffers)
|
|
||||||
{
|
{
|
||||||
static int show_warning = 1;
|
static int show_warning = 1;
|
||||||
|
|
||||||
|
@ -464,56 +405,16 @@ int nAuxBuffers)
|
||||||
color_texture = free_texture++;
|
color_texture = free_texture++;
|
||||||
depth_texture = free_texture++;
|
depth_texture = free_texture++;
|
||||||
|
|
||||||
LOG("grSstWinOpen(%08lx, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution&~0x80000000, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
|
WriteTrace(TraceGlitch, TraceDebug, "refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "g_width: %d, g_height: %d fullscreen: %d", g_width, g_height, fullscreen);
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
if ((HWND)hWnd == NULL) hWnd = GetActiveWindow();
|
|
||||||
hwnd_win = (HWND)hWnd;
|
|
||||||
#endif // _WIN32
|
|
||||||
width = height = 0;
|
|
||||||
|
|
||||||
m64p_handle video_general_section;
|
|
||||||
printf("&ConfigOpenSection is %p\n", &ConfigOpenSection);
|
|
||||||
if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS)
|
|
||||||
{
|
|
||||||
printf("Could not open video settings");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
width = ConfigGetParamInt(video_general_section, "ScreenWidth");
|
|
||||||
height = ConfigGetParamInt(video_general_section, "ScreenHeight");
|
|
||||||
fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
|
|
||||||
int vsync = ConfigGetParamBool(video_general_section, "VerticalSync");
|
|
||||||
//viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20;
|
//viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20;
|
||||||
// ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero
|
// ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero
|
||||||
viewport_offset = 0; //-10 //-20;
|
viewport_offset = 0; //-10 //-20;
|
||||||
|
|
||||||
CoreVideo_Init();
|
printf("(II) Setting video mode %dx%d...\n", g_width, g_height);
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
|
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, vsync);
|
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
|
|
||||||
|
|
||||||
printf("(II) Setting video mode %dx%d...\n", width, height);
|
glViewport(0, viewport_offset, g_width, g_height);
|
||||||
if (CoreVideo_SetVideoMode(width, height, 0, fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags)0) != M64ERR_SUCCESS)
|
|
||||||
{
|
|
||||||
printf("(EE) Error setting videomode %dx%d\n", width, height);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char caption[500];
|
|
||||||
# ifdef _DEBUG
|
|
||||||
sprintf(caption, "Glide64mk2 debug");
|
|
||||||
# else // _DEBUG
|
|
||||||
sprintf(caption, "Glide64mk2");
|
|
||||||
# endif // _DEBUG
|
|
||||||
CoreVideo_SetCaption(caption);
|
|
||||||
|
|
||||||
glViewport(0, viewport_offset, width, height);
|
|
||||||
lfb_color_fmt = color_format;
|
lfb_color_fmt = color_format;
|
||||||
if (origin_location != GR_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner");
|
if (origin_location != GR_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner");
|
||||||
if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2");
|
if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2");
|
||||||
|
@ -603,7 +504,7 @@ int nAuxBuffers)
|
||||||
use_fbo = config.fbo;
|
use_fbo = config.fbo;
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
LOGINFO("use_fbo %d\n", use_fbo);
|
//LOGINFO("use_fbo %d\n", use_fbo);
|
||||||
|
|
||||||
if (isExtensionSupported("GL_ARB_shading_language_100") &&
|
if (isExtensionSupported("GL_ARB_shading_language_100") &&
|
||||||
isExtensionSupported("GL_ARB_shader_objects") &&
|
isExtensionSupported("GL_ARB_shader_objects") &&
|
||||||
|
@ -646,9 +547,9 @@ int nAuxBuffers)
|
||||||
viewport_height = height;
|
viewport_height = height;
|
||||||
nvidia_viewport_hack = 1;
|
nvidia_viewport_hack = 1;
|
||||||
#else
|
#else
|
||||||
glViewport(0, viewport_offset, width, height);
|
glViewport(0, viewport_offset, g_width, g_height);
|
||||||
viewport_width = width;
|
viewport_width = g_width;
|
||||||
viewport_height = height;
|
viewport_height = g_height;
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
// void do_benchmarks();
|
// void do_benchmarks();
|
||||||
|
@ -660,8 +561,8 @@ int nAuxBuffers)
|
||||||
// glTranslatef(0, 0, 1-zscale);
|
// glTranslatef(0, 0, 1-zscale);
|
||||||
// glScalef(1, 1, zscale);
|
// glScalef(1, 1, zscale);
|
||||||
|
|
||||||
widtho = width / 2;
|
widtho = g_width / 2;
|
||||||
heighto = height / 2;
|
heighto = g_height / 2;
|
||||||
|
|
||||||
pBufferWidth = pBufferHeight = -1;
|
pBufferWidth = pBufferHeight = -1;
|
||||||
|
|
||||||
|
@ -677,12 +578,12 @@ int nAuxBuffers)
|
||||||
|
|
||||||
if (!use_fbo && nbAuxBuffers == 0) {
|
if (!use_fbo && nbAuxBuffers == 0) {
|
||||||
// create the framebuffer saving texture
|
// create the framebuffer saving texture
|
||||||
int w = width, h = height;
|
int w = g_width, h = g_height;
|
||||||
glBindTexture(GL_TEXTURE_2D, color_texture);
|
glBindTexture(GL_TEXTURE_2D, color_texture);
|
||||||
if (!npot_support) {
|
if (!npot_support) {
|
||||||
w = h = 1;
|
w = h = 1;
|
||||||
while (w < width) w *= 2;
|
while (w < g_width) w *= 2;
|
||||||
while (h < height) h *= 2;
|
while (h < g_height) h *= 2;
|
||||||
}
|
}
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
@ -721,14 +622,14 @@ int nAuxBuffers)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grGlideShutdown(void)
|
grGlideShutdown(void)
|
||||||
{
|
{
|
||||||
LOG("grGlideShutdown\r\n");
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY FxBool FX_CALL
|
FX_ENTRY FxBool FX_CALL
|
||||||
grSstWinClose(GrContext_t context)
|
grSstWinClose(GrContext_t context)
|
||||||
{
|
{
|
||||||
int i, clear_texbuff = use_fbo;
|
int i, clear_texbuff = use_fbo;
|
||||||
LOG("grSstWinClose(%d)\r\n", context);
|
WriteTrace(TraceGlitch, TraceDebug, "context: %d", context);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
tmu_usage[i].min = 0xfffffff;
|
tmu_usage[i].min = 0xfffffff;
|
||||||
|
@ -737,7 +638,7 @@ grSstWinClose(GrContext_t context)
|
||||||
}
|
}
|
||||||
|
|
||||||
free_combiners();
|
free_combiners();
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
try // I don't know why, but opengl can be killed before this function call when emulator is closed (Gonetz).
|
try // I don't know why, but opengl can be killed before this function call when emulator is closed (Gonetz).
|
||||||
// ZIGGY : I found the problem : it is a function pointer, when the extension isn't supported , it is then zero, so just need to check the pointer prior to do the call.
|
// ZIGGY : I found the problem : it is a function pointer, when the extension isn't supported , it is then zero, so just need to check the pointer prior to do the call.
|
||||||
{
|
{
|
||||||
|
@ -762,7 +663,7 @@ grSstWinClose(GrContext_t context)
|
||||||
nb_fb = 0;
|
nb_fb = 0;
|
||||||
|
|
||||||
free_textures();
|
free_textures();
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
// ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit
|
// ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit
|
||||||
remove_tex(0, 0xfffffff);
|
remove_tex(0, 0xfffffff);
|
||||||
#endif
|
#endif
|
||||||
|
@ -787,13 +688,7 @@ grSstWinClose(GrContext_t context)
|
||||||
if (windowedMenu) SetMenu(hwnd_win, windowedMenu);
|
if (windowedMenu) SetMenu(hwnd_win, windowedMenu);
|
||||||
fullscreen = 0;
|
fullscreen = 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
//sleep(2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CoreVideo_Quit();
|
|
||||||
|
|
||||||
return FXTRUE;
|
return FXTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,8 +703,7 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
int i;
|
int i;
|
||||||
static int fbs_init = 0;
|
static int fbs_init = 0;
|
||||||
|
|
||||||
//printf("grTextureBufferExt(%d, %d, %d, %d, %d, %d, %d)\r\n", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d lodmin: %d lodmax: %d aspect: %d fmt: %d evenOdd: %d", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
|
||||||
LOG("grTextureBufferExt(%d, %d, %d, %d %d, %d, %d)\r\n", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
|
|
||||||
if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "grTextureBufferExt : loading more than one LOD");
|
if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "grTextureBufferExt : loading more than one LOD");
|
||||||
if (!use_fbo) {
|
if (!use_fbo) {
|
||||||
if (!render_to_texture) { //initialization
|
if (!render_to_texture) { //initialization
|
||||||
|
@ -898,11 +792,11 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
// printf("tmu %d usage now %gMb - %gMb\n",
|
// printf("tmu %d usage now %gMb - %gMb\n",
|
||||||
// rtmu, tmu_usage[rtmu].min/1024.0f, tmu_usage[rtmu].max/1024.0f);
|
// rtmu, tmu_usage[rtmu].min/1024.0f, tmu_usage[rtmu].max/1024.0f);
|
||||||
|
|
||||||
width = pBufferWidth;
|
g_width = pBufferWidth;
|
||||||
height = pBufferHeight;
|
g_height = pBufferHeight;
|
||||||
|
|
||||||
widtho = width / 2;
|
widtho = g_width / 2;
|
||||||
heighto = height / 2;
|
heighto = g_height / 2;
|
||||||
|
|
||||||
// this could be improved, but might be enough as long as the set of
|
// this could be improved, but might be enough as long as the set of
|
||||||
// texture buffer addresses stay small
|
// texture buffer addresses stay small
|
||||||
|
@ -922,13 +816,13 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
add_tex(pBufferAddress);
|
add_tex(pBufferAddress);
|
||||||
|
|
||||||
//printf("viewport %dx%d\n", width, height);
|
//printf("viewport %dx%d\n", width, height);
|
||||||
if (height > screen_height) {
|
if (g_height > screen_height) {
|
||||||
glViewport(0, viewport_offset + screen_height - height, width, height);
|
glViewport(0, viewport_offset + screen_height - g_height, g_width, g_height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glViewport(0, viewport_offset, width, height);
|
glViewport(0, viewport_offset, g_width, g_height);
|
||||||
|
|
||||||
glScissor(0, viewport_offset, width, height);
|
glScissor(0, viewport_offset, g_width, g_height);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!render_to_texture) //initialization
|
if (!render_to_texture) //initialization
|
||||||
|
@ -956,25 +850,25 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
}
|
}
|
||||||
pBufferAddress = startAddress + 1;
|
pBufferAddress = startAddress + 1;
|
||||||
|
|
||||||
width = pBufferWidth;
|
g_width = pBufferWidth;
|
||||||
height = pBufferHeight;
|
g_height = pBufferHeight;
|
||||||
|
|
||||||
widtho = width / 2;
|
widtho = g_width / 2;
|
||||||
heighto = height / 2;
|
heighto = g_height / 2;
|
||||||
|
|
||||||
for (i = 0; i < nb_fb; i++)
|
for (i = 0; i < nb_fb; i++)
|
||||||
{
|
{
|
||||||
if (fbs[i].address == pBufferAddress)
|
if (fbs[i].address == pBufferAddress)
|
||||||
{
|
{
|
||||||
if (fbs[i].width == width && fbs[i].height == height) //select already allocated FBO
|
if (fbs[i].width == g_width && fbs[i].height == g_height) //select already allocated FBO
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fbs[i].fbid);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbs[i].fbid);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbs[i].texid, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbs[i].texid, 0);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, fbs[i].zbid);
|
glBindRenderbuffer(GL_RENDERBUFFER, fbs[i].zbid);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbs[i].zbid);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbs[i].zbid);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, g_width, g_height);
|
||||||
glScissor(0, 0, width, height);
|
glScissor(0, 0, g_width, g_height);
|
||||||
if (fbs[i].buff_clear)
|
if (fbs[i].buff_clear)
|
||||||
{
|
{
|
||||||
glDepthMask(1);
|
glDepthMask(1);
|
||||||
|
@ -997,20 +891,20 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_tex(pBufferAddress, pBufferAddress + width*height * 2/*grTexFormatSize(fmt)*/);
|
remove_tex(pBufferAddress, pBufferAddress + g_width*g_height * 2/*grTexFormatSize(fmt)*/);
|
||||||
//create new FBO
|
//create new FBO
|
||||||
glGenFramebuffers(1, &(fbs[nb_fb].fbid));
|
glGenFramebuffers(1, &(fbs[nb_fb].fbid));
|
||||||
glGenRenderbuffers(1, &(fbs[nb_fb].zbid));
|
glGenRenderbuffers(1, &(fbs[nb_fb].zbid));
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, fbs[nb_fb].zbid);
|
glBindRenderbuffer(GL_RENDERBUFFER, fbs[nb_fb].zbid);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, g_width, g_height);
|
||||||
fbs[nb_fb].address = pBufferAddress;
|
fbs[nb_fb].address = pBufferAddress;
|
||||||
fbs[nb_fb].width = width;
|
fbs[nb_fb].width = g_width;
|
||||||
fbs[nb_fb].height = height;
|
fbs[nb_fb].height = g_height;
|
||||||
fbs[nb_fb].texid = pBufferAddress;
|
fbs[nb_fb].texid = pBufferAddress;
|
||||||
fbs[nb_fb].buff_clear = 0;
|
fbs[nb_fb].buff_clear = 0;
|
||||||
add_tex(fbs[nb_fb].texid);
|
add_tex(fbs[nb_fb].texid);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbs[nb_fb].texid);
|
glBindTexture(GL_TEXTURE_2D, fbs[nb_fb].texid);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, g_width, g_height, 0,
|
||||||
GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
@ -1019,8 +913,8 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER,
|
glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||||
GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbs[nb_fb].texid, 0);
|
GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbs[nb_fb].texid, 0);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbs[nb_fb].zbid);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbs[nb_fb].zbid);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, g_width, g_height);
|
||||||
glScissor(0, 0, width, height);
|
glScissor(0, 0, g_width, g_height);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
glDepthMask(1);
|
glDepthMask(1);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
@ -1125,7 +1019,7 @@ GrAspectRatio_t aspectRatio,
|
||||||
GrTextureFormat_t format,
|
GrTextureFormat_t format,
|
||||||
FxU32 odd_even_mask)
|
FxU32 odd_even_mask)
|
||||||
{
|
{
|
||||||
LOG("grTextureAuxBufferExt(%d, %d, %d, %d %d, %d, %d)\r\n", tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d thisLOD: %d largeLOD: %d aspectRatio: %d format: %d odd_even_mask: %d", tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
|
||||||
//WriteTrace(TraceGlitch, TraceWarning, "grTextureAuxBufferExt");
|
//WriteTrace(TraceGlitch, TraceWarning, "grTextureAuxBufferExt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,7 +1028,7 @@ FX_ENTRY void FX_CALL grAuxBufferExt(GrBuffer_t buffer);
|
||||||
FX_ENTRY GrProc FX_CALL
|
FX_ENTRY GrProc FX_CALL
|
||||||
grGetProcAddress(char *procName)
|
grGetProcAddress(char *procName)
|
||||||
{
|
{
|
||||||
LOG("grGetProcAddress(%s)\r\n", procName);
|
WriteTrace(TraceGlitch, TraceDebug, "procName: %s", procName);
|
||||||
if (!strcmp(procName, "grSstWinOpenExt"))
|
if (!strcmp(procName, "grSstWinOpenExt"))
|
||||||
return (GrProc)grSstWinOpenExt;
|
return (GrProc)grSstWinOpenExt;
|
||||||
if (!strcmp(procName, "grTextureBufferExt"))
|
if (!strcmp(procName, "grTextureBufferExt"))
|
||||||
|
@ -1181,7 +1075,7 @@ grGetProcAddress(char *procName)
|
||||||
FX_ENTRY FxU32 FX_CALL
|
FX_ENTRY FxU32 FX_CALL
|
||||||
grGet(FxU32 pname, FxU32 plength, FxI32 *params)
|
grGet(FxU32 pname, FxU32 plength, FxI32 *params)
|
||||||
{
|
{
|
||||||
LOG("grGet(%d,%d)\r\n", pname, plength);
|
WriteTrace(TraceGlitch, TraceDebug, "pname: %d plength: %d", pname, plength);
|
||||||
switch (pname)
|
switch (pname)
|
||||||
{
|
{
|
||||||
case GR_MAX_TEXTURE_SIZE:
|
case GR_MAX_TEXTURE_SIZE:
|
||||||
|
@ -1193,8 +1087,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params)
|
||||||
if (plength < 4 || params == NULL) return 0;
|
if (plength < 4 || params == NULL) return 0;
|
||||||
if (!nbTextureUnits)
|
if (!nbTextureUnits)
|
||||||
{
|
{
|
||||||
grSstWinOpen((unsigned long)NULL, GR_RESOLUTION_640x480 | 0x80000000, 0, GR_COLORFORMAT_ARGB,
|
grSstWinOpen(0, GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1);
|
||||||
GR_ORIGIN_UPPER_LEFT, 2, 1);
|
|
||||||
grSstWinClose(0);
|
grSstWinClose(0);
|
||||||
}
|
}
|
||||||
#ifdef VOODOO1
|
#ifdef VOODOO1
|
||||||
|
@ -1299,7 +1192,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params)
|
||||||
FX_ENTRY const char * FX_CALL
|
FX_ENTRY const char * FX_CALL
|
||||||
grGetString(FxU32 pname)
|
grGetString(FxU32 pname)
|
||||||
{
|
{
|
||||||
LOG("grGetString(%d)\r\n", pname);
|
WriteTrace(TraceGlitch, TraceDebug, "pname: %d", pname);
|
||||||
switch (pname)
|
switch (pname)
|
||||||
{
|
{
|
||||||
case GR_EXTENSION:
|
case GR_EXTENSION:
|
||||||
|
@ -1343,7 +1236,7 @@ static void render_rectangle(int texture_number,
|
||||||
int src_width, int src_height,
|
int src_width, int src_height,
|
||||||
int tex_width, int tex_height, int invert)
|
int tex_width, int tex_height, int invert)
|
||||||
{
|
{
|
||||||
LOGINFO("render_rectangle(%d,%d,%d,%d,%d,%d,%d,%d)", texture_number, dst_x, dst_y, src_width, src_height, tex_width, tex_height, invert);
|
//LOGINFO("render_rectangle(%d,%d,%d,%d,%d,%d,%d,%d)",texture_number,dst_x,dst_y,src_width,src_height,tex_width,tex_height,invert);
|
||||||
int vertexOffset_location;
|
int vertexOffset_location;
|
||||||
int textureSizes_location;
|
int textureSizes_location;
|
||||||
static float data[] = {
|
static float data[] = {
|
||||||
|
@ -1420,7 +1313,7 @@ void reloadTexture()
|
||||||
if (use_fbo || !render_to_texture || buffer_cleared)
|
if (use_fbo || !render_to_texture || buffer_cleared)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG("reload texture %dx%d\n", width, height);
|
WriteTrace(TraceGlitch, TraceDebug, "width: %d height: %d", g_width, g_height);
|
||||||
//printf("reload texture %dx%d\n", width, height);
|
//printf("reload texture %dx%d\n", width, height);
|
||||||
|
|
||||||
buffer_cleared = 1;
|
buffer_cleared = 1;
|
||||||
|
@ -1435,11 +1328,11 @@ void reloadTexture()
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
if (height > screen_height) h = screen_height - height;
|
if (g_height > screen_height) h = screen_height - g_height;
|
||||||
render_rectangle(texture_unit,
|
render_rectangle(texture_unit,
|
||||||
-w, -h,
|
-w, -h,
|
||||||
width, height,
|
g_width, g_height,
|
||||||
width, height, -1);
|
g_width, g_height, -1);
|
||||||
glBindTexture(GL_TEXTURE_2D, default_texture);
|
glBindTexture(GL_TEXTURE_2D, default_texture);
|
||||||
//glPopAttrib();
|
//glPopAttrib();
|
||||||
}
|
}
|
||||||
|
@ -1447,12 +1340,12 @@ void reloadTexture()
|
||||||
void updateTexture()
|
void updateTexture()
|
||||||
{
|
{
|
||||||
if (!use_fbo && render_to_texture == 2) {
|
if (!use_fbo && render_to_texture == 2) {
|
||||||
LOG("update texture %x\n", pBufferAddress);
|
WriteTrace(TraceGlitch, TraceDebug, "pBufferAddress: %x", pBufferAddress);
|
||||||
//printf("update texture %x\n", pBufferAddress);
|
//printf("update texture %x\n", pBufferAddress);
|
||||||
|
|
||||||
// nothing changed, don't update the texture
|
// nothing changed, don't update the texture
|
||||||
if (!buffer_cleared) {
|
if (!buffer_cleared) {
|
||||||
LOG("update cancelled\n", pBufferAddress);
|
WriteTrace(TraceGlitch, TraceDebug, "update cancelled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1361,7 @@ void updateTexture()
|
||||||
//glDeleteTextures( 1, &pBufferAddress );
|
//glDeleteTextures( 1, &pBufferAddress );
|
||||||
glBindTexture(GL_TEXTURE_2D, pBufferAddress);
|
glBindTexture(GL_TEXTURE_2D, pBufferAddress);
|
||||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
||||||
0, viewport_offset, width, height, 0);
|
0, viewport_offset, g_width, g_height, 0);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, default_texture);
|
glBindTexture(GL_TEXTURE_2D, default_texture);
|
||||||
//glPopAttrib();
|
//glPopAttrib();
|
||||||
|
@ -1481,11 +1374,11 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h,
|
||||||
if (mode == GR_FBCOPY_MODE_DEPTH) {
|
if (mode == GR_FBCOPY_MODE_DEPTH) {
|
||||||
int tw = 1, th = 1;
|
int tw = 1, th = 1;
|
||||||
if (npot_support) {
|
if (npot_support) {
|
||||||
tw = width; th = height;
|
tw = g_width; th = g_height;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (tw < width) tw <<= 1;
|
while (tw < g_width) tw <<= 1;
|
||||||
while (th < height) th <<= 1;
|
while (th < g_height) th <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from == GR_FBCOPY_BUFFER_BACK && to == GR_FBCOPY_BUFFER_FRONT) {
|
if (from == GR_FBCOPY_BUFFER_BACK && to == GR_FBCOPY_BUFFER_FRONT) {
|
||||||
|
@ -1512,7 +1405,7 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h,
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
render_rectangle(texture_unit,
|
render_rectangle(texture_unit,
|
||||||
0, 0,
|
0, 0,
|
||||||
width, height,
|
g_width, g_height,
|
||||||
tw, th, -1);
|
tw, th, -1);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
glBindTexture(GL_TEXTURE_2D, default_texture);
|
glBindTexture(GL_TEXTURE_2D, default_texture);
|
||||||
|
@ -1529,7 +1422,7 @@ grRenderBuffer(GrBuffer_t buffer)
|
||||||
static HANDLE region = NULL;
|
static HANDLE region = NULL;
|
||||||
int realWidth = pBufferWidth, realHeight = pBufferHeight;
|
int realWidth = pBufferWidth, realHeight = pBufferHeight;
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
LOG("grRenderBuffer(%d)\r\n", buffer);
|
WriteTrace(TraceGlitch, TraceDebug, "buffer: %d", buffer);
|
||||||
//printf("grRenderBuffer(%d)\n", buffer);
|
//printf("grRenderBuffer(%d)\n", buffer);
|
||||||
|
|
||||||
switch (buffer)
|
switch (buffer)
|
||||||
|
@ -1547,8 +1440,8 @@ grRenderBuffer(GrBuffer_t buffer)
|
||||||
inverted_culling = 0;
|
inverted_culling = 0;
|
||||||
grCullMode(culling_mode);
|
grCullMode(culling_mode);
|
||||||
|
|
||||||
width = savedWidth;
|
g_width = savedWidth;
|
||||||
height = savedHeight;
|
g_height = savedHeight;
|
||||||
widtho = savedWidtho;
|
widtho = savedWidtho;
|
||||||
heighto = savedHeighto;
|
heighto = savedHeighto;
|
||||||
if (use_fbo) {
|
if (use_fbo) {
|
||||||
|
@ -1557,8 +1450,8 @@ grRenderBuffer(GrBuffer_t buffer)
|
||||||
}
|
}
|
||||||
curBufferAddr = 0;
|
curBufferAddr = 0;
|
||||||
|
|
||||||
glViewport(0, viewport_offset, width, viewport_height);
|
glViewport(0, viewport_offset, g_width, viewport_height);
|
||||||
glScissor(0, viewport_offset, width, height);
|
glScissor(0, viewport_offset, g_width, g_height);
|
||||||
|
|
||||||
#ifdef SAVE_CBUFFER
|
#ifdef SAVE_CBUFFER
|
||||||
if (!use_fbo && render_to_texture == 2) {
|
if (!use_fbo && render_to_texture == 2) {
|
||||||
|
@ -1606,8 +1499,8 @@ grRenderBuffer(GrBuffer_t buffer)
|
||||||
case 6: // RENDER TO TEXTURE
|
case 6: // RENDER TO TEXTURE
|
||||||
if (!render_to_texture)
|
if (!render_to_texture)
|
||||||
{
|
{
|
||||||
savedWidth = width;
|
savedWidth = g_width;
|
||||||
savedHeight = height;
|
savedHeight = g_height;
|
||||||
savedWidtho = widtho;
|
savedWidtho = widtho;
|
||||||
savedHeighto = heighto;
|
savedHeighto = heighto;
|
||||||
}
|
}
|
||||||
|
@ -1646,7 +1539,7 @@ grRenderBuffer(GrBuffer_t buffer)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grAuxBufferExt(GrBuffer_t buffer)
|
grAuxBufferExt(GrBuffer_t buffer)
|
||||||
{
|
{
|
||||||
LOG("grAuxBufferExt(%d)\r\n", buffer);
|
WriteTrace(TraceGlitch, TraceDebug, "buffer: %d", buffer);
|
||||||
//WriteTrace(TraceGlitch, TraceWarning, "grAuxBufferExt");
|
//WriteTrace(TraceGlitch, TraceWarning, "grAuxBufferExt");
|
||||||
|
|
||||||
if (buffer == GR_BUFFER_AUXBUFFER) {
|
if (buffer == GR_BUFFER_AUXBUFFER) {
|
||||||
|
@ -1667,12 +1560,12 @@ grAuxBufferExt(GrBuffer_t buffer)
|
||||||
need_to_compile = 1;
|
need_to_compile = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void vbo_draw();
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU32 depth)
|
grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU32 depth)
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "color: %d alpha: %d depth: %d", color, alpha, depth);
|
||||||
vbo_draw();
|
vbo_draw();
|
||||||
LOG("grBufferClear(%d,%d,%d)\r\n", color, alpha, depth);
|
|
||||||
switch (lfb_color_fmt)
|
switch (lfb_color_fmt)
|
||||||
{
|
{
|
||||||
case GR_COLORFORMAT_ARGB:
|
case GR_COLORFORMAT_ARGB:
|
||||||
|
@ -1691,6 +1584,8 @@ grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU32 depth)
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grBufferClear: unknown color format : %x", lfb_color_fmt);
|
WriteTrace(TraceGlitch, TraceWarning, "grBufferClear: unknown color format : %x", lfb_color_fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
if (w_buffer_mode)
|
if (w_buffer_mode)
|
||||||
glClearDepthf(1.0f - ((1.0f + (depth >> 4) / 4096.0f) * (1 << (depth & 0xF))) / 65528.0);
|
glClearDepthf(1.0f - ((1.0f + (depth >> 4) / 4096.0f) * (1 << (depth & 0xF))) / 65528.0);
|
||||||
else
|
else
|
||||||
|
@ -1710,22 +1605,22 @@ grBufferSwap(FxU32 swap_interval)
|
||||||
vbo_draw();
|
vbo_draw();
|
||||||
// glFinish();
|
// glFinish();
|
||||||
// printf("rendercallback is %p\n", renderCallback);
|
// printf("rendercallback is %p\n", renderCallback);
|
||||||
if (renderCallback) {
|
//if (renderCallback) {
|
||||||
// glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*) &program);
|
// glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*) &program);
|
||||||
// glUseProgramObjectARB(0);
|
// glUseProgramObjectARB(0);
|
||||||
(*renderCallback)(1);
|
//(*renderCallback)(1);
|
||||||
// if (program)
|
// if (program)
|
||||||
// glUseProgramObjectARB(program);
|
// glUseProgramObjectARB(program);
|
||||||
}
|
//}
|
||||||
int i;
|
int i;
|
||||||
LOG("grBufferSwap(%d)\r\n", swap_interval);
|
WriteTrace(TraceGlitch, TraceDebug, "swap_interval: %d", swap_interval);
|
||||||
//printf("swap\n");
|
//printf("swap\n");
|
||||||
if (render_to_texture) {
|
if (render_to_texture) {
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "swap while render_to_texture\n");
|
WriteTrace(TraceGlitch, TraceWarning, "swap while render_to_texture\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreVideo_GL_SwapBuffers();
|
Android_JNI_SwapWindow();
|
||||||
for (i = 0; i < nb_fb; i++)
|
for (i = 0; i < nb_fb; i++)
|
||||||
fbs[i].buff_clear = 1;
|
fbs[i].buff_clear = 1;
|
||||||
|
|
||||||
|
@ -1761,7 +1656,7 @@ grLfbLock(GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode,
|
||||||
GrOriginLocation_t origin, FxBool pixelPipeline,
|
GrOriginLocation_t origin, FxBool pixelPipeline,
|
||||||
GrLfbInfo_t *info)
|
GrLfbInfo_t *info)
|
||||||
{
|
{
|
||||||
LOG("grLfbLock(%d,%d,%d,%d,%d)\r\n", type, buffer, writeMode, origin, pixelPipeline);
|
WriteTrace(TraceGlitch, TraceDebug, "type: %d buffer: %d writeMode: %d origin: %d pixelPipeline: %d", type, buffer, writeMode, origin, pixelPipeline);
|
||||||
if (type == GR_LFB_WRITE_ONLY)
|
if (type == GR_LFB_WRITE_ONLY)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grLfbLock : write only");
|
WriteTrace(TraceGlitch, TraceWarning, "grLfbLock : write only");
|
||||||
|
@ -1788,28 +1683,28 @@ GrLfbInfo_t *info)
|
||||||
if (writeMode == GR_LFBWRITEMODE_888) {
|
if (writeMode == GR_LFBWRITEMODE_888) {
|
||||||
//printf("LfbLock GR_LFBWRITEMODE_888\n");
|
//printf("LfbLock GR_LFBWRITEMODE_888\n");
|
||||||
info->lfbPtr = frameBuffer;
|
info->lfbPtr = frameBuffer;
|
||||||
info->strideInBytes = width * 4;
|
info->strideInBytes = g_width * 4;
|
||||||
info->writeMode = GR_LFBWRITEMODE_888;
|
info->writeMode = GR_LFBWRITEMODE_888;
|
||||||
info->origin = origin;
|
info->origin = origin;
|
||||||
//glReadPixels(0, viewport_offset, width, height, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffer);
|
glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf = (unsigned char*)malloc(width*height * 4);
|
buf = (unsigned char*)malloc(g_width*g_height * 4);
|
||||||
|
|
||||||
info->lfbPtr = frameBuffer;
|
info->lfbPtr = frameBuffer;
|
||||||
info->strideInBytes = width * 2;
|
info->strideInBytes = g_width * 2;
|
||||||
info->writeMode = GR_LFBWRITEMODE_565;
|
info->writeMode = GR_LFBWRITEMODE_565;
|
||||||
info->origin = origin;
|
info->origin = origin;
|
||||||
glReadPixels(0, viewport_offset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < g_height; j++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < g_width; i++)
|
||||||
{
|
{
|
||||||
frameBuffer[(height - j - 1)*width + i] =
|
frameBuffer[(g_height - j - 1)*g_width + i] =
|
||||||
((buf[j*width * 4 + i * 4 + 0] >> 3) << 11) |
|
((buf[j*g_width * 4 + i * 4 + 0] >> 3) << 11) |
|
||||||
((buf[j*width * 4 + i * 4 + 1] >> 2) << 5) |
|
((buf[j*g_width * 4 + i * 4 + 1] >> 2) << 5) |
|
||||||
(buf[j*width * 4 + i * 4 + 2] >> 3);
|
(buf[j*g_width * 4 + i * 4 + 2] >> 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -1818,10 +1713,10 @@ GrLfbInfo_t *info)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->lfbPtr = depthBuffer;
|
info->lfbPtr = depthBuffer;
|
||||||
info->strideInBytes = width * 2;
|
info->strideInBytes = g_width * 2;
|
||||||
info->writeMode = GR_LFBWRITEMODE_ZA16;
|
info->writeMode = GR_LFBWRITEMODE_ZA16;
|
||||||
info->origin = origin;
|
info->origin = origin;
|
||||||
glReadPixels(0, viewport_offset, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
|
glReadPixels(0, viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1831,7 +1726,7 @@ GrLfbInfo_t *info)
|
||||||
FX_ENTRY FxBool FX_CALL
|
FX_ENTRY FxBool FX_CALL
|
||||||
grLfbUnlock(GrLock_t type, GrBuffer_t buffer)
|
grLfbUnlock(GrLock_t type, GrBuffer_t buffer)
|
||||||
{
|
{
|
||||||
LOG("grLfbUnlock(%d,%d)\r\n", type, buffer);
|
WriteTrace(TraceGlitch, TraceDebug, "type: %d, buffer: %d", type, buffer);
|
||||||
if (type == GR_LFB_WRITE_ONLY)
|
if (type == GR_LFB_WRITE_ONLY)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grLfbUnlock : write only");
|
WriteTrace(TraceGlitch, TraceWarning, "grLfbUnlock : write only");
|
||||||
|
@ -1849,7 +1744,7 @@ FxU32 dst_stride, void *dst_data)
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
unsigned short *frameBuffer = (unsigned short*)dst_data;
|
unsigned short *frameBuffer = (unsigned short*)dst_data;
|
||||||
unsigned short *depthBuffer = (unsigned short*)dst_data;
|
unsigned short *depthBuffer = (unsigned short*)dst_data;
|
||||||
LOG("grLfbReadRegion(%d,%d,%d,%d,%d,%d)\r\n", src_buffer, src_x, src_y, src_width, src_height, dst_stride);
|
WriteTrace(TraceGlitch, TraceDebug, "src_buffer: %d src_x: %d src_y: %d src_width: %d src_height: %d dst_stride: %d", src_buffer, src_x, src_y, src_width, src_height, dst_stride);
|
||||||
|
|
||||||
switch (src_buffer)
|
switch (src_buffer)
|
||||||
{
|
{
|
||||||
|
@ -1870,7 +1765,7 @@ FxU32 dst_stride, void *dst_data)
|
||||||
{
|
{
|
||||||
buf = (unsigned char*)malloc(src_width*src_height * 4);
|
buf = (unsigned char*)malloc(src_width*src_height * 4);
|
||||||
|
|
||||||
glReadPixels(src_x, (viewport_offset)+height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||||
|
|
||||||
for (j = 0; j < src_height; j++)
|
for (j = 0; j < src_height; j++)
|
||||||
{
|
{
|
||||||
|
@ -1888,7 +1783,7 @@ FxU32 dst_stride, void *dst_data)
|
||||||
{
|
{
|
||||||
buf = (unsigned char*)malloc(src_width*src_height * 2);
|
buf = (unsigned char*)malloc(src_width*src_height * 2);
|
||||||
|
|
||||||
glReadPixels(src_x, (viewport_offset)+height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
|
glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer);
|
||||||
|
|
||||||
for (j = 0; j < src_height; j++)
|
for (j = 0; j < src_height; j++)
|
||||||
{
|
{
|
||||||
|
@ -1917,7 +1812,7 @@ FxI32 src_stride, void *src_data)
|
||||||
unsigned short *frameBuffer = (unsigned short*)src_data;
|
unsigned short *frameBuffer = (unsigned short*)src_data;
|
||||||
int texture_number;
|
int texture_number;
|
||||||
unsigned int tex_width = 1, tex_height = 1;
|
unsigned int tex_width = 1, tex_height = 1;
|
||||||
LOG("grLfbWriteRegion(%d,%d,%d,%d,%d,%d,%d,%d)\r\n", dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride);
|
WriteTrace(TraceGlitch, TraceDebug, "dst_buffer: %d dst_x: %d dst_y: %d src_format: %d src_width: %d src_height: %d pixelPipeline: %d src_stride: %d", dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride);
|
||||||
|
|
||||||
//glPushAttrib(GL_ALL_ATTRIB_BITS);
|
//glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
|
|
||||||
|
@ -2065,20 +1960,17 @@ FxI32 src_stride, void *src_data)
|
||||||
/* wrapper-specific glide extensions */
|
/* wrapper-specific glide extensions */
|
||||||
|
|
||||||
FX_ENTRY char ** FX_CALL
|
FX_ENTRY char ** FX_CALL
|
||||||
grQueryResolutionsExt(FxI32 * Size)
|
grQueryResolutionsExt(int32_t * Size)
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
|
||||||
LOG("grQueryResolutionsExt\r\n");
|
|
||||||
return g_FullScreenResolutions.getResolutionsList(Size);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height)
|
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height)
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
/*
|
||||||
LOG("grWrapperFullScreenResolutionExt\r\n");
|
|
||||||
g_FullScreenResolutions.getResolution(config.res, width, height);
|
g_FullScreenResolutions.getResolution(config.res, width, height);
|
||||||
return config.res;
|
return config.res;
|
||||||
*/
|
*/
|
||||||
|
@ -2087,35 +1979,11 @@ FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* wi
|
||||||
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key)
|
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
|
||||||
#ifdef _WIN32
|
|
||||||
return (GetAsyncKeyState(key) & 0x8000);
|
|
||||||
#else
|
|
||||||
if (key == 1) //LBUTTON
|
|
||||||
{
|
|
||||||
Uint8 mstate = SDL_GetMouseState(NULL, NULL);
|
|
||||||
return (mstate & SDL_BUTTON_LMASK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Uint8 *keystates = SDL_GetKeyState( NULL );
|
|
||||||
if( keystates[ key ] )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 resolution, FxI32 vram, FxBool fbo, FxBool aniso)
|
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 vram, FxBool fbo, FxBool aniso)
|
||||||
{
|
{
|
||||||
LOG("grConfigWrapperExt\r\n");
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
config.res = resolution;
|
|
||||||
config.vram_size = vram;
|
config.vram_size = vram;
|
||||||
config.fbo = fbo;
|
config.fbo = fbo;
|
||||||
config.anisofilter = aniso;
|
config.anisofilter = aniso;
|
||||||
|
@ -2130,7 +1998,7 @@ grQueryResolutions(const GrResolution *resTemplate, GrResolution *output)
|
||||||
int res_sup = 0xf;
|
int res_sup = 0xf;
|
||||||
int i;
|
int i;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
LOG("grQueryResolutions\r\n");
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grQueryResolutions");
|
WriteTrace(TraceGlitch, TraceWarning, "grQueryResolutions");
|
||||||
if ((unsigned int)resTemplate->resolution != GR_QUERY_ANY)
|
if ((unsigned int)resTemplate->resolution != GR_QUERY_ANY)
|
||||||
{
|
{
|
||||||
|
@ -2162,7 +2030,7 @@ grReset(FxU32 what)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grEnable(GrEnableMode_t mode)
|
grEnable(GrEnableMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grEnable(%d)\r\n", mode);
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
if (mode == GR_TEXTURE_UMA_EXT)
|
if (mode == GR_TEXTURE_UMA_EXT)
|
||||||
UMAmode = 1;
|
UMAmode = 1;
|
||||||
}
|
}
|
||||||
|
@ -2170,7 +2038,7 @@ grEnable(GrEnableMode_t mode)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grDisable(GrEnableMode_t mode)
|
grDisable(GrEnableMode_t mode)
|
||||||
{
|
{
|
||||||
LOG("grDisable(%d)\r\n", mode);
|
WriteTrace(TraceGlitch, TraceDebug, "-");
|
||||||
if (mode == GR_TEXTURE_UMA_EXT)
|
if (mode == GR_TEXTURE_UMA_EXT)
|
||||||
UMAmode = 0;
|
UMAmode = 0;
|
||||||
}
|
}
|
||||||
|
@ -2363,40 +2231,11 @@ GrTexInfo *info)
|
||||||
WriteTrace(TraceGlitch, TraceWarning, "grTexMultibaseAddress");
|
WriteTrace(TraceGlitch, TraceWarning, "grTexMultibaseAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
inline void MySleep(FxU32 ms)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
Sleep(ms);
|
|
||||||
#else
|
|
||||||
SDL_Delay(ms);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
static void CorrectGamma(LPVOID apGammaRamp)
|
|
||||||
{
|
|
||||||
HDC hdc = GetDC(NULL);
|
|
||||||
if (hdc != NULL)
|
|
||||||
{
|
|
||||||
SetDeviceGammaRamp(hdc, apGammaRamp);
|
|
||||||
ReleaseDC(NULL, hdc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void CorrectGamma(const FxU16 aGammaRamp[3][256])
|
|
||||||
{
|
|
||||||
//TODO?
|
|
||||||
//int res = SDL_SetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]);
|
|
||||||
//LOG("SDL_SetGammaRamp returned %d\r\n", res);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grLoadGammaTable(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)
|
grLoadGammaTable(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)
|
||||||
{
|
{
|
||||||
LOG("grLoadGammaTable\r\n");
|
//TODO?
|
||||||
|
/*LOG("grLoadGammaTable\r\n");
|
||||||
if (!fullscreen)
|
if (!fullscreen)
|
||||||
return;
|
return;
|
||||||
FxU16 aGammaRamp[3][256];
|
FxU16 aGammaRamp[3][256];
|
||||||
|
@ -2406,8 +2245,7 @@ grLoadGammaTable(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)
|
||||||
aGammaRamp[1][i] = (FxU16)((green[i] << 8) & 0xFFFF);
|
aGammaRamp[1][i] = (FxU16)((green[i] << 8) & 0xFFFF);
|
||||||
aGammaRamp[2][i] = (FxU16)((blue[i] << 8) & 0xFFFF);
|
aGammaRamp[2][i] = (FxU16)((blue[i] << 8) & 0xFFFF);
|
||||||
}
|
}
|
||||||
CorrectGamma(aGammaRamp);
|
CorrectGamma(aGammaRamp);*/
|
||||||
//MySleep(1000); //workaround for Mupen64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -2442,6 +2280,8 @@ grGetGammaTableExt(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB)
|
guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB)
|
||||||
{
|
{
|
||||||
|
//TODO?
|
||||||
|
/*
|
||||||
LOG("guGammaCorrectionRGB()\r\n");
|
LOG("guGammaCorrectionRGB()\r\n");
|
||||||
if (!fullscreen)
|
if (!fullscreen)
|
||||||
return;
|
return;
|
||||||
|
@ -2452,7 +2292,7 @@ guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB)
|
||||||
aGammaRamp[1][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaG)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
|
aGammaRamp[1][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaG)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
|
||||||
aGammaRamp[2][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaB)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
|
aGammaRamp[2][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaB)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
|
||||||
}
|
}
|
||||||
CorrectGamma(aGammaRamp);
|
CorrectGamma(aGammaRamp);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -2547,7 +2387,8 @@ void dump_stop()
|
||||||
if (fmt != GL_DEPTH_COMPONENT && fmt != 0x1902) {
|
if (fmt != GL_DEPTH_COMPONENT && fmt != 0x1902) {
|
||||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||||
ilTexImage(w, h, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, pixels);
|
ilTexImage(w, h, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, pixels);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, pixels);
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, pixels);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < w*h; i++)
|
for (i = 0; i < w*h; i++)
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "glide.h"
|
#include "glide.h"
|
||||||
#include "glitchmain.h"
|
#include "glitchmain.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <Glide64/trace.h>
|
||||||
|
|
||||||
/* Napalm extensions to GrTextureFormat_t */
|
/* Napalm extensions to GrTextureFormat_t */
|
||||||
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
|
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
|
||||||
|
@ -160,7 +161,7 @@ void free_textures()
|
||||||
FX_ENTRY FxU32 FX_CALL
|
FX_ENTRY FxU32 FX_CALL
|
||||||
grTexMinAddress( GrChipID_t tmu )
|
grTexMinAddress( GrChipID_t tmu )
|
||||||
{
|
{
|
||||||
LOG("grTexMinAddress(%d)\r\n", tmu);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu);
|
||||||
if (UMAmode)
|
if (UMAmode)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
|
@ -170,7 +171,7 @@ grTexMinAddress( GrChipID_t tmu )
|
||||||
FX_ENTRY FxU32 FX_CALL
|
FX_ENTRY FxU32 FX_CALL
|
||||||
grTexMaxAddress( GrChipID_t tmu )
|
grTexMaxAddress( GrChipID_t tmu )
|
||||||
{
|
{
|
||||||
LOG("grTexMaxAddress(%d)\r\n", tmu);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu);
|
||||||
if (UMAmode)
|
if (UMAmode)
|
||||||
return TMU_SIZE*2 - 1;
|
return TMU_SIZE*2 - 1;
|
||||||
else
|
else
|
||||||
|
@ -181,8 +182,8 @@ FX_ENTRY FxU32 FX_CALL
|
||||||
grTexTextureMemRequired( FxU32 evenOdd,
|
grTexTextureMemRequired( FxU32 evenOdd,
|
||||||
GrTexInfo *info )
|
GrTexInfo *info )
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "evenOdd = %d", evenOdd);
|
||||||
int width, height;
|
int width, height;
|
||||||
LOG("grTextureMemRequired(%d)\r\n", evenOdd);
|
|
||||||
if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "grTexTextureMemRequired : loading more than one LOD");
|
if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "grTexTextureMemRequired : loading more than one LOD");
|
||||||
|
|
||||||
if (info->aspectRatioLog2 < 0)
|
if (info->aspectRatioLog2 < 0)
|
||||||
|
@ -231,8 +232,8 @@ grTexCalcMemRequired(
|
||||||
GrLOD_t lodmin, GrLOD_t lodmax,
|
GrLOD_t lodmin, GrLOD_t lodmax,
|
||||||
GrAspectRatio_t aspect, GrTextureFormat_t fmt)
|
GrAspectRatio_t aspect, GrTextureFormat_t fmt)
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "lodmin = %d, lodmax: %d aspect: %d fmt: %d", lodmin, lodmax, aspect, fmt);
|
||||||
int width, height;
|
int width, height;
|
||||||
LOG("grTexCalcMemRequired(%d, %d, %d, %d)\r\n", lodmin, lodmax, aspect, fmt);
|
|
||||||
if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "grTexCalcMemRequired : loading more than one LOD");
|
if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "grTexCalcMemRequired : loading more than one LOD");
|
||||||
|
|
||||||
if (aspect < 0)
|
if (aspect < 0)
|
||||||
|
@ -413,11 +414,11 @@ grTexDownloadMipMap( GrChipID_t tmu,
|
||||||
FxU32 evenOdd,
|
FxU32 evenOdd,
|
||||||
GrTexInfo *info )
|
GrTexInfo *info )
|
||||||
{
|
{
|
||||||
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd);
|
||||||
int width, height, i, j;
|
int width, height, i, j;
|
||||||
int factor;
|
int factor;
|
||||||
int glformat = 0;
|
int glformat = 0;
|
||||||
int gltexfmt, glpixfmt, glpackfmt;
|
int gltexfmt, glpixfmt, glpackfmt;
|
||||||
LOG("grTexDownloadMipMap(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
|
|
||||||
if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "grTexDownloadMipMap : loading more than one LOD");
|
if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "grTexDownloadMipMap : loading more than one LOD");
|
||||||
|
|
||||||
if (info->aspectRatioLog2 < 0)
|
if (info->aspectRatioLog2 < 0)
|
||||||
|
@ -679,7 +680,7 @@ grTexSource( GrChipID_t tmu,
|
||||||
FxU32 evenOdd,
|
FxU32 evenOdd,
|
||||||
GrTexInfo *info )
|
GrTexInfo *info )
|
||||||
{
|
{
|
||||||
LOG("grTexSource(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd);
|
||||||
|
|
||||||
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
||||||
{
|
{
|
||||||
|
@ -762,7 +763,7 @@ grTexDetailControl(
|
||||||
float detail_max
|
float detail_max
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LOG("grTexDetailControl(%d,%d,%d,%d)\r\n", tmu, lod_bias, detail_scale, detail_max);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, lod_bias: %d detail_scale: %d detail_max: %d", tmu, lod_bias, detail_scale, detail_max);
|
||||||
if (lod_bias != 31 && detail_scale != 7)
|
if (lod_bias != 31 && detail_scale != 7)
|
||||||
{
|
{
|
||||||
if (!lod_bias && !detail_scale && !detail_max) return;
|
if (!lod_bias && !detail_scale && !detail_max) return;
|
||||||
|
@ -782,7 +783,7 @@ grTexDetailControl(
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grTexLodBiasValue(GrChipID_t tmu, float bias )
|
grTexLodBiasValue(GrChipID_t tmu, float bias )
|
||||||
{
|
{
|
||||||
LOG("grTexLodBiasValue(%d,%f)\r\n", tmu, bias);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %f", tmu, bias);
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
|
@ -792,7 +793,7 @@ grTexFilterMode(
|
||||||
GrTextureFilterMode_t magfilter_mode
|
GrTextureFilterMode_t magfilter_mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LOG("grTexFilterMode(%d,%d,%d)\r\n", tmu, minfilter_mode, magfilter_mode);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %d magfilter_mode: %d", tmu, minfilter_mode, magfilter_mode);
|
||||||
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
||||||
{
|
{
|
||||||
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
|
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
|
||||||
|
@ -827,7 +828,7 @@ grTexClampMode(
|
||||||
GrTextureClampMode_t t_clampmode
|
GrTextureClampMode_t t_clampmode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LOG("grTexClampMode(%d, %d, %d)\r\n", tmu, s_clampmode, t_clampmode);
|
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, s_clampmode: %d t_clampmode: %d", tmu, s_clampmode, t_clampmode);
|
||||||
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
|
||||||
{
|
{
|
||||||
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
|
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
|
||||||
|
|
|
@ -0,0 +1,415 @@
|
||||||
|
/*
|
||||||
|
* Glide64 - Glide video plugin for Nintendo 64 emulators.
|
||||||
|
* Copyright (c) 2002 Dave2001
|
||||||
|
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "glitchmain.h"
|
||||||
|
|
||||||
|
#undef glActiveTexture
|
||||||
|
#undef glBindTexture
|
||||||
|
#undef glBlendEquation
|
||||||
|
#undef glBlendEquationSeparate
|
||||||
|
#undef glBlendFunc
|
||||||
|
#undef glBlendFuncSeparate
|
||||||
|
#undef glClearColor
|
||||||
|
#undef glClearDepthf
|
||||||
|
#undef glCullFace
|
||||||
|
#undef glDepthFunc
|
||||||
|
#undef glDepthMask
|
||||||
|
#undef glDepthRangef
|
||||||
|
#undef glDisable
|
||||||
|
#undef glEnable
|
||||||
|
#undef glFrontFace
|
||||||
|
#undef glPolygonOffset
|
||||||
|
#undef glScissor
|
||||||
|
#undef glUseProgram
|
||||||
|
#undef glViewport
|
||||||
|
|
||||||
|
void vbo_draw();
|
||||||
|
|
||||||
|
void cache_glActiveTexture (GLenum texture)
|
||||||
|
{
|
||||||
|
static GLenum cached_texture;
|
||||||
|
|
||||||
|
if(texture != cached_texture)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "texture: %d",texture);
|
||||||
|
vbo_draw();
|
||||||
|
glActiveTexture(texture);
|
||||||
|
cached_texture = texture;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - texture: %d",texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glBindTexture (GLenum target, GLuint texture)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "target: %d texture: %d",target, texture);
|
||||||
|
vbo_draw();
|
||||||
|
glBindTexture(target, texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glBlendEquation ( GLenum mode )
|
||||||
|
{
|
||||||
|
static GLenum cached_mode;
|
||||||
|
|
||||||
|
if(mode != cached_mode)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode);
|
||||||
|
vbo_draw();
|
||||||
|
glBlendEquation(mode);
|
||||||
|
cached_mode = mode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha)
|
||||||
|
{
|
||||||
|
static GLenum cached_modeRGB;
|
||||||
|
static GLenum cached_modeAlpha;
|
||||||
|
|
||||||
|
if(modeRGB != cached_modeRGB || modeAlpha != cached_modeAlpha)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "modeRGB: %d cached_modeAlpha: %d",modeRGB, cached_modeAlpha);
|
||||||
|
vbo_draw();
|
||||||
|
glBlendEquationSeparate(modeRGB, modeAlpha);
|
||||||
|
cached_modeRGB = modeRGB;
|
||||||
|
cached_modeAlpha = modeAlpha;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - modeRGB: %d cached_modeAlpha: %d",modeRGB, cached_modeAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glBlendFunc (GLenum sfactor, GLenum dfactor)
|
||||||
|
{
|
||||||
|
static GLenum cached_sfactor;
|
||||||
|
static GLenum cached_dfactor;
|
||||||
|
|
||||||
|
if(sfactor != cached_sfactor || dfactor != cached_dfactor)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "sfactor: %d dfactor: %d",sfactor, dfactor);
|
||||||
|
vbo_draw();
|
||||||
|
glBlendFunc(sfactor, dfactor);
|
||||||
|
cached_sfactor = sfactor;
|
||||||
|
cached_dfactor = dfactor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - sfactor: %d dfactor: %d",sfactor, dfactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
||||||
|
{
|
||||||
|
static GLenum cached_BlendFuncSeparate_srcRGB;
|
||||||
|
static GLenum cached_BlendFuncSeparate_dstRGB;
|
||||||
|
static GLenum cached_BlendFuncSeparate_srcAlpha;
|
||||||
|
static GLenum cached_BlendFuncSeparate_dstAlpha;
|
||||||
|
|
||||||
|
if(srcRGB != cached_BlendFuncSeparate_srcRGB || dstRGB != cached_BlendFuncSeparate_dstRGB || srcAlpha != cached_BlendFuncSeparate_srcAlpha || dstAlpha != cached_BlendFuncSeparate_dstAlpha)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d",srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||||
|
vbo_draw();
|
||||||
|
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||||
|
cached_BlendFuncSeparate_srcRGB = srcRGB;
|
||||||
|
cached_BlendFuncSeparate_dstRGB = dstRGB;
|
||||||
|
cached_BlendFuncSeparate_srcAlpha = srcAlpha;
|
||||||
|
cached_BlendFuncSeparate_dstAlpha = dstAlpha;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d",srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glClearDepthf (GLclampf depth)
|
||||||
|
{
|
||||||
|
static GLclampf cached_depth;
|
||||||
|
|
||||||
|
if(depth != cached_depth)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "depth: %d",depth);
|
||||||
|
vbo_draw();
|
||||||
|
glClearDepthf(depth);
|
||||||
|
cached_depth = depth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - depth: %d",depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glCullFace (GLenum mode)
|
||||||
|
{
|
||||||
|
static GLenum cached_CullFace_mode;
|
||||||
|
|
||||||
|
if(mode != cached_CullFace_mode)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode);
|
||||||
|
vbo_draw();
|
||||||
|
glCullFace(mode);
|
||||||
|
cached_CullFace_mode = mode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glDepthFunc (GLenum func)
|
||||||
|
{
|
||||||
|
static GLenum cached_func;
|
||||||
|
|
||||||
|
if(func != cached_func)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "func: %d",func);
|
||||||
|
vbo_draw();
|
||||||
|
glDepthFunc(func);
|
||||||
|
cached_func = func;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - func: %d",func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glDepthMask (GLboolean flag)
|
||||||
|
{
|
||||||
|
static GLboolean cached_DepthMask_flag;
|
||||||
|
|
||||||
|
if(flag != cached_DepthMask_flag)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "flag: %d",(int)flag);
|
||||||
|
vbo_draw();
|
||||||
|
glDepthMask(flag);
|
||||||
|
cached_DepthMask_flag = flag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - flag: %d",(int)flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glDepthRangef (GLclampf zNear, GLclampf zFar)
|
||||||
|
{
|
||||||
|
static GLclampf cached_zNear;
|
||||||
|
static GLclampf cached_zFar;
|
||||||
|
if(zNear != cached_zNear || zFar != cached_zFar)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "zNear: %d zFar: %d",zNear, zFar);
|
||||||
|
vbo_draw();
|
||||||
|
glDepthRangef(zNear, zFar);
|
||||||
|
cached_zNear = zNear;
|
||||||
|
cached_zFar = zFar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - zNear: %d zFar: %d",zNear, zFar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cache_glEnableDisableItem (GLenum cap, bool enable, bool & cached_state, const char * StateName)
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if(!cached_state)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%s)",StateName);
|
||||||
|
vbo_draw();
|
||||||
|
glEnable(cap);
|
||||||
|
cached_state = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)",StateName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cached_state)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%s)",StateName);
|
||||||
|
vbo_draw();
|
||||||
|
glDisable(cap);
|
||||||
|
cached_state = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)",StateName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glEnableDisable (GLenum cap, bool enable)
|
||||||
|
{
|
||||||
|
static bool cached_BLEND = false;
|
||||||
|
static bool cached_CULL_FACE = false;
|
||||||
|
static bool cached_DEPTH_TEST = false;
|
||||||
|
static bool cached_DITHER = false;
|
||||||
|
static bool cached_POLYGON_OFFSET_FILL = false;
|
||||||
|
static bool cached_SAMPLE_ALPHA_TO_COVERAGE = false;
|
||||||
|
static bool cached_SAMPLE_COVERAGE = false;
|
||||||
|
static bool cached_SCISSOR_TEST = false;
|
||||||
|
static bool cached_STENCIL_TEST = false;
|
||||||
|
|
||||||
|
if(cap == GL_BLEND) { cache_glEnableDisableItem(cap, enable, cached_BLEND, "GL_BLEND"); }
|
||||||
|
else if(cap == GL_CULL_FACE) { cache_glEnableDisableItem(cap, enable, cached_CULL_FACE, "GL_CULL_FACE"); }
|
||||||
|
else if(cap == GL_DEPTH_TEST) { cache_glEnableDisableItem(cap, enable, cached_DEPTH_TEST, "GL_DEPTH_TEST"); }
|
||||||
|
else if(cap == GL_DITHER) { cache_glEnableDisableItem(cap, enable, cached_DITHER, "GL_DITHER"); }
|
||||||
|
else if(cap == GL_POLYGON_OFFSET_FILL) { cache_glEnableDisableItem(cap, enable, cached_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL"); }
|
||||||
|
else if(cap == GL_SAMPLE_ALPHA_TO_COVERAGE) { cache_glEnableDisableItem(cap, enable, cached_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE"); }
|
||||||
|
else if(cap == GL_SAMPLE_COVERAGE) { cache_glEnableDisableItem(cap, enable, cached_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE"); }
|
||||||
|
else if(cap == GL_SCISSOR_TEST) { cache_glEnableDisableItem(cap, enable, cached_SCISSOR_TEST, "GL_SCISSOR_TEST"); }
|
||||||
|
else if(cap == GL_STENCIL_TEST) { cache_glEnableDisableItem(cap, enable, cached_STENCIL_TEST, "GL_STENCIL_TEST"); }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%d)",cap);
|
||||||
|
vbo_draw();
|
||||||
|
glEnable(cap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%d)",cap);
|
||||||
|
vbo_draw();
|
||||||
|
glDisable(cap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glFrontFace (GLenum mode)
|
||||||
|
{
|
||||||
|
static GLenum cached_FrontFace_mode;
|
||||||
|
if(mode != cached_FrontFace_mode)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode);
|
||||||
|
vbo_draw();
|
||||||
|
glFrontFace(mode);
|
||||||
|
cached_FrontFace_mode = mode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glPolygonOffset (GLfloat factor, GLfloat units)
|
||||||
|
{
|
||||||
|
static GLfloat cached_factor;
|
||||||
|
static GLfloat cached_units;
|
||||||
|
if(factor != cached_factor || units != cached_units)
|
||||||
|
{
|
||||||
|
vbo_draw();
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "factor: %f units: %f",factor, units);
|
||||||
|
glPolygonOffset(factor, units);
|
||||||
|
cached_factor = factor;
|
||||||
|
cached_units = units;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - factor: %f units: %f",factor, units);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
||||||
|
{
|
||||||
|
static GLclampf cached_red, cached_green, cached_blue, cached_alpha;
|
||||||
|
|
||||||
|
if(red != cached_red || green != cached_green || blue != cached_blue || alpha != cached_alpha)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha);
|
||||||
|
vbo_draw();
|
||||||
|
glClearColor(red, green, blue, alpha);
|
||||||
|
cached_red = red;
|
||||||
|
cached_green = green;
|
||||||
|
cached_blue = blue;
|
||||||
|
cached_alpha = alpha;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glScissor (GLint x, GLint y, GLsizei width, GLsizei height)
|
||||||
|
{
|
||||||
|
static GLint cached_x, cached_y;
|
||||||
|
static GLsizei cached_width, cached_height;
|
||||||
|
|
||||||
|
if(x != cached_x || y != cached_y || width != cached_width || height != cached_height)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
||||||
|
vbo_draw();
|
||||||
|
glScissor(x, y, width, height);
|
||||||
|
cached_x = x;
|
||||||
|
cached_y = y;
|
||||||
|
cached_width = width;
|
||||||
|
cached_height = height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glUseProgram (GLuint program)
|
||||||
|
{
|
||||||
|
static GLuint cached_program;
|
||||||
|
if(program != cached_program)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "program: %d", program);
|
||||||
|
vbo_draw();
|
||||||
|
glUseProgram(program);
|
||||||
|
cached_program = program;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - program: %d", program);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache_glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
|
||||||
|
{
|
||||||
|
static GLint cached_x = 0, cached_y = 0;
|
||||||
|
static GLsizei cached_width = 0, cached_height = 0;
|
||||||
|
|
||||||
|
if(x != cached_x || y != cached_y || width != cached_width || height != cached_height)
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
||||||
|
vbo_draw();
|
||||||
|
glViewport(x, y, width, height);
|
||||||
|
cached_x = x;
|
||||||
|
cached_y = y;
|
||||||
|
cached_width = width;
|
||||||
|
cached_height = height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteTrace(TraceOGLWrapper, TraceDebug, "ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#pragma once
|
||||||
|
#include "opengl.h"
|
||||||
|
void vbo_draw();
|
||||||
|
|
||||||
|
void cache_glActiveTexture (GLenum texture);
|
||||||
|
void cache_glBindTexture (GLenum target, GLuint texture);
|
||||||
|
void cache_glBlendEquation ( GLenum mode );
|
||||||
|
void cache_glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
|
||||||
|
void cache_glBlendFunc (GLenum sfactor, GLenum dfactor);
|
||||||
|
void cache_glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
|
||||||
|
void cache_glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||||
|
void cache_glClearDepthf (GLclampf depth);
|
||||||
|
void cache_glCullFace (GLenum mode);
|
||||||
|
void cache_glDepthFunc (GLenum func);
|
||||||
|
void cache_glDepthMask (GLboolean flag);
|
||||||
|
void cache_glDepthRangef (GLclampf zNear, GLclampf zFar);
|
||||||
|
void cache_glEnableDisable (GLenum cap, bool enable);
|
||||||
|
void cache_glPolygonOffset (GLfloat factor, GLfloat units);
|
||||||
|
void cache_glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
|
void cache_glUseProgram (GLuint program);
|
||||||
|
void cache_glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
|
|
||||||
|
#define glActiveTexture(texture) cache_glActiveTexture(texture)
|
||||||
|
#define glBindTexture(target, texture) cache_glBindTexture(target, texture)
|
||||||
|
#define glBlendEquation(mode) cache_glBlendEquation(mode)
|
||||||
|
#define glBlendEquationSeparate(modeRGB, modeAlpha) cache_glBlendEquationSeparate(modeRGB, modeAlpha)
|
||||||
|
#define glBlendFunc(sfactor, dfactor) cache_glBlendFunc(sfactor, dfactor)
|
||||||
|
#define glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) cache_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)
|
||||||
|
#define glClearColor(red, green, blue, alpha) cache_glClearColor(red, green, blue, alpha)
|
||||||
|
#define glClearDepthf(depth) cache_glClearDepthf(depth)
|
||||||
|
#define glCullFace(mode) cache_glCullFace(mode)
|
||||||
|
#define glDepthFunc(func) cache_glDepthFunc(func)
|
||||||
|
#define glDepthMask(flag) cache_glDepthMask(flag)
|
||||||
|
#define glDepthRangef(zNear, zFar) cache_glDepthRangef(zNear, zFar)
|
||||||
|
#define glDisable(cap) cache_glEnableDisable(cap, false)
|
||||||
|
#define glEnable(cap) cache_glEnableDisable(cap, true)
|
||||||
|
#define glFrontFace(mode) cache_glFrontFace(mode)
|
||||||
|
#define glPolygonOffset(factor, units) cache_glPolygonOffset(factor, units)
|
||||||
|
#define glScissor(x, y, width, height) cache_glScissor(x, y, width, height)
|
||||||
|
#define glUseProgram(program) cache_glUseProgram(program)
|
||||||
|
#define glViewport(x, y, width, height) cache_glViewport(x, y, width, height)
|
||||||
|
|
|
@ -17,7 +17,9 @@ extern int dumping;
|
||||||
|
|
||||||
typedef struct _wrapper_config
|
typedef struct _wrapper_config
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
int res;
|
int res;
|
||||||
|
#endif
|
||||||
int fbo;
|
int fbo;
|
||||||
int anisofilter;
|
int anisofilter;
|
||||||
int vram_size;
|
int vram_size;
|
||||||
|
@ -117,6 +119,17 @@ extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
|
||||||
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
|
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
|
||||||
extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
|
extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
|
||||||
#endif
|
#endif
|
||||||
|
void check_compile(GLuint shader);
|
||||||
|
void check_link(GLuint program);
|
||||||
|
void vbo_enable();
|
||||||
|
void vbo_disable();
|
||||||
|
|
||||||
|
//Vertex Attribute Locations
|
||||||
|
#define POSITION_ATTR 0
|
||||||
|
#define COLOUR_ATTR 1
|
||||||
|
#define TEXCOORD_0_ATTR 2
|
||||||
|
#define TEXCOORD_1_ATTR 3
|
||||||
|
#define FOG_ATTR 4
|
||||||
|
|
||||||
extern int w_buffer_mode;
|
extern int w_buffer_mode;
|
||||||
extern int nbTextureUnits;
|
extern int nbTextureUnits;
|
||||||
|
@ -154,11 +167,15 @@ void free_combiners();
|
||||||
void compile_shader();
|
void compile_shader();
|
||||||
void set_lambda();
|
void set_lambda();
|
||||||
void set_copy_shader();
|
void set_copy_shader();
|
||||||
|
void disable_textureSizes();
|
||||||
|
|
||||||
// config functions
|
// config functions
|
||||||
|
|
||||||
//FX_ENTRY void FX_CALL grConfigWrapperExt(HINSTANCE instance, HWND hwnd);
|
#ifdef _WIN32
|
||||||
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
|
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
|
||||||
|
#else
|
||||||
|
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxBool, FxBool);
|
||||||
|
#endif
|
||||||
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
|
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
|
||||||
FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*);
|
FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*);
|
||||||
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
|
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
|
||||||
|
|
|
@ -623,15 +623,11 @@ grFinish(void);
|
||||||
FX_ENTRY void FX_CALL
|
FX_ENTRY void FX_CALL
|
||||||
grFlush(void);
|
grFlush(void);
|
||||||
|
|
||||||
FX_ENTRY GrContext_t FX_CALL
|
#ifdef _WIN32
|
||||||
grSstWinOpen(
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpen( HWND hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers);
|
||||||
HWND hWnd,
|
#else
|
||||||
GrScreenResolution_t screen_resolution,
|
FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers);
|
||||||
GrScreenRefresh_t refresh_rate,
|
#endif
|
||||||
GrColorFormat_t color_format,
|
|
||||||
GrOriginLocation_t origin_location,
|
|
||||||
int nColBuffers,
|
|
||||||
int nAuxBuffers);
|
|
||||||
|
|
||||||
FX_ENTRY FxBool FX_CALL
|
FX_ENTRY FxBool FX_CALL
|
||||||
grSstWinClose( GrContext_t context );
|
grSstWinClose( GrContext_t context );
|
||||||
|
|
Loading…
Reference in New Issue