Implement dithering where relevant (#473)

This commit is contained in:
Anders Jenbo 2025-07-02 12:07:20 +02:00 committed by GitHub
parent cca65ba178
commit 55c13cd140
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 50 additions and 3 deletions

View File

@ -600,6 +600,10 @@ void Citro3DRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, con
C3D_ImmDrawEnd();
}
void Citro3DRenderer::SetDither(bool dither)
{
}
void Citro3DRenderer::Download(SDL_Surface* target)
{
MINIWIN_NOT_IMPLEMENTED();

View File

@ -278,6 +278,10 @@ void DirectX9Renderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, co
Actual_Draw2DImage(m_textures[textureId].dxTexture, srcRect, dstRect);
}
void DirectX9Renderer::SetDither(bool dither)
{
}
void DirectX9Renderer::Download(SDL_Surface* target)
{
Actual_Download(target);

View File

@ -354,3 +354,13 @@ void GL11_Download(SDL_Surface* target)
glFinish();
glReadPixels(0, 0, target->w, target->h, GL_RGBA, GL_UNSIGNED_BYTE, target->pixels);
}
void GL11_SetDither(bool dither)
{
if (dither) {
glEnable(GL_DITHER);
}
else {
glDisable(GL_DITHER);
}
}

View File

@ -87,4 +87,5 @@ void GL11_Draw2DImage(
float bottom,
float top
);
void GL11_SetDither(bool dither);
void GL11_Download(SDL_Surface* target);

View File

@ -384,6 +384,11 @@ void OpenGL1Renderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, con
GL11_Draw2DImage(m_textures[textureId], srcRect, dstRect, left, right, bottom, top);
}
void OpenGL1Renderer::SetDither(bool dither)
{
GL11_SetDither(dither);
}
void OpenGL1Renderer::Download(SDL_Surface* target)
{
GL11_Download(m_renderedImage);

View File

@ -706,3 +706,13 @@ void OpenGLES2Renderer::Download(SDL_Surface* target)
SDL_DestroySurface(bufferClone);
}
void OpenGLES2Renderer::SetDither(bool dither)
{
if (dither) {
glEnable(GL_DITHER);
}
else {
glDisable(GL_DITHER);
}
}

View File

@ -942,6 +942,10 @@ void Direct3DRMSDL3GPURenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& sr
SDL_SetGPUScissor(m_renderPass, &fullViewport);
}
void Direct3DRMSDL3GPURenderer::SetDither(bool dither)
{
}
void Direct3DRMSDL3GPURenderer::Download(SDL_Surface* target)
{
if (!m_cmdbuf) {

View File

@ -788,6 +788,10 @@ void Direct3DRMSoftwareRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& s
SDL_LockSurface(surface);
}
void Direct3DRMSoftwareRenderer::SetDither(bool dither)
{
}
void Direct3DRMSoftwareRenderer::Download(SDL_Surface* target)
{
SDL_Rect srcRect = {

View File

@ -84,9 +84,7 @@ D3DRMRENDERQUALITY Direct3DRMDevice2Impl::GetQuality()
HRESULT Direct3DRMDevice2Impl::SetDither(BOOL dither)
{
if (dither) {
MINIWIN_NOT_IMPLEMENTED();
}
m_renderer->SetDither(dither);
return DD_OK;
}

View File

@ -53,6 +53,7 @@ public:
virtual void Flip() = 0;
virtual void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) = 0;
virtual void Download(SDL_Surface* target) = 0;
virtual void SetDither(bool dither) = 0;
protected:
int m_width, m_height;

View File

@ -50,6 +50,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
void AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* texture);

View File

@ -36,6 +36,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
void AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* texture);

View File

@ -36,6 +36,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
void AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* texture);

View File

@ -57,6 +57,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
void AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* texture);

View File

@ -67,6 +67,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
Direct3DRMSDL3GPURenderer(

View File

@ -49,6 +49,7 @@ public:
void Flip() override;
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) override;
void Download(SDL_Surface* target) override;
void SetDither(bool dither) override;
private:
void ClearZBuffer();