1 2 3 4 5 6 7 8 | glBindFramebuffer( GL_READ_FRAMEBUFFER, frameBufferHandles[0] ); glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); glViewport(drawRegion.minX, drawRegion.minY, windowWidth, windowHeight); glBlitFramebuffer(0, 0, GetWidth(drawRegion), GetHeight(drawRegion), drawRegion.minX, drawRegion.minY, drawRegion.maxX, drawRegion.maxY, GL_COLOR_BUFFER_BIT, GL_LINEAR); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | GLuint texHandle[2]; glGenTextures(2, texHandle); glBindTexture( slot, texHandle[0] ); Assert( glGetError() == GL_NO_ERROR ); glTexImage2D( slot, 0, opengl.defaultFramebufferTextureFormat, GetWidth( drawRegion ), GetHeight( drawRegion ), 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 0); Assert(glGetError() == GL_NO_ERROR); glBindTexture(slot, texHandle[1]); glTexImage2D( slot, 0, GL_DEPTH_COMPONENT24, GetWidth( drawRegion ), GetHeight( drawRegion ), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0); Assert(glGetError() == GL_NO_ERROR); glBindTexture(slot, 0); frameBufferTextures[targetIndex] = texHandle[0]; frameBufferDepth[targetIndex] = texHandle[1]; glBindFramebuffer(GL_FRAMEBUFFER, frameBufferHandles[targetIndex]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, slot, texHandle[0], 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, slot, texHandle[1], 0); GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); Assert(Status == GL_FRAMEBUFFER_COMPLETE); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #if 0 glBindFramebuffer( GL_READ_FRAMEBUFFER, frameBufferHandles[0] ); glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); glViewport(drawRegion.minX, drawRegion.minY, windowWidth, windowHeight); glBlitFramebuffer(0, 0, GetWidth(drawRegion), GetHeight(drawRegion), drawRegion.minX, drawRegion.minY, drawRegion.maxX, drawRegion.maxY, GL_COLOR_BUFFER_BIT, GL_LINEAR); #else glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); glDisable(GL_DEPTH_TEST); RenderSetup setup = {}; TexturedVertex vertices[] = { {{-1.0f, 1.0f, 0, 1.0f} ,{0.0f, 1.0f}, 0xffffffff}, {{-1.0f, -1.0f, 0, 1.0f} ,{0.0f, 0.0f}, 0xffffffff}, {{1.0f, 1.0f, 0, 1.0f} ,{1.0f, 1.0f}, 0xffffffff}, {{1.0f, -1.0f, 0, 1.0f} ,{1.0f, 0.0f}, 0xffffffff}, }; glBufferData( GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STREAM_DRAW ); OpenGLUseProgramBegin(&opengl.peelComposite, &setup); glViewport(drawRegion.minX, drawRegion.minY, windowWidth, windowHeight); glClearColor( 1, 0, 0, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); #if 0 glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, ( GLuint ) U32FromPointer( opengl.whiteBitmap.textureHandle ) ); glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, ( GLuint ) U32FromPointer( opengl.whiteBitmap.textureHandle ) ); #else glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, frameBufferTextures[0] ); glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, frameBufferTextures[0] ); #endif glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); OpenGLUseProgramEnd(&opengl.peelComposite); #endif |
1 2 3 4 5 6 7 8 9 10 11 12 | GLuint handle; glGenTextures( 1, &handle ); glBindTexture( GL_TEXTURE_2D, handle ); glTexImage2D(GL_TEXTURE_2D, 0, opengl.defaultSpriteTextureFormat, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, data ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glBindTexture( GL_TEXTURE_2D, 0 ); |
1 2 3 4 5 | glBindTexture( GL_TEXTURE_2D, ( GLuint ) frameBufferTextures[0] ); u8* pixels = ( u8* ) malloc( 1920 * 1080 * 4 ); memset( pixels, 0, 1920 * 1080 * 4 ); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); free( pixels ); |
1 2 3 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |