Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDL2] [PSP] SDL_RenderGeometry / SDL_RenderGeometryRaw does not render textures and vertices colors properly. #9767

Open
antim0118 opened this issue May 11, 2024 · 2 comments
Milestone

Comments

@antim0118
Copy link

As far as I can understand, SDL_RenderGeometry / SDL_RenderGeometryRaw is supposed to color vertices as a gradient, however in both cases only the last color is used.

Code snippet:

//blue triangle
SDL_Vertex vertex_1 = { {100, 100}, {255, 0, 0, 255}, {1, 1} };
SDL_Vertex vertex_2 = { {200, 100}, {0, 255, 0, 255}, {1, 1} };
SDL_Vertex vertex_3 = { {200, 200}, {0, 0, 255, 255}, {1, 1} }; // <- this color is being used (blue)
SDL_Vertex vertices[] = { vertex_1,vertex_2,vertex_3 };
SDL_RenderGeometry(renderer, NULL, vertices, 3, NULL, 0);

//pink triangle
float xy[6] = { 200, 100, 400, 200, 200, 200 };
SDL_Color colors[3] = {
    {255, 0, 0, 255},
    {255, 255, 0, 255},
    {255, 0, 255, 255} // <- this color is being used (pink)
};
float uv[6] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
SDL_RenderGeometryRaw(renderer, NULL, xy, 8, colors, 4, uv, 8, 3, NULL, 1, 1);

Result:
image

@antim0118
Copy link
Author

I did some investigation.
This bug happens after calling SDL_RenderFillRect.
It looks normal when I call SDL_RenderGeometry before SDL_RenderFillRect.

@antim0118
Copy link
Author

antim0118 commented May 12, 2024

Also, I cannot apply textures, it also break the colors.

Code snippet:

SDL_Vertex vertex_0 = { {100, 100}, {255, 0, 0, 255}, {1, 1} };
SDL_Vertex vertex_1 = { {200, 100}, {0, 255, 0, 255}, {1, 1} };
SDL_Vertex vertex_2 = { {200, 200}, {0, 0, 255, 255}, {1, 1} };
SDL_Vertex vertex_3 = { {100, 200}, {0, 0, 255, 255}, {1, 1} };
SDL_Vertex vertices[] = { vertex_0,vertex_1,vertex_2,vertex_3 };
int indices[] = { 0, 1, 2, 2, 3, 0 };
SDL_RenderGeometry(renderer, mTexture, vertices, 4, indices, 6);

image

@antim0118 antim0118 changed the title [SDL2] [PSP] SDL_RenderGeometry / SDL_RenderGeometryRaw does not render vertices colors properly. [SDL2] [PSP] SDL_RenderGeometry / SDL_RenderGeometryRaw does not render textures and vertices colors properly. May 12, 2024
@slouken slouken added this to the 2.32.0 milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants