PDA

View Full Version : Orienting myself in OpenGL



MuteClown
15-03-2011, 05:01 PM
I seem to be having some trouble orienting myself in 3d world, im drawing single objects to get myself use to OpenGL. Though im sure my object are fine and should be drawing, im having trouble to figure where im facing in the world, if you know what im saying. I am fairly new to it all.

Does anyone got any tips?

code_glitch
15-03-2011, 05:43 PM
Have you taken a look at Nehe's tutorials? if you're coming from the 2d world take a look at http://freepascal-meets-sdl.net/ and their 8th lesson since it covers 3d and opengl with opengl.

MuteClown
15-03-2011, 07:14 PM
yeah i had read through some of the nehe tutorials, i also got the red book 7th edition.
I just remembered that the red book refers to nate robins suite, that has help me some what.

Am i right when describing glutLookAt function like this:
the first 3 cords(eye) define the angle the camera is look at. The next 3 cords(center) define a point that the camera is looking at, and last cords(up) define which way is up?

Can i assume that you must only use one of:
glFrustum
gluPerspective
glOrtho

so not to use them in conjunction with each other?

code_glitch
15-03-2011, 10:11 PM
the glutLookAt bit sounds a tad precarious to me, since from what I have heard glut is quite badly deprecated. Also, I do not see why you cannot use those together... Might I propose a slightly different approach, I would recommend an approach more where you have a program that does something, perhaps in sdl, and then try to break it down and port it to OpenGl so that you understand the program and then how to do it in OpenGl. That way you don't learn a hypothetical understanding of OpenGl but a practical one solving real programming problems...

Just a thought. I am no OpenGl expert, so I can only suggest not really recommend strongly. :)

MuteClown
16-03-2011, 08:58 AM
I meant GluLookAt :S

i think thats a good idea on learning the practical side, because the theory stuff is kicking my ass.

wodzu
16-03-2011, 07:45 PM
@Code_glitch gluLookAt doesn't belong to glut library:) It belongs to OpenGL extentions defined in glu unit:)
I was confusing that too:) and started to implement my own camera cause I wanted to get rid of this glut dependancy which turned out to be non-existant :)

@MuteClown: The thing with gluLookAt is a bit different compared to your understanding of it. The first 3 parameters in the procedure are defining the position of the "camera" in space. Not the angle. The angle is calculated by procedure based on the position of the camera and point on which the camera is looking.

You can mix gluOrtho with gluPerspective and even you should in some cases:) For example, to draw a menu, all the windows and so on, you should switch to gluOrtho, to render 3d objects you switch back to gluPerspective.

I am beginner with OpenGL but feel free to ask any further questions. Maybe we could help each other :)

code_glitch
16-03-2011, 10:28 PM
Well, looks like I made the same mistake as wodzu here... Just a testament to show how little on the topic I know. I am familiar with glu, but if I might interject into this topic, what is glu? I just realized I include this but don't actually know what it is/does 8-} so yay for opengl and double yay for wodzu for pointing that out... And yes, ask me anything and I will see if I know anything useful... Who knows, my limited knowledge may be of some use yet (evil laugh)

cheers,
code_glitch

MuteClown
17-03-2011, 10:10 AM
cheers all :D

Yeah Wodzu, i just read the section in the red book about the perspective matrix, and how you can draw 2d menus using the glOrtho. Since the perspective matrix is 2 deep, you can switch to glortho just to draw the menus etc...

Glu(OpenGL Utility Library) is like another layer on top of OpenGL. So commonly used routines would be included, to extend from OpenGL. I think thats right describing it like that.
Does anyone have a camera class that i could take a look at? I want to try to implement my own, so i can get a better understanding.

wodzu
17-03-2011, 11:17 AM
I have a camera class which doesn't work to well :D Honestly this transformation of matricies and the order in which you transform objects is making me crazy :S I've spent two days thinking about why the cube is rotating in a particular way and still I am confused.

And the red book doesn't make it any easier telling you that you can think about the order of transofrmation in two ways (top to bottom or bottom to top).

Anyway, you can start to analyze camera things by looking at NeHe tutorial, the one in which you are moving like in a first person shoter.

MuteClown
17-03-2011, 11:25 AM
I have a camera class which doesn't work to well :D Honestly this transformation of matricies and the order in which you transform objects is making me crazy :S I've spent two days thinking about why the cube is rotating in a particular way and still I am confused.

And the red book doesn't make it any easier telling you that you can think about the order of transofrmation in two ways (top to bottom or bottom to top).

Anyway, you can start to analyze camera things by looking at NeHe tutorial, the one in which you are moving like in a first person shoter.

I know exactly what you mean by that, im still pondering the same in my head =/

code_glitch
18-03-2011, 06:06 PM
Although it was a while back, I think I know of this 'red book'... At least, I remember looking at those matrices and going: WOH?

Let me see if I can find you that good tut on rotation I once saw... Its not the exact one, its in c but it gives some good pointers (excuse the pun): http://gpwiki.org/index.php/OpenGL:Tutorials:Theory