mirror of https://github.com/snes9xgit/snes9x.git
Change GLSL to use bsnes 071's unified files.
This commit is contained in:
parent
63b355430d
commit
007f73c2b3
|
@ -332,7 +332,6 @@ Snes9xConfig::save_config_file (void)
|
||||||
xml_out_int (xml, "npot_textures", npot_textures);
|
xml_out_int (xml, "npot_textures", npot_textures);
|
||||||
xml_out_int (xml, "use_shaders", use_shaders);
|
xml_out_int (xml, "use_shaders", use_shaders);
|
||||||
xml_out_string (xml, "fragment_shader", fragment_shader);
|
xml_out_string (xml, "fragment_shader", fragment_shader);
|
||||||
xml_out_string (xml, "vertex_shader", vertex_shader);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_JOYSTICK
|
#ifdef USE_JOYSTICK
|
||||||
|
@ -550,7 +549,7 @@ Snes9xConfig::set_option (const char *name, const char *value)
|
||||||
else if (!strcasecmp (name, "vertex_shader"))
|
else if (!strcasecmp (name, "vertex_shader"))
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
strncpy (vertex_shader, value, PATH_MAX);
|
/* Deprecated */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!strcasecmp (name, "joystick_threshold"))
|
else if (!strcasecmp (name, "joystick_threshold"))
|
||||||
|
@ -1141,6 +1140,8 @@ Snes9xConfig::load_config_file (void)
|
||||||
|
|
||||||
parse_snes9x (xml_root);
|
parse_snes9x (xml_root);
|
||||||
|
|
||||||
|
xmlFreeDoc (xml_doc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
#include <libxml/parser.h>
|
||||||
|
#include <libxml/tree.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#include <GL/glxext.h>
|
#include <GL/glxext.h>
|
||||||
|
@ -40,44 +42,6 @@ static const char *glUnmapBufferNames[] = { "glUnmapBuffer",
|
||||||
"glUnmapBufferEXT",
|
"glUnmapBufferEXT",
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
static char *
|
|
||||||
get_file_contents (const char *filename)
|
|
||||||
{
|
|
||||||
struct stat fs;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if (!filename || !strlen (filename) || stat (filename, &fs))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open (filename, O_RDONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
char *contents = new char[fs.st_size + 1];
|
|
||||||
|
|
||||||
int bytes_read = 0;
|
|
||||||
while (bytes_read < fs.st_size)
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
retval = read (fd, contents + bytes_read, fs.st_size - bytes_read);
|
|
||||||
if (retval == -1)
|
|
||||||
{
|
|
||||||
delete[] contents;
|
|
||||||
close (fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
bytes_read += retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
contents[fs.st_size] = '\0';
|
|
||||||
|
|
||||||
close (fd);
|
|
||||||
|
|
||||||
return contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
gl_proc
|
gl_proc
|
||||||
get_null_address_proc (const GLubyte *name)
|
get_null_address_proc (const GLubyte *name)
|
||||||
{
|
{
|
||||||
|
@ -539,10 +503,11 @@ S9xOpenGLDisplayDriver::load_shader_functions (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
S9xOpenGLDisplayDriver::load_shaders (const char *vertex_file,
|
S9xOpenGLDisplayDriver::load_shaders (const char *shader_file)
|
||||||
const char *fragment_file)
|
|
||||||
{
|
{
|
||||||
char *fragment, *vertex;
|
xmlDoc *xml_doc = NULL;
|
||||||
|
xmlNodePtr node = NULL;
|
||||||
|
char *fragment = NULL, *vertex = NULL;
|
||||||
|
|
||||||
if (!load_shader_functions ())
|
if (!load_shader_functions ())
|
||||||
{
|
{
|
||||||
|
@ -550,18 +515,42 @@ S9xOpenGLDisplayDriver::load_shaders (const char *vertex_file,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment = get_file_contents (fragment_file);
|
xml_doc = xmlReadFile (shader_file, NULL, 0);
|
||||||
if (!fragment)
|
|
||||||
|
if (!xml_doc)
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Cannot load fragment program.\n"));
|
fprintf (stderr, _("Cannot read shader file.\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vertex = get_file_contents (vertex_file);
|
node = xmlDocGetRootElement (xml_doc);
|
||||||
if (!vertex)
|
|
||||||
|
if (xmlStrcasecmp (node->name, BAD_CAST "shader"))
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Cannot load vertex program.\n"));
|
fprintf (stderr, _("File %s is not a shader file.\n"), shader_file);
|
||||||
delete[] fragment;
|
xmlFreeDoc (xml_doc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (xmlNodePtr i = node->children; i; i = i->next)
|
||||||
|
{
|
||||||
|
if (!xmlStrcasecmp (i->name, BAD_CAST "vertex"))
|
||||||
|
{
|
||||||
|
if (i->children)
|
||||||
|
vertex = (char *) i->children->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xmlStrcasecmp (i->name, BAD_CAST "fragment"))
|
||||||
|
{
|
||||||
|
if (i->children)
|
||||||
|
fragment = (char *) i->children->content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vertex || !fragment)
|
||||||
|
{
|
||||||
|
fprintf (stderr, _("Shader is missing either a vertex or fragment program.\n"));
|
||||||
|
xmlFreeDoc (xml_doc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,6 +567,8 @@ S9xOpenGLDisplayDriver::load_shaders (const char *vertex_file,
|
||||||
|
|
||||||
glUseProgram (program);
|
glUseProgram (program);
|
||||||
|
|
||||||
|
xmlFreeDoc (xml_doc);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +593,7 @@ S9xOpenGLDisplayDriver::opengl_defaults (void)
|
||||||
using_shaders = 0;
|
using_shaders = 0;
|
||||||
if (config->use_shaders)
|
if (config->use_shaders)
|
||||||
{
|
{
|
||||||
if (!load_shaders (config->vertex_shader, config->fragment_shader))
|
if (!load_shaders (config->fragment_shader))
|
||||||
{
|
{
|
||||||
config->use_shaders = 0;
|
config->use_shaders = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
|
||||||
void gl_swap (void);
|
void gl_swap (void);
|
||||||
int load_pixel_buffer_functions (void);
|
int load_pixel_buffer_functions (void);
|
||||||
int load_shader_functions (void);
|
int load_shader_functions (void);
|
||||||
int load_shaders (const char *, const char *);
|
int load_shaders (const char *);
|
||||||
gl_proc get_aliased_extension (const char **name);
|
gl_proc get_aliased_extension (const char **name);
|
||||||
void update_texture_size (int width, int height);
|
void update_texture_size (int width, int height);
|
||||||
int init_glx (void);
|
int init_glx (void);
|
||||||
|
|
|
@ -232,10 +232,6 @@ event_shader_select (GtkButton *widget, gpointer data)
|
||||||
{
|
{
|
||||||
entry = GTK_ENTRY (window->get_widget ("fragment_shader"));
|
entry = GTK_ENTRY (window->get_widget ("fragment_shader"));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
entry = GTK_ENTRY (window->get_widget ("vertex_shader"));
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog = gtk_file_chooser_dialog_new ("Select Shader File",
|
dialog = gtk_file_chooser_dialog_new ("Select Shader File",
|
||||||
window->get_window (),
|
window->get_window (),
|
||||||
|
@ -733,7 +729,6 @@ Snes9xPreferences::move_settings_to_dialog (void)
|
||||||
set_check ("npot_textures", config->npot_textures);
|
set_check ("npot_textures", config->npot_textures);
|
||||||
set_check ("use_shaders", config->use_shaders);
|
set_check ("use_shaders", config->use_shaders);
|
||||||
set_entry_text ("fragment_shader", config->fragment_shader);
|
set_entry_text ("fragment_shader", config->fragment_shader);
|
||||||
set_entry_text ("vertex_shader", config->vertex_shader);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_JOYSTICK
|
#ifdef USE_JOYSTICK
|
||||||
|
@ -861,7 +856,6 @@ Snes9xPreferences::get_settings_from_dialog (void)
|
||||||
config->sync_every_frame = get_check ("sync_every_frame");
|
config->sync_every_frame = get_check ("sync_every_frame");
|
||||||
|
|
||||||
strncpy (config->fragment_shader, get_entry_text ("fragment_shader"), PATH_MAX);
|
strncpy (config->fragment_shader, get_entry_text ("fragment_shader"), PATH_MAX);
|
||||||
strncpy (config->vertex_shader, get_entry_text ("vertex_shader"), PATH_MAX);
|
|
||||||
|
|
||||||
config->pbo_format = get_combo ("pixel_format");
|
config->pbo_format = get_combo ("pixel_format");
|
||||||
#endif
|
#endif
|
||||||
|
|
4770
gtk/src/snes9x.ui
4770
gtk/src/snes9x.ui
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue