mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-19 03:15:27 +00:00
Add OpenGL support.
This commit is contained in:
parent
c354f59b72
commit
dd08fd2e7d
55 changed files with 2957 additions and 802 deletions
|
|
@ -27,7 +27,7 @@
|
|||
#include "gfx/gl/gfxGLCubemap.h"
|
||||
#include "gfx/gfxTextureManager.h"
|
||||
#include "gfx/gfxCardProfile.h"
|
||||
#include "gfx/bitmap/DDSFile.h"
|
||||
#include "gfx/bitmap/ddsFile.h"
|
||||
|
||||
|
||||
GLenum GFXGLCubemap::faceList[6] =
|
||||
|
|
@ -56,9 +56,9 @@ GFXGLCubemap::~GFXGLCubemap()
|
|||
|
||||
void GFXGLCubemap::fillCubeTextures(GFXTexHandle* faces)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
PRESERVE_CUBEMAP_TEXTURE();
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0 ); // TODO OPENGL GFXGLCubemap mipmaps
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
|
@ -89,9 +89,6 @@ void GFXGLCubemap::fillCubeTextures(GFXTexHandle* faces)
|
|||
0, GFXGLTextureFormat[faceFormat], GFXGLTextureType[faceFormat], buf);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
|
||||
}
|
||||
|
||||
void GFXGLCubemap::initStatic(GFXTexHandle* faces)
|
||||
|
|
@ -128,9 +125,9 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
|||
|
||||
glGenTextures(1, &mCubemap);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
PRESERVE_CUBEMAP_TEXTURE();
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0 );
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
|
@ -162,9 +159,6 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
|||
glCompressedTexImage2D( faceList[i], 0, GFXGLTextureInternalFormat[mFaceFormat],
|
||||
mWidth, mHeight, 0, surfaceSize, buffer );
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
|
||||
}
|
||||
|
||||
void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat)
|
||||
|
|
@ -173,6 +167,7 @@ void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat)
|
|||
mFaceFormat = faceFormat;
|
||||
|
||||
glGenTextures(1, &mCubemap);
|
||||
PRESERVE_CUBEMAP_TEXTURE();
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
|
@ -187,7 +182,6 @@ void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat)
|
|||
glTexImage2D( faceList[i], 0, GFXGLTextureInternalFormat[faceFormat], texSize, texSize,
|
||||
0, GFXGLTextureFormat[faceFormat], GFXGLTextureType[faceFormat], NULL);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||
}
|
||||
|
||||
void GFXGLCubemap::zombify()
|
||||
|
|
@ -223,6 +217,7 @@ void GFXGLCubemap::bind(U32 textureUnit) const
|
|||
{
|
||||
glActiveTexture(GL_TEXTURE0 + textureUnit);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||
static_cast<GFXGLDevice*>(getOwningDevice())->getOpenglCache()->setCacheBindedTex(textureUnit, GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||
|
||||
GFXGLStateBlockRef sb = static_cast<GFXGLDevice*>(GFX)->getCurrentStateBlock();
|
||||
AssertFatal(sb, "GFXGLCubemap::bind - No active stateblock!");
|
||||
|
|
@ -235,8 +230,6 @@ void GFXGLCubemap::bind(U32 textureUnit) const
|
|||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GFXGLTextureAddress[ssd.addressModeU]);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GFXGLTextureAddress[ssd.addressModeV]);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GFXGLTextureAddress[ssd.addressModeW]);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, ssd.mipLODBias);
|
||||
}
|
||||
|
||||
void GFXGLCubemap::_onTextureEvent( GFXTexCallbackCode code )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue