mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-21 03:41:51 +02:00
Update to v093r02 release.
byuu says: Changelog: - nall: fixed major memory leak in string class - ruby: video shaders support #define-based settings now - phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab - sfc: remove random/ and config/, merge into system/ - ethos: delete higan.png (48x48), replace with higan512.png (512x512) as new higan.png - ethos: default gamma to 100% (no color adjustment) - ethos: use "Video Shaders/Display Emulation/" instead of "Video Shaders/Emulation/" - use g++ instead of g++-4.7 (g++ -v must be >= 4.7) - use -std=c++11 instead of -std=gnu++11 - applied a few patches from Debian upstream to make their packaging job easier So because colors are normalized in GLSL, I won't be able to offer video shaders absolute color literals. We will have to perform basic color conversion inside the core. As such, the current plan is to create some sort of Emulator::Settings interface. With that, I'll connect an option for color correction, which will be on by default. For FC/SFC, that will mean gamma correction (darker / stronger colors), and for GB/GBC/GBA, it will mean simulating the weird brightness levels of the displays. I am undecided on whether to use pea soup green for the GB or not. By not doing so, it'll be easier for the display emulation shader to do it.
This commit is contained in:
@@ -5,6 +5,8 @@ void OpenGL::shader(const char* pathname) {
|
||||
for(auto& frame : frames) glDeleteTextures(1, &frame.texture);
|
||||
frames.reset();
|
||||
|
||||
settings.reset();
|
||||
|
||||
format = GL_RGBA8;
|
||||
filter = GL_LINEAR;
|
||||
wrap = GL_CLAMP_TO_BORDER;
|
||||
@@ -13,6 +15,11 @@ void OpenGL::shader(const char* pathname) {
|
||||
|
||||
if(pathname) {
|
||||
auto document = Markup::Document(file::read({pathname, "manifest.bml"}));
|
||||
|
||||
for(auto& node : document["settings"]) {
|
||||
settings.insert({node.name, node.text()});
|
||||
}
|
||||
|
||||
for(auto& node : document.find("program")) {
|
||||
unsigned n = programs.size();
|
||||
programs(n).bind(this, node, pathname);
|
||||
|
@@ -2,10 +2,10 @@
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#define glGetProcAddress(name) (*glXGetProcAddress)((const GLubyte*)(name))
|
||||
#elif defined(PLATFORM_OSX)
|
||||
#elif defined(PLATFORM_MACOSX)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/gl3.h>
|
||||
#elif defined(PLATFORM_WIN)
|
||||
#elif defined(PLATFORM_WINDOWS)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#define glGetProcAddress(name) wglGetProcAddress(name)
|
||||
@@ -57,6 +57,7 @@ struct OpenGLProgram : OpenGLSurface {
|
||||
vector<OpenGLTexture> pixmaps;
|
||||
|
||||
void bind(OpenGL* instance, const Markup::Node& node, const string& pathname);
|
||||
void parse(OpenGL* instance, string& source);
|
||||
void release();
|
||||
};
|
||||
|
||||
@@ -74,6 +75,17 @@ struct OpenGL : OpenGLProgram {
|
||||
unsigned outputWidth = 0;
|
||||
unsigned outputHeight = 0;
|
||||
|
||||
struct Setting {
|
||||
string name;
|
||||
string value;
|
||||
bool operator< (const Setting& source) { return name < source.name; }
|
||||
bool operator==(const Setting& source) { return name == source.name; }
|
||||
Setting() {}
|
||||
Setting(const string& name) : name(name) {}
|
||||
Setting(const string& name, const string& value) : name(name), value(value) {}
|
||||
};
|
||||
set<Setting> settings;
|
||||
|
||||
void shader(const char* pathname);
|
||||
void bind(const Markup::Node& node, const string& pathname);
|
||||
bool lock(uint32_t*& data, unsigned& pitch);
|
||||
|
@@ -17,6 +17,7 @@ void OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
|
||||
|
||||
if(file::exists({pathname, node["vertex"].text()})) {
|
||||
string source = file::read({pathname, node["vertex"].text()});
|
||||
parse(instance, source);
|
||||
vertex = glrCreateShader(program, GL_VERTEX_SHADER, source);
|
||||
} else {
|
||||
vertex = glrCreateShader(program, GL_VERTEX_SHADER, OpenGLVertexShader);
|
||||
@@ -24,6 +25,7 @@ void OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
|
||||
|
||||
if(file::exists({pathname, node["geometry"].text()})) {
|
||||
string source = file::read({pathname, node["geometry"].text()});
|
||||
parse(instance, source);
|
||||
geometry = glrCreateShader(program, GL_GEOMETRY_SHADER, source);
|
||||
} else {
|
||||
//geometry shaders, when attached, must pass all vertex output through to the fragment shaders
|
||||
@@ -32,6 +34,7 @@ void OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
|
||||
|
||||
if(file::exists({pathname, node["fragment"].text()})) {
|
||||
string source = file::read({pathname, node["fragment"].text()});
|
||||
parse(instance, source);
|
||||
fragment = glrCreateShader(program, GL_FRAGMENT_SHADER, source);
|
||||
} else {
|
||||
fragment = glrCreateShader(program, GL_FRAGMENT_SHADER, OpenGLFragmentShader);
|
||||
@@ -68,6 +71,25 @@ void OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
|
||||
glrLinkProgram(program);
|
||||
}
|
||||
|
||||
//apply manifest settings to shader source #in tags
|
||||
void OpenGLProgram::parse(OpenGL* instance, string& source) {
|
||||
lstring lines = source.split("\n");
|
||||
for(auto& line : lines) {
|
||||
string s = line;
|
||||
if(auto position = s.find("//")) s.resize(position()); //strip comments
|
||||
s.strip(); //remove extraneous whitespace
|
||||
if(s.match("#in ?*")) {
|
||||
s.ltrim<1>("#in ").strip();
|
||||
if(auto setting = instance->settings.find({s})) {
|
||||
line = {"#define ", setting().name, " ", setting().value};
|
||||
} else {
|
||||
line.reset(); //undefined variable (test in source with #ifdef)
|
||||
}
|
||||
}
|
||||
}
|
||||
source = lines.merge("\n");
|
||||
}
|
||||
|
||||
void OpenGLProgram::release() {
|
||||
OpenGLSurface::release();
|
||||
for(auto& pixmap : pixmaps) glDeleteTextures(1, &pixmap.texture);
|
||||
|
Reference in New Issue
Block a user