Fix Text shader and RenderTexture viewport for SDL2 backend
Text rendering fix: - Add ShaderType parameter to drawTriangles() to allow explicit shader selection - Text::draw() now properly uses text shader (alpha-only sampling) - Previously drawTriangles() always overrode to sprite shader RenderTexture fix: - Add pushRenderState/popRenderState to save/restore viewport and projection - RenderTexture::clear() now sets viewport/projection to FBO dimensions - RenderTexture::display() restores previous state - This fixes grid rendering which uses RenderTexture for tile chunks Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
be6fe23499
commit
e08f189d60
2 changed files with 66 additions and 8 deletions
|
|
@ -82,11 +82,16 @@ public:
|
|||
// Drawing primitives
|
||||
void drawTriangles(const float* vertices, size_t vertexCount,
|
||||
const float* colors, const float* texCoords,
|
||||
unsigned int textureId = 0);
|
||||
unsigned int textureId = 0,
|
||||
ShaderType shaderType = ShaderType::Shape);
|
||||
|
||||
// Projection matrix access (for shaders)
|
||||
const float* getProjectionMatrix() const { return projectionMatrix_; }
|
||||
|
||||
// Push/pop viewport and projection for RenderTexture
|
||||
void pushRenderState(unsigned int width, unsigned int height);
|
||||
void popRenderState();
|
||||
|
||||
private:
|
||||
SDL2Renderer() = default;
|
||||
~SDL2Renderer() = default;
|
||||
|
|
@ -107,6 +112,13 @@ private:
|
|||
// FBO stack for nested render-to-texture
|
||||
std::vector<unsigned int> fboStack_;
|
||||
|
||||
// Viewport/projection stack for nested rendering
|
||||
struct RenderState {
|
||||
int viewport[4]; // x, y, width, height
|
||||
float projection[16];
|
||||
};
|
||||
std::vector<RenderState> renderStateStack_;
|
||||
|
||||
// Helper functions
|
||||
bool compileAndLinkProgram(const char* vertexSrc, const char* fragmentSrc, unsigned int& programOut);
|
||||
unsigned int compileShaderStage(unsigned int type, const char* source);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue