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
}
Пример #3
0
/*
=================
R_AttachFBOTexture1D
=================
*/
void R_AttachFBOTexture1D( int texId, int index )
{
	if ( index < 0 || index >= glConfig2.maxColorAttachments )
	{
		ri.Printf( PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index );
		return;
	}

	glFramebufferTexture1DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_1D, texId, 0 );
}
 inline void VL_glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
 {
   if (glFramebufferTexture1D)
     glFramebufferTexture1D(target, attachment, textarget, texture, level);
   else
   if (glFramebufferTexture1DEXT)
     glFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
   else
     VL_UNSUPPORTED_FUNC();
 }
Пример #5
0
/**
 * Attaches a GL texture to the framebuffer
 */
void FBO::AttachTexture(const GLuint texId, const GLenum texTarget, const GLenum attachment, const int mipLevel, const int zSlice )
{
	if (texTarget == GL_TEXTURE_1D) {
		glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, texId, mipLevel);
	} else if (texTarget == GL_TEXTURE_3D) {
		glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, texId, mipLevel, zSlice);
	} else {
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, texTarget, texId, mipLevel);
	}
}
Пример #6
0
static int
create_1d_fbo(void)
{
	GLuint tex, fb;
	GLenum status;

	glGenTextures(1, &tex);
	glBindTexture(GL_TEXTURE_1D, tex);

	glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA,
		     BUF_WIDTH,
		     0,
		     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	assert(glGetError() == 0);

	glGenFramebuffersEXT(1, &fb);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

	glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
				  GL_COLOR_ATTACHMENT0_EXT,
				  GL_TEXTURE_1D,
				  tex,
				  0);

	assert(glGetError() == 0);

	status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
		fprintf(stderr, "FBO incomplete\n");
		goto done;
	}

	glViewport(0, 0, BUF_WIDTH, 1);
	piglit_ortho_projection(BUF_WIDTH, 1, GL_FALSE);

	/* left side: red */
	glColor4f(1.0, 0.0, 0.0, 0.0);
	piglit_draw_rect(0, 0, BUF_WIDTH / 2, 1);

	/* right side: green */
	glColor4f(0.0, 1.0, 0.0, 0.0);
	piglit_draw_rect(BUF_WIDTH / 2, 0, BUF_WIDTH, 1);

done:
	glDeleteFramebuffersEXT(1, &fb);

	return tex;
}
Пример #7
0
 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;
 }
Пример #8
0
// attach the texture to a FBO
void
CFrameBufferObject::attachTexture( GLenum texTarget, GLuint texId, 
                                   GLenum attachment, int mipLevel, int zSlice )
{
    bindRenderPath();
    switch (texTarget) {
        case GL_TEXTURE_1D:
            glFramebufferTexture1DEXT( GL_FRAMEBUFFER_EXT, attachment,
                                       GL_TEXTURE_1D, texId, mipLevel );
            break;
        case GL_TEXTURE_3D:
            glFramebufferTexture3DEXT( GL_FRAMEBUFFER_EXT, attachment,
                                       GL_TEXTURE_3D, texId, mipLevel, zSlice );
           break;
        default:
            // Default is GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, or cube faces
            glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment,
                                       texTarget, texId, mipLevel );
            break;
    }
    unbindRenderPath();
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTFramebufferObject_glFramebufferTexture1DEXT(JNIEnv *__env, jclass clazz, jint target, jint attachment, jint textarget, jint texture, jint level) {
    glFramebufferTexture1DEXTPROC glFramebufferTexture1DEXT = (glFramebufferTexture1DEXTPROC)tlsGetFunction(1709);
    UNUSED_PARAM(clazz)
    glFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
}
				void frame_buffer_texture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
					glFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
					CHECK_GL_ERROR();
				}
Пример #11
0
static void create_1d_fbo(GLuint *out_tex, GLuint *out_ds)
{
	GLuint tex, ds, fb;
	GLenum status;

	/* Create the color buffer. */
	glGenTextures(1, &tex);
	glBindTexture(GL_TEXTURE_1D, tex);
	glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA,
		     BUF_WIDTH,
		     0,
		     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	assert(glGetError() == 0);

	/* Create the depth-stencil buffer. */
	glGenTextures(1, &ds);
	glBindTexture(GL_TEXTURE_1D, ds);
	glTexImage1D(GL_TEXTURE_1D, 0, f.iformat, BUF_WIDTH, 0, f.format, f.type, NULL);
	assert(glGetError() == 0);

	/* Create the FBO. */
	glGenFramebuffersEXT(1, &fb);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

	glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
				  GL_COLOR_ATTACHMENT0_EXT,
				  GL_TEXTURE_1D,
				  tex,
				  0);

	glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
				  GL_DEPTH_ATTACHMENT_EXT,
				  GL_TEXTURE_1D,
				  ds,
				  0);

	if (f.format == GL_DEPTH_STENCIL) {
		glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
					  GL_STENCIL_ATTACHMENT_EXT,
					  GL_TEXTURE_1D,
					  ds,
					  0);
	}

	assert(glGetError() == 0);

	status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
		piglit_report_result(PIGLIT_SKIP);
	}

	glViewport(0, 0, BUF_WIDTH, 1);
	glClearDepth(1);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_ALWAYS);
	glDepthRange(0, 0);

	glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	piglit_ortho_projection(BUF_WIDTH, 1, GL_FALSE);

	/* green */
	glColor4f(0.0, 1.0, 0.0, 0.0);
	piglit_draw_rect(0, 0, BUF_WIDTH, 1);

	glBindFramebufferEXT(GL_FRAMEBUFFER, piglit_winsys_fbo);
	glDeleteFramebuffersEXT(1, &fb);

	*out_tex = tex;
	*out_ds = ds;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTFramebufferObject_nglFramebufferTexture1DEXT(JNIEnv *env, jclass clazz, jint target, jint attachment, jint textarget, jint texture, jint level, jlong function_pointer) {
	glFramebufferTexture1DEXTPROC glFramebufferTexture1DEXT = (glFramebufferTexture1DEXTPROC)((intptr_t)function_pointer);
	glFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
}