をレンダするためにレンダリング私は上のフレームバッファオブジェクトのメモ、次のオフスクリーンレンダリングのための拡張と例を使用しようとしていますこんにちは: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_offscreen/opengl_offscreen.htmlFBOと
私はFBO上に描かれている内容を表示する方法に問題が生じています窓に!私は完全に黒い画面しか得ていない!
テクスチャも好ましいですか?私は、レンダバッファのパフォーマンスが優れていることを発見したそうですか?
誰でもこのplsで私を助けることができますか?ここで
#include <stdio.h>
#include <stdlib.h>
#include <GLUT/glut.h>
void drawfunc();
void init(int argc, char** argv);
void initialise_FBO_toRenderBuf();
void onExit();
GLuint renderbufID;
GLuint bufferID;
int main(int argc, char** argv)
{
init(argc,argv);
initialise_FBO_toRenderBuf();
glutDisplayFunc(drawfunc);
glutMainLoop();
}
void init(int argc, char** argv)
{
//initialising window settings
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GL_RGBA8);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("Hello Leanne mine");
/*GLubyte* versiongl;
versiongl = glGetString(GL_VERSION);
printf("version is: %s\n",versiongl);
*/
//initial background colour of the window
glClearColor(0.0, 0.0, 0.0, 0.0);
//the coordinate system to be used
glOrtho(0.0, 1.0, 0.0, 1.0, -10.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void initialise_FBO_toRenderBuf(void)
{
//generate FBO name (bufferID) and create a buffer objct with the texture name (bufferID)
glGenFramebuffersEXT(1, &bufferID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bufferID);
//generate renderbuffer name (renderbufID) and create a renderbuffer object with the renderbuffer name (renderbufID)
glGenRenderbuffersEXT(1, &renderbufID);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbufID);
//Create data storage and establish the pixel format and dimensions of the renderbuffer image by calling the following function
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_RGBA8,250, 250);
//attach the texture to the FBO
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, renderbufID);
switch(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT))
{
case GL_FRAMEBUFFER_COMPLETE_EXT: printf("The fbo is complete\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: printf("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: printf("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: printf("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: printf("GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n"); break;
}
}
void drawfunc()
{
//use the FBO with name bufferID
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bufferID);
//clears the FBO to this color when glClear is called i.e it is the texture background color
glClearColor(0.0, 1.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
//drawing here
glColor3f(0.0, 1.0, 1.0);
glBegin(GL_QUADS);
glVertex2f(0.25, 0.25);
glVertex2f(0.25, 0.75);
glVertex2f(0.75, 0.75);
glVertex2f(0.75, 0.25);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, 0.65);
glVertex2f(0.65, 0.65);
glVertex2f(0.65, 0.5);
glEnd();
GLvoid* pixels = malloc(250*250*4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0,0, 250,250, GL_RGBA8, GL_UNSIGNED_BYTE, pixels);
glDrawBuffer(0);
//glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
glRasterPos2d(0, 0);
glDrawPixels(250, 250, GL_RGBA8,GL_UNSIGNED_BYTE,pixels);
glFlush();
onExit();
}
void onExit()
{
//glDeleteTextures(1, &renderbufID);
glDeleteFramebuffersEXT(1, &bufferID);
}
「テクスチャも好ましいですか?」 –