Archived

This topic is now archived and is closed to further replies.

MARS_999

OpenGL Is it possible to do a top down RTS in OpenGL?

Recommended Posts

Is it possible to do a top down view like TA in OpenGL? I think it is but not sure how one would go about it? Would I use glOrtho() or gluPerspective()? I am not sure, but from what I see TA''s tilesets are 2D textures? So if that is the case then the only 3D part of the game is the units. Which you would have to use 3DS for right? Now if you use those units you will have to use gluPerspective() so you have all three axis''s. Because if you use glOrtho() and you have an airplane fly by and do a roll its not going to show up when its rolling. So if I use a tile based engine with 512x512 textures for the map, wouldn''t I need to load each 512x512 texture with a heightmap and somehow determine the height at any given textel on the screen? Any help would be great thanks!! Bill Gates is my Pool Boy!! Nothing is to good for me!!

Share this post


Link to post
Share on other sites
newer 3d rts games use 3D maps with variable hieght terran (empire earth, warcraft 3). Just do the whole thing in 3D. Storing a hieghtfield is cheap anyways (just 8 bits more per tile, plus they compress well). Use a perspective projection and keep the camera at some fixed distance from the ground plane looking down at a fixed angle (most games let you scroll down to horizontal with the mouse wheel, but for gameplay, thats worthless). If you have seen war3, they basically still use tiles for textures instead of the more tranditional large texture / detail texture used in most terrain renderers.

Share this post


Link to post
Share on other sites
How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks!

Bill Gates is my Pool Boy!!
Nothing is to good for me!!

Share this post


Link to post
Share on other sites
>>How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks! <<

yes its possible look atsetting up a orthogonal viewport +
setup the camera like so

gluLookAt(-10,sqrt(200),10,0,0,0,0,1,0) as an example

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
quote:
Original post by zedzeek
>>How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks! <<

yes its possible look atsetting up a orthogonal viewport +
setup the camera like so

gluLookAt(-10,sqrt(200),10,0,0,0,0,1,0) as an example

http://uk.geocities.com/sloppyturds/gotterdammerung.html


Ok here is what I got setup and am seeing nothing? My code compiles fine but not sure why I don''t see a simple quad?


  
void Draw(void)
{
glLoadIdentity();
gluLookAt(-10, sqrt(200), 10, 0, 0, 0, 0, 1, 0);

glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-10.0f, -10.0f);
glVertex2f(10.0f, -10.0f);
glVertex2f(10.0f, 10.0f);
glVertex2f(-10.0f, 10.0f);
glEnd();
}

bool InitOpenGL(int width, int height)
{
float ratio = float(width) / float(height);

glViewport(0, 0, width, height);

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);

glDepthFunc(GL_LEQUAL);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0.0f, float(width), 0.0f, float(height), -1.0f, 100.0f);

glMatrixMode(GL_MODELVIEW);

return true;
}


I think I got everyting setup right? Thanks for the help in advance. =)

Bill Gates is my Pool Boy!!
Nothing is to good for me!!

Share this post


Link to post
Share on other sites
your screen is say 1024x768 pixels large, though that quad is only 20x20 pixels large thus it might be a bit small

use 3d vertices (x,y,z) y is going up
eg

glVertex3f(-10.0f, 0, -10.0f);
glVertex3f(10.0f,0, -10.0f);
glVertex3f(10.0f, 0, 10.0f);
glVertex3f(-10.0f, 0, 10.0f);

turn off backface culling, texturing/alphatest/lighting etc

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
quote:
Original post by zedzeek
your screen is say 1024x768 pixels large, though that quad is only 20x20 pixels large thus it might be a bit small

use 3d vertices (x,y,z) y is going up
eg

glVertex3f(-10.0f, 0, -10.0f);
glVertex3f(10.0f,0, -10.0f);
glVertex3f(10.0f, 0, 10.0f);
glVertex3f(-10.0f, 0, 10.0f);

turn off backface culling, texturing/alphatest/lighting etc

http://uk.geocities.com/sloppyturds/gotterdammerung.html


Great its showing up now. I am a little consfused on how I should move the screen around now? I must have to make a bi-axis move now to move on what would have been one axis before? The image is showing up on the far left and would like to move it to the center of the screen so I can get a better look at it. The quad don''t look right but like I said I can''t see the whole quad. I have to admit I have only worked with glOrtho() as a x,y axis map and glPerspective as x,y,z using glTranslatef() and glRotatef() so this is all new to me. =) Thanks

Bill Gates is my Pool Boy!!
Nothing is to good for me!!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if it''s just 2d you can use glOrtho2d and 2d coordinates

Share this post


Link to post
Share on other sites
There is nothing prohibiting you from using ortho to make a top-down RTS, even one with 3D units. Ortho just means that there is no perspective correction, where things get smaller with distance or lean a certain way near the edges of the screen.

Check the screenshots at my website (below) for an example of me starting out with ortho and switching to perspective. While I''m not using 3D units, you can still see the difference.

Speaking of TA, I believe it used 3D terrain AND 3D units, same as TA:K. The terrain utilized height-mapped sections with 2D textures mapped onto them.

And where do you get the idea that you can''t see a rolling plane in ortho projection? Ortho is just a method of projecting things onto the screen. There is no perspective in ortho, so there is no reduction/enlargement based on distance. I.e., that plane right at your nose and 50 units into the screen will still look the same size unless you scale it or your viewport.


Care,
Chris Rasmus

Florida, USA
RTS Engine in Development
http://www.knology.net/~heaven
Jesus is LORD!

Share this post


Link to post
Share on other sites
quote:
Original post by Heaven
There is nothing prohibiting you from using ortho to make a top-down RTS, even one with 3D units. Ortho just means that there is no perspective correction, where things get smaller with distance or lean a certain way near the edges of the screen.

Check the screenshots at my website (below) for an example of me starting out with ortho and switching to perspective. While I''m not using 3D units, you can still see the difference.

Speaking of TA, I believe it used 3D terrain AND 3D units, same as TA:K. The terrain utilized height-mapped sections with 2D textures mapped onto them.

And where do you get the idea that you can''t see a rolling plane in ortho projection? Ortho is just a method of projecting things onto the screen. There is no perspective in ortho, so there is no reduction/enlargement based on distance. I.e., that plane right at your nose and 50 units into the screen will still look the same size unless you scale it or your viewport.


Care,
Chris Rasmus

Florida, USA
RTS Engine in Development
http://www.knology.net/~heaven
Jesus is LORD!


Wow it works!! glOrtho() will do 3D. =) Oops my bad. Now I can do a game in glOrtho() top down and use 3D units. I am not worried about perspective since I can enlarge or shrink my units to make them look in proportion. Thanks a million. Now off to work on code to load .3ds models.

Bill Gates is my Pool Boy!!
Nothing is to good for me!!

Share this post


Link to post
Share on other sites

  • Forum Statistics

    • Total Topics
      627778
    • Total Posts
      2979025
  • Similar Content

    • By lonewolff
      Hi guys,
      With OpenGL not having a dedicated SDK, how were libraries like GLUT and the likes ever written?
      Could someone these days write an OpenGL library from scratch? How would you even go about this?
      Obviously this question stems from the fact that there is no OpenGL SDK.
      DirectX is a bit different as MS has the advantage of having the relationship with the vendors and having full access to OS source code and the entire works.
      If I were to attempt to write the most absolute basic lib to access OpenGL on the GPU, how would I go about this?
    • By DelicateTreeFrog
      Hello! As an exercise for delving into modern OpenGL, I'm creating a simple .obj renderer. I want to support things like varying degrees of specularity, geometry opacity, things like that, on a per-material basis. Different materials can also have different textures. Basic .obj necessities. I've done this in old school OpenGL, but modern OpenGL has its own thing going on, and I'd like to conform as closely to the standards as possible so as to keep the program running correctly, and I'm hoping to avoid picking up bad habits this early on.
      Reading around on the OpenGL Wiki, one tip in particular really stands out to me on this page:
      For something like a renderer for .obj files, this sort of thing seems almost ideal, but according to the wiki, it's a bad idea. Interesting to note!
      So, here's what the plan is so far as far as loading goes:
      Set up a type for materials so that materials can be created and destroyed. They will contain things like diffuse color, diffuse texture, geometry opacity, and so on, for each material in the .mtl file. Since .obj files are conveniently split up by material, I can load different groups of vertices/normals/UVs and triangles into different blocks of data for different models. When it comes to the rendering, I get a bit lost. I can either:
      Between drawing triangle groups, call glUseProgram to use a different shader for that particular geometry (so a unique shader just for the material that is shared by this triangle group). or
      Between drawing triangle groups, call glUniform a few times to adjust different parameters within the "master shader", such as specularity, diffuse color, and geometry opacity. In both cases, I still have to call glBindTexture between drawing triangle groups in order to bind the diffuse texture used by the material, so there doesn't seem to be a way around having the CPU do *something* during the rendering process instead of letting the GPU do everything all at once.
      The second option here seems less cluttered, however. There are less shaders to keep up with while one "master shader" handles it all. I don't have to duplicate any code or compile multiple shaders. Arguably, I could always have the shader program for each material be embedded in the material itself, and be auto-generated upon loading the material from the .mtl file. But this still leads to constantly calling glUseProgram, much more than is probably necessary in order to properly render the .obj. There seem to be a number of differing opinions on if it's okay to use hundreds of shaders or if it's best to just use tens of shaders.
      So, ultimately, what is the "right" way to do this? Does using a "master shader" (or a few variants of one) bog down the system compared to using hundreds of shader programs each dedicated to their own corresponding materials? Keeping in mind that the "master shaders" would have to track these additional uniforms and potentially have numerous branches of ifs, it may be possible that the ifs will lead to additional and unnecessary processing. But would that more expensive than constantly calling glUseProgram to switch shaders, or storing the shaders to begin with?
      With all these angles to consider, it's difficult to come to a conclusion. Both possible methods work, and both seem rather convenient for their own reasons, but which is the most performant? Please help this beginner/dummy understand. Thank you!
    • By JJCDeveloper
      I want to make professional java 3d game with server program and database,packet handling for multiplayer and client-server communicating,maps rendering,models,and stuffs Which aspect of java can I learn and where can I learn java Lwjgl OpenGL rendering Like minecraft and world of tanks
    • By AyeRonTarpas
      A friend of mine and I are making a 2D game engine as a learning experience and to hopefully build upon the experience in the long run.

      -What I'm using:
          C++;. Since im learning this language while in college and its one of the popular language to make games with why not.     Visual Studios; Im using a windows so yea.     SDL or GLFW; was thinking about SDL since i do some research on it where it is catching my interest but i hear SDL is a huge package compared to GLFW, so i may do GLFW to start with as learning since i may get overwhelmed with SDL.  
      -Questions
      Knowing what we want in the engine what should our main focus be in terms of learning. File managements, with headers, functions ect. How can i properly manage files with out confusing myself and my friend when sharing code. Alternative to Visual studios: My friend has a mac and cant properly use Vis studios, is there another alternative to it?  
    • By ferreiradaselva
      Both functions are available since 3.0, and I'm currently using `glMapBuffer()`, which works fine.
      But, I was wondering if anyone has experienced advantage in using `glMapBufferRange()`, which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
      Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
  • Popular Now