Create a BO with texture_2d_array for shadows.
This commit is contained in:
parent
c8844486fa
commit
da6e6daeaa
@ -54,6 +54,11 @@ PFNGLTEXBUFFERPROC glTexBuffer;
|
|||||||
PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||||
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
||||||
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
||||||
|
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||||
|
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||||
|
PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||||
|
PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||||
|
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool is_gl_init = false;
|
static bool is_gl_init = false;
|
||||||
@ -177,6 +182,11 @@ void initGL()
|
|||||||
glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv");
|
glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv");
|
||||||
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData");
|
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData");
|
||||||
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer");
|
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer");
|
||||||
|
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers");
|
||||||
|
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer");
|
||||||
|
glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture");
|
||||||
|
glTexImage3D = (PFNGLTEXIMAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexImage3D");
|
||||||
|
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
|
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,6 +75,11 @@ extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
|||||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||||
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||||
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
||||||
|
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||||
|
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||||
|
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||||
|
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||||
|
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
RTT::RTT()
|
RTT::RTT()
|
||||||
{
|
{
|
||||||
|
initGL();
|
||||||
using namespace video;
|
using namespace video;
|
||||||
using namespace core;
|
using namespace core;
|
||||||
|
|
||||||
@ -140,6 +141,19 @@ RTT::RTT()
|
|||||||
drv->setRenderTarget(0, false, false);
|
drv->setRenderTarget(0, false, false);
|
||||||
|
|
||||||
drv->endScene();
|
drv->endScene();
|
||||||
|
glGenFramebuffers(1, &shadowFBO);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO);
|
||||||
|
glGenTextures(1, &shadowColorTex);
|
||||||
|
glBindTexture(GL_TEXTURE_2D_ARRAY, shadowColorTex);
|
||||||
|
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_R8, 1024, 1024, 3, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
|
||||||
|
glGenTextures(1, &shadowDepthTex);
|
||||||
|
glBindTexture(GL_TEXTURE_2D_ARRAY, shadowDepthTex);
|
||||||
|
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 3, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
|
||||||
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, shadowColorTex, 0);
|
||||||
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowDepthTex, 0);
|
||||||
|
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
assert(result == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RTT::~RTT()
|
RTT::~RTT()
|
||||||
|
@ -79,6 +79,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ITexture *rtts[RTT_COUNT];
|
ITexture *rtts[RTT_COUNT];
|
||||||
|
unsigned shadowFBO, shadowColorTex, shadowDepthTex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user