* frame buffer 는 3개의 render buffer 를 가지고 있다.
(frame buffer = color render buffer + depth render buffer + stencil render buffer)


* render buffer 생성
glGenRenderbuffers(1, &_renderBufferColor);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBufferColor);

glGenRenderbuffers(1, &_renderBufferDepth);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBufferDepth);


* frame buffer 생성
GLuint frame_buffer;
glGenFramebuffers(1, &frame_buffer);
glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer);


* frame buffer 에 render buffer 연결
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _renderBufferColor);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBufferDepth);


* VBO
// vertex buffer
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glVertexAttribPointer(_attribLocation_Position, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), 0);

// texture buffer
GLuint textureBuffer;
glGenBuffers(1, &textureBuffer);
glBindBuffer(GL_ARRAY_BUFFER, textureBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(Textures), Textures, GL_STATIC_DRAW);
glVertexAttribPointer(_attribLocation_Texture, 2, GL_FLOAT, GL_FALSE, 2*sizeof(GLfloat), 0);

// index buffer
GLuint indexBuffer;
glGenBuffers(1, &indexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);



반응형
Posted by 돌비
,