iDevGames Forums
Starting with OpenGL, need some help - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Starting with OpenGL, need some help (/thread-7868.html)



Starting with OpenGL, need some help - wsc981 - Jul 16, 2010 04:43 AM

Hi all, I just registered to this forum since I'm getting serious about developing a game and learning OpenGL. I'm following the tutorials from this blog while simultaneously starting on a game with very basic OpenGL functionality. At home I've also got the RedBook, but I intend to read more into it at a later point, once I know the basics.

I stumbled upon a problem and I could use some help. For my personal project I use Apple's OpenGL template. In the ES2Renderer class I've created a figure and now I'm trying to set the 'camera'. In order to set the camera I've added the glFrustum function, see the following code:

Code:
...
    [EAGLContext setCurrentContext:context];
    glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);

    glViewport(0, 0, backingWidth, backingHeight);
    glFrustumf(0.0, 200.0, 0.0, 200.0, 0.01, 1000.0); // this is causing an error

    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    ...

I get the following warning for the glFrustumf function: implicit declaration of function 'glFrustumf'. The warning doesn't make sense to me, since I believe the required header that contains the function should already be imported as part of the ES2Renderer class - the function should be part of gl.h, right?. When I comment out the line containing the glFrustumf function the code works just fine. Anyone have any idea what's going wrong here?


RE: Starting with OpenGL, need some help - sealfin - Jul 16, 2010 05:51 AM

I believe that should be glFrustum(), not glFrustumf() Wink

Edit: yeah, I'm: 1) wrong; 2) far too trusting of the documentation Annoyed


RE: Starting with OpenGL, need some help - wsc981 - Jul 16, 2010 06:18 AM

I realize I've posted my question in the wrong subforum. Could some admin move this thread to the 2d / 3d graphics subforum?

Also, glFrustumf() should be correct, it's also color coded like any correct function is. It just seems to be missing somehow. I'm developing for the iPhone / iPad btw, perhaps my issue got something to do with this?

Edit: I think I figured out the issue. It seems glFrustumf() is a function that can only be used in OpenGL ES 1.x. I guess in OpenGL ES 2.0 I need shaders or some other method to achieve my goal, anyone got some suggestions?


RE: Starting with OpenGL, need some help - Oddity007 - Jul 16, 2010 07:15 AM

I believe all matrix related things in ES 2 were removed.


RE: Starting with OpenGL, need some help - ThemsAllTook - Jul 16, 2010 09:17 AM

Yes, you'll need to do all your own matrix math under ES2. This might help: http://sacredsoftware.net/tutorials/Matrices/Matrices.xhtml


RE: Starting with OpenGL, need some help - wsc981 - Jul 17, 2010 06:28 AM

(Jul 16, 2010 09:17 AM)ThemsAllTook Wrote:  Yes, you'll need to do all your own matrix math under ES2. This might help: http://sacredsoftware.net/tutorials/Matrices/Matrices.xhtml

Thanks for the link, but after globally reading through the page I figured it might be a better idea to just start out with OpenGL ES 1.x before moving to OpenGL ES 2.0. It seems to me OpenGL ES 2.0 is quite a bit more complex, it doesn't seem a good introduction for a beginner.