mirror of
https://github.com/libretro/snes9x.git
synced 2024-12-14 04:28:36 +00:00
Add rudimentary Cg support for Gtk+ based on the Win32 port.
This commit is contained in:
parent
0c1976b0ef
commit
b34ecf8973
@ -234,7 +234,10 @@ endif
|
||||
if OPENGL
|
||||
snes9x_gtk_SOURCES += \
|
||||
src/gtk_display_driver_opengl.cpp \
|
||||
src/gtk_display_driver_opengl.h
|
||||
src/gtk_display_driver_opengl.h \
|
||||
src/Cg/CGLCG.cpp \
|
||||
src/Cg/cgFunctions.cpp \
|
||||
src/Cg/CCGShader.cpp
|
||||
endif
|
||||
|
||||
if XV
|
||||
|
0
gtk/src/Cg/.dirstamp
Normal file
0
gtk/src/Cg/.dirstamp
Normal file
338
gtk/src/Cg/CCGShader.cpp
Normal file
338
gtk/src/Cg/CCGShader.cpp
Normal file
@ -0,0 +1,338 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
#include "CCGShader.h"
|
||||
#include "../conffile.h"
|
||||
|
||||
CCGShader::CCGShader(void) {}
|
||||
|
||||
CCGShader::~CCGShader(void) {}
|
||||
|
||||
cgScaleType CCGShader::scaleStringToEnum(const char* scale)
|
||||
{
|
||||
if (!strcasecmp(scale, "source"))
|
||||
{
|
||||
return CG_SCALE_SOURCE;
|
||||
}
|
||||
else if (!strcasecmp(scale, "viewport"))
|
||||
{
|
||||
return CG_SCALE_VIEWPORT;
|
||||
}
|
||||
else if (!strcasecmp(scale, "absolute"))
|
||||
{
|
||||
return CG_SCALE_ABSOLUTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CG_SCALE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
bool CCGShader::LoadShader(const char* path)
|
||||
{
|
||||
ConfigFile conf;
|
||||
int shaderCount;
|
||||
char keyName[100];
|
||||
|
||||
shaderPasses.clear();
|
||||
lookupTextures.clear();
|
||||
|
||||
if (strlen(path) < 4 || strcasecmp(&path[strlen(path) - 4], ".cgp"))
|
||||
{
|
||||
shaderPass pass;
|
||||
pass.scaleParams.scaleTypeX = CG_SCALE_NONE;
|
||||
pass.scaleParams.scaleTypeY = CG_SCALE_NONE;
|
||||
pass.linearFilter = false;
|
||||
pass.filterSet = false;
|
||||
strcpy(pass.cgShaderFile, path);
|
||||
shaderPasses.push_back(pass);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
conf.LoadFile(path);
|
||||
}
|
||||
|
||||
shaderCount = conf.GetInt("::shaders", 0);
|
||||
|
||||
if (shaderCount < 1)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < shaderCount; i++)
|
||||
{
|
||||
shaderPass pass;
|
||||
sprintf(keyName, "::filter_linear%u", i);
|
||||
pass.linearFilter = conf.GetBool(keyName);
|
||||
pass.filterSet = conf.Exists(keyName);
|
||||
|
||||
sprintf(keyName, "::scale_type%u", i);
|
||||
const char* scaleType = conf.GetString(keyName, "");
|
||||
|
||||
if (!strcasecmp(scaleType, ""))
|
||||
{
|
||||
sprintf(keyName, "::scale_type_x%u", i);
|
||||
const char* scaleTypeX = conf.GetString(keyName, "");
|
||||
|
||||
if (*scaleTypeX == '\0' && (i != (shaderCount - 1)))
|
||||
scaleTypeX = "source";
|
||||
|
||||
pass.scaleParams.scaleTypeX = scaleStringToEnum(scaleTypeX);
|
||||
|
||||
sprintf(keyName, "::scale_type_y%u", i);
|
||||
const char* scaleTypeY = conf.GetString(keyName, "");
|
||||
|
||||
if (*scaleTypeY == '\0' && (i != (shaderCount - 1)))
|
||||
scaleTypeY = "source";
|
||||
|
||||
pass.scaleParams.scaleTypeY = scaleStringToEnum(scaleTypeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
cgScaleType sType = scaleStringToEnum(scaleType);
|
||||
pass.scaleParams.scaleTypeX = sType;
|
||||
pass.scaleParams.scaleTypeY = sType;
|
||||
}
|
||||
|
||||
sprintf(keyName, "::scale%u", i);
|
||||
const char* scaleFloat = conf.GetString(keyName, "");
|
||||
int scaleInt = conf.GetInt(keyName, 0);
|
||||
if (!strcasecmp(scaleFloat, ""))
|
||||
{
|
||||
sprintf(keyName, "::scale_x%u", i);
|
||||
const char* scaleFloatX = conf.GetString(keyName, "1.0");
|
||||
pass.scaleParams.scaleX = atof(scaleFloatX);
|
||||
pass.scaleParams.absX = conf.GetInt(keyName, 1);
|
||||
sprintf(keyName, "::scale_y%u", i);
|
||||
const char* scaleFloatY = conf.GetString(keyName, "1.0");
|
||||
pass.scaleParams.scaleY = atof(scaleFloatY);
|
||||
pass.scaleParams.absY = conf.GetInt(keyName, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
float floatval = atof(scaleFloat);
|
||||
pass.scaleParams.scaleX = floatval;
|
||||
pass.scaleParams.absX = scaleInt;
|
||||
pass.scaleParams.scaleY = floatval;
|
||||
pass.scaleParams.absY = scaleInt;
|
||||
}
|
||||
|
||||
sprintf(keyName, "::shader%u", i);
|
||||
strcpy(pass.cgShaderFile, conf.GetString(keyName, ""));
|
||||
|
||||
sprintf(keyName, "::frame_count_mod%u", i);
|
||||
pass.frameCounterMod = conf.GetInt(keyName, 0);
|
||||
|
||||
sprintf(keyName, "::float_framebuffer%u", i);
|
||||
pass.floatFbo = conf.GetBool(keyName);
|
||||
|
||||
shaderPasses.push_back(pass);
|
||||
}
|
||||
|
||||
char* shaderIds = conf.GetStringDup("::textures", "");
|
||||
|
||||
char* id = strtok(shaderIds, ";");
|
||||
|
||||
while (id != NULL)
|
||||
{
|
||||
lookupTexture tex;
|
||||
sprintf(keyName, "::%s", id);
|
||||
strcpy(tex.id, id);
|
||||
strcpy(tex.texturePath, conf.GetString(keyName, ""));
|
||||
sprintf(keyName, "::%s_linear", id);
|
||||
tex.linearfilter = conf.GetBool(keyName, true);
|
||||
lookupTextures.push_back(tex);
|
||||
id = strtok(NULL, ";");
|
||||
}
|
||||
|
||||
free(shaderIds);
|
||||
|
||||
return true;
|
||||
}
|
250
gtk/src/Cg/CCGShader.h
Normal file
250
gtk/src/Cg/CCGShader.h
Normal file
@ -0,0 +1,250 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
#ifndef CCGSHADER_H
|
||||
#define CCGSHADER_H
|
||||
|
||||
#include "cgFunctions.h"
|
||||
#include "port.h"
|
||||
#include <vector>
|
||||
|
||||
enum cgScaleType
|
||||
{
|
||||
CG_SCALE_NONE,
|
||||
CG_SCALE_SOURCE,
|
||||
CG_SCALE_VIEWPORT,
|
||||
CG_SCALE_ABSOLUTE
|
||||
};
|
||||
|
||||
typedef struct _cgScaleParams
|
||||
{
|
||||
cgScaleType scaleTypeX;
|
||||
cgScaleType scaleTypeY;
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
unsigned absX;
|
||||
unsigned absY;
|
||||
} cgScaleParams;
|
||||
|
||||
class CCGShader
|
||||
{
|
||||
private:
|
||||
cgScaleType scaleStringToEnum(const char* scale);
|
||||
|
||||
public:
|
||||
typedef struct _shaderPass
|
||||
{
|
||||
cgScaleParams scaleParams;
|
||||
bool linearFilter;
|
||||
bool filterSet;
|
||||
bool floatFbo;
|
||||
unsigned frameCounterMod;
|
||||
char cgShaderFile[PATH_MAX];
|
||||
} shaderPass;
|
||||
|
||||
typedef struct _lookupTexture
|
||||
{
|
||||
char id[PATH_MAX];
|
||||
char texturePath[PATH_MAX];
|
||||
bool linearfilter;
|
||||
} lookupTexture;
|
||||
|
||||
CCGShader(void);
|
||||
~CCGShader(void);
|
||||
bool LoadShader(const char* path);
|
||||
|
||||
typedef std::vector<shaderPass> passVector;
|
||||
typedef std::vector<lookupTexture> lutVector;
|
||||
passVector shaderPasses;
|
||||
lutVector lookupTextures;
|
||||
};
|
||||
|
||||
#endif
|
1132
gtk/src/Cg/CGLCG.cpp
Normal file
1132
gtk/src/Cg/CGLCG.cpp
Normal file
File diff suppressed because it is too large
Load Diff
326
gtk/src/Cg/CGLCG.h
Normal file
326
gtk/src/Cg/CGLCG.h
Normal file
@ -0,0 +1,326 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
#ifndef CGGLCG_H
|
||||
#define CGGLCG_H
|
||||
|
||||
#include "CCGShader.h"
|
||||
#include "GL/glext.h"
|
||||
#include "cgFunctions.h"
|
||||
#include <GL/gl.h>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
typedef struct _xySize
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
operator const float*() const;
|
||||
} xySize;
|
||||
|
||||
class CGLCG
|
||||
{
|
||||
private:
|
||||
typedef struct _STGA
|
||||
{
|
||||
_STGA()
|
||||
{
|
||||
data = (unsigned char*)0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
byteCount = 0;
|
||||
}
|
||||
|
||||
~_STGA()
|
||||
{
|
||||
delete[] data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
delete[] data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
unsigned char byteCount;
|
||||
unsigned char* data;
|
||||
} STGA;
|
||||
|
||||
typedef struct _shaderPass
|
||||
{
|
||||
cgScaleParams scaleParams;
|
||||
bool linearFilter;
|
||||
unsigned frameCounterMod;
|
||||
bool floatFbo;
|
||||
CGprogram cgVertexProgram, cgFragmentProgram;
|
||||
GLuint tex;
|
||||
GLuint fbo;
|
||||
xySize outputSize;
|
||||
xySize textureSize;
|
||||
GLfloat texcoords[8];
|
||||
_shaderPass()
|
||||
{
|
||||
cgVertexProgram = NULL;
|
||||
cgFragmentProgram = NULL;
|
||||
fbo = 0;
|
||||
tex = 0;
|
||||
}
|
||||
} shaderPass;
|
||||
|
||||
typedef struct _prevPass
|
||||
{
|
||||
GLuint tex;
|
||||
xySize videoSize;
|
||||
xySize textureSize;
|
||||
GLfloat texCoords[8];
|
||||
_prevPass() { tex = 0; }
|
||||
} prevPass;
|
||||
|
||||
typedef struct _lookupTexture
|
||||
{
|
||||
char id[PATH_MAX];
|
||||
GLuint tex;
|
||||
_lookupTexture() { tex = 0; }
|
||||
} lookupTexture;
|
||||
|
||||
typedef std::vector<shaderPass> glPassVector;
|
||||
typedef std::vector<lookupTexture> glLutVector;
|
||||
typedef std::deque<prevPass> glPrevDeque;
|
||||
typedef std::vector<CGparameter> glAttribParams;
|
||||
glPassVector shaderPasses;
|
||||
glLutVector lookupTextures;
|
||||
glPrevDeque prevPasses;
|
||||
glAttribParams cgAttribParams;
|
||||
|
||||
bool fboFunctionsLoaded;
|
||||
bool shaderLoaded;
|
||||
bool LoadFBOFunctions();
|
||||
void checkForCgError(const char* situation);
|
||||
void setTexCoords(int pass,
|
||||
xySize inputSize,
|
||||
xySize textureSize,
|
||||
bool topdown = false);
|
||||
void setShaderVars(int pass);
|
||||
void resetAttribParams();
|
||||
bool loadPngImage(const char* name,
|
||||
int& outWidth,
|
||||
int& outHeight,
|
||||
bool& outHasAlpha,
|
||||
GLubyte** outData);
|
||||
bool loadTGA(const char* filename, STGA& tgaFile);
|
||||
|
||||
CGcontext cgContext;
|
||||
unsigned int frameCnt;
|
||||
static const GLfloat lut_coords[8];
|
||||
|
||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
PFNGLACTIVETEXTUREPROC glClientActiveTexture;
|
||||
|
||||
public:
|
||||
CGLCG(CGcontext cgContext);
|
||||
~CGLCG(void);
|
||||
|
||||
bool LoadShader(const char* shaderFile);
|
||||
void Render(GLuint& origTex,
|
||||
xySize textureSize,
|
||||
xySize inputSize,
|
||||
xySize viewportSize);
|
||||
void ClearPasses();
|
||||
};
|
||||
|
||||
#endif
|
338
gtk/src/Cg/cgFunctions.cpp
Normal file
338
gtk/src/Cg/cgFunctions.cpp
Normal file
@ -0,0 +1,338 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
|
||||
#include "cgFunctions.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void* hCgDll = NULL;
|
||||
void* hCgGLDll = NULL;
|
||||
|
||||
// cg.dll
|
||||
CGCC cgCreateContext = NULL;
|
||||
CGDC cgDestroyContext = NULL;
|
||||
CGGNP cgGetNamedParameter = NULL;
|
||||
CGGE cgGetError = NULL;
|
||||
CGGES cgGetErrorString = NULL;
|
||||
CGGLL cgGetLastListing = NULL;
|
||||
CGCP cgCreateProgram = NULL;
|
||||
CGDP cgDestroyProgram = NULL;
|
||||
CGGPRI cgGetParameterResourceIndex = NULL;
|
||||
CGGFP cgGetFirstParameter = NULL;
|
||||
CGGNEP cgGetNextParameter = NULL;
|
||||
CGGPD cgGetParameterDirection = NULL;
|
||||
CGGPS cgGetParameterSemantic = NULL;
|
||||
CGGRS cgGetResourceString = NULL;
|
||||
CGGPV cgGetParameterVariability = NULL;
|
||||
CGGPT cgGetParameterType = NULL;
|
||||
CGGFSP cgGetFirstStructParameter = NULL;
|
||||
CGGPN cgGetParameterName = NULL;
|
||||
// cggl.dll
|
||||
CGGLSSMP cgGLSetStateMatrixParameter = NULL;
|
||||
CGGLSP2FV cgGLSetParameter2fv = NULL;
|
||||
CGGLSP1F cgGLSetParameter1f = NULL;
|
||||
CGGLGLP cgGLGetLatestProfile = NULL;
|
||||
CGGLEP cgGLEnableProfile = NULL;
|
||||
CGGLDP cgGLDisableProfile = NULL;
|
||||
CGGLSOO cgGLSetOptimalOptions = NULL;
|
||||
CGGLLP cgGLLoadProgram = NULL;
|
||||
CGGLBP cgGLBindProgram = NULL;
|
||||
CGGLSTP cgGLSetTextureParameter = NULL;
|
||||
CGGLETP cgGLEnableTextureParameter = NULL;
|
||||
CGGLSPP cgGLSetParameterPointer = NULL;
|
||||
CGGLECS cgGLEnableClientState = NULL;
|
||||
CGGLDCS cgGLDisableClientState = NULL;
|
||||
|
||||
bool loadCgFunctions()
|
||||
{
|
||||
if (hCgDll && hCgGLDll)
|
||||
return true;
|
||||
|
||||
hCgDll = dlopen("libCg.so", RTLD_LAZY);
|
||||
if (hCgDll)
|
||||
{
|
||||
hCgGLDll = dlopen("libCgGL.so", RTLD_LAZY);
|
||||
}
|
||||
|
||||
if (!hCgDll || !hCgGLDll)
|
||||
{
|
||||
unloadCgLibrary();
|
||||
return false;
|
||||
}
|
||||
// cg.dll
|
||||
cgCreateContext = (CGCC)dlsym(hCgDll, "cgCreateContext");
|
||||
cgDestroyContext = (CGDC)dlsym(hCgDll, "cgDestroyContext");
|
||||
cgGetNamedParameter = (CGGNP)dlsym(hCgDll, "cgGetNamedParameter");
|
||||
cgGetError = (CGGE)dlsym(hCgDll, "cgGetError");
|
||||
cgGetErrorString = (CGGES)dlsym(hCgDll, "cgGetErrorString");
|
||||
cgGetLastListing = (CGGLL)dlsym(hCgDll, "cgGetLastListing");
|
||||
cgCreateProgram = (CGCP)dlsym(hCgDll, "cgCreateProgram");
|
||||
cgDestroyProgram = (CGDP)dlsym(hCgDll, "cgDestroyProgram");
|
||||
cgGetParameterResourceIndex = (CGGPRI)dlsym(hCgDll, "cgGetParameterResourceIndex");
|
||||
cgGetFirstParameter = (CGGFP)dlsym(hCgDll, "cgGetFirstParameter");
|
||||
cgGetNextParameter = (CGGNEP)dlsym(hCgDll, "cgGetNextParameter");
|
||||
cgGetParameterDirection = (CGGPD)dlsym(hCgDll, "cgGetParameterDirection");
|
||||
cgGetParameterSemantic = (CGGPS)dlsym(hCgDll, "cgGetParameterSemantic");
|
||||
cgGetResourceString = (CGGRS)dlsym(hCgDll, "cgGetResourceString");
|
||||
cgGetParameterVariability = (CGGPV)dlsym(hCgDll, "cgGetParameterVariability");
|
||||
cgGetParameterType = (CGGPT)dlsym(hCgDll, "cgGetParameterType");
|
||||
cgGetFirstStructParameter = (CGGFSP)dlsym(hCgDll, "cgGetFirstStructParameter");
|
||||
cgGetParameterName = (CGGPN)dlsym(hCgDll, "cgGetParameterName");
|
||||
// cggl.dll
|
||||
cgGLSetStateMatrixParameter = (CGGLSSMP)dlsym(hCgGLDll, "cgGLSetStateMatrixParameter");
|
||||
cgGLSetParameter2fv = (CGGLSP2FV)dlsym(hCgGLDll, "cgGLSetParameter2fv");
|
||||
cgGLSetParameter1f = (CGGLSP1F)dlsym(hCgGLDll, "cgGLSetParameter1f");
|
||||
cgGLGetLatestProfile = (CGGLGLP)dlsym(hCgGLDll, "cgGLGetLatestProfile");
|
||||
cgGLEnableProfile = (CGGLEP)dlsym(hCgGLDll, "cgGLEnableProfile");
|
||||
cgGLDisableProfile = (CGGLDP)dlsym(hCgGLDll, "cgGLDisableProfile");
|
||||
cgGLSetOptimalOptions = (CGGLSOO)dlsym(hCgGLDll, "cgGLSetOptimalOptions");
|
||||
cgGLLoadProgram = (CGGLLP)dlsym(hCgGLDll, "cgGLLoadProgram");
|
||||
cgGLBindProgram = (CGGLBP)dlsym(hCgGLDll, "cgGLBindProgram");
|
||||
cgGLSetTextureParameter = (CGGLSTP)dlsym(hCgGLDll, "cgGLSetTextureParameter");
|
||||
cgGLEnableTextureParameter = (CGGLETP)dlsym(hCgGLDll, "cgGLEnableTextureParameter");
|
||||
cgGLSetParameterPointer = (CGGLSPP)dlsym(hCgGLDll, "cgGLSetParameterPointer");
|
||||
cgGLEnableClientState = (CGGLECS)dlsym(hCgGLDll, "cgGLEnableClientState");
|
||||
cgGLDisableClientState = (CGGLDCS)dlsym(hCgGLDll, "cgGLDisableClientState");
|
||||
|
||||
if (
|
||||
// cg.dll
|
||||
!cgCreateContext || !cgDestroyContext || !cgGetNamedParameter || !cgGetError || !cgGetErrorString || !cgGetLastListing || !cgCreateProgram || !cgDestroyProgram || !cgGetParameterResourceIndex || !cgGetFirstParameter || !cgGetNextParameter || !cgGetParameterDirection || !cgGetParameterSemantic || !cgGetResourceString || !cgGetParameterVariability || !cgGetParameterType || !cgGetFirstStructParameter || !cgGetParameterName ||
|
||||
// cggl.dll
|
||||
!cgGLSetStateMatrixParameter || !cgGLSetParameter2fv || !cgGLSetParameter1f || !cgGLGetLatestProfile || !cgGLEnableProfile || !cgGLDisableProfile || !cgGLSetOptimalOptions || !cgGLLoadProgram || !cgGLBindProgram || !cgGLSetTextureParameter || !cgGLEnableTextureParameter || !cgGLSetParameterPointer || !cgGLEnableClientState || !cgGLDisableClientState)
|
||||
{
|
||||
unloadCgLibrary();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unloadCgLibrary()
|
||||
{
|
||||
if (hCgDll)
|
||||
dlclose(hCgDll);
|
||||
if (hCgGLDll)
|
||||
dlclose(hCgGLDll);
|
||||
|
||||
hCgDll = hCgGLDll = NULL;
|
||||
|
||||
// cg.dll
|
||||
cgCreateContext = NULL;
|
||||
cgDestroyContext = NULL;
|
||||
cgGetNamedParameter = NULL;
|
||||
cgGetError = NULL;
|
||||
cgGetErrorString = NULL;
|
||||
cgGetLastListing = NULL;
|
||||
cgCreateProgram = NULL;
|
||||
cgDestroyProgram = NULL;
|
||||
cgGetParameterResourceIndex = NULL;
|
||||
cgGetFirstParameter = NULL;
|
||||
cgGetNextParameter = NULL;
|
||||
cgGetParameterDirection = NULL;
|
||||
cgGetParameterSemantic = NULL;
|
||||
cgGetResourceString = NULL;
|
||||
cgGetParameterVariability = NULL;
|
||||
cgGetParameterType = NULL;
|
||||
cgGetFirstStructParameter = NULL;
|
||||
cgGetParameterName = NULL;
|
||||
// cggl.dll
|
||||
cgGLSetStateMatrixParameter = NULL;
|
||||
cgGLSetParameter2fv = NULL;
|
||||
cgGLGetLatestProfile = NULL;
|
||||
cgGLEnableProfile = NULL;
|
||||
cgGLDisableProfile = NULL;
|
||||
cgGLSetOptimalOptions = NULL;
|
||||
cgGLLoadProgram = NULL;
|
||||
cgGLBindProgram = NULL;
|
||||
cgGLEnableClientState = NULL;
|
||||
cgGLDisableClientState = NULL;
|
||||
}
|
292
gtk/src/Cg/cgFunctions.h
Normal file
292
gtk/src/Cg/cgFunctions.h
Normal file
@ -0,0 +1,292 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
|
||||
#ifndef CGFUNCTIONS_H
|
||||
#define CGFUNCTIONS_H
|
||||
|
||||
#include "cgMini.h"
|
||||
|
||||
// cg.dll
|
||||
typedef CG_API
|
||||
CGcontext(CGENTRY* CGCC)(void);
|
||||
extern CGCC cgCreateContext;
|
||||
typedef CG_API void(CGENTRY* CGDC)(CGcontext context);
|
||||
extern CGDC cgDestroyContext;
|
||||
typedef CG_API
|
||||
CGparameter(CGENTRY* CGGNP)(CGprogram program, const char* name);
|
||||
extern CGGNP cgGetNamedParameter;
|
||||
typedef CG_API
|
||||
CGerror(CGENTRY* CGGE)(void);
|
||||
extern CGGE cgGetError;
|
||||
typedef CG_API const char*(CGENTRY* CGGES)(CGerror error);
|
||||
extern CGGES cgGetErrorString;
|
||||
typedef CG_API const char*(CGENTRY* CGGLL)(CGcontext context);
|
||||
extern CGGLL cgGetLastListing;
|
||||
typedef CG_API
|
||||
CGprogram(CGENTRY* CGCP)(CGcontext context,
|
||||
CGenum program_type,
|
||||
const char* program,
|
||||
CGprofile profile,
|
||||
const char* entry,
|
||||
const char** args);
|
||||
extern CGCP cgCreateProgram;
|
||||
typedef CG_API void(CGENTRY* CGDP)(CGprogram program);
|
||||
extern CGDP cgDestroyProgram;
|
||||
typedef CG_API unsigned long(CGENTRY* CGGPRI)(CGparameter param);
|
||||
extern CGGPRI cgGetParameterResourceIndex;
|
||||
typedef CG_API
|
||||
CGparameter(CGENTRY* CGGFP)(CGprogram program, CGenum name_space);
|
||||
extern CGGFP cgGetFirstParameter;
|
||||
typedef CG_API
|
||||
CGparameter(CGENTRY* CGGNEP)(CGparameter current);
|
||||
extern CGGNEP cgGetNextParameter;
|
||||
typedef CG_API
|
||||
CGenum(CGENTRY* CGGPD)(CGparameter param);
|
||||
extern CGGPD cgGetParameterDirection;
|
||||
typedef CG_API const char*(CGENTRY* CGGPS)(CGparameter param);
|
||||
extern CGGPS cgGetParameterSemantic;
|
||||
typedef CG_API const char*(CGENTRY* CGGRS)(CGresource resource);
|
||||
extern CGGRS cgGetResourceString;
|
||||
typedef CG_API
|
||||
CGenum(CGENTRY* CGGPV)(CGparameter param);
|
||||
extern CGGPV cgGetParameterVariability;
|
||||
typedef CG_API
|
||||
CGtype(CGENTRY* CGGPT)(CGparameter param);
|
||||
extern CGGPT cgGetParameterType;
|
||||
typedef CG_API
|
||||
CGparameter(CGENTRY* CGGFSP)(CGparameter param);
|
||||
extern CGGFSP cgGetFirstStructParameter;
|
||||
typedef CG_API const char*(CGENTRY* CGGPN)(CGparameter param);
|
||||
extern CGGPN cgGetParameterName;
|
||||
|
||||
// cggl.dll
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSSMP)(CGparameter param,
|
||||
CGGLenum matrix,
|
||||
CGGLenum transform);
|
||||
extern CGGLSSMP cgGLSetStateMatrixParameter;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSP1F)(CGparameter param, float x);
|
||||
extern CGGLSP1F cgGLSetParameter1f;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSP2FV)(CGparameter param, const float* v);
|
||||
extern CGGLSP2FV cgGLSetParameter2fv;
|
||||
typedef CGGL_API
|
||||
CGprofile(CGGLENTRY* CGGLGLP)(CGGLenum profile_type);
|
||||
extern CGGLGLP cgGLGetLatestProfile;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLEP)(CGprofile profile);
|
||||
extern CGGLEP cgGLEnableProfile;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLDP)(CGprofile profile);
|
||||
extern CGGLDP cgGLDisableProfile;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSOO)(CGprofile profile);
|
||||
extern CGGLSOO cgGLSetOptimalOptions;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLLP)(CGprogram program);
|
||||
extern CGGLLP cgGLLoadProgram;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLBP)(CGprogram program);
|
||||
extern CGGLBP cgGLBindProgram;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSTP)(CGparameter param, GLuint texobj);
|
||||
extern CGGLSTP cgGLSetTextureParameter;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLETP)(CGparameter param);
|
||||
extern CGGLETP cgGLEnableTextureParameter;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLSPP)(CGparameter param,
|
||||
GLint fsize,
|
||||
GLenum type,
|
||||
GLsizei stride,
|
||||
const GLvoid* pointer);
|
||||
extern CGGLSPP cgGLSetParameterPointer;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLECS)(CGparameter param);
|
||||
extern CGGLECS cgGLEnableClientState;
|
||||
typedef CGGL_API void(CGGLENTRY* CGGLDCS)(CGparameter param);
|
||||
extern CGGLDCS cgGLDisableClientState;
|
||||
|
||||
// cgfunctions.cpp
|
||||
bool loadCgFunctions();
|
||||
void unloadCgLibrary();
|
||||
|
||||
#endif // CGFUNCTIONS_H
|
661
gtk/src/Cg/cgMini.h
Normal file
661
gtk/src/Cg/cgMini.h
Normal file
@ -0,0 +1,661 @@
|
||||
/***********************************************************************************
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
|
||||
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
|
||||
Jerremy Koot (jkoot@snes9x.com)
|
||||
|
||||
(c) Copyright 2002 - 2004 Matthew Kendora
|
||||
|
||||
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
|
||||
|
||||
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
|
||||
|
||||
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
|
||||
|
||||
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
|
||||
Kris Bleakley (codeviolation@hotmail.com)
|
||||
|
||||
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
|
||||
Nach (n-a-c-h@users.sourceforge.net),
|
||||
|
||||
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
|
||||
|
||||
(c) Copyright 2006 - 2007 nitsuja
|
||||
|
||||
(c) Copyright 2009 - 2017 BearOso,
|
||||
OV2
|
||||
|
||||
(c) Copyright 2017 qwertymodo
|
||||
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
BS-X C emulator code
|
||||
(c) Copyright 2005 - 2006 Dreamer Nom,
|
||||
zones
|
||||
|
||||
C4 x86 assembler and some C emulation code
|
||||
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
|
||||
Nach,
|
||||
zsKnight (zsknight@zsnes.com)
|
||||
|
||||
C4 C++ code
|
||||
(c) Copyright 2003 - 2006 Brad Jorsch,
|
||||
Nach
|
||||
|
||||
DSP-1 emulator code
|
||||
(c) Copyright 1998 - 2006 _Demo_,
|
||||
Andreas Naive (andreasnaive@gmail.com),
|
||||
Gary Henderson,
|
||||
Ivar (ivar@snes9x.com),
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
neviksti (neviksti@hotmail.com)
|
||||
|
||||
DSP-2 emulator code
|
||||
(c) Copyright 2003 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lord Nightmare
|
||||
(lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti
|
||||
|
||||
DSP-3 emulator code
|
||||
(c) Copyright 2003 - 2006 John Weidman,
|
||||
Kris Bleakley,
|
||||
Lancer,
|
||||
z80 gaiden
|
||||
|
||||
DSP-4 emulator code
|
||||
(c) Copyright 2004 - 2006 Dreamer Nom,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Nach,
|
||||
z80 gaiden
|
||||
|
||||
OBC1 emulator code
|
||||
(c) Copyright 2001 - 2004 zsKnight,
|
||||
pagefault (pagefault@zsnes.com),
|
||||
Kris Bleakley
|
||||
Ported from x86 assembler to C by sanmaiwashi
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.39-1.51
|
||||
(c) Copyright 2002 Matthew Kendora with research by
|
||||
zsKnight,
|
||||
John Weidman,
|
||||
Dark Force
|
||||
|
||||
SPC7110 and RTC C++ emulator code used in 1.52+
|
||||
(c) Copyright 2009 byuu,
|
||||
neviksti
|
||||
|
||||
S-DD1 C emulator code
|
||||
(c) Copyright 2003 Brad Jorsch with research by
|
||||
Andreas Naive,
|
||||
John Weidman
|
||||
|
||||
S-RTC C emulator code
|
||||
(c) Copyright 2001 - 2006 byuu,
|
||||
John Weidman
|
||||
|
||||
ST010 C++ emulator code
|
||||
(c) Copyright 2003 Feather,
|
||||
John Weidman,
|
||||
Kris Bleakley,
|
||||
Matthew Kendora
|
||||
|
||||
Super FX x86 assembler emulator code
|
||||
(c) Copyright 1998 - 2003 _Demo_,
|
||||
pagefault,
|
||||
zsKnight
|
||||
|
||||
Super FX C emulator code
|
||||
(c) Copyright 1997 - 1999 Ivar,
|
||||
Gary Henderson,
|
||||
John Weidman
|
||||
|
||||
Sound emulator code used in 1.5-1.51
|
||||
(c) Copyright 1998 - 2003 Brad Martin
|
||||
(c) Copyright 1998 - 2006 Charles Bilyue'
|
||||
|
||||
Sound emulator code used in 1.52+
|
||||
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
|
||||
|
||||
S-SMP emulator code used in 1.54+
|
||||
(c) Copyright 2016 byuu
|
||||
|
||||
SH assembler code partly based on x86 assembler code
|
||||
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
|
||||
|
||||
2xSaI filter
|
||||
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
|
||||
|
||||
HQ2x, HQ3x, HQ4x filters
|
||||
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
|
||||
|
||||
NTSC filter
|
||||
(c) Copyright 2006 - 2007 Shay Green
|
||||
|
||||
GTK+ GUI code
|
||||
(c) Copyright 2004 - 2017 BearOso
|
||||
|
||||
Win32 GUI code
|
||||
(c) Copyright 2003 - 2006 blip,
|
||||
funkyass,
|
||||
Matthew Kendora,
|
||||
Nach,
|
||||
nitsuja
|
||||
(c) Copyright 2009 - 2017 OV2
|
||||
|
||||
Mac OS GUI code
|
||||
(c) Copyright 1998 - 2001 John Stiles
|
||||
(c) Copyright 2001 - 2011 zones
|
||||
|
||||
Libretro port
|
||||
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
|
||||
Daniel De Matteis
|
||||
(Under no circumstances will commercial rights be
|
||||
given)
|
||||
|
||||
|
||||
Specific ports contains the works of other authors. See headers in
|
||||
individual files.
|
||||
|
||||
|
||||
Snes9x homepage: http://www.snes9x.com/
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event shall the authors be held liable for any damages
|
||||
arising from the use of this software or it's derivatives.
|
||||
|
||||
Snes9x is freeware for PERSONAL USE only. Commercial users should
|
||||
seek permission of the copyright holders first. Commercial use includes,
|
||||
but is not limited to, charging money for Snes9x or software derived from
|
||||
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
|
||||
using Snes9x as a promotion for your commercial product.
|
||||
|
||||
The copyright holders request that bug fixes and improvements to the code
|
||||
should be forwarded to them so everyone can benefit from the modifications
|
||||
in future versions.
|
||||
|
||||
Super NES and Super Nintendo Entertainment System are trademarks of
|
||||
Nintendo Co., Limited and its subsidiary companies.
|
||||
***********************************************************************************/
|
||||
|
||||
#ifndef CGMINI_H
|
||||
#define CGMINI_H
|
||||
|
||||
#define CGENTRY
|
||||
#define CGD3D9ENTRY
|
||||
#define CGGLENTRY
|
||||
#define CGD3D9DLL_API
|
||||
#define CGGL_API
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define CG_API
|
||||
typedef struct _CGprogram* CGprogram;
|
||||
typedef struct _CGcontext* CGcontext;
|
||||
typedef struct _CGparameter* CGparameter;
|
||||
typedef enum {
|
||||
CG_NO_ERROR = 0,
|
||||
CG_COMPILER_ERROR = 1,
|
||||
CG_INVALID_PARAMETER_ERROR = 2,
|
||||
CG_INVALID_PROFILE_ERROR = 3,
|
||||
CG_PROGRAM_LOAD_ERROR = 4,
|
||||
CG_PROGRAM_BIND_ERROR = 5,
|
||||
CG_PROGRAM_NOT_LOADED_ERROR = 6,
|
||||
CG_UNSUPPORTED_GL_EXTENSION_ERROR = 7,
|
||||
CG_INVALID_VALUE_TYPE_ERROR = 8,
|
||||
CG_NOT_MATRIX_PARAM_ERROR = 9,
|
||||
CG_INVALID_ENUMERANT_ERROR = 10,
|
||||
CG_NOT_4x4_MATRIX_ERROR = 11,
|
||||
CG_FILE_READ_ERROR = 12,
|
||||
CG_FILE_WRITE_ERROR = 13,
|
||||
CG_NVPARSE_ERROR = 14,
|
||||
CG_MEMORY_ALLOC_ERROR = 15,
|
||||
CG_INVALID_CONTEXT_HANDLE_ERROR = 16,
|
||||
CG_INVALID_PROGRAM_HANDLE_ERROR = 17,
|
||||
CG_INVALID_PARAM_HANDLE_ERROR = 18,
|
||||
CG_UNKNOWN_PROFILE_ERROR = 19,
|
||||
CG_VAR_ARG_ERROR = 20,
|
||||
CG_INVALID_DIMENSION_ERROR = 21,
|
||||
CG_ARRAY_PARAM_ERROR = 22,
|
||||
CG_OUT_OF_ARRAY_BOUNDS_ERROR = 23,
|
||||
CG_CONFLICTING_TYPES_ERROR = 24,
|
||||
CG_CONFLICTING_PARAMETER_TYPES_ERROR = 25,
|
||||
CG_PARAMETER_IS_NOT_SHARED_ERROR = 26,
|
||||
CG_INVALID_PARAMETER_VARIABILITY_ERROR = 27,
|
||||
CG_CANNOT_DESTROY_PARAMETER_ERROR = 28,
|
||||
CG_NOT_ROOT_PARAMETER_ERROR = 29,
|
||||
CG_PARAMETERS_DO_NOT_MATCH_ERROR = 30,
|
||||
CG_IS_NOT_PROGRAM_PARAMETER_ERROR = 31,
|
||||
CG_INVALID_PARAMETER_TYPE_ERROR = 32,
|
||||
CG_PARAMETER_IS_NOT_RESIZABLE_ARRAY_ERROR = 33,
|
||||
CG_INVALID_SIZE_ERROR = 34,
|
||||
CG_BIND_CREATES_CYCLE_ERROR = 35,
|
||||
CG_ARRAY_TYPES_DO_NOT_MATCH_ERROR = 36,
|
||||
CG_ARRAY_DIMENSIONS_DO_NOT_MATCH_ERROR = 37,
|
||||
CG_ARRAY_HAS_WRONG_DIMENSION_ERROR = 38,
|
||||
CG_TYPE_IS_NOT_DEFINED_IN_PROGRAM_ERROR = 39,
|
||||
CG_INVALID_EFFECT_HANDLE_ERROR = 40,
|
||||
CG_INVALID_STATE_HANDLE_ERROR = 41,
|
||||
CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR = 42,
|
||||
CG_INVALID_PASS_HANDLE_ERROR = 43,
|
||||
CG_INVALID_ANNOTATION_HANDLE_ERROR = 44,
|
||||
CG_INVALID_TECHNIQUE_HANDLE_ERROR = 45,
|
||||
CG_INVALID_PARAMETER_HANDLE_ERROR = 46,
|
||||
CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR = 47,
|
||||
CG_INVALID_FUNCTION_HANDLE_ERROR = 48,
|
||||
CG_INVALID_TECHNIQUE_ERROR = 49,
|
||||
CG_INVALID_POINTER_ERROR = 50,
|
||||
CG_NOT_ENOUGH_DATA_ERROR = 51,
|
||||
CG_NON_NUMERIC_PARAMETER_ERROR = 52,
|
||||
CG_ARRAY_SIZE_MISMATCH_ERROR = 53,
|
||||
CG_CANNOT_SET_NON_UNIFORM_PARAMETER_ERROR = 54,
|
||||
CG_DUPLICATE_NAME_ERROR = 55,
|
||||
CG_INVALID_OBJ_HANDLE_ERROR = 56,
|
||||
CG_INVALID_BUFFER_HANDLE_ERROR = 57,
|
||||
CG_BUFFER_INDEX_OUT_OF_RANGE_ERROR = 58,
|
||||
CG_BUFFER_ALREADY_MAPPED_ERROR = 59,
|
||||
CG_BUFFER_UPDATE_NOT_ALLOWED_ERROR = 60,
|
||||
CG_GLSLG_UNCOMBINED_LOAD_ERROR = 61
|
||||
} CGerror;
|
||||
typedef enum {
|
||||
CG_UNKNOWN = 4096,
|
||||
CG_IN = 4097,
|
||||
CG_OUT = 4098,
|
||||
CG_INOUT = 4099,
|
||||
CG_MIXED = 4100,
|
||||
CG_VARYING = 4101,
|
||||
CG_UNIFORM = 4102,
|
||||
CG_CONSTANT = 4103,
|
||||
CG_PROGRAM_SOURCE = 4104, /* cgGetProgramString */
|
||||
CG_PROGRAM_ENTRY = 4105, /* cgGetProgramString */
|
||||
CG_COMPILED_PROGRAM = 4106, /* cgGetProgramString */
|
||||
CG_PROGRAM_PROFILE = 4107, /* cgGetProgramString */
|
||||
CG_GLOBAL = 4108,
|
||||
CG_PROGRAM = 4109,
|
||||
CG_DEFAULT = 4110,
|
||||
CG_ERROR = 4111,
|
||||
CG_SOURCE = 4112,
|
||||
CG_OBJECT = 4113,
|
||||
CG_COMPILE_MANUAL = 4114,
|
||||
CG_COMPILE_IMMEDIATE = 4115,
|
||||
CG_COMPILE_LAZY = 4116,
|
||||
CG_CURRENT = 4117,
|
||||
CG_LITERAL = 4118,
|
||||
CG_VERSION = 4119, /* cgGetString */
|
||||
CG_ROW_MAJOR = 4120,
|
||||
CG_COLUMN_MAJOR = 4121,
|
||||
CG_FRAGMENT = 4122, /* cgGetProgramInput and cgGetProgramOutput */
|
||||
CG_VERTEX = 4123, /* cgGetProgramInput and cgGetProgramOutput */
|
||||
CG_POINT = 4124, /* Geometry program cgGetProgramInput */
|
||||
CG_LINE = 4125, /* Geometry program cgGetProgramInput */
|
||||
CG_LINE_ADJ = 4126, /* Geometry program cgGetProgramInput */
|
||||
CG_TRIANGLE = 4127, /* Geometry program cgGetProgramInput */
|
||||
CG_TRIANGLE_ADJ = 4128, /* Geometry program cgGetProgramInput */
|
||||
CG_POINT_OUT = 4129, /* Geometry program cgGetProgramOutput */
|
||||
CG_LINE_OUT = 4130, /* Geometry program cgGetProgramOutput */
|
||||
CG_TRIANGLE_OUT = 4131, /* Geometry program cgGetProgramOutput */
|
||||
CG_IMMEDIATE_PARAMETER_SETTING = 4132,
|
||||
CG_DEFERRED_PARAMETER_SETTING = 4133,
|
||||
CG_NO_LOCKS_POLICY = 4134,
|
||||
CG_THREAD_SAFE_POLICY = 4135,
|
||||
CG_FORCE_UPPER_CASE_POLICY = 4136,
|
||||
CG_UNCHANGED_CASE_POLICY = 4137,
|
||||
CG_IS_OPENGL_PROFILE = 4138,
|
||||
CG_IS_DIRECT3D_PROFILE = 4139,
|
||||
CG_IS_DIRECT3D_8_PROFILE = 4140,
|
||||
CG_IS_DIRECT3D_9_PROFILE = 4141,
|
||||
CG_IS_DIRECT3D_10_PROFILE = 4142,
|
||||
CG_IS_VERTEX_PROFILE = 4143,
|
||||
CG_IS_FRAGMENT_PROFILE = 4144,
|
||||
CG_IS_GEOMETRY_PROFILE = 4145,
|
||||
CG_IS_TRANSLATION_PROFILE = 4146,
|
||||
CG_IS_HLSL_PROFILE = 4147,
|
||||
CG_IS_GLSL_PROFILE = 4148,
|
||||
CG_IS_TESSELLATION_CONTROL_PROFILE = 4149,
|
||||
CG_IS_TESSELLATION_EVALUATION_PROFILE = 4150,
|
||||
CG_PATCH = 4152, /* cgGetProgramInput and cgGetProgramOutput */
|
||||
CG_IS_DIRECT3D_11_PROFILE = 4153
|
||||
} CGenum;
|
||||
|
||||
typedef enum {
|
||||
CG_PROFILE_INVALID
|
||||
} CGprofile;
|
||||
|
||||
typedef enum {
|
||||
CG_RESOURCE_INVALID
|
||||
} CGresource;
|
||||
|
||||
typedef enum {
|
||||
CG_UNKNOWN_TYPE = 0,
|
||||
CG_ARRAY = 2,
|
||||
CG_STRING = 1135,
|
||||
CG_STRUCT = 1,
|
||||
CG_TYPELESS_STRUCT = 3,
|
||||
CG_TEXTURE = 1137,
|
||||
CG_BUFFER = 1319,
|
||||
CG_UNIFORMBUFFER = 1320,
|
||||
CG_ADDRESS = 1321,
|
||||
CG_PIXELSHADER_TYPE = 1142,
|
||||
CG_PROGRAM_TYPE = 1136,
|
||||
CG_VERTEXSHADER_TYPE = 1141,
|
||||
CG_SAMPLER = 1143,
|
||||
CG_SAMPLER1D = 1065,
|
||||
CG_SAMPLER1DARRAY = 1138,
|
||||
CG_SAMPLER1DSHADOW = 1313,
|
||||
CG_SAMPLER2D = 1066,
|
||||
CG_SAMPLER2DARRAY = 1139,
|
||||
CG_SAMPLER2DMS = 1317, /* ARB_texture_multisample */
|
||||
CG_SAMPLER2DMSARRAY = 1318, /* ARB_texture_multisample */
|
||||
CG_SAMPLER2DSHADOW = 1314,
|
||||
CG_SAMPLER3D = 1067,
|
||||
CG_SAMPLERBUF = 1144,
|
||||
CG_SAMPLERCUBE = 1069,
|
||||
CG_SAMPLERCUBEARRAY = 1140,
|
||||
CG_SAMPLERRBUF = 1316, /* NV_explicit_multisample */
|
||||
CG_SAMPLERRECT = 1068,
|
||||
CG_SAMPLERRECTSHADOW = 1315,
|
||||
CG_TYPE_START_ENUM = 1024,
|
||||
CG_BOOL = 1114,
|
||||
CG_BOOL1 = 1115,
|
||||
CG_BOOL2 = 1116,
|
||||
CG_BOOL3 = 1117,
|
||||
CG_BOOL4 = 1118,
|
||||
CG_BOOL1x1 = 1119,
|
||||
CG_BOOL1x2 = 1120,
|
||||
CG_BOOL1x3 = 1121,
|
||||
CG_BOOL1x4 = 1122,
|
||||
CG_BOOL2x1 = 1123,
|
||||
CG_BOOL2x2 = 1124,
|
||||
CG_BOOL2x3 = 1125,
|
||||
CG_BOOL2x4 = 1126,
|
||||
CG_BOOL3x1 = 1127,
|
||||
CG_BOOL3x2 = 1128,
|
||||
CG_BOOL3x3 = 1129,
|
||||
CG_BOOL3x4 = 1130,
|
||||
CG_BOOL4x1 = 1131,
|
||||
CG_BOOL4x2 = 1132,
|
||||
CG_BOOL4x3 = 1133,
|
||||
CG_BOOL4x4 = 1134,
|
||||
CG_CHAR = 1166,
|
||||
CG_CHAR1 = 1167,
|
||||
CG_CHAR2 = 1168,
|
||||
CG_CHAR3 = 1169,
|
||||
CG_CHAR4 = 1170,
|
||||
CG_CHAR1x1 = 1171,
|
||||
CG_CHAR1x2 = 1172,
|
||||
CG_CHAR1x3 = 1173,
|
||||
CG_CHAR1x4 = 1174,
|
||||
CG_CHAR2x1 = 1175,
|
||||
CG_CHAR2x2 = 1176,
|
||||
CG_CHAR2x3 = 1177,
|
||||
CG_CHAR2x4 = 1178,
|
||||
CG_CHAR3x1 = 1179,
|
||||
CG_CHAR3x2 = 1180,
|
||||
CG_CHAR3x3 = 1181,
|
||||
CG_CHAR3x4 = 1182,
|
||||
CG_CHAR4x1 = 1183,
|
||||
CG_CHAR4x2 = 1184,
|
||||
CG_CHAR4x3 = 1185,
|
||||
CG_CHAR4x4 = 1186,
|
||||
CG_DOUBLE = 1145,
|
||||
CG_DOUBLE1 = 1146,
|
||||
CG_DOUBLE2 = 1147,
|
||||
CG_DOUBLE3 = 1148,
|
||||
CG_DOUBLE4 = 1149,
|
||||
CG_DOUBLE1x1 = 1150,
|
||||
CG_DOUBLE1x2 = 1151,
|
||||
CG_DOUBLE1x3 = 1152,
|
||||
CG_DOUBLE1x4 = 1153,
|
||||
CG_DOUBLE2x1 = 1154,
|
||||
CG_DOUBLE2x2 = 1155,
|
||||
CG_DOUBLE2x3 = 1156,
|
||||
CG_DOUBLE2x4 = 1157,
|
||||
CG_DOUBLE3x1 = 1158,
|
||||
CG_DOUBLE3x2 = 1159,
|
||||
CG_DOUBLE3x3 = 1160,
|
||||
CG_DOUBLE3x4 = 1161,
|
||||
CG_DOUBLE4x1 = 1162,
|
||||
CG_DOUBLE4x2 = 1163,
|
||||
CG_DOUBLE4x3 = 1164,
|
||||
CG_DOUBLE4x4 = 1165,
|
||||
CG_FIXED = 1070,
|
||||
CG_FIXED1 = 1092,
|
||||
CG_FIXED2 = 1071,
|
||||
CG_FIXED3 = 1072,
|
||||
CG_FIXED4 = 1073,
|
||||
CG_FIXED1x1 = 1074,
|
||||
CG_FIXED1x2 = 1075,
|
||||
CG_FIXED1x3 = 1076,
|
||||
CG_FIXED1x4 = 1077,
|
||||
CG_FIXED2x1 = 1078,
|
||||
CG_FIXED2x2 = 1079,
|
||||
CG_FIXED2x3 = 1080,
|
||||
CG_FIXED2x4 = 1081,
|
||||
CG_FIXED3x1 = 1082,
|
||||
CG_FIXED3x2 = 1083,
|
||||
CG_FIXED3x3 = 1084,
|
||||
CG_FIXED3x4 = 1085,
|
||||
CG_FIXED4x1 = 1086,
|
||||
CG_FIXED4x2 = 1087,
|
||||
CG_FIXED4x3 = 1088,
|
||||
CG_FIXED4x4 = 1089,
|
||||
CG_FLOAT = 1045,
|
||||
CG_FLOAT1 = 1091,
|
||||
CG_FLOAT2 = 1046,
|
||||
CG_FLOAT3 = 1047,
|
||||
CG_FLOAT4 = 1048,
|
||||
CG_FLOAT1x1 = 1049,
|
||||
CG_FLOAT1x2 = 1050,
|
||||
CG_FLOAT1x3 = 1051,
|
||||
CG_FLOAT1x4 = 1052,
|
||||
CG_FLOAT2x1 = 1053,
|
||||
CG_FLOAT2x2 = 1054,
|
||||
CG_FLOAT2x3 = 1055,
|
||||
CG_FLOAT2x4 = 1056,
|
||||
CG_FLOAT3x1 = 1057,
|
||||
CG_FLOAT3x2 = 1058,
|
||||
CG_FLOAT3x3 = 1059,
|
||||
CG_FLOAT3x4 = 1060,
|
||||
CG_FLOAT4x1 = 1061,
|
||||
CG_FLOAT4x2 = 1062,
|
||||
CG_FLOAT4x3 = 1063,
|
||||
CG_FLOAT4x4 = 1064,
|
||||
CG_HALF = 1025,
|
||||
CG_HALF1 = 1090,
|
||||
CG_HALF2 = 1026,
|
||||
CG_HALF3 = 1027,
|
||||
CG_HALF4 = 1028,
|
||||
CG_HALF1x1 = 1029,
|
||||
CG_HALF1x2 = 1030,
|
||||
CG_HALF1x3 = 1031,
|
||||
CG_HALF1x4 = 1032,
|
||||
CG_HALF2x1 = 1033,
|
||||
CG_HALF2x2 = 1034,
|
||||
CG_HALF2x3 = 1035,
|
||||
CG_HALF2x4 = 1036,
|
||||
CG_HALF3x1 = 1037,
|
||||
CG_HALF3x2 = 1038,
|
||||
CG_HALF3x3 = 1039,
|
||||
CG_HALF3x4 = 1040,
|
||||
CG_HALF4x1 = 1041,
|
||||
CG_HALF4x2 = 1042,
|
||||
CG_HALF4x3 = 1043,
|
||||
CG_HALF4x4 = 1044,
|
||||
CG_INT = 1093,
|
||||
CG_INT1 = 1094,
|
||||
CG_INT2 = 1095,
|
||||
CG_INT3 = 1096,
|
||||
CG_INT4 = 1097,
|
||||
CG_INT1x1 = 1098,
|
||||
CG_INT1x2 = 1099,
|
||||
CG_INT1x3 = 1100,
|
||||
CG_INT1x4 = 1101,
|
||||
CG_INT2x1 = 1102,
|
||||
CG_INT2x2 = 1103,
|
||||
CG_INT2x3 = 1104,
|
||||
CG_INT2x4 = 1105,
|
||||
CG_INT3x1 = 1106,
|
||||
CG_INT3x2 = 1107,
|
||||
CG_INT3x3 = 1108,
|
||||
CG_INT3x4 = 1109,
|
||||
CG_INT4x1 = 1110,
|
||||
CG_INT4x2 = 1111,
|
||||
CG_INT4x3 = 1112,
|
||||
CG_INT4x4 = 1113,
|
||||
CG_LONG = 1271,
|
||||
CG_LONG1 = 1272,
|
||||
CG_LONG2 = 1273,
|
||||
CG_LONG3 = 1274,
|
||||
CG_LONG4 = 1275,
|
||||
CG_LONG1x1 = 1276,
|
||||
CG_LONG1x2 = 1277,
|
||||
CG_LONG1x3 = 1278,
|
||||
CG_LONG1x4 = 1279,
|
||||
CG_LONG2x1 = 1280,
|
||||
CG_LONG2x2 = 1281,
|
||||
CG_LONG2x3 = 1282,
|
||||
CG_LONG2x4 = 1283,
|
||||
CG_LONG3x1 = 1284,
|
||||
CG_LONG3x2 = 1285,
|
||||
CG_LONG3x3 = 1286,
|
||||
CG_LONG3x4 = 1287,
|
||||
CG_LONG4x1 = 1288,
|
||||
CG_LONG4x2 = 1289,
|
||||
CG_LONG4x3 = 1290,
|
||||
CG_LONG4x4 = 1291,
|
||||
CG_SHORT = 1208,
|
||||
CG_SHORT1 = 1209,
|
||||
CG_SHORT2 = 1210,
|
||||
CG_SHORT3 = 1211,
|
||||
CG_SHORT4 = 1212,
|
||||
CG_SHORT1x1 = 1213,
|
||||
CG_SHORT1x2 = 1214,
|
||||
CG_SHORT1x3 = 1215,
|
||||
CG_SHORT1x4 = 1216,
|
||||
CG_SHORT2x1 = 1217,
|
||||
CG_SHORT2x2 = 1218,
|
||||
CG_SHORT2x3 = 1219,
|
||||
CG_SHORT2x4 = 1220,
|
||||
CG_SHORT3x1 = 1221,
|
||||
CG_SHORT3x2 = 1222,
|
||||
CG_SHORT3x3 = 1223,
|
||||
CG_SHORT3x4 = 1224,
|
||||
CG_SHORT4x1 = 1225,
|
||||
CG_SHORT4x2 = 1226,
|
||||
CG_SHORT4x3 = 1227,
|
||||
CG_SHORT4x4 = 1228,
|
||||
CG_UCHAR = 1187,
|
||||
CG_UCHAR1 = 1188,
|
||||
CG_UCHAR2 = 1189,
|
||||
CG_UCHAR3 = 1190,
|
||||
CG_UCHAR4 = 1191,
|
||||
CG_UCHAR1x1 = 1192,
|
||||
CG_UCHAR1x2 = 1193,
|
||||
CG_UCHAR1x3 = 1194,
|
||||
CG_UCHAR1x4 = 1195,
|
||||
CG_UCHAR2x1 = 1196,
|
||||
CG_UCHAR2x2 = 1197,
|
||||
CG_UCHAR2x3 = 1198,
|
||||
CG_UCHAR2x4 = 1199,
|
||||
CG_UCHAR3x1 = 1200,
|
||||
CG_UCHAR3x2 = 1201,
|
||||
CG_UCHAR3x3 = 1202,
|
||||
CG_UCHAR3x4 = 1203,
|
||||
CG_UCHAR4x1 = 1204,
|
||||
CG_UCHAR4x2 = 1205,
|
||||
CG_UCHAR4x3 = 1206,
|
||||
CG_UCHAR4x4 = 1207,
|
||||
CG_UINT = 1250,
|
||||
CG_UINT1 = 1251,
|
||||
CG_UINT2 = 1252,
|
||||
CG_UINT3 = 1253,
|
||||
CG_UINT4 = 1254,
|
||||
CG_UINT1x1 = 1255,
|
||||
CG_UINT1x2 = 1256,
|
||||
CG_UINT1x3 = 1257,
|
||||
CG_UINT1x4 = 1258,
|
||||
CG_UINT2x1 = 1259,
|
||||
CG_UINT2x2 = 1260,
|
||||
CG_UINT2x3 = 1261,
|
||||
CG_UINT2x4 = 1262,
|
||||
CG_UINT3x1 = 1263,
|
||||
CG_UINT3x2 = 1264,
|
||||
CG_UINT3x3 = 1265,
|
||||
CG_UINT3x4 = 1266,
|
||||
CG_UINT4x1 = 1267,
|
||||
CG_UINT4x2 = 1268,
|
||||
CG_UINT4x3 = 1269,
|
||||
CG_UINT4x4 = 1270,
|
||||
CG_ULONG = 1292,
|
||||
CG_ULONG1 = 1293,
|
||||
CG_ULONG2 = 1294,
|
||||
CG_ULONG3 = 1295,
|
||||
CG_ULONG4 = 1296,
|
||||
CG_ULONG1x1 = 1297,
|
||||
CG_ULONG1x2 = 1298,
|
||||
CG_ULONG1x3 = 1299,
|
||||
CG_ULONG1x4 = 1300,
|
||||
CG_ULONG2x1 = 1301,
|
||||
CG_ULONG2x2 = 1302,
|
||||
CG_ULONG2x3 = 1303,
|
||||
CG_ULONG2x4 = 1304,
|
||||
CG_ULONG3x1 = 1305,
|
||||
CG_ULONG3x2 = 1306,
|
||||
CG_ULONG3x3 = 1307,
|
||||
CG_ULONG3x4 = 1308,
|
||||
CG_ULONG4x1 = 1309,
|
||||
CG_ULONG4x2 = 1310,
|
||||
CG_ULONG4x3 = 1311,
|
||||
CG_ULONG4x4 = 1312,
|
||||
CG_USHORT = 1229,
|
||||
CG_USHORT1 = 1230,
|
||||
CG_USHORT2 = 1231,
|
||||
CG_USHORT3 = 1232,
|
||||
CG_USHORT4 = 1233,
|
||||
CG_USHORT1x1 = 1234,
|
||||
CG_USHORT1x2 = 1235,
|
||||
CG_USHORT1x3 = 1236,
|
||||
CG_USHORT1x4 = 1237,
|
||||
CG_USHORT2x1 = 1238,
|
||||
CG_USHORT2x2 = 1239,
|
||||
CG_USHORT2x3 = 1240,
|
||||
CG_USHORT2x4 = 1241,
|
||||
CG_USHORT3x1 = 1242,
|
||||
CG_USHORT3x2 = 1243,
|
||||
CG_USHORT3x3 = 1244,
|
||||
CG_USHORT3x4 = 1245,
|
||||
CG_USHORT4x1 = 1246,
|
||||
CG_USHORT4x2 = 1247,
|
||||
CG_USHORT4x3 = 1248,
|
||||
CG_USHORT4x4 = 1249
|
||||
} CGtype;
|
||||
typedef int CGbool;
|
||||
typedef enum {
|
||||
CG_GL_MATRIX_IDENTITY = 0,
|
||||
CG_GL_MATRIX_TRANSPOSE = 1,
|
||||
CG_GL_MATRIX_INVERSE = 2,
|
||||
CG_GL_MATRIX_INVERSE_TRANSPOSE = 3,
|
||||
CG_GL_MODELVIEW_MATRIX = 4,
|
||||
CG_GL_PROJECTION_MATRIX = 5,
|
||||
CG_GL_TEXTURE_MATRIX = 6,
|
||||
CG_GL_MODELVIEW_PROJECTION_MATRIX = 7,
|
||||
CG_GL_VERTEX = 8,
|
||||
CG_GL_FRAGMENT = 9,
|
||||
CG_GL_GEOMETRY = 10,
|
||||
CG_GL_TESSELLATION_CONTROL = 11,
|
||||
CG_GL_TESSELLATION_EVALUATION = 12
|
||||
} CGGLenum;
|
||||
|
||||
#endif
|
@ -13,6 +13,8 @@
|
||||
#include "gtk_display.h"
|
||||
#include "gtk_display_driver_opengl.h"
|
||||
|
||||
#include "Cg/CGLCG.h"
|
||||
|
||||
static const char *glGenBuffersNames[] = { "glGenBuffers",
|
||||
"glGenBuffersARB",
|
||||
"glGenBuffersEXT",
|
||||
@ -42,6 +44,8 @@ static const char *glUnmapBufferNames[] = { "glUnmapBuffer",
|
||||
"glUnmapBufferEXT",
|
||||
NULL };
|
||||
|
||||
getProcAddressProc xglGetProcAddress = NULL;
|
||||
|
||||
gl_proc
|
||||
get_null_address_proc (const GLubyte *name)
|
||||
{
|
||||
@ -84,6 +88,7 @@ __extension__
|
||||
#endif
|
||||
getProcAddressProc functor = reinterpret_cast<getProcAddressProc> (dlsym (dl_handle, "glXGetProcAddress"));
|
||||
glGetProcAddress = functor;
|
||||
xglGetProcAddress = glGetProcAddress;
|
||||
|
||||
if (dlerror () != NULL)
|
||||
{
|
||||
@ -92,6 +97,7 @@ __extension__
|
||||
#endif
|
||||
getProcAddressProc functor = reinterpret_cast<getProcAddressProc> (dlsym (dl_handle, "glXGetProcAddressARB"));
|
||||
glGetProcAddress = functor;
|
||||
xglGetProcAddress = glGetProcAddress;
|
||||
|
||||
if (dlerror () != NULL)
|
||||
glGetProcAddress = get_null_address_proc;
|
||||
@ -133,6 +139,11 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset)
|
||||
|
||||
#endif
|
||||
|
||||
if (using_cg_shaders)
|
||||
{
|
||||
glBindTexture (tex_target, texmap);
|
||||
}
|
||||
|
||||
GLint filter = config->bilinear_filter ? GL_LINEAR : GL_NEAREST;
|
||||
glTexParameteri (tex_target, GL_TEXTURE_MAG_FILTER, filter);
|
||||
glTexParameteri (tex_target, GL_TEXTURE_MIN_FILTER, filter);
|
||||
@ -313,7 +324,20 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset)
|
||||
texcoords[4] = texcoords[2];
|
||||
}
|
||||
|
||||
if (using_shaders)
|
||||
if (using_shaders && using_cg_shaders)
|
||||
{
|
||||
xySize texture_size, input_size, viewport_size;
|
||||
texture_size.x = texture_width;
|
||||
texture_size.y = texture_height;
|
||||
input_size.x = width;
|
||||
input_size.y = height;
|
||||
viewport_size.x = w;
|
||||
viewport_size.y = h;
|
||||
|
||||
cg_shader->Render (texmap, texture_size, input_size, viewport_size);
|
||||
glViewport (x, allocation.height - y - h, w, h);
|
||||
}
|
||||
else if (using_shaders)
|
||||
{
|
||||
GLint location;
|
||||
float inputSize[2];
|
||||
@ -508,6 +532,35 @@ S9xOpenGLDisplayDriver::load_shaders (const char *shader_file)
|
||||
xmlNodePtr node = NULL;
|
||||
char *fragment = NULL, *vertex = NULL;
|
||||
|
||||
int length = strlen (shader_file);
|
||||
if ((length > 4 && !strcasecmp(shader_file + length - 4, ".cgp")) ||
|
||||
(length > 3 && !strcasecmp(shader_file + length - 3, ".cg")))
|
||||
{
|
||||
if (loadCgFunctions())
|
||||
{
|
||||
cg_context = cgCreateContext ();
|
||||
cg_shader = new CGLCG (cg_context);
|
||||
if (!cg_shader->LoadShader (shader_file))
|
||||
{
|
||||
delete cg_shader;
|
||||
cgDestroyContext (cg_context);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
using_cg_shaders = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Cannot load CG library.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!load_shader_functions ())
|
||||
{
|
||||
fprintf (stderr, _("Cannot load GLSL shader functions.\n"));
|
||||
@ -598,6 +651,9 @@ S9xOpenGLDisplayDriver::opengl_defaults (void)
|
||||
}
|
||||
|
||||
using_shaders = 0;
|
||||
using_cg_shaders = 0;
|
||||
cg_context = NULL;
|
||||
cg_shader = NULL;
|
||||
if (config->use_shaders)
|
||||
{
|
||||
if (!load_shaders (config->fragment_shader))
|
||||
@ -611,8 +667,8 @@ S9xOpenGLDisplayDriver::opengl_defaults (void)
|
||||
}
|
||||
|
||||
tex_target = GL_TEXTURE_2D;
|
||||
texture_width = 1024;
|
||||
texture_height = 1024;
|
||||
texture_width = 256;
|
||||
texture_height = 256;
|
||||
dyn_resizing = FALSE;
|
||||
|
||||
const char *extensions = (const char *) glGetString (GL_EXTENSIONS);
|
||||
@ -632,8 +688,8 @@ S9xOpenGLDisplayDriver::opengl_defaults (void)
|
||||
}
|
||||
}
|
||||
|
||||
glEnable (GL_VERTEX_ARRAY);
|
||||
glEnable (GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
vertices[0] = 0.0f;
|
||||
vertices[1] = 0.0f;
|
||||
@ -935,7 +991,12 @@ S9xOpenGLDisplayDriver::deinit (void)
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
if (using_shaders)
|
||||
if (using_shaders && using_cg_shaders)
|
||||
{
|
||||
delete cg_shader;
|
||||
cgDestroyContext (cg_context);
|
||||
}
|
||||
else if (using_shaders)
|
||||
{
|
||||
glUseProgram (0);
|
||||
glDetachShader (program, vertex_shader);
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include "Cg/CGLCG.h"
|
||||
|
||||
#define PBO_FMT_16 0
|
||||
#define PBO_FMT_24 1
|
||||
#define PBO_FMT_32 2
|
||||
@ -137,6 +139,10 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
|
||||
int using_shaders;
|
||||
int initialized;
|
||||
|
||||
int using_cg_shaders;
|
||||
CGcontext cg_context;
|
||||
CGLCG *cg_shader;
|
||||
|
||||
Display *display;
|
||||
Window xwindow;
|
||||
Colormap xcolormap;
|
||||
|
Loading…
Reference in New Issue
Block a user