mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
GL: Add RendererGL::getSpecializedShader
This commit is contained in:
parent
ddc14cea09
commit
fdfb012aa1
2 changed files with 22 additions and 4 deletions
|
@ -60,6 +60,7 @@ class RendererGL final : public Renderer {
|
||||||
|
|
||||||
OpenGL::Framebuffer getColourFBO();
|
OpenGL::Framebuffer getColourFBO();
|
||||||
OpenGL::Texture getTexture(Texture& tex);
|
OpenGL::Texture getTexture(Texture& tex);
|
||||||
|
OpenGL::Program getSpecializedShader();
|
||||||
|
|
||||||
PICA::ShaderGen::FragmentGenerator fragShaderGen;
|
PICA::ShaderGen::FragmentGenerator fragShaderGen;
|
||||||
|
|
||||||
|
|
|
@ -393,10 +393,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
std::string fs = fragShaderGen.generate(regs);
|
std::string fs = fragShaderGen.generate(regs);
|
||||||
std::cout << fs << "\n\n\n";
|
std::cout << fs << "\n\n\n";
|
||||||
|
|
||||||
OpenGL::Program program;
|
OpenGL::Program program = getSpecializedShader();
|
||||||
OpenGL::Shader vertShader({vs.c_str(), vs.size()}, OpenGL::Vertex);
|
|
||||||
OpenGL::Shader fragShader({fs.c_str(), fs.size()}, OpenGL::Fragment);
|
|
||||||
program.create({vertShader, fragShader});
|
|
||||||
|
|
||||||
const auto primitiveTopology = primTypes[static_cast<usize>(primType)];
|
const auto primitiveTopology = primTypes[static_cast<usize>(primType)];
|
||||||
gl.disableScissor();
|
gl.disableScissor();
|
||||||
|
@ -787,6 +784,26 @@ std::optional<ColourBuffer> RendererGL::getColourBuffer(u32 addr, PICA::ColorFmt
|
||||||
return colourBufferCache.add(sampleBuffer);
|
return colourBufferCache.add(sampleBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGL::Program RendererGL::getSpecializedShader() {
|
||||||
|
OpenGL::Program program;
|
||||||
|
|
||||||
|
std::string vs = fragShaderGen.getVertexShader(regs);
|
||||||
|
std::string fs = fragShaderGen.generate(regs);
|
||||||
|
|
||||||
|
OpenGL::Shader vertShader({vs.c_str(), vs.size()}, OpenGL::Vertex);
|
||||||
|
OpenGL::Shader fragShader({fs.c_str(), fs.size()}, OpenGL::Fragment);
|
||||||
|
program.create({vertShader, fragShader});
|
||||||
|
program.use();
|
||||||
|
|
||||||
|
// Init sampler objects. Texture 0 goes in texture unit 0, texture 1 in TU 1, texture 2 in TU 2, and the light maps go in TU 3
|
||||||
|
glUniform1i(OpenGL::uniformLocation(program, "u_tex0"), 0);
|
||||||
|
glUniform1i(OpenGL::uniformLocation(program, "u_tex1"), 1);
|
||||||
|
glUniform1i(OpenGL::uniformLocation(program, "u_tex2"), 2);
|
||||||
|
glUniform1i(OpenGL::uniformLocation(program, "u_tex_lighting_lut"), 3);
|
||||||
|
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
void RendererGL::screenshot(const std::string& name) {
|
void RendererGL::screenshot(const std::string& name) {
|
||||||
constexpr uint width = 400;
|
constexpr uint width = 400;
|
||||||
constexpr uint height = 2 * 240;
|
constexpr uint height = 2 * 240;
|
||||||
|
|
Loading…
Add table
Reference in a new issue