Jump to content
  • Advertisement
Sign in to follow this  
Solance

Little opengl help

This topic is 4779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am createing a tile based game and currently i have a tile drawing function that draws tiles at there x,y locations but i recently implimented a tile scrolling method i was wondering how could i be like this tile is drawn top left of window next tile is drawn beside that one. the current for loop is set up like this (example of it i know that is not the syntax) for y for x draw code here if more info is needed just post and ask i would really like to know how to do this because if i change the map size right now i keep having to translate the pictures because they are drawn offscreen or something like that :) thanks i am using open GL and c++

Share this post


Link to post
Share on other sites
Advertisement
That's really confusing - I assume you're using gluOrtho2D? That makes things a breeze if you have no need for the Ortho or the other matrices. Please provide some more information first: bmp or pixel, camera movement? What do you mean by tile scrolling?

Share this post


Link to post
Share on other sites
Ok, I'm still a little confused, but if you are NOT using Ortho2D, then it becomes a bit more difficult to make sure the tile is at the right corner - basically, you'll need to do a little experimentation (or calculation beforehand) and have the tiles drawn out along whatever plane you want (probable the x/z plane) and then play with the camera till it contains only the tiles. You can find out the total area the tiles will take up and then use the camera angle to determine what will be seen.

Share this post


Link to post
Share on other sites
ok well can i just alter my code to use that view and my draw function still work with changes or will it require MAJOR changes?

Any other methods?

Share this post


Link to post
Share on other sites
It's tough because I'm not sure exactly where you're coming from - to change to Ortho2D, your display and reshape code will have no modelview matrix.

...
glViewport(...)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(left, right, bottom, top)
...

The thing is, that makes for very simple paint programs and 2D interactive projects. However, it has lots of constraints. When you're using, say, gluPerspective along with the Projection and Modelview matrices, you have lots of flexibility, but something as exact as filling the screen and only the screen with what you want becomes much more difficult. Considering NeHe is very thorough, you probably have MFC and the 3D code, so what you should consider is perhaps creating tiles via GL_QUAD or GL_QUAD_STRIP in your display function and then maybe going for a nice camera angle. The Red book is very helpful in this matter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!