From d866e18ca367d36a558b64040af2928416ffdc41 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 24 Feb 2007 12:33:16 +0000 Subject: [PATCH] support GL_ARB_texture_float --- stepmania/src/ActorFrameTexture.cpp | 4 ++++ stepmania/src/ActorFrameTexture.h | 2 ++ stepmania/src/RageDisplay_OGL.cpp | 11 +++++++++-- stepmania/src/RageDisplay_OGL_Helpers.cpp | 1 + stepmania/src/RageDisplay_OGL_Helpers.h | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/stepmania/src/ActorFrameTexture.cpp b/stepmania/src/ActorFrameTexture.cpp index c3cf3fb27e..f123652c56 100644 --- a/stepmania/src/ActorFrameTexture.cpp +++ b/stepmania/src/ActorFrameTexture.cpp @@ -11,6 +11,7 @@ ActorFrameTexture::ActorFrameTexture() { m_bDepthBuffer = false; m_bAlphaBuffer = false; + m_bFloat = false; m_bPreserveTexture = false; static uint64_t i = 0; ++i; @@ -37,6 +38,7 @@ void ActorFrameTexture::Create() RenderTargetParam param; param.bWithDepthBuffer = m_bDepthBuffer; param.bWithAlpha = m_bAlphaBuffer; + param.bFloat = m_bFloat; param.iWidth = (int) m_size.x; param.iHeight = (int) m_size.y; m_pRenderTarget = new RageTextureRenderTarget( id, param ); @@ -67,6 +69,7 @@ public: static int Create( T* p, lua_State *L ) { p->Create(); return 0; } static int EnableDepthBuffer( T* p, lua_State *L ) { p->EnableDepthBuffer(BArg(1)); return 0; } static int EnableAlphaBuffer( T* p, lua_State *L ) { p->EnableAlphaBuffer(BArg(1)); return 0; } + static int EnableFloat( T* p, lua_State *L ) { p->EnableFloat(BArg(1)); return 0; } static int EnablePreserveTexture( T* p, lua_State *L ) { p->EnablePreserveTexture(BArg(1)); return 0; } static int SetTextureName( T* p, lua_State *L ) { p->SetTextureName(SArg(1)); return 0; } static int GetTexture( T* p, lua_State *L ) @@ -83,6 +86,7 @@ public: ADD_METHOD( Create ); ADD_METHOD( EnableDepthBuffer ); ADD_METHOD( EnableAlphaBuffer ); + ADD_METHOD( EnableFloat ); ADD_METHOD( EnablePreserveTexture ); ADD_METHOD( SetTextureName ); ADD_METHOD( GetTexture ); diff --git a/stepmania/src/ActorFrameTexture.h b/stepmania/src/ActorFrameTexture.h index 8cfb862f43..4ea943c6ff 100644 --- a/stepmania/src/ActorFrameTexture.h +++ b/stepmania/src/ActorFrameTexture.h @@ -22,6 +22,7 @@ public: void EnableDepthBuffer( bool b ) { m_bDepthBuffer = b; } void EnableAlphaBuffer( bool b ) { m_bAlphaBuffer = b; } + void EnableFloat( bool b ) { m_bFloat = b; } void EnablePreserveTexture( bool b ) { m_bPreserveTexture = b; } void Create(); @@ -38,6 +39,7 @@ private: bool m_bDepthBuffer; bool m_bAlphaBuffer; + bool m_bFloat; bool m_bPreserveTexture; RString m_sTextureName; }; diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 8bae839534..74b9b353c0 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -2132,8 +2132,15 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam ¶m, int iTextureHeightOut = iTextureHeight; glBindTexture( GL_TEXTURE_2D, m_iTexHandle ); - glTexImage2D( GL_TEXTURE_2D, 0, param.bWithAlpha? GL_RGBA8:GL_RGB8, - iTextureWidth, iTextureHeight, 0, param.bWithAlpha? GL_RGBA:GL_RGB, GL_UNSIGNED_BYTE, NULL ); + GLenum internalformat; + GLenum type = param.bWithAlpha? GL_RGBA:GL_RGB; + if( param.bFloat && GLExt.m_bGL_ARB_texture_float ) + internalformat = param.bWithAlpha? GL_RGBA16F_ARB:GL_RGB16F_ARB; + else + internalformat = param.bWithAlpha? GL_RGBA8:GL_RGB8; + + glTexImage2D( GL_TEXTURE_2D, 0, internalformat, + iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, NULL ); AssertNoGLError(); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); diff --git a/stepmania/src/RageDisplay_OGL_Helpers.cpp b/stepmania/src/RageDisplay_OGL_Helpers.cpp index 1ad802dd63..0287d4a186 100644 --- a/stepmania/src/RageDisplay_OGL_Helpers.cpp +++ b/stepmania/src/RageDisplay_OGL_Helpers.cpp @@ -106,6 +106,7 @@ void GLExt_t::Load( LowLevelWindow *pWind ) m_bARB_texture_env_combine = HasExtension("GL_ARB_texture_env_combine"); m_bEXT_texture_env_combine = HasExtension("GL_EXT_texture_env_combine"); m_bGL_EXT_bgra = HasExtension("GL_EXT_bgra"); + m_bGL_ARB_texture_float = HasExtension("GL_ARB_texture_float"); #if defined(WIN32) if( HasExtension("WGL_EXT_swap_control") ) diff --git a/stepmania/src/RageDisplay_OGL_Helpers.h b/stepmania/src/RageDisplay_OGL_Helpers.h index f1ca6ccbdf..742ed5ade0 100644 --- a/stepmania/src/RageDisplay_OGL_Helpers.h +++ b/stepmania/src/RageDisplay_OGL_Helpers.h @@ -65,6 +65,7 @@ struct GLExt_t bool m_bARB_texture_env_combine; bool m_bEXT_texture_env_combine; bool m_bGL_EXT_bgra; + bool m_bGL_ARB_texture_float; PWSWAPINTERVALEXTPROC wglSwapIntervalEXT; PFNGLCOLORTABLEPROC glColorTableEXT;