Advertisement
Guest User

fbotest.c

a guest
Jul 12th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. #include <GL/glew.h>
  2. #include <GLFW/glfw3.h>
  3. #include <assert.h>
  4. #include <stdio.h>
  5.  
  6. void main( )
  7. {
  8.     //Window init
  9.     assert( glfwInit( ) == GLFW_TRUE );
  10.     glfwWindowHint( GLFW_SAMPLES, 1 );
  11.     glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
  12.     glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 5 );
  13.     glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
  14.     glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
  15.     GLFWwindow *window = glfwCreateWindow( 800, 600, "FBO test", NULL, NULL );
  16.     assert( window != NULL );
  17.     glfwMakeContextCurrent( window );
  18.     glewExperimental = GL_TRUE;
  19.     assert( glewInit( ) == GLEW_OK );
  20.    
  21.     //Create textures
  22.     GLuint tex[2];
  23.     glCreateTextures( GL_TEXTURE_2D, 2, tex );
  24.     glTextureStorage2D( tex[0], 1, GL_RGB8, 2048, 2048 );
  25.     glTextureStorage2D( tex[1], 1, GL_RGB8, 1024, 1024 );
  26.    
  27.     //Create FBO
  28.     GLuint fbo;
  29.     glCreateFramebuffers( 1, &fbo );
  30.     glNamedFramebufferTexture( fbo, GL_COLOR_ATTACHMENT0, tex[0], 0 );
  31.     glNamedFramebufferTexture( fbo, GL_COLOR_ATTACHMENT1, tex[1], 0 );
  32.    
  33.     //Check completeness
  34.     GLenum comp = glCheckNamedFramebufferStatus( fbo, GL_FRAMEBUFFER );
  35.     if ( comp != GL_FRAMEBUFFER_COMPLETE )
  36.     {
  37.         printf( "0x%x\n", comp );
  38.         printf( "0x%x - GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n", GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT );
  39.         assert( comp != GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT );
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement