Created
August 26, 2018 16:06
-
-
Save Ohmnivore/0d4a8eaf1cc850ea607867dedd5d27fb to your computer and use it in GitHub Desktop.
oryol uniform layout generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 | |
#ifdef GL_ARB_shading_language_420pack | |
#extension GL_ARB_shading_language_420pack : require | |
#endif | |
uniform vec4 params[6]; | |
layout(location = 0) in vec4 position; | |
out vec2 uv; | |
layout(location = 2) in vec2 texcoord0; | |
void main() | |
{ | |
vec2 _28 = mat2(params[4].xy, params[5].xy) * vec2(position.xy); | |
vec4 pos; | |
pos = vec4(_28.x, _28.y, pos.z, pos.w); | |
pos.z = position.z; | |
pos.w = position.w; | |
gl_Position = mat4(params[0], params[1], params[2], params[3]) * pos; | |
uv = texcoord0; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------------------------------------------------------------- | |
// #version:49# machine generated, do not edit! | |
//----------------------------------------------------------------------------- | |
#include "Pre.h" | |
#include "shaders.h" | |
static const char* mainVS_glsl330_src = | |
"#version 330\n" | |
"#ifdef GL_ARB_shading_language_420pack\n" | |
"#extension GL_ARB_shading_language_420pack : require\n" | |
"#endif\n" | |
"\n" | |
"uniform vec4 params[6];\n" | |
"layout(location = 0) in vec4 position;\n" | |
"out vec2 uv;\n" | |
"layout(location = 2) in vec2 texcoord0;\n" | |
"\n" | |
"void main()\n" | |
"{\n" | |
" vec2 _28 = mat2(params[4].xy, params[5].xy) * vec2(position.xy);\n" | |
" vec4 pos;\n" | |
" pos = vec4(_28.x, _28.y, pos.z, pos.w);\n" | |
" pos.z = position.z;\n" | |
" pos.w = position.w;\n" | |
" gl_Position = mat4(params[0], params[1], params[2], params[3]) * pos;\n" | |
" uv = texcoord0;\n" | |
"}\n" | |
"\n" | |
; | |
static const char* mainFS_glsl330_src = | |
"#version 330\n" | |
"#ifdef GL_ARB_shading_language_420pack\n" | |
"#extension GL_ARB_shading_language_420pack : require\n" | |
"#endif\n" | |
"\n" | |
"uniform sampler2D tex;\n" | |
"\n" | |
"out vec4 fragColor;\n" | |
"in vec2 uv;\n" | |
"\n" | |
"void main()\n" | |
"{\n" | |
" fragColor = texture(tex, uv);\n" | |
"}\n" | |
"\n" | |
; | |
Oryol::ShaderSetup MainShader::Setup() { | |
Oryol::ShaderSetup setup("MainShader"); | |
Oryol::VertexLayout mainVS_input; | |
mainVS_input.Add(Oryol::VertexAttr::Position, Oryol::VertexFormat::Float4); | |
mainVS_input.Add(Oryol::VertexAttr::TexCoord0, Oryol::VertexFormat::Float2); | |
setup.SetInputLayout(mainVS_input); | |
setup.SetProgramFromSources(Oryol::ShaderLang::GLSL330, mainVS_glsl330_src, mainFS_glsl330_src); | |
setup.AddUniformBlock("params", "_15", 989138735, 96, params::_bindShaderStage, params::_bindSlotIndex); | |
setup.AddTexture("tex", Oryol::TextureType::Texture2D, Oryol::ShaderStage::FS, 0); | |
return setup; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
//----------------------------------------------------------------------------- | |
/* #version:49# | |
machine generated, do not edit! | |
*/ | |
#include "Gfx/GfxTypes.h" | |
#include "glm/vec2.hpp" | |
#include "glm/vec3.hpp" | |
#include "glm/vec4.hpp" | |
#include "glm/mat2x2.hpp" | |
#include "glm/mat3x3.hpp" | |
#include "glm/mat4x4.hpp" | |
#include "Resource/Id.h" | |
namespace MainShader { | |
#pragma pack(push,1) | |
struct params { | |
static const int _bindSlotIndex = 0; | |
static const Oryol::ShaderStage::Code _bindShaderStage = Oryol::ShaderStage::VS; | |
static const uint32_t _layoutHash = 989138735; | |
glm::mat4 viewProj; | |
glm::mat2 model; | |
}; | |
#pragma pack(pop) | |
static const int tex = 0; | |
extern Oryol::ShaderSetup Setup(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment