From be37147342ff9032f0557d732abfc6cfd2c77efe Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 01:47:53 +0100 Subject: fixed border rendering in the editor's image preview. Closes #908 --- src/engine/client/backend_sdl.cpp | 14 ++++++++++++++ src/engine/client/graphics.cpp | 12 ++++++++++++ src/engine/client/graphics.h | 3 +++ src/engine/client/graphics_threaded.cpp | 11 +++++++++++ src/engine/client/graphics_threaded.h | 10 ++++++++++ src/engine/graphics.h | 2 ++ 6 files changed, 52 insertions(+) (limited to 'src/engine') diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 3f74f87e..4f738949 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -133,6 +133,20 @@ void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &St else glDisable(GL_TEXTURE_2D); + switch(State.m_WrapMode) + { + case CCommandBuffer::WRAP_REPEAT: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + break; + case CCommandBuffer::WRAP_CLAMP: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + break; + default: + dbg_msg("render", "unknown wrapmode %d\n", State.m_WrapMode); + }; + // screen mapping glMatrixMode(GL_PROJECTION); glLoadIdentity(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index ad3926f2..5baff939 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -197,6 +197,18 @@ void CGraphics_OpenGL::BlendAdditive() glBlendFunc(GL_SRC_ALPHA, GL_ONE); } +void CGraphics_OpenGL::WrapNormal() +{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +} + +void CGraphics_OpenGL::WrapClamp() +{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + int CGraphics_OpenGL::MemoryUsage() const { return m_TextureMemoryUsage; diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index 3ab550dc..fdd83aa7 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -78,6 +78,9 @@ public: virtual void BlendNormal(); virtual void BlendAdditive(); + virtual void WrapNormal(); + virtual void WrapClamp(); + virtual int MemoryUsage() const; virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index c6947e33..286428d7 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -154,6 +154,7 @@ CGraphics_Threaded::CGraphics_Threaded() m_State.m_ClipH = 0; m_State.m_Texture = -1; m_State.m_BlendMode = CCommandBuffer::BLEND_NONE; + m_State.m_WrapMode = CCommandBuffer::WRAP_REPEAT; m_CurrentCommandBuffer = 0; m_pCommandBuffer = 0x0; @@ -214,6 +215,16 @@ void CGraphics_Threaded::BlendAdditive() m_State.m_BlendMode = CCommandBuffer::BLEND_ADDITIVE; } +void CGraphics_Threaded::WrapNormal() +{ + m_State.m_WrapMode = CCommandBuffer::WRAP_REPEAT; +} + +void CGraphics_Threaded::WrapClamp() +{ + m_State.m_WrapMode = CCommandBuffer::WRAP_CLAMP; +} + int CGraphics_Threaded::MemoryUsage() const { return m_TextureMemoryUsage; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index f4f17ec2..3f3bec89 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -120,6 +120,12 @@ public: BLEND_ADDITIVE, }; + enum + { + WRAP_REPEAT = 0, + WRAP_CLAMP, + }; + struct SPoint { float x, y, z; }; struct STexCoord { float u, v; }; struct SColor { float r, g, b, a; }; @@ -142,6 +148,7 @@ public: struct SState { int m_BlendMode; + int m_WrapMode; int m_Texture; SPoint m_ScreenTL; SPoint m_ScreenBR; @@ -382,6 +389,9 @@ public: virtual void BlendNormal(); virtual void BlendAdditive(); + virtual void WrapNormal(); + virtual void WrapClamp(); + virtual int MemoryUsage() const; virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY); diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 6d31060e..46750e03 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -77,6 +77,8 @@ public: virtual void BlendNone() = 0; virtual void BlendNormal() = 0; virtual void BlendAdditive() = 0; + virtual void WrapNormal() = 0; + virtual void WrapClamp() = 0; virtual int MemoryUsage() const = 0; virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0; -- cgit 1.4.1