Merge branch 'master' of git://github.com/snes9xgit/snes9x

Conflicts:
	win32/CDirect3D.cpp
This commit is contained in:
gocha 2011-02-26 08:13:06 +09:00
commit 0e76f2d5ca
21 changed files with 8234 additions and 8642 deletions

View File

@ -181,11 +181,12 @@
#define ALL_COLOR_MASK (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK)
#ifdef GFX_MULTI_FORMAT
static uint16 lowPixelMask = 0, qlowPixelMask = 0;
static uint16 lowPixelMask = 0, qlowPixelMask = 0, highBitsMask = 0;
static uint32 colorMask = 0;
#else
#define lowPixelMask (RGB_LOW_BITS_MASK)
#define qlowPixelMask ((RGB_HI_BITS_MASK >> 3) | TWO_LOW_BITS_MASK)
#define highBitsMask (ALL_COLOR_MASK & RGB_REMOVE_LOW_BITS_MASK)
#define colorMask (((~RGB_HI_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_HI_BITS_MASK & ALL_COLOR_MASK))
#endif
@ -204,6 +205,7 @@ bool8 S9xBlitFilterInit (void)
#ifdef GFX_MULTI_FORMAT
lowPixelMask = RGB_LOW_BITS_MASK;
qlowPixelMask = (RGB_HI_BITS_MASK >> 3) | TWO_LOW_BITS_MASK;
highBitsMask = ALL_COLOR_MASK & RGB_REMOVE_LOW_BITS_MASK;
colorMask = ((~RGB_HI_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_HI_BITS_MASK & ALL_COLOR_MASK);
#endif
@ -252,7 +254,7 @@ void S9xBlitNTSCFilterSet (const snes_ntsc_setup_t *setup)
snes_ntsc_init(ntsc, setup);
}
void S9xBlitPixSmall16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixSimple1x1 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
width <<= 1;
@ -264,7 +266,41 @@ void S9xBlitPixSmall16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRo
}
}
void S9xBlitPixScaled16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixSimple1x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
width <<= 1;
for (; height; height--)
{
memcpy(dstPtr, srcPtr, width);
dstPtr += dstRowBytes;
memcpy(dstPtr, srcPtr, width);
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
}
}
void S9xBlitPixSimple2x1 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
for (; height; height--)
{
uint16 *dP = (uint16 *) dstPtr, *bP = (uint16 *) srcPtr;
for (int i = 0; i < (width >> 1); i++)
{
*dP++ = *bP;
*dP++ = *bP++;
*dP++ = *bP;
*dP++ = *bP++;
}
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
}
}
void S9xBlitPixSimple2x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes, *deltaPtr = XDelta;
dstRowBytes <<= 1;
@ -313,21 +349,83 @@ void S9xBlitPixScaled16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstR
}
}
void S9xBlitPixHiRes16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixBlend1x1 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
width <<= 1;
for (; height; height--)
{
memcpy(dstPtr, srcPtr, width);
dstPtr += dstRowBytes;
memcpy(dstPtr, srcPtr, width);
uint16 *dP = (uint16 *) dstPtr, *bP = (uint16 *) srcPtr;
uint16 prev, curr;
prev = *bP;
for (int i = 0; i < (width >> 1); i++)
{
curr = *bP++;
*dP++ = (prev & curr) + (((prev ^ curr) & highBitsMask) >> 1);
prev = curr;
curr = *bP++;
*dP++ = (prev & curr) + (((prev ^ curr) & highBitsMask) >> 1);
prev = curr;
}
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
}
}
void S9xBlitPixScaledTV16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixBlend2x1 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
for (; height; height--)
{
uint16 *dP = (uint16 *) dstPtr, *bP = (uint16 *) srcPtr;
uint16 prev, curr;
prev = *bP;
for (int i = 0; i < (width >> 1); i++)
{
curr = *bP++;
*dP++ = (prev & curr) + (((prev ^ curr) & highBitsMask) >> 1);
*dP++ = curr;
prev = curr;
curr = *bP++;
*dP++ = (prev & curr) + (((prev ^ curr) & highBitsMask) >> 1);
*dP++ = curr;
prev = curr;
}
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
}
}
void S9xBlitPixTV1x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes;
dstRowBytes <<= 1;
for (; height; height--)
{
uint32 *dP1 = (uint32 *) dstPtr, *dP2 = (uint32 *) dstPtr2, *bP = (uint32 *) srcPtr;
uint32 product, darkened;
for (int i = 0; i < (width >> 1); i++)
{
product = *dP1++ = *bP++;
darkened = (product = (product >> 1) & colorMask);
darkened += (product = (product >> 1) & colorMask);
*dP2++ = darkened;
}
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
dstPtr2 += dstRowBytes;
}
}
void S9xBlitPixTV2x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes, *deltaPtr = XDelta;
dstRowBytes <<= 1;
@ -438,31 +536,7 @@ void S9xBlitPixScaledTV16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int ds
}
}
void S9xBlitPixHiResTV16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes;
dstRowBytes <<= 1;
for (; height; height--)
{
uint32 *dP1 = (uint32 *) dstPtr, *dP2 = (uint32 *) dstPtr2, *bP = (uint32 *) srcPtr;
uint32 product, darkened;
for (int i = 0; i < (width >> 1); i++)
{
product = *dP1++ = *bP++;
darkened = (product = (product >> 1) & colorMask);
darkened += (product = (product >> 1) & colorMask);
*dP2++ = darkened;
}
srcPtr += srcRowBytes;
dstPtr += dstRowBytes;
dstPtr2 += dstRowBytes;
}
}
void S9xBlitPixHiResMixedTV16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixMixedTV1x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes, *srcPtr2 = srcPtr + srcRowBytes;
dstRowBytes <<= 1;
@ -503,7 +577,7 @@ void S9xBlitPixHiResMixedTV16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, in
}
}
void S9xBlitPixSmooth16 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
void S9xBlitPixSmooth2x2 (uint8 *srcPtr, int srcRowBytes, uint8 *dstPtr, int dstRowBytes, int width, int height)
{
uint8 *dstPtr2 = dstPtr + dstRowBytes, *deltaPtr = XDelta;
uint32 lastLinePix[SNES_WIDTH << 1];

View File

@ -189,13 +189,16 @@ void S9xBlitClearDelta (void);
bool8 S9xBlitNTSCFilterInit (void);
void S9xBlitNTSCFilterDeinit (void);
void S9xBlitNTSCFilterSet (const snes_ntsc_setup_t *);
void S9xBlitPixSmall16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixScaled16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixHiRes16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixScaledTV16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixHiResTV16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixHiResMixedTV16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSmooth16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSimple1x1 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSimple1x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSimple2x1 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSimple2x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixBlend1x1 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixBlend2x1 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixTV1x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixTV2x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixMixedTV1x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSmooth2x2 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSuperEagle16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPix2xSaI16 (uint8 *, int, uint8 *, int, int, int);
void S9xBlitPixSuper2xSaI16 (uint8 *, int, uint8 *, int, int, int);

View File

@ -452,6 +452,20 @@ Snes9xPreferences::calibration_dialog (void)
#endif
static void
event_input_rate_changed (GtkRange *range, gpointer data)
{
char text[256];
GtkLabel *label = GTK_LABEL (data);
double value = gtk_range_get_value (range) / 32040.0 * 60.09881389744051;
snprintf (text, 256, "%.4f hz", value);
gtk_label_set_text (label, text);
return;
}
static void
event_about_clicked (GtkButton *widget, gpointer data)
{
@ -548,6 +562,13 @@ Snes9xPreferences::Snes9xPreferences (Snes9xConfig *config) :
signal_connect (callbacks);
g_signal_connect_data (get_widget ("sound_input_rate"),
"value-changed",
G_CALLBACK (event_input_rate_changed),
get_widget ("relative_video_rate"),
NULL,
(GConnectFlags) 0);
return;
}

View File

@ -2095,7 +2095,7 @@
<child>
<object class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<property name="row_spacing">5</property>
@ -2141,8 +2141,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@ -2154,8 +2154,8 @@
<property name="label" translatable="yes">Buffer size:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@ -2216,6 +2216,30 @@
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label139">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Video rate:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="relative_video_rate">
<property name="visible">True</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@ -5,7 +5,7 @@
<key>IBFramework Version</key>
<string>823</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../macpdate.xcodeproj</string>
<string>../snes9x.xcodeproj</string>
<key>IBOldestOS</key>
<integer>6</integer>
<key>IBOpenObjects</key>

File diff suppressed because it is too large Load Diff

View File

@ -238,6 +238,7 @@ enum
VIDEOMODE_BLOCKY,
VIDEOMODE_TV,
VIDEOMODE_SMOOTH,
VIDEOMODE_BLEND,
VIDEOMODE_SUPEREAGLE,
VIDEOMODE_2XSAI,
VIDEOMODE_SUPER2XSAI,

View File

@ -267,6 +267,7 @@ enum
iOpenGLBlocky = 1,
iOpenGLTVMode,
iOpenGLSmoothMode,
iOpenGLBlendMode,
iOpenGLEagleMode,
iOpenGL2xSAIMode,
iOpenGLSuper2xSAIMode,
@ -308,7 +309,7 @@ static PrefList prefList[] =
{ 'gl32', &gl32bit, sizeof(bool8 ) },
{ 'glst', &glstretch, sizeof(bool8 ) },
{ 'draw', &drawingMethod, sizeof(long ) },
{ 'vmod', &videoMode, sizeof(int ) },
{ 'Vmod', &videoMode, sizeof(int ) },
{ 'MPmt', &multiprocessor, sizeof(bool8 ) },
{ 'VSNC', &vsync, sizeof(bool8 ) },
{ 'H239', &drawoverscan, sizeof(bool8 ) },
@ -592,6 +593,10 @@ void ConfigurePreferences (void)
SetControl32BitValue(ctl, iOpenGLSmoothMode);
break;
case VIDEOMODE_BLEND:
SetControl32BitValue(ctl, iOpenGLBlendMode);
break;
case VIDEOMODE_SUPEREAGLE:
SetControl32BitValue(ctl, iOpenGLEagleMode);
break;
@ -954,6 +959,11 @@ void ConfigurePreferences (void)
videoMode = VIDEOMODE_SMOOTH;
break;
case iOpenGLBlendMode:
drawingMethod = kDrawingBlitGL;
videoMode = VIDEOMODE_BLEND;
break;
case iOpenGLEagleMode:
drawingMethod = kDrawingBlitGL;
videoMode = VIDEOMODE_SUPEREAGLE;

File diff suppressed because it is too large Load Diff

View File

@ -1388,8 +1388,8 @@ extern struct SLineMatrixData LineMatrixData[240];
#define DRAW_PIXEL_H2x1(N, M) \
if (Z1 > GFX.DB[Offset + 2 * N] && (M)) \
{ \
GFX.S[Offset + 2 * N] = MATH(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]); \
GFX.S[Offset + 2 * N + 1] = MATH((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N + 2]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); \
GFX.S[Offset + 2 * N] = MATH((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); \
GFX.S[Offset + 2 * N + 1] = MATH(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]); \
GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2; \
}

View File

@ -789,19 +789,28 @@ void S9xPutImage (int width, int height)
if (width <= SNES_WIDTH)
{
copyWidth = width * 2;
copyHeight = height * 2;
switch (GUI.video_mode)
if (height > SNES_HEIGHT_EXTENDED)
{
case VIDEOMODE_BLOCKY: blitFn = S9xBlitPixScaled16; break;
case VIDEOMODE_TV: blitFn = S9xBlitPixScaledTV16; break;
case VIDEOMODE_SMOOTH: blitFn = S9xBlitPixSmooth16; break;
case VIDEOMODE_SUPEREAGLE: blitFn = S9xBlitPixSuperEagle16; break;
case VIDEOMODE_2XSAI: blitFn = S9xBlitPix2xSaI16; break;
case VIDEOMODE_SUPER2XSAI: blitFn = S9xBlitPixSuper2xSaI16; break;
case VIDEOMODE_EPX: blitFn = S9xBlitPixEPX16; break;
case VIDEOMODE_HQ2X: blitFn = S9xBlitPixHQ2x16; break;
copyWidth = width * 2;
copyHeight = height;
blitFn = S9xBlitPixSimple2x1;
}
else
{
copyWidth = width * 2;
copyHeight = height * 2;
switch (GUI.video_mode)
{
case VIDEOMODE_BLOCKY: blitFn = S9xBlitPixSimple2x2; break;
case VIDEOMODE_TV: blitFn = S9xBlitPixTV2x2; break;
case VIDEOMODE_SMOOTH: blitFn = S9xBlitPixSmooth2x2; break;
case VIDEOMODE_SUPEREAGLE: blitFn = S9xBlitPixSuperEagle16; break;
case VIDEOMODE_2XSAI: blitFn = S9xBlitPix2xSaI16; break;
case VIDEOMODE_SUPER2XSAI: blitFn = S9xBlitPixSuper2xSaI16; break;
case VIDEOMODE_EPX: blitFn = S9xBlitPixEPX16; break;
case VIDEOMODE_HQ2X: blitFn = S9xBlitPixHQ2x16; break;
}
}
}
else
@ -812,16 +821,15 @@ void S9xPutImage (int width, int height)
switch (GUI.video_mode)
{
default: blitFn = S9xBlitPixHiRes16; break;
case VIDEOMODE_TV: blitFn = S9xBlitPixHiResTV16; break;
default: blitFn = S9xBlitPixSimple1x2; break;
case VIDEOMODE_TV: blitFn = S9xBlitPixTV1x2; break;
}
}
else
{
copyWidth = width;
copyHeight = height;
blitFn = S9xBlitPixSmall16;
blitFn = S9xBlitPixSimple1x1;
}
blitFn((uint8 *) GFX.Screen, GFX.Pitch, GUI.blit_screen, GUI.blit_screen_pitch, width, height);

View File

@ -178,6 +178,9 @@
#pragma comment( lib, "d3dx9" )
#pragma comment( lib, "DxErr" )
#pragma comment( lib, "cg.lib" )
#pragma comment( lib, "cgd3d9.lib" )
#include "cdirect3d.h"
#include "win32_display.h"
#include "../snes9x.h"
@ -216,10 +219,12 @@ CDirect3D::CDirect3D()
rubyLUT[i] = NULL;
}
effect=NULL;
shader_compiled=false;
shader_type = D3D_SHADER_NONE;
shaderTimer = 1.0f;
shaderTimeStart = 0;
shaderTimeElapsed = 0;
cgContext = NULL;
cgVertexProgram = cgFragmentProgram = NULL;
}
/* CDirect3D::~CDirect3D()
@ -259,7 +264,8 @@ bool CDirect3D::Initialize(HWND hWnd)
HRESULT hr = pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_MIXED_VERTEXPROCESSING,
D3DCREATE_MIXED_VERTEXPROCESSING
| D3DCREATE_FPU_PRESERVE, // for lua
&dPresentParams,
&pDevice);
if(FAILED(hr)) {
@ -273,6 +279,12 @@ bool CDirect3D::Initialize(HWND hWnd)
return false;
}
cgContext = cgCreateContext();
hr = cgD3D9SetDevice(pDevice);
if(FAILED(hr)) {
DXTRACE_ERR_MSGBOX(TEXT("Error setting cg device"), hr);
}
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
init_done = true;
@ -303,6 +315,13 @@ void CDirect3D::DeInitialize()
pD3D = NULL;
}
if(cgContext) {
cgDestroyContext(cgContext);
cgContext = NULL;
}
cgD3D9SetDevice(NULL);
init_done = false;
afterRenderWidth = 0;
afterRenderHeight = 0;
@ -312,6 +331,73 @@ void CDirect3D::DeInitialize()
}
bool CDirect3D::SetShader(const TCHAR *file)
{
SetShaderCG(NULL);
SetShaderHLSL(NULL);
shader_type = D3D_SHADER_NONE;
if(file!=NULL && lstrlen(file)>3 && _tcsncicmp(&file[lstrlen(file)-3],TEXT(".cg"),3)==0) {
return SetShaderCG(file);
} else {
return SetShaderHLSL(file);
}
}
bool CDirect3D::SetShaderCG(const TCHAR *file)
{
TCHAR errorMsg[MAX_PATH + 50];
HRESULT hr;
if(cgFragmentProgram) {
cgDestroyProgram(cgFragmentProgram);
cgFragmentProgram = NULL;
}
if(cgVertexProgram) {
cgDestroyProgram(cgVertexProgram);
cgVertexProgram = NULL;
}
if (file == NULL || *file==TEXT('\0'))
return true;
CGprofile vertexProfile = cgD3D9GetLatestVertexProfile();
CGprofile pixelProfile = cgD3D9GetLatestPixelProfile();
const char** vertexOptions = cgD3D9GetOptimalOptions(vertexProfile);
const char** pixelOptions = cgD3D9GetOptimalOptions(pixelProfile);
char *fileContents = ReadShaderFileContents(file);
if(!fileContents)
return false;
cgVertexProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
vertexProfile, "main_vertex", vertexOptions);
cgFragmentProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
pixelProfile, "main_fragment", pixelOptions);
delete [] fileContents;
if(!cgVertexProgram && !cgFragmentProgram) {
_stprintf(errorMsg,TEXT("No vertex or fragment program in file:\n%s"),file);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(cgVertexProgram) {
hr = cgD3D9LoadProgram(cgVertexProgram,false,0);
hr = cgD3D9BindProgram(cgVertexProgram);
}
if(cgFragmentProgram) {
hr = cgD3D9LoadProgram(cgFragmentProgram,false,0);
hr = cgD3D9BindProgram(cgFragmentProgram);
}
shader_type = D3D_SHADER_CG;
return true;
}
bool CDirect3D::SetShaderHLSL(const TCHAR *file)
{
//MUDLORD: the guts
//Compiles a shader from files on disc
@ -331,7 +417,6 @@ bool CDirect3D::SetShader(const TCHAR *file)
HRESULT hr;
shader_compiled = false;
shaderTimer = 1.0f;
shaderTimeStart = 0;
shaderTimeElapsed = 0;
@ -462,48 +547,77 @@ bool CDirect3D::SetShader(const TCHAR *file)
D3DXHANDLE hTech;
effect->FindNextValidTechnique(NULL,&hTech);
effect->SetTechnique( hTech );
shader_compiled = true;
shader_type = D3D_SHADER_HLSL;
return true;
}
void CDirect3D::SetShaderVars()
{
D3DXVECTOR4 rubyTextureSize;
D3DXVECTOR4 rubyInputSize;
D3DXVECTOR4 rubyOutputSize;
D3DXHANDLE rubyTimer;
if(shader_type == D3D_SHADER_HLSL) {
D3DXVECTOR4 rubyTextureSize;
D3DXVECTOR4 rubyInputSize;
D3DXVECTOR4 rubyOutputSize;
D3DXHANDLE rubyTimer;
int shaderTime = GetTickCount();
shaderTimeElapsed += shaderTime - shaderTimeStart;
shaderTimeStart = shaderTime;
if(shaderTimeElapsed > 100) {
shaderTimeElapsed = 0;
shaderTimer += 0.01f;
}
rubyTextureSize.x = rubyTextureSize.y = (float)quadTextureSize;
rubyTextureSize.z = rubyTextureSize.w = 1.0 / quadTextureSize;
rubyInputSize.x = (float)afterRenderWidth;
rubyInputSize.y = (float)afterRenderHeight;
rubyInputSize.z = 1.0 / rubyInputSize.y;
rubyInputSize.w = 1.0 / rubyInputSize.z;
rubyOutputSize.x = GUI.Stretch?(float)dPresentParams.BackBufferWidth:(float)afterRenderWidth;
rubyOutputSize.y = GUI.Stretch?(float)dPresentParams.BackBufferHeight:(float)afterRenderHeight;
rubyOutputSize.z = 1.0 / rubyOutputSize.y;
rubyOutputSize.w = 1.0 / rubyOutputSize.x;
rubyTimer = effect->GetParameterByName(0, "rubyTimer");
effect->SetFloat(rubyTimer, shaderTimer);
effect->SetVector("rubyTextureSize", &rubyTextureSize);
effect->SetVector("rubyInputSize", &rubyInputSize);
effect->SetVector("rubyOutputSize", &rubyOutputSize);
effect->SetTexture("rubyTexture", drawSurface);
for(int i = 0; i < MAX_SHADER_TEXTURES; i++) {
char rubyLUTName[256];
sprintf(rubyLUTName, "rubyLUT%d", i);
if (rubyLUT[i] != NULL) {
effect->SetTexture( rubyLUTName, rubyLUT[i] );
int shaderTime = GetTickCount();
shaderTimeElapsed += shaderTime - shaderTimeStart;
shaderTimeStart = shaderTime;
if(shaderTimeElapsed > 100) {
shaderTimeElapsed = 0;
shaderTimer += 0.01f;
}
rubyTextureSize.x = rubyTextureSize.y = (float)quadTextureSize;
rubyTextureSize.z = rubyTextureSize.w = 1.0 / quadTextureSize;
rubyInputSize.x = (float)afterRenderWidth;
rubyInputSize.y = (float)afterRenderHeight;
rubyInputSize.z = 1.0 / rubyInputSize.y;
rubyInputSize.w = 1.0 / rubyInputSize.z;
rubyOutputSize.x = GUI.Stretch?(float)dPresentParams.BackBufferWidth:(float)afterRenderWidth;
rubyOutputSize.y = GUI.Stretch?(float)dPresentParams.BackBufferHeight:(float)afterRenderHeight;
rubyOutputSize.z = 1.0 / rubyOutputSize.y;
rubyOutputSize.w = 1.0 / rubyOutputSize.x;
rubyTimer = effect->GetParameterByName(0, "rubyTimer");
effect->SetFloat(rubyTimer, shaderTimer);
effect->SetVector("rubyTextureSize", &rubyTextureSize);
effect->SetVector("rubyInputSize", &rubyInputSize);
effect->SetVector("rubyOutputSize", &rubyOutputSize);
effect->SetTexture("rubyTexture", drawSurface);
for(int i = 0; i < MAX_SHADER_TEXTURES; i++) {
char rubyLUTName[256];
sprintf(rubyLUTName, "rubyLUT%d", i);
if (rubyLUT[i] != NULL) {
effect->SetTexture( rubyLUTName, rubyLUT[i] );
}
}
} else if(shader_type == D3D_SHADER_CG) {
CGparameter cgpModelViewProj = cgGetNamedParameter(cgVertexProgram, "modelViewProj");
CGparameter cgpVideoSize = cgGetNamedParameter(cgFragmentProgram, "IN.video_size");
CGparameter cgpTextureSize = cgGetNamedParameter(cgFragmentProgram, "IN.texture_size");
CGparameter cgpOutputSize = cgGetNamedParameter(cgFragmentProgram, "IN.output_size");
D3DXMATRIX mvpMat;
D3DXVECTOR2 videoSize;
D3DXVECTOR2 textureSize;
D3DXVECTOR2 outputSize;
videoSize.x = (float)afterRenderWidth;
videoSize.y = (float)afterRenderHeight;
textureSize.x = textureSize.y = (float)quadTextureSize;
outputSize.x = GUI.Stretch?(float)dPresentParams.BackBufferWidth:(float)afterRenderWidth;
outputSize.y = GUI.Stretch?(float)dPresentParams.BackBufferHeight:(float)afterRenderHeight;
D3DXMatrixIdentity(&mvpMat);
if(cgpModelViewProj)
cgD3D9SetUniformMatrix(cgpModelViewProj,&mvpMat);
if(cgpVideoSize)
cgD3D9SetUniform(cgpVideoSize,&videoSize);
if(cgpTextureSize)
cgD3D9SetUniform(cgpTextureSize,&textureSize);
if(cgpOutputSize)
cgD3D9SetUniform(cgpOutputSize,&outputSize);
}
}
@ -579,10 +693,15 @@ void CDirect3D::Render(SSurface Src)
pDevice->SetFVF(FVF_COORDS_TEX);
pDevice->SetStreamSource(0,vertexBuffer,0,sizeof(VERTEX));
if (shader_compiled) {
if(shader_type == D3D_SHADER_CG) {
cgD3D9BindProgram(cgFragmentProgram);
cgD3D9BindProgram(cgVertexProgram);
}
SetShaderVars();
if (shader_type == D3D_SHADER_HLSL) {
UINT passes;
SetShaderVars();
hr = effect->Begin(&passes, 0);
for(UINT pass = 0; pass < passes; pass++ ) {
@ -893,8 +1012,8 @@ returns true if successful, false otherwise
*/
bool CDirect3D::ApplyDisplayChanges(void)
{
if(GUI.shaderEnabled && GUI.HLSLshaderFileName)
SetShader(GUI.HLSLshaderFileName);
if(GUI.shaderEnabled && GUI.D3DshaderFileName)
SetShader(GUI.D3DshaderFileName);
else
SetShader(NULL);

View File

@ -183,6 +183,9 @@
#include <d3dx9.h>
#include <windows.h>
#include <Cg/cg.h>
#include <Cg/cgD3D9.h>
#include "render.h"
#include "wsnes9x.h"
#include "IS9xDisplayOutput.h"
@ -199,6 +202,8 @@ typedef struct _VERTEX {
}
} VERTEX; //our custom vertex with a constuctor for easier assignment
enum current_d3d_shader_type { D3D_SHADER_NONE, D3D_SHADER_HLSL, D3D_SHADER_CG };
class CDirect3D: public IS9xDisplayOutput
{
private:
@ -218,7 +223,9 @@ private:
LPD3DXEFFECT effect;
LPDIRECT3DTEXTURE9 rubyLUT[MAX_SHADER_TEXTURES];
bool shader_compiled;
CGcontext cgContext;
CGprogram cgVertexProgram, cgFragmentProgram;
current_d3d_shader_type shader_type;
float shaderTimer;
int shaderTimeStart;
int shaderTimeElapsed;
@ -231,6 +238,8 @@ private:
bool ResetDevice();
void SetShaderVars();
bool SetShader(const TCHAR *file);
bool SetShaderHLSL(const TCHAR *file);
bool SetShaderCG(const TCHAR *file);
public:
CDirect3D();

View File

@ -9,6 +9,9 @@
#include "../filter/hq2x.h"
#include "../filter/2xsai.h"
#pragma comment( lib, "cg.lib" )
#pragma comment( lib, "cggl.lib" )
COpenGL::COpenGL(void)
{
@ -23,11 +26,13 @@ COpenGL::COpenGL(void)
afterRenderHeight = 0;
fullscreen = false;
shaderFunctionsLoaded = false;
shaderCompiled = false;
shader_type = OGL_SHADER_NONE;
pboFunctionsLoaded = false;
shaderProgram = 0;
vertexShader = 0;
fragmentShader = 0;
cgContext = NULL;
cgVertexProgram = cgFragmentProgram = NULL;
}
COpenGL::~COpenGL(void)
@ -99,6 +104,8 @@ bool COpenGL::Initialize(HWND hWnd)
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
cgContext = cgCreateContext();
GetClientRect(hWnd,&windowRect);
ChangeRenderSize(windowRect.right,windowRect.bottom);
@ -113,8 +120,7 @@ bool COpenGL::Initialize(HWND hWnd)
void COpenGL::DeInitialize()
{
initDone = false;
if(shaderCompiled)
SetShaders(NULL);
SetShaders(NULL);
DestroyDrawSurface();
wglMakeCurrent(NULL,NULL);
if(hRC) {
@ -132,7 +138,7 @@ void COpenGL::DeInitialize()
afterRenderWidth = 0;
afterRenderHeight = 0;
shaderFunctionsLoaded = false;
shaderCompiled = false;
shader_type = OGL_SHADER_NONE;
}
void COpenGL::CreateDrawSurface()
@ -254,24 +260,37 @@ void COpenGL::Render(SSurface Src)
ApplyDisplayChanges();
}
if (shaderCompiled) {
GLint location;
if (shader_type != OGL_SHADER_NONE) {
GLint location;
float inputSize[2] = { (float)afterRenderWidth, (float)afterRenderHeight };
location = glGetUniformLocation (shaderProgram, "rubyInputSize");
glUniform2fv (location, 1, inputSize);
RECT windowSize;
GetClientRect(hWnd,&windowSize);
float outputSize[2] = {(float)(GUI.Stretch?windowSize.right:afterRenderWidth),
(float)(GUI.Stretch?windowSize.bottom:afterRenderHeight) };
location = glGetUniformLocation (shaderProgram, "rubyOutputSize");
glUniform2fv (location, 1, outputSize);
float textureSize[2] = { (float)quadTextureSize, (float)quadTextureSize };
location = glGetUniformLocation (shaderProgram, "rubyTextureSize");
glUniform2fv (location, 1, textureSize);
if(shader_type == OGL_SHADER_GLSL) {
location = glGetUniformLocation (shaderProgram, "rubyInputSize");
glUniform2fv (location, 1, inputSize);
location = glGetUniformLocation (shaderProgram, "rubyOutputSize");
glUniform2fv (location, 1, outputSize);
location = glGetUniformLocation (shaderProgram, "rubyTextureSize");
glUniform2fv (location, 1, textureSize);
} else if(shader_type == OGL_SHADER_CG) {
CGparameter cgpModelViewProj = cgGetNamedParameter(cgVertexProgram, "modelViewProj");
CGparameter cgpVideoSize = cgGetNamedParameter(cgFragmentProgram, "IN.video_size");
CGparameter cgpTextureSize = cgGetNamedParameter(cgFragmentProgram, "IN.texture_size");
CGparameter cgpOutputSize = cgGetNamedParameter(cgFragmentProgram, "IN.output_size");
cgGLSetStateMatrixParameter(cgpModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
cgGLSetParameter2fv(cgpVideoSize, inputSize);
cgGLSetParameter2fv(cgpTextureSize, textureSize);
cgGLSetParameter2fv(cgpOutputSize, outputSize);
}
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, quadTextureSize);
@ -305,8 +324,8 @@ bool COpenGL::ApplyDisplayChanges(void)
if(wglSwapIntervalEXT) {
wglSwapIntervalEXT(GUI.Vsync?1:0);
}
if(GUI.shaderEnabled && GUI.GLSLshaderFileName)
SetShaders(GUI.GLSLshaderFileName);
if(GUI.shaderEnabled && GUI.OGLshaderFileName)
SetShaders(GUI.OGLshaderFileName);
else
SetShaders(NULL);
@ -456,32 +475,79 @@ bool COpenGL::LoadShaderFunctions()
return shaderFunctionsLoaded;
}
char *ReadFileContents(const TCHAR *filename)
bool COpenGL::SetShaders(const TCHAR *file)
{
HANDLE hFile;
DWORD size;
DWORD bytesRead;
char *contents;
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN , 0);
if(hFile == INVALID_HANDLE_VALUE){
return NULL;
SetShadersCG(NULL);
SetShadersGLSL(NULL);
shader_type = OGL_SHADER_NONE;
if(file!=NULL && lstrlen(file)>3 && _tcsncicmp(&file[lstrlen(file)-3],TEXT(".cg"),3)==0) {
return SetShadersCG(file);
} else {
return SetShadersGLSL(file);
}
size = GetFileSize(hFile,NULL);
contents = new char[size+1];
if(!ReadFile(hFile,contents,size,&bytesRead,NULL)) {
CloseHandle(hFile);
delete[] contents;
return NULL;
}
CloseHandle(hFile);
contents[size] = '\0';
return contents;
}
bool COpenGL::SetShaders(const TCHAR *glslFileName)
bool COpenGL::SetShadersCG(const TCHAR *file)
{
TCHAR errorMsg[MAX_PATH + 50];
HRESULT hr;
if(cgFragmentProgram) {
cgDestroyProgram(cgFragmentProgram);
cgFragmentProgram = NULL;
}
if(cgVertexProgram) {
cgDestroyProgram(cgVertexProgram);
cgVertexProgram = NULL;
}
CGprofile vertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
CGprofile fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLDisableProfile(vertexProfile);
cgGLDisableProfile(fragmentProfile);
if (file == NULL || *file==TEXT('\0'))
return true;
cgGLSetOptimalOptions(vertexProfile);
cgGLSetOptimalOptions(fragmentProfile);
char *fileContents = ReadShaderFileContents(file);
if(!fileContents)
return false;
cgVertexProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
vertexProfile, "main_vertex", NULL);
cgFragmentProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
fragmentProfile, "main_fragment", NULL);
delete [] fileContents;
if(!cgVertexProgram && !cgFragmentProgram) {
_stprintf(errorMsg,TEXT("No vertex or fragment program in file:\n%s"),file);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(cgVertexProgram) {
cgGLEnableProfile(vertexProfile);
cgGLLoadProgram(cgVertexProgram);
cgGLBindProgram(cgVertexProgram);
}
if(cgFragmentProgram) {
cgGLEnableProfile(fragmentProfile);
cgGLLoadProgram(cgFragmentProgram);
cgGLBindProgram(cgFragmentProgram);
}
shader_type = OGL_SHADER_CG;
return true;
}
bool COpenGL::SetShadersGLSL(const TCHAR *glslFileName)
{
char *fragment=NULL, *vertex=NULL;
IXMLDOMDocument * pXMLDoc = NULL;
@ -492,8 +558,6 @@ bool COpenGL::SetShaders(const TCHAR *glslFileName)
TCHAR errorMsg[MAX_PATH + 50];
shaderCompiled = false;
if(fragmentShader) {
glDetachShader(shaderProgram,fragmentShader);
glDeleteShader(fragmentShader);
@ -631,7 +695,7 @@ bool COpenGL::SetShaders(const TCHAR *glslFileName)
glLinkProgram(shaderProgram);
glUseProgram(shaderProgram);
shaderCompiled = true;
shader_type = OGL_SHADER_GLSL;
return true;
}

View File

@ -181,13 +181,15 @@
#include <windows.h>
#include <gl\gl.h>
#include <Cg/cg.h>
#include <Cg/cgGL.h>
#include "glext.h"
#include "wglext.h"
#include "IS9xDisplayOutput.h"
/* IS9xDisplayOutput
Interface for display driver.
*/
enum current_ogl_shader_type { OGL_SHADER_NONE, OGL_SHADER_GLSL, OGL_SHADER_CG };
class COpenGL : public IS9xDisplayOutput
{
private:
@ -207,10 +209,13 @@ private:
unsigned int afterRenderWidth, afterRenderHeight;
bool shaderFunctionsLoaded;
bool shaderCompiled;
bool pboFunctionsLoaded;
CGcontext cgContext;
CGprogram cgVertexProgram, cgFragmentProgram;
current_ogl_shader_type shader_type;
GLuint shaderProgram;
GLuint vertexShader;
GLuint fragmentShader;
@ -240,7 +245,9 @@ private:
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
bool SetShaders(const TCHAR *glslFileName);
bool SetShaders(const TCHAR *file);
bool SetShadersCG(const TCHAR *file);
bool SetShadersGLSL(const TCHAR *glslFileName);
bool LoadShaderFunctions();
bool LoadPBOFunctions();
void CreateDrawSurface(void);

View File

@ -550,15 +550,15 @@ inline void SetRect(RECT* rect, int width, int height, int scale)
}
#define AVERAGE_565(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0xF7DE) >> 1))
void RenderMergeHires(void *buffer, int pitch, unsigned int &width, unsigned int &height)
void RenderMergeHires(void *src, void* dst, int pitch, unsigned int &width, unsigned int &height)
{
if (width <= 256)
return;
for (register int y = 0; y < height; y++)
{
register uint16 *input = (uint16 *) ((uint8 *) buffer + y * pitch);
register uint16 *output = input;
register uint16 *input = (uint16 *) ((uint8 *) src + y * pitch);
register uint16 *output = (uint16 *) ((uint8 *) dst + y * pitch);
register uint16 l, r;
l = 0;

View File

@ -195,7 +195,7 @@ typedef void (*TRenderMethod)( SSurface Src, SSurface Dst, RECT *);
void SelectRenderMethod();
void InitLUTsWin32();
void RenderMergeHires(void *buffer, int pitch, unsigned int &width, unsigned int &height);
void RenderMergeHires(void *src, void* dst, int pitch, unsigned int &width, unsigned int &height);
extern TRenderMethod RenderMethod;
extern TRenderMethod RenderMethodHiRes;

View File

@ -218,10 +218,10 @@ BEGIN
LTEXT "Amount skipped:",IDC_STATIC,62,158,67,8
LTEXT "Output Method",IDC_STATIC,10,19,51,11
CONTROL "Use Shader",IDC_SHADER_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,176,52,9
LTEXT "HLSL Effect File",IDC_STATIC,13,187,104,8
LTEXT "Direct3D Shader File",IDC_STATIC,13,187,104,8
EDITTEXT IDC_SHADER_GLSL_FILE,13,227,306,14,ES_AUTOHSCROLL | WS_DISABLED
PUSHBUTTON "...",IDC_SHADER_GLSL_BROWSE,322,227,19,14,WS_DISABLED
LTEXT "GLSL shader",IDC_STATIC,13,216,104,8
LTEXT "OpenGL Shader File",IDC_STATIC,13,216,104,8
CONTROL "Blend Hi-Res Images",IDC_HIRESBLEND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,136,82,10
CONTROL "VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,102,37,10
END

View File

@ -865,8 +865,8 @@ void WinRegisterConfigItems()
AddUIntC("FilterHiRes", GUI.ScaleHiRes, 0, filterString2);
AddBoolC("BlendHiRes", GUI.BlendHiRes, true, "true to horizontally blend Hi-Res images (better transparency effect on filters that do not account for this)");
AddBoolC("ShaderEnabled", GUI.shaderEnabled, false, "true to use pixel shader (if supported by output method)");
AddStringC("Direct3D:HLSLFileName", GUI.HLSLshaderFileName, MAX_PATH, "", "shader filename for Direct3D mode");
AddStringC("OpenGL:GLSLFileName", GUI.GLSLshaderFileName, MAX_PATH, "", "shader filename for OpenGL mode (bsnes-style XML shader)");
AddStringC("Direct3D:D3DShader", GUI.D3DshaderFileName, MAX_PATH, "", "shader filename for Direct3D mode (HLSL effect file or CG shader");
AddStringC("OpenGL:OGLShader", GUI.OGLshaderFileName, MAX_PATH, "", "shader filename for OpenGL mode (bsnes-style XML shader or CG shader)");
AddBoolC("ExtendHeight", GUI.HeightExtend, false, "true to display an extra 15 pixels at the bottom, which few games use. Also increases AVI output size from 256x224 to 256x240.");
AddBoolC("AlwaysCenterImage", GUI.AlwaysCenterImage,false, "true to center the image even if larger than window");
AddIntC("Window:Width", GUI.window_size.right, 512, "256=1x, 512=2x, 768=3x, 1024=4x, etc. (usually)");

View File

@ -205,5 +205,6 @@ void WinDisplayStringFromBottom (const char *string, int linesFromBottom, int pi
void WinSetCustomDisplaySurface(void *screen, int ppl, int width, int height, int scale);
template<typename screenPtrType>
void WinDisplayStringInBuffer (const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap);
char *ReadShaderFileContents(const TCHAR *filename);
#endif

View File

@ -6958,10 +6958,10 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
// temporary GUI state for restoring after previewing while selecting options
static int prevScale, prevScaleHiRes, prevPPL;
static bool prevStretch, prevAspectRatio, prevHeightExtend, prevAutoDisplayMessages, prevBilinearFilter, prevShaderEnabled;
static bool prevStretch, prevAspectRatio, prevHeightExtend, prevAutoDisplayMessages, prevBilinearFilter, prevShaderEnabled, prevBlendHires;
static int prevAspectWidth;
static OutputMethod prevOutputMethod;
static TCHAR prevHLSLShaderFile[MAX_PATH],prevGLSLShaderFile[MAX_PATH];
static TCHAR prevD3DShaderFile[MAX_PATH],prevOGLShaderFile[MAX_PATH];
switch(msg)
{
@ -6989,8 +6989,9 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
prevHeightExtend = GUI.HeightExtend;
prevAutoDisplayMessages = Settings.AutoDisplayMessages != 0;
prevShaderEnabled = GUI.shaderEnabled;
lstrcpy(prevHLSLShaderFile,GUI.HLSLshaderFileName);
lstrcpy(prevGLSLShaderFile,GUI.GLSLshaderFileName);
prevBlendHires = GUI.BlendHiRes;
lstrcpy(prevD3DShaderFile,GUI.D3DshaderFileName);
lstrcpy(prevOGLShaderFile,GUI.OGLshaderFileName);
_stprintf(s,TEXT("Current: %dx%d %dbit %dHz"),GUI.FullscreenMode.width,GUI.FullscreenMode.height,GUI.FullscreenMode.depth,GUI.FullscreenMode.rate);
@ -7067,8 +7068,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
EnableWindow(GetDlgItem(hDlg, IDC_SHADER_GLSL_FILE),TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_SHADER_GLSL_BROWSE),TRUE);
}
SetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.HLSLshaderFileName);
SetDlgItemText(hDlg,IDC_SHADER_GLSL_FILE,GUI.GLSLshaderFileName);
SetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.D3DshaderFileName);
SetDlgItemText(hDlg,IDC_SHADER_GLSL_FILE,GUI.OGLshaderFileName);
lpfnOldWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg,IDC_SHADER_GROUP),GWLP_WNDPROC,(LONG_PTR)GroupBoxCheckBoxTitle);
@ -7187,6 +7188,11 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
WinRefreshDisplay();
break;
case IDC_HIRESBLEND:
GUI.BlendHiRes = (bool)(IsDlgButtonChecked(hDlg,IDC_HIRESBLEND)==BST_CHECKED);
WinRefreshDisplay();
break;
case IDC_AUTOFRAME:
if(BN_CLICKED==HIWORD(wParam)||BN_DBLCLK==HIWORD(wParam))
{
@ -7228,8 +7234,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
EnableWindow(GetDlgItem(hDlg, IDC_SHADER_GLSL_FILE),GUI.shaderEnabled);
EnableWindow(GetDlgItem(hDlg, IDC_SHADER_GLSL_BROWSE),GUI.shaderEnabled);
GetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.HLSLshaderFileName,MAX_PATH);
GetDlgItemText(hDlg,IDC_SHADER_GLSL_FILE,GUI.GLSLshaderFileName,MAX_PATH);
GetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.D3DshaderFileName,MAX_PATH);
GetDlgItemText(hDlg,IDC_SHADER_GLSL_FILE,GUI.OGLshaderFileName,MAX_PATH);
WinDisplayApplyChanges();
WinRefreshDisplay();
break;
@ -7239,7 +7245,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = TEXT("Shader Files\0*.shader\0All Files\0*.*\0\0");
ofn.lpstrFilter = TEXT("Shader Files\0*.shader;*.cg\0All Files\0*.*\0\0");
ofn.lpstrFile = openFileName;
ofn.lpstrTitle = TEXT("Select Shader");
ofn.lpstrDefExt = TEXT("shader");
@ -7247,7 +7253,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn)) {
SetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,openFileName);
lstrcpy(GUI.HLSLshaderFileName,openFileName);
lstrcpy(GUI.D3DshaderFileName,openFileName);
WinDisplayApplyChanges();
WinRefreshDisplay();
}
@ -7258,7 +7264,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = TEXT("Shader Files\0*.shader\0All Files\0*.*\0\0");
ofn.lpstrFilter = TEXT("Shader Files\0*.shader;*.cg\0All Files\0*.*\0\0");
ofn.lpstrFile = openFileName;
ofn.lpstrTitle = TEXT("Select Shader");
ofn.lpstrDefExt = TEXT("shader");
@ -7266,7 +7272,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn)) {
SetDlgItemText(hDlg,IDC_SHADER_GLSL_FILE,openFileName);
lstrcpy(GUI.GLSLshaderFileName,openFileName);
lstrcpy(GUI.OGLshaderFileName,openFileName);
WinDisplayApplyChanges();
WinRefreshDisplay();
}
@ -7394,7 +7400,7 @@ updateFilterBox2:
GUI.FullscreenMode = dm[index];
GetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.HLSLshaderFileName,MAX_PATH);
GetDlgItemText(hDlg,IDC_SHADER_HLSL_FILE,GUI.D3DshaderFileName,MAX_PATH);
// we might've changed the region that the game draws over
@ -7446,8 +7452,9 @@ updateFilterBox2:
GUI.AspectWidth = prevAspectWidth;
GUI.HeightExtend = prevHeightExtend;
GUI.shaderEnabled = prevShaderEnabled;
lstrcpy(GUI.HLSLshaderFileName,prevHLSLShaderFile);
lstrcpy(GUI.GLSLshaderFileName,prevGLSLShaderFile);
GUI.BlendHiRes = prevBlendHires;
lstrcpy(GUI.D3DshaderFileName,prevD3DShaderFile);
lstrcpy(GUI.OGLshaderFileName,prevOGLShaderFile);
}
EndDialog(hDlg,0);