mirror of https://github.com/bsnes-emu/bsnes.git
Update to v070r03 release.
byuu says: - fixed a bug in xml_element::parse() with <![CDATA[...]]> tags - merged FragmentShader and and VertexShader into Shader, which is an XML file that contains all relevant data - updated Qt port to reflect the above - added support for pixel shaders to the phoenix port - updated all pixel shaders to use the new format - ruby won't crash if you give an HLSL driver a GLSL shader or vice versa, but it will still crash on bad programs - phoenix::Viewport has its own window class, that paints a black brush background [The XML shader] format is subject to change, more specifically I may change the <source> tag from HLSL shaders. In the long-long term, it'd be nice to extend the format to allow multiple shaders to be chained together and to encode base64 texture files. But for now, this is good enough.
This commit is contained in:
parent
73fdbf893f
commit
f28d70f9e6
|
@ -17,31 +17,44 @@ namespace nall {
|
|||
|
||||
struct data_t {
|
||||
R (*callback)(const data_t&, P...);
|
||||
union {
|
||||
R (*callback_global)(P...);
|
||||
struct {
|
||||
R (derived::*callback_member)(P...);
|
||||
void *object;
|
||||
};
|
||||
R (*callback_global)(P...);
|
||||
struct {
|
||||
R (derived::*callback_member)(P...);
|
||||
void *callback_object;
|
||||
};
|
||||
std::function<R (P...)> callback_lambda;
|
||||
} data;
|
||||
|
||||
static R callback_global(const data_t &data, P... p) {
|
||||
return data.callback_global(p...);
|
||||
return data.callback_global(std::forward<P>(p)...);
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
static R callback_member(const data_t &data, P... p) {
|
||||
return (((C*)data.object)->*((R (C::*&)(P...))data.callback_member))(p...);
|
||||
return (((C*)data.callback_object)->*((R (C::*&)(P...))data.callback_member))(std::forward<P>(p)...);
|
||||
}
|
||||
|
||||
static R callback_lambda(const data_t &data, P... p) {
|
||||
return data.callback_lambda(std::forward<P>(p)...);
|
||||
}
|
||||
|
||||
public:
|
||||
R operator()(P... p) const { return data.callback(data, p...); }
|
||||
R operator()(P... p) const { return data.callback(data, std::forward<P>(p)...); }
|
||||
operator bool() const { return data.callback; }
|
||||
void reset() { data.callback = 0; }
|
||||
|
||||
function& operator=(const function &source) { memcpy(&data, &source.data, sizeof(data_t)); return *this; }
|
||||
function(const function &source) { operator=(source); }
|
||||
function& operator=(const function &source) {
|
||||
data.callback = source.data.callback;
|
||||
data.callback_global = source.data.callback_global;
|
||||
data.callback_member = source.data.callback_member;
|
||||
data.callback_object = source.data.callback_object;
|
||||
data.callback_lambda = source.data.callback_lambda;
|
||||
return *this;
|
||||
}
|
||||
|
||||
function(const function &source) {
|
||||
operator=(source);
|
||||
}
|
||||
|
||||
//no pointer
|
||||
function() {
|
||||
|
@ -66,7 +79,7 @@ namespace nall {
|
|||
static_assert(sizeof data.callback_member >= sizeof callback, "callback_member is too small");
|
||||
data.callback = &callback_member<C>;
|
||||
(R (C::*&)(P...))data.callback_member = callback;
|
||||
data.object = object;
|
||||
data.callback_object = object;
|
||||
}
|
||||
|
||||
//const member function pointer
|
||||
|
@ -75,15 +88,15 @@ namespace nall {
|
|||
static_assert(sizeof data.callback_member >= sizeof callback, "callback_member is too small");
|
||||
data.callback = &callback_member<C>;
|
||||
(R (C::*&)(P...))data.callback_member = (R (C::*&)(P...))callback;
|
||||
data.object = object;
|
||||
data.callback_object = object;
|
||||
}
|
||||
|
||||
//lambda function pointer
|
||||
template<typename T>
|
||||
function(T callback) {
|
||||
function(const T &callback) {
|
||||
static_assert(std::is_same<R, typename std::result_of<T(P...)>::type>::value, "lambda mismatch");
|
||||
data.callback = &callback_global;
|
||||
data.callback_global = (R (*)(P...))callback;
|
||||
data.callback = &callback_lambda;
|
||||
data.callback_lambda = callback;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ inline string xml_element::parse() const {
|
|||
data << cdata;
|
||||
offset += strlen(cdata);
|
||||
|
||||
source += offset + 3;
|
||||
source += 9 + offset + 3;
|
||||
continue;
|
||||
} else {
|
||||
return "";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
void Viewport::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
|
||||
widget->window = CreateWindow(
|
||||
L"phoenix_window", L"",
|
||||
L"phoenix_viewport", L"",
|
||||
WS_CHILD | WS_VISIBLE | WS_DISABLED,
|
||||
x, y, width, height,
|
||||
parent.widget->window, (HMENU)object->id, GetModuleHandle(0), 0
|
||||
|
@ -11,3 +11,7 @@ void Viewport::create(Window &parent, unsigned x, unsigned y, unsigned width, un
|
|||
uintptr_t Viewport::handle() {
|
||||
return (uintptr_t)widget->window;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK Viewport_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
|
|
@ -440,6 +440,18 @@ OS::OS() {
|
|||
wc.lpszMenuName = 0;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
RegisterClass(&wc);
|
||||
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hInstance = GetModuleHandle(0);
|
||||
wc.lpfnWndProc = Viewport_windowProc;
|
||||
wc.lpszClassName = L"phoenix_viewport";
|
||||
wc.lpszMenuName = 0;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
RegisterClass(&wc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ InputInterface input;
|
|||
const char *Video::Handle = "Handle";
|
||||
const char *Video::Synchronize = "Synchronize";
|
||||
const char *Video::Filter = "Filter";
|
||||
const char *Video::Shader = "Shader";
|
||||
const char *Video::FragmentShader = "FragmentShader";
|
||||
const char *Video::VertexShader = "VertexShader";
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ public:
|
|||
static const char *Handle;
|
||||
static const char *Synchronize;
|
||||
static const char *Filter;
|
||||
static const char *Shader;
|
||||
static const char *FragmentShader;
|
||||
static const char *VertexShader;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
LPDIRECT3DTEXTURE9 texture;
|
||||
LPDIRECT3DSURFACE9 surface;
|
||||
LPD3DXEFFECT effect;
|
||||
string shaderSource;
|
||||
string shader_source_xml;
|
||||
|
||||
bool lost;
|
||||
unsigned iwidth, iheight;
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
if(name == Video::Handle) return true;
|
||||
if(name == Video::Synchronize) return true;
|
||||
if(name == Video::Filter) return true;
|
||||
if(name == Video::FragmentShader) return true;
|
||||
if(name == Video::Shader) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::FragmentShader) {
|
||||
set_fragment_shader(any_cast<const char*>(value));
|
||||
if(name == Video::Shader) {
|
||||
set_shader(any_cast<const char*>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ public:
|
|||
//failure to do so causes scaling issues on some video drivers.
|
||||
if(state.width != rd.right || state.height != rd.bottom) {
|
||||
init();
|
||||
set_fragment_shader(shaderSource);
|
||||
set_shader(shader_source_xml);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ public:
|
|||
if(device->Present(0, 0, 0, 0) == D3DERR_DEVICELOST) lost = true;
|
||||
}
|
||||
|
||||
void set_fragment_shader(const char *source) {
|
||||
void set_shader(const char *source) {
|
||||
if(!caps.shader) return;
|
||||
|
||||
if(effect) {
|
||||
|
@ -336,11 +336,27 @@ public:
|
|||
}
|
||||
|
||||
if(!source || !*source) {
|
||||
shaderSource = "";
|
||||
shader_source_xml = "";
|
||||
return;
|
||||
}
|
||||
shader_source_xml = source;
|
||||
|
||||
shaderSource = source;
|
||||
bool is_hlsl = false;
|
||||
string shader_source;
|
||||
xml_element document = xml_parse(shader_source_xml);
|
||||
foreach(head, document.element) {
|
||||
if(head.name == "shader") {
|
||||
foreach(attribute, head.attribute) {
|
||||
if(attribute.name == "language" && attribute.content == "HLSL") is_hlsl = true;
|
||||
}
|
||||
foreach(element, head.element) {
|
||||
if(element.name == "source") {
|
||||
if(is_hlsl) shader_source = element.parse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(shader_source == "") return;
|
||||
|
||||
HMODULE d3dx;
|
||||
for(unsigned i = 0; i < 256; i++) {
|
||||
|
@ -356,7 +372,7 @@ public:
|
|||
TextureProc textureProc = (TextureProc)GetProcAddress(d3dx, "D3DXCreateTextureFromFileA");
|
||||
|
||||
LPD3DXBUFFER pBufferErrors = NULL;
|
||||
effectProc(device, shaderSource, lstrlenA(source), NULL, NULL, 0, NULL, &effect, &pBufferErrors);
|
||||
effectProc(device, shader_source, lstrlenA(shader_source), NULL, NULL, 0, NULL, &effect, &pBufferErrors);
|
||||
|
||||
D3DXHANDLE hTech;
|
||||
effect->FindNextValidTechnique(NULL, &hTech);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
video.glx
|
||||
author: byuu
|
||||
license: public domain
|
||||
last updated: 2010-01-05
|
||||
last updated: 2010-09-28
|
||||
|
||||
Design notes:
|
||||
SGI's GLX is the X11/Xlib interface to OpenGL.
|
||||
|
@ -62,6 +62,7 @@ public:
|
|||
if(name == Video::Handle) return true;
|
||||
if(name == Video::Synchronize) return true;
|
||||
if(name == Video::Filter) return true;
|
||||
if(name == Video::Shader) return true;
|
||||
if(name == Video::FragmentShader) return true;
|
||||
if(name == Video::VertexShader) return true;
|
||||
return false;
|
||||
|
@ -93,6 +94,11 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::Shader) {
|
||||
OpenGL::set_shader(any_cast<const char*>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::FragmentShader) {
|
||||
OpenGL::set_fragment_shader(any_cast<const char*>(value));
|
||||
return true;
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void set_fragment_shader(const char *source) {
|
||||
void set_shader(const char *source) {
|
||||
if(!shader_support) return;
|
||||
|
||||
if(fragmentshader) {
|
||||
|
@ -131,19 +131,6 @@ public:
|
|||
fragmentshader = 0;
|
||||
}
|
||||
|
||||
if(source) {
|
||||
fragmentshader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(fragmentshader, 1, &source, 0);
|
||||
glCompileShader(fragmentshader);
|
||||
glAttachShader(glprogram, fragmentshader);
|
||||
}
|
||||
|
||||
glLinkProgram(glprogram);
|
||||
}
|
||||
|
||||
void set_vertex_shader(const char *source) {
|
||||
if(!shader_support) return;
|
||||
|
||||
if(vertexshader) {
|
||||
glDetachShader(glprogram, vertexshader);
|
||||
glDeleteShader(vertexshader);
|
||||
|
@ -151,15 +138,49 @@ public:
|
|||
}
|
||||
|
||||
if(source) {
|
||||
vertexshader = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vertexshader, 1, &source, 0);
|
||||
glCompileShader(vertexshader);
|
||||
glAttachShader(glprogram, vertexshader);
|
||||
bool is_glsl = false;
|
||||
string fragment_source;
|
||||
string vertex_source;
|
||||
|
||||
xml_element document = xml_parse(source);
|
||||
foreach(head, document.element) {
|
||||
if(head.name == "shader") {
|
||||
foreach(attribute, head.attribute) {
|
||||
if(attribute.name == "language" && attribute.content == "GLSL") is_glsl = true;
|
||||
}
|
||||
foreach(element, head.element) {
|
||||
if(element.name == "fragment") {
|
||||
fragment_source = element.parse();
|
||||
} else if(element.name == "vertex") {
|
||||
vertex_source = element.parse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_glsl) {
|
||||
if(fragment_source != "") set_fragment_shader(fragment_source);
|
||||
if(vertex_source != "") set_vertex_shader(vertex_source);
|
||||
}
|
||||
}
|
||||
|
||||
glLinkProgram(glprogram);
|
||||
}
|
||||
|
||||
void set_fragment_shader(const char *source) {
|
||||
fragmentshader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(fragmentshader, 1, &source, 0);
|
||||
glCompileShader(fragmentshader);
|
||||
glAttachShader(glprogram, fragmentshader);
|
||||
}
|
||||
|
||||
void set_vertex_shader(const char *source) {
|
||||
vertexshader = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vertexshader, 1, &source, 0);
|
||||
glCompileShader(vertexshader);
|
||||
glAttachShader(glprogram, vertexshader);
|
||||
}
|
||||
|
||||
void init() {
|
||||
//disable unused features
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
|
|
@ -29,8 +29,7 @@ public:
|
|||
if(name == Video::Handle) return true;
|
||||
if(name == Video::Synchronize) return true;
|
||||
if(name == Video::Filter) return true;
|
||||
if(name == Video::FragmentShader) return true;
|
||||
if(name == Video::VertexShader) return true;
|
||||
if(name == Video::Shader) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -59,13 +58,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::FragmentShader) {
|
||||
OpenGL::set_fragment_shader(any_cast<const char*>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::VertexShader) {
|
||||
OpenGL::set_vertex_shader(any_cast<const char*>(value));
|
||||
if(name == Video::Shader) {
|
||||
OpenGL::set_shader(any_cast<const char*>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace SNES {
|
||||
namespace Info {
|
||||
static const char Name[] = "bsnes";
|
||||
static const char Version[] = "070.02";
|
||||
static const char Version[] = "070.03";
|
||||
static const unsigned SerializerVersion = 13;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,9 @@ void Configuration::create() {
|
|||
|
||||
attach(video.driver = "", "video.driver");
|
||||
attach(video.synchronize = false, "video.synchronize");
|
||||
attach(video.region = 0, "video.region");
|
||||
attach(video.smooth = true, "video.smooth");
|
||||
attach(video.shader = "", "video.shader");
|
||||
attach(video.region = 0, "video.region");
|
||||
attach(video.scale = 2, "video.scale");
|
||||
attach(video.aspectRatioCorrection = true, "video.aspectRatioCorrection");
|
||||
attach(video.contrast = 100, "video.contrast");
|
||||
|
|
|
@ -11,8 +11,9 @@ struct Configuration : public configuration {
|
|||
struct Video {
|
||||
string driver;
|
||||
bool synchronize;
|
||||
bool region;
|
||||
bool smooth;
|
||||
string shader;
|
||||
bool region;
|
||||
unsigned scale;
|
||||
bool aspectRatioCorrection;
|
||||
unsigned contrast;
|
||||
|
|
|
@ -48,6 +48,9 @@ void FileBrowser::fileOpen(FileBrowser::Mode requestedMode, function<void (strin
|
|||
filters.append(".gbc");
|
||||
filters.append(".sgb");
|
||||
}
|
||||
case Mode::Shader: {
|
||||
filters.append(".shader");
|
||||
}
|
||||
}
|
||||
|
||||
setVisible(false);
|
||||
|
|
|
@ -4,7 +4,7 @@ struct FileBrowser : Window {
|
|||
Button upButton;
|
||||
ListBox contentsBox;
|
||||
|
||||
enum class Mode : unsigned { Cartridge, Satellaview, SufamiTurbo, GameBoy } mode;
|
||||
enum class Mode : unsigned { Cartridge, Satellaview, SufamiTurbo, GameBoy, Shader } mode;
|
||||
void fileOpen(Mode mode, function<void (string)> callback);
|
||||
void create();
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ void Application::main(int argc, char **argv) {
|
|||
video.driver("None");
|
||||
video.init();
|
||||
}
|
||||
utility.setShader();
|
||||
|
||||
audio.driver(config.audio.driver);
|
||||
audio.set(Audio::Handle, mainWindow.viewport.handle());
|
||||
|
|
|
@ -5,7 +5,7 @@ void VideoSettings::create() {
|
|||
Window::create(0, 0, 256, 256, "Video Settings");
|
||||
setDefaultFont(application.proportionalFont);
|
||||
|
||||
unsigned x = 5, y = 5;
|
||||
unsigned x = 5, y = 5, height = Style::TextBoxHeight;
|
||||
|
||||
colorAdjustmentLabel.create(*this, x, y, 430, Style::LabelHeight, "Color Adjustment :."); y += Style::LabelHeight + 5;
|
||||
colorAdjustmentLabel.setFont(application.proportionalFontBold);
|
||||
|
@ -24,6 +24,15 @@ void VideoSettings::create() {
|
|||
|
||||
gammaRampCheck.create (*this, x, y, 430, Style::CheckBoxHeight, "Enable NTSC gamma ramp simulation"); y += Style::CheckBoxHeight + 5;
|
||||
|
||||
shaderLabel.create(*this, x, y, 340, Style::LabelHeight, "Pixel Shader :."); y += Style::LabelHeight + 5;
|
||||
shaderLabel.setFont(application.proportionalFontBold);
|
||||
|
||||
shaderPath.create(*this, x, y, 430 - height - height - 10, height);
|
||||
shaderPath.setEditable(false);
|
||||
shaderPath.setText(config.video.shader);
|
||||
shaderClear.create(*this, x + 430 - height - height - 5, y, height, height, "");
|
||||
shaderSelect.create(*this, x + 430 - height, y, height, height, "..."); y += height + 5;
|
||||
|
||||
setGeometry(160, 160, 440, y);
|
||||
|
||||
contrastSlider.setPosition(config.video.contrast);
|
||||
|
@ -33,6 +42,20 @@ void VideoSettings::create() {
|
|||
|
||||
contrastSlider.onChange = brightnessSlider.onChange = gammaSlider.onChange = gammaRampCheck.onTick =
|
||||
{ &VideoSettings::adjust, this };
|
||||
|
||||
shaderClear.onTick = []() {
|
||||
config.video.shader = "";
|
||||
videoSettings.shaderPath.setText(config.video.shader);
|
||||
utility.setShader();
|
||||
};
|
||||
|
||||
shaderSelect.onTick = []() {
|
||||
fileBrowser.fileOpen(FileBrowser::Mode::Shader, [](string filename) {
|
||||
config.video.shader = filename;
|
||||
videoSettings.shaderPath.setText(config.video.shader);
|
||||
utility.setShader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
void VideoSettings::adjust() {
|
||||
|
|
|
@ -10,6 +10,10 @@ struct VideoSettings : Window {
|
|||
Label gammaValue;
|
||||
HorizontalSlider gammaSlider;
|
||||
CheckBox gammaRampCheck;
|
||||
Label shaderLabel;
|
||||
TextBox shaderPath;
|
||||
Button shaderClear;
|
||||
Button shaderSelect;
|
||||
|
||||
void create();
|
||||
void adjust();
|
||||
|
|
|
@ -51,6 +51,12 @@ void Utility::setScale(unsigned scale) {
|
|||
mainWindow.setGeometry(128, 128, width, height);
|
||||
}
|
||||
|
||||
void Utility::setShader() {
|
||||
string data;
|
||||
data.readfile(config.video.shader);
|
||||
video.set(Video::Shader, (const char*)data);
|
||||
}
|
||||
|
||||
void Utility::cartridgeLoaded() {
|
||||
SNES::system.power();
|
||||
cheatEditor.load(cartridge.baseName);
|
||||
|
|
|
@ -5,6 +5,7 @@ struct Utility : property<Utility> {
|
|||
void showMessage(const char *text);
|
||||
|
||||
void setScale(unsigned scale = 0);
|
||||
void setShader();
|
||||
|
||||
void cartridgeLoaded();
|
||||
void cartridgeUnloaded();
|
||||
|
|
|
@ -60,8 +60,7 @@ Configuration::Configuration() {
|
|||
attach(path.bsx = "", "path.bsx");
|
||||
attach(path.st = "", "path.st");
|
||||
attach(path.sgb = "", "path.sgb");
|
||||
attach(path.fragmentShader = "", "path.fragmentShader");
|
||||
attach(path.vertexShader = "", "path.vertexShader");
|
||||
attach(path.shader = "", "path.shader");
|
||||
|
||||
attach(path.current.folder = "", "path.current.folder");
|
||||
attach(path.current.movie = "", "path.current.movie");
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
string startup; //startup path
|
||||
string rom, save, state, patch, cheat, data;
|
||||
string bsx, st, sgb;
|
||||
string fragmentShader, vertexShader;
|
||||
string shader;
|
||||
|
||||
struct Current {
|
||||
string folder, movie, shader, cartridge;
|
||||
|
|
|
@ -138,29 +138,14 @@ VideoSettingsWindow::VideoSettingsWindow() {
|
|||
pixelShaderLayout = new QGridLayout;
|
||||
layout->addLayout(pixelShaderLayout);
|
||||
|
||||
fragmentShaderLabel = new QLabel("Fragment:");
|
||||
pixelShaderLayout->addWidget(fragmentShaderLabel, 0, 0);
|
||||
shaderValue = new QLineEdit;
|
||||
pixelShaderLayout->addWidget(shaderValue, 0, 0);
|
||||
|
||||
fragmentShaderValue = new QLineEdit;
|
||||
pixelShaderLayout->addWidget(fragmentShaderValue, 0, 1);
|
||||
shaderSelect = new QPushButton("Select ...");
|
||||
pixelShaderLayout->addWidget(shaderSelect, 0, 1);
|
||||
|
||||
fragmentShaderSelect = new QPushButton("Select ...");
|
||||
pixelShaderLayout->addWidget(fragmentShaderSelect, 0, 2);
|
||||
|
||||
fragmentShaderDefault = new QPushButton("Default");
|
||||
pixelShaderLayout->addWidget(fragmentShaderDefault, 0, 3);
|
||||
|
||||
vertexShaderLabel = new QLabel("Vertex:");
|
||||
pixelShaderLayout->addWidget(vertexShaderLabel, 1, 0);
|
||||
|
||||
vertexShaderValue = new QLineEdit;
|
||||
pixelShaderLayout->addWidget(vertexShaderValue, 1, 1);
|
||||
|
||||
vertexShaderSelect = new QPushButton("Select ...");
|
||||
pixelShaderLayout->addWidget(vertexShaderSelect, 1, 2);
|
||||
|
||||
vertexShaderDefault = new QPushButton("Default");
|
||||
pixelShaderLayout->addWidget(vertexShaderDefault, 1, 3);
|
||||
shaderDefault = new QPushButton("Default");
|
||||
pixelShaderLayout->addWidget(shaderDefault, 0, 2);
|
||||
|
||||
connect(autoHideFullscreenMenu, SIGNAL(stateChanged(int)), this, SLOT(autoHideFullscreenMenuToggle()));
|
||||
connect(contrastSlider, SIGNAL(valueChanged(int)), this, SLOT(contrastAdjust(int)));
|
||||
|
@ -172,31 +157,18 @@ VideoSettingsWindow::VideoSettingsWindow() {
|
|||
connect(cropTopSlider, SIGNAL(valueChanged(int)), this, SLOT(cropTopAdjust(int)));
|
||||
connect(cropRightSlider, SIGNAL(valueChanged(int)), this, SLOT(cropRightAdjust(int)));
|
||||
connect(cropBottomSlider, SIGNAL(valueChanged(int)), this, SLOT(cropBottomAdjust(int)));
|
||||
connect(fragmentShaderSelect, SIGNAL(released()), this, SLOT(selectFragmentShader()));
|
||||
connect(fragmentShaderDefault, SIGNAL(released()), this, SLOT(defaultFragmentShader()));
|
||||
connect(vertexShaderSelect, SIGNAL(released()), this, SLOT(selectVertexShader()));
|
||||
connect(vertexShaderDefault, SIGNAL(released()), this, SLOT(defaultVertexShader()));
|
||||
connect(shaderSelect, SIGNAL(released()), this, SLOT(selectShader()));
|
||||
connect(shaderDefault, SIGNAL(released()), this, SLOT(defaultShader()));
|
||||
|
||||
syncUi();
|
||||
}
|
||||
|
||||
void VideoSettingsWindow::synchronizePixelShaderSettings() {
|
||||
if(!video.cap(Video::FragmentShader) && !video.cap(Video::VertexShader)) {
|
||||
if(video.cap(Video::Shader) == false) {
|
||||
pixelShaderLabel->hide();
|
||||
}
|
||||
|
||||
if(!video.cap(Video::FragmentShader)) {
|
||||
fragmentShaderLabel->hide();
|
||||
fragmentShaderValue->hide();
|
||||
fragmentShaderSelect->hide();
|
||||
fragmentShaderDefault->hide();
|
||||
}
|
||||
|
||||
if(!video.cap(Video::VertexShader)) {
|
||||
vertexShaderLabel->hide();
|
||||
vertexShaderValue->hide();
|
||||
vertexShaderSelect->hide();
|
||||
vertexShaderDefault->hide();
|
||||
shaderValue->hide();
|
||||
shaderSelect->hide();
|
||||
shaderDefault->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,8 +211,7 @@ void VideoSettingsWindow::syncUi() {
|
|||
cropBottomValue->setText(string() << n << "%");
|
||||
cropBottomSlider->setSliderPosition(n);
|
||||
|
||||
fragmentShaderValue->setText(config().path.fragmentShader);
|
||||
vertexShaderValue->setText(config().path.vertexShader);
|
||||
shaderValue->setText(config().path.shader);
|
||||
}
|
||||
|
||||
void VideoSettingsWindow::autoHideFullscreenMenuToggle() {
|
||||
|
@ -301,41 +272,21 @@ void VideoSettingsWindow::cropBottomAdjust(int state) {
|
|||
syncUi();
|
||||
}
|
||||
|
||||
void VideoSettingsWindow::selectFragmentShader() {
|
||||
void VideoSettingsWindow::selectShader() {
|
||||
fileBrowser->onChange.reset();
|
||||
fileBrowser->onActivate = { &VideoSettingsWindow::assignFragmentShader, this };
|
||||
fileBrowser->onAccept = { &VideoSettingsWindow::assignFragmentShader, this };
|
||||
fileBrowser->setWindowTitle("Select Fragment Shader");
|
||||
fileBrowser->onActivate = { &VideoSettingsWindow::assignShader, this };
|
||||
fileBrowser->onAccept = { &VideoSettingsWindow::assignShader, this };
|
||||
fileBrowser->setWindowTitle("Select Pixel Shader");
|
||||
fileBrowser->setPath(config().path.current.shader);
|
||||
fileBrowser->setNameFilters("All files (*)");
|
||||
fileBrowser->setNameFilters("Shader files (*.shader)");
|
||||
fileBrowser->chooseFile();
|
||||
}
|
||||
|
||||
void VideoSettingsWindow::selectVertexShader() {
|
||||
fileBrowser->onChange.reset();
|
||||
fileBrowser->onActivate = { &VideoSettingsWindow::assignVertexShader, this };
|
||||
fileBrowser->onAccept = { &VideoSettingsWindow::assignVertexShader, this };
|
||||
fileBrowser->setWindowTitle("Select Vertex Shader");
|
||||
fileBrowser->setPath(config().path.current.shader);
|
||||
fileBrowser->setNameFilters("All files (*)");
|
||||
fileBrowser->chooseFile();
|
||||
}
|
||||
void VideoSettingsWindow::defaultShader() { assignShader(""); }
|
||||
|
||||
void VideoSettingsWindow::defaultFragmentShader() { assignFragmentShader(""); }
|
||||
void VideoSettingsWindow::defaultVertexShader() { assignVertexShader(""); }
|
||||
|
||||
void VideoSettingsWindow::assignFragmentShader(const string &filename) {
|
||||
void VideoSettingsWindow::assignShader(const string &filename) {
|
||||
if(filename == "" || QDir(filename).exists() == false) {
|
||||
config().path.fragmentShader = filename;
|
||||
if(filename != "") config().path.current.shader = dir(filename);
|
||||
syncUi();
|
||||
utility.updatePixelShader();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSettingsWindow::assignVertexShader(const string &filename) {
|
||||
if(filename == "" || QDir(filename).exists() == false) {
|
||||
config().path.vertexShader = filename;
|
||||
config().path.shader = filename;
|
||||
if(filename != "") config().path.current.shader = dir(filename);
|
||||
syncUi();
|
||||
utility.updatePixelShader();
|
||||
|
|
|
@ -37,14 +37,9 @@ public:
|
|||
QSlider *cropBottomSlider;
|
||||
QLabel *pixelShaderLabel;
|
||||
QGridLayout *pixelShaderLayout;
|
||||
QLabel *fragmentShaderLabel;
|
||||
QLineEdit *fragmentShaderValue;
|
||||
QPushButton *fragmentShaderSelect;
|
||||
QPushButton *fragmentShaderDefault;
|
||||
QLabel *vertexShaderLabel;
|
||||
QLineEdit *vertexShaderValue;
|
||||
QPushButton *vertexShaderSelect;
|
||||
QPushButton *vertexShaderDefault;
|
||||
QLineEdit *shaderValue;
|
||||
QPushButton *shaderSelect;
|
||||
QPushButton *shaderDefault;
|
||||
|
||||
void synchronizePixelShaderSettings();
|
||||
void syncUi();
|
||||
|
@ -61,14 +56,11 @@ private slots:
|
|||
void cropTopAdjust(int);
|
||||
void cropRightAdjust(int);
|
||||
void cropBottomAdjust(int);
|
||||
void selectFragmentShader();
|
||||
void selectVertexShader();
|
||||
void defaultFragmentShader();
|
||||
void defaultVertexShader();
|
||||
void selectShader();
|
||||
void defaultShader();
|
||||
|
||||
private:
|
||||
void assignFragmentShader(const string &filename);
|
||||
void assignVertexShader(const string &filename);
|
||||
void assignShader(const string &filename);
|
||||
};
|
||||
|
||||
extern VideoSettingsWindow *videoSettingsWindow;
|
||||
|
|
|
@ -73,16 +73,10 @@ void Utility::updateColorFilter() {
|
|||
void Utility::updatePixelShader() {
|
||||
string filedata;
|
||||
|
||||
if(filedata.readfile(config().path.fragmentShader)) {
|
||||
video.set(Video::FragmentShader, (const char*)filedata);
|
||||
if(filedata.readfile(config().path.shader)) {
|
||||
video.set(Video::Shader, (const char*)filedata);
|
||||
} else {
|
||||
video.set(Video::FragmentShader, (const char*)0);
|
||||
}
|
||||
|
||||
if(filedata.readfile(config().path.vertexShader)) {
|
||||
video.set(Video::VertexShader, (const char*)filedata);
|
||||
} else {
|
||||
video.set(Video::VertexShader, (const char*)0);
|
||||
video.set(Video::Shader, (const char*)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue