EXTERN_C_ENTER JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTextureArray_glFramebufferTextureLayerEXT(JNIEnv *__env, jclass clazz, jint target, jint attachment, jint texture, jint level, jint layer) { glFramebufferTextureLayerEXTPROC glFramebufferTextureLayerEXT = (glFramebufferTextureLayerEXTPROC)tlsGetFunction(1813); UNUSED_PARAM(clazz) glFramebufferTextureLayerEXT(target, attachment, texture, level, layer); }
void FramebufferObject::detachTexture(GLenum attachment) { size_t index = decodeAttachment(attachment); if (attachments_[index] != 0) { switch (attachments_[index]->getType()) { case GL_TEXTURE_1D: glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, 0, 0); break; case GL_TEXTURE_2D_ARRAY: glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment, 0, 0, 0); break; case GL_TEXTURE_3D: glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, 0, 0, 0); break; default: // GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0); break; } attachments_[index] = 0; LGL_ERROR; if (index < CGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS) --numColorAttachments_; } else { LWARNING("Trying to detach unknown texture!"); } }
void FramebufferObject::attachTexture(Texture* texture, GLenum attachment, int mipLevel, int zSlice) { switch(texture->getType()) { case GL_TEXTURE_1D: glFramebufferTexture1DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, texture->getId(), mipLevel ); break; case GL_TEXTURE_3D: glFramebufferTexture3DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, texture->getId(), mipLevel, zSlice ); break; case GL_TEXTURE_2D_ARRAY: glFramebufferTextureLayerEXT( GL_FRAMEBUFFER_EXT, attachment, texture->getId(), mipLevel, zSlice ); break; default: //GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, texture->getType(), texture->getId(), mipLevel ); break; } LGL_ERROR; size_t index = decodeAttachment(attachment); attachments_[index] = texture; if (index < CGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS) ++numColorAttachments_; #ifdef CAMPVIS_DEBUG this->isComplete(); #endif }
void GLDepthRenderTarget::makeTargetLayer(int l) { GLRenderTarget::makeTarget(); if(passes[0]->arrayTexture) glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, passes[0]->texmaps[0], 0, l); else glFramebufferTexture(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, passes[0]->texmaps[0], 0); #ifdef DEBUG GLSL_catchLastError("GLDepthRenderTarget::makeTargetLayer"); #endif }
inline void VL_glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) { if (glFramebufferTextureLayer) glFramebufferTextureLayer(target, attachment, texture, level, layer); else if (glFramebufferTextureLayerARB) glFramebufferTextureLayerARB(target, attachment, texture, level, layer); else if (glFramebufferTextureLayerEXT) glFramebufferTextureLayerEXT(target, attachment, texture, level, layer); else VL_UNSUPPORTED_FUNC(); }
void FramebufferObject::attachTexture(Texture* texture, GLenum attachment, int mipLevel, int zSlice) { switch (texture->getType()) { case GL_TEXTURE_1D: glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, texture->getId(), mipLevel); break; case GL_TEXTURE_3D: glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, texture->getId(), mipLevel, zSlice); break; case GL_TEXTURE_2D_ARRAY_EXT: glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment, texture->getId(), mipLevel, zSlice); break; default: //GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, texture->getType(), texture->getId(), mipLevel); break; } attachedTextures_[attachment] = texture; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGeometryShader4_nglFramebufferTextureLayerEXT(JNIEnv *env, jclass clazz, jint target, jint attachment, jint texture, jint level, jint layer, jlong function_pointer) { glFramebufferTextureLayerEXTPROC glFramebufferTextureLayerEXT = (glFramebufferTextureLayerEXTPROC)((intptr_t)function_pointer); glFramebufferTextureLayerEXT(target, attachment, texture, level, layer); }
// here all shadow map textures and their corresponding matrices are created void CShadowMap::MakeShadowMap( float cam_pos[3], float cam_view[3], float light_dir[4] ) { glUseProgram(0); g_render.m_useShader = CFalse; glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT ); float shad_modelview[16]; glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); // since the shadow maps have only a depth channel, we don't need color computation glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); gluLookAt(0, 0, 0, -light_dir[0], -light_dir[1], -light_dir[2], 0.0f, 1.0f, 0.0f); glGetFloatv(GL_MODELVIEW_MATRIX, shad_modelview); // redirect rendering to the depth texture glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depth_fb); // and render only to the shadowmap glViewport(0, 0, depth_size, depth_size); // offset the geometry slightly to prevent z-fighting // note that this introduces some light-leakage artifacts glPolygonOffset( 1.0, 1024); glEnable(GL_POLYGON_OFFSET_FILL); //glCullFace( GL_FRONT ); // I assume that our objects are closed, so I don't disable face culling. //glDisable(GL_CULL_FACE); // compute the z-distances for each split as seen in camera space UpdateSplitDist(f, g_shadowProperties.m_shadowNearClipPlane, g_shadowProperties.m_shadowFarClipPlane); // for all shadow maps: for(int i=0; i<cur_num_splits; i++) { // compute the camera frustum slice boundary points in world space UpdateFrustumPoints(f[i], vec3f(cam_pos), vec3f(cam_view)); // adjust the view frustum of the light, so that it encloses the camera frustum slice fully. // note that this function sets the projection matrix as it sees best fit // minZ is just for optimization to cull trees that do not affect the shadows float minZ = ApplyCropMatrix(f[i]); // make the current depth map a rendering target glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, depth_tex_ar, 0, i); // clear the depth texture from last time glClear(GL_DEPTH_BUFFER_BIT); for( CUInt j = 0 ; j < g_scene.size(); j++ ) { g_render.SetScene( g_scene[j] ); if( !g_render.GetScene()->m_isTrigger /*&& g_render.GetScene()->m_hasAnimation*/ ) { //g_render.GetScene()->Update(); g_render.GetScene()->RenderAnimatedModels(CFalse); g_render.GetScene()->Render(CFalse); } if( !g_render.GetScene()->m_isTrigger ) { //g_render.GetScene()->Update(); g_render.GetScene()->RenderModelsControlledByPhysX(CFalse); } } glMatrixMode(GL_PROJECTION); // store the product of all shadow matries for later glMultMatrixf(shad_modelview); glGetFloatv(GL_PROJECTION_MATRIX, shad_cpm[i]); } glDisable(GL_POLYGON_OFFSET_FILL); glCullFace( GL_BACK ); glPopAttrib(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }