Quick(hopefully) question.

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Quick(hopefully) question.

Post by ibly31 »

Is there the concept of a camera in OpenGL? A camera as in a specific point in space, looking in a direction, and that is what is rendered, basically like an eye. I have made games in SDL, in which there is no concept of a camera(I think) and I had to make all my images display on a specific offset, and display only what would be visible in the view of my screen. But that would be very hard/confusing to do in OpenGL ES for the iPhone, so... I was wondering, how to go about doing this.

My game is 2D, so the only things I'd be changing would be the X,Y positions. No rotation needed.

My guess is it has something to do with calling:

glOrthof(x,y,w,h);
glViewport(0,0,320,480);

but that is just a guess. Also: what exactly do orthof and viewport do? Im pretty sure that orthof and frustmf define the chunk of space to be rendered, and I really have no idea what viewport does... didn't we already say what to render? Maybe it is telling it which ways to stretch/resize if necessary...

Anyway, after that long rant... please answer, because I am at a standstill in development for now until this is answered. Thanks, seeya.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: Quick(hopefully) question.

Post by RyanPridgeon »

You can use glTranslate and a bit of logic.

glTranslate basically moves where you're about to draw with a translation matrix.

ortho and frustum create projection matrices which change how the 3d coordinates will be projected onto 2d screen coordinates.

viewport is what openGL uses to turn the 2d coordinates into pixel coordinates on the screen.

Dont hurt me if any of that is slightly wrong D:
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Quick(hopefully) question.

Post by ibly31 »

So, during the program, can I call glViewport(xoffset, yoffset, xoffset + 320, yoffset + 480); ????
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: Quick(hopefully) question.

Post by RyanPridgeon »

You would do something like

- clear screen
- glTranslatef(camerax, cameray, 0.0f);
- draw objects
- update screen
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Quick(hopefully) question.

Post by Falco Girgis »

And of course there is no concept of a "camera." OpenGL is a graphics API, not a game development library.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Quick(hopefully) question.

Post by ibly31 »

Okay. I have a GLView class inheriting from UIView, and a GLViewController class inheriting from UIViewController, which has a setupView: and drawView: function. How would I pause the GLViewController, and switch control to a pause menu, and then switch back? Also, how exactly do you tell the app to start off with a user interface, like a menu, then go to a GLView? Sorry if these questions are repetitive, or stupid, no matter how many times I ask, I still don't fully(even partially) understand how the whole subview/viewcontroller/app delegate/application flow works.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: Quick(hopefully) question.

Post by RyanPridgeon »

Use glOrtho for the projection matrix to set up a 2d / orthographic view for the menu/overlay/HUD

Use glFrustum or gluPerspective to set up a 3d perspective view for the 3d scene
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Quick(hopefully) question.

Post by ibly31 »

i don't think OpenGL ES has the glu prefixed methods...
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
Post Reply