mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-11 03:25:36 +00:00
gpu renderer: always pass tex_coord to fragment shader
As suggested in #14843, pass vertex tex_coord to vertex shader and to fragment shader even when no texture is bounded so they can be used by custom fragment shaders.
This commit is contained in:
committed by
Sam Lantinga
parent
15ceaffcb5
commit
b1aaa41921
@@ -665,7 +665,7 @@ static bool GPU_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
float *verts;
|
||||
size_t sz = 2 * sizeof(float) + 4 * sizeof(float) + (texture ? 2 : 0) * sizeof(float);
|
||||
size_t sz = 2 * sizeof(float) + 4 * sizeof(float) + 2 * sizeof(float);
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
|
||||
verts = (float *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
@@ -705,10 +705,13 @@ static bool GPU_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
|
||||
*(verts++) = col_.b;
|
||||
*(verts++) = col_.a;
|
||||
|
||||
if (texture) {
|
||||
if (uv) {
|
||||
float *uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
*(verts++) = uv_[0];
|
||||
*(verts++) = uv_[1];
|
||||
} else {
|
||||
*(verts++) = 0.0f;
|
||||
*(verts++) = 0.0f;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user