Re: FBO problem
"Gernot Ziegler" <[email protected]> Thu, 31 Jul 2008 06:05:29 -0800
| Newsgroups | gmane.games.devel.opengl |
|---|---|
| Organization | Fat City Network Services, San Diego, California |
| Message-ID | <[email protected]> |
i am glad it worked out alright :) if you want, then send me the code one= more time, marking where the difference lies with a #define and i can re= port it as a bug /gernot ________________ Reply Header ________________ Subject: Re: FBO problem Author: Rhadam=E9s Carmona <[email protected]> Date: 31st July 2008 01:35 Hello Guys Now works. The trick was to use GL_RGBA32F_ARB instead of GL_RGBA32F_NV Regards Rhadam=E9s ----- Original Message -----=20 To: "Multiple recipients of list OPENGL-GAMEDEV-L" <OPENGL-GAMEDEV-L@fatc= ity.com> Sent: Wednesday, July 30, 2008 5:50 AM > Hej, >=20 > have you actually used shaders? Float FBOs only work with shaders. Also= =20 > note that your texture coordinates are different for GL_TEXTURE_RECTANG= LE=20 > in contrast to GL_TEXTURE_2D, but it seems you only use texture rectang= le=20 > anyways. >=20 >> I am playing a little bit with FBO. By the way, I am rendering a littl= e red >> quad in the middle of the FBO. It works perfect while I use >>=20 >> glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, w, h, 0, GL_RGBA, >> GL_UNSIGNED_BYTE, NULL); >>=20 >> yeah...a 8 bits FBO. I can change GL_UNSIGNED_BYTE by GL_FLOAT, and I = always >> get a 8 bits FBO... (well known behaviour). >>=20 >> But, If I just change that command by >>=20 >> glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA16_NV, w, h, >> 0,GL_RGBA, GL_UNSIGNED_SHORT, NULL); >>=20 >> or even by >>=20 >> glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA32_NV, w, h, >> 0,GL_RGBA, GL_FLOAT, NULL); >>=20 >> then, I get a full screen red image (even if I comment the glBegin(QUA= DS) - >> glEnd() block to render the quad). The entire FBO gets the color of my >> glColor3ub(255,0,0). >>=20 >> I have test every OpenGL code line with glGetError(), and there is not= any >> error. I also installed latest glew and drivers for my 8800 NVidia gra= phics >> board. >>=20 >> I hope some of you could have a suggestion about what I am doing wrong. >>=20 >> Thanks a lot! >> Rhadam=E9s >>=20 >>=20 >> #include "glew.h" >> #include <gl/glut.h> >> #include <stdio.h> >> #include <stdlib.h> >> #include <iostream> >>=20 >> #define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV >>=20 >> int height=3D0, width=3D0; >> GLuint g_fb=3D0; >> GLuint g_tex=3D0; >> GLuint g_depth=3D0; >>=20 >> using namespace std; >>=20 >>=20 >> void Abort(char *msg) >> { >> printf(msg); >> exit(1); >> } >>=20 >>=20 >>=20 >> void CheckErrorsGL(const char* location=3DNULL, ostream& ostr=3D std::= cerr ) >> { >> GLuint errnum; >> const char *errstr; >> int counter =3D 0; >> while (errnum =3D glGetError()) >> { >> errstr =3D reinterpret_cast<const char *>(gluErrorString(errnum)); >> if(errstr) >> { >> ostr << errstr; >> } >> else >> { >> ostr << "Error " << errnum; >> } >>=20 >> if(location) >> ostr << " at " << location;=20 >> ostr << endl; >> counter++; >> } >> if (counter) >> Abort("Application cannot continue!\n"); >>=20 >> return; >> } >>=20 >> void TestOpenGLError() >> { >> CheckErrorsGL(NULL); >> } >>=20 >>=20 >> void Draw() >> { >> // working with main object (the application) >> if (!width || !height) >> return; >>=20 >> glClearColor(0,0,0,0); >> glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); >>=20 >>=20 >> glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fb); TestOpenGLError(); >> glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT ); TestOpenGLError(); >> glViewport(0,0,width, height); TestOpenGLError(); >> glClearColor(0,0,0,0); TestOpenGLError(); >> glClear(GL_COLOR_BUFFER_BIT); TestOpenGLError(); >>=20 >>=20 >> float size =3D 100.0f; >>=20 >> glColor3f(1,0,0.5f); >> glBegin(GL_QUADS); >> glVertex2f(width*0.5f - size, height*0.5f - size); >> glVertex2f(width*0.5f - size, height*0.5f + size); >> glVertex2f(width*0.5f + size, height*0.5f + size); >> glVertex2f(width*0.5f + size, height*0.5f - size); >> glEnd(); >> //glColor3ub(0,0,0); >>=20 >>=20 >>=20 >>=20 >> glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); >> glDrawBuffer( GL_BACK ); >> glViewport(0,0,width, height); TestOpenGLError(); >> glFinish(); >> glEnable(GL_TEXTURE_RECTANGLE); >> glBindTexture(GL_TEXTURE_RECTANGLE, g_tex); TestOpenGLError(); >> glEnable(GL_TEXTURE_RECTANGLE); TestOpenGLError(); >>=20 >>=20 >> glBegin(GL_QUADS); >> glTexCoord2f(0.0f, 0.0f); >> glVertex2f(0.0f, 0.0f); >> glTexCoord2f(0.0f, height); >> glVertex2f(0.0f, height); >> glTexCoord2f(width, height); >> glVertex2f(width, height); >> glTexCoord2f(width, 0.0f); >> glVertex2f(width, 0.0f); >> glEnd(); >>=20 >> glDisable(GL_TEXTURE_RECTANGLE); TestOpenGLError(); >> // back to 3D mode >>=20 >>=20 >> glFinish(); >> glutSwapBuffers(); >> } >>=20 >> void Init() >> { >> GLenum err =3D glewInit(); >> if (GLEW_OK !=3D err) >> // Problem: glewInit failed, something is seriously wrong. >> Abort("init error\n"); >>=20 >>=20 >> TestOpenGLError(); >> glGenFramebuffersEXT(1, &g_fb); ; TestOpenGLError(); >> glBindTexture(GL_TEXTURE_2D, 0); TestOpenGLError(); >> glBindTexture(GL_TEXTURE_RECTANGLE, 0); TestOpenGLError(); >> glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fb); TestOpenGLError(); >>=20 >> // create the texture for the color >> glGenTextures(1, &g_tex); &nbs p; TestOpenGLError(); >> glBindTexture(GL_TEXTURE_RECTANGLE, g_tex); TestOpenGLError(); >>=20 >> glTexParameteri (GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP); >> glTexParameteri (GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP); >> glTexParameteri (GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEARE= ST); >> glTexParameteri (GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEARE= ST); TestOpenGLError(); &nbs p; >>=20 >> //glTexImage2D(GL_TEXTURE_RECTANGLE, 0, 4, width, height, 0, GL_RGBA, = GL_UNSIGNED_BYTE, NULL); //works >> //glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA16, width, height, 0,GL= _RGBA, GL_UNSIGNED_SHORT, NULL); //works >> //glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_FLOAT_RGBA32_NV, w, h, 0,GL= _RGBA, GL_FLOAT, NULL); //does not work >> glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_FLOAT_RGBA16_NV, width, heigh= t, 0,GL_RGBA, GL_UNSIGNED_SHORT, NULL); >>=20 >> TestOpenGLError(); >> glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,= GL_TEX TURE_RECTANGLE,g_tex, 0); >> if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) !=3D GL_FRAMEBUFFE= R_COMPLETE_EXT) >> Abort("Error adding color to FBO\n"); >> TestOpenGLError(); >>=20 >> glMatrixMode(GL_PROJECTION); >> glLoadIdentity(); >> glOrtho(0,width,0,height,-1,100.0f); >> glMatrixMode(GL_TEXTURE); >> glLoadIdentity(); >> glMatrixMode(GL_MODELVIEW); >> glLoadIdentity(); >> glTranslatef(0,0,-5); >> } >>=20 >> void Reshape(int w, int h) >> { >> width =3D w; >> height=3D h; >> glViewport(0,0,width,height); >> Init(); >> } >>=20 >>=20 >> void main(int argc, char **argv) >> { >> glutInit(&argc, argv); >> glutInitDisplayString("double blue>=3D8 red>=3D8 alpha>=3D8 green>=3D8= depth=3D32");// rgba>=3D8 depth>=3D24"); >> glutInitWindowSize(640,480); >> glutInitWindowPosition(0,0); >> glutCreateWindow("test"); >> glutSetWindowTitle("test"); >>=20 >>=20 >> glutIdleFunc(Draw); >> glutDisplayFunc(Draw); >> glutReshapeFunc(Reshape); >>=20 >> glutShowWindow(); >> glutMainLoop(); >>=20 >> } >> ----- FAQ and OpenGL Resources at: http://www.geocities.com/SiliconVal= ley/Hills/9956/OpenGL -- Author: [email protected] >> INET: [email protected] Fat City Hosting, San Diego, California -- http= ://www.fatcity.com >> --------------------------------------------------------------------- = To REMOVE yourself from this mailing list, send an >> E-Mail message to: [email protected] (note EXACT spelling of 'ListG= uru') and in the message BODY, include a line >> containing: UNSUB OPENGL-GAMEDEV-L (or the name of mailing list you wa= nt to be removed from). You may also send the HELP >> command for other information (like subscribing). >> >=20 > Servus, > Gernot >=20 > GPU. 3D Vision. Europe. Future. Now. > Drop by: www.mpi-sb.mpg.de/~gziegler - www.geofront.eu > --=20 Estoy usando la versi=F3n gratuita de SPAMfighter para usuarios privados. Ha eliminado 29139 correos spam hasta la fecha. Los usuarios de pago no tienen este mensaje en sus correos. Obtenga SPAMfighter gratis aqu=ED: http://www.spamfighter.com/les -----=20 FAQ and OpenGL Resources at: http://www.geocities.com/SiliconValley/Hills/9956/OpenGL --=20 Author: Gernot Ziegler INET: [email protected] Fat City Hosting, San Diego, California -- http://www.fatcity.com --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [email protected] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).