Renderer colors now have floating point precision

This commit is contained in:
Sam Lantinga 2024-01-29 13:28:33 -08:00
parent da8fc70a83
commit 554f0625d3
21 changed files with 603 additions and 347 deletions

View file

@ -77,7 +77,7 @@ typedef struct
{
Float2 pos;
Float2 tex;
SDL_Color color;
SDL_FColor color;
} VertexPositionColor;
/* Per-texture data */
@ -1694,11 +1694,6 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
{
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
int i;
SDL_Color color;
color.r = cmd->data.draw.r;
color.g = cmd->data.draw.g;
color.b = cmd->data.draw.b;
color.a = cmd->data.draw.a;
if (!verts) {
return -1;
@ -1711,7 +1706,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
verts->pos.y = points[i].y + 0.5f;
verts->tex.x = 0.0f;
verts->tex.y = 0.0f;
verts->color = color;
verts->color = cmd->data.draw.color;
verts++;
}
@ -1719,7 +1714,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
}
static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y)
{
@ -1751,7 +1746,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
verts->pos.x = xy_[0] * scale_x;
verts->pos.y = xy_[1] * scale_y;
verts->color = *(SDL_Color *)((char *)color + j * color_stride);
verts->color = *(SDL_FColor *)((char *)color + j * color_stride);
if (texture) {
float *uv_ = (float *)((char *)uv + j * uv_stride);
@ -2195,13 +2190,7 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
case SDL_RENDERCMD_CLEAR:
{
const float colorRGBA[] = {
(cmd->data.color.r / 255.0f),
(cmd->data.color.g / 255.0f),
(cmd->data.color.b / 255.0f),
(cmd->data.color.a / 255.0f)
};
ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), colorRGBA);
ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), &cmd->data.color.color.r);
break;
}