Simple graphical project, satellite tracking / visualization

Hello,

I would like to create a simple satellite tracking / visualization software with OpenGL, that would result in something like this :


( I did not produce and don’t own the image, I found it by image searching )
It is basically a map of Earth on which points are projected, that represent satellite’s position above that location on Earth. Of course these points move in time and create a line. I have the calculations part covered, I believe, but I don’t know about graphical implementation.

I have C++ experience and no OpenGL experience. I have a video card that supports OpenGL 3.2 , but someone recommended me to use legacy OpenGL for such a simple project. I am little doubtful, because I would like to learn core profile, that will be of use for me in future too. But legacy coding is supposed to be much easier. Can I have your opinions on it ? And maybe some online resources / books / tips that will help me get the basics I need to complete my project ?

Thank you, it is much appreciated
thor36

Your project is extremely simple. If you want to learn modern OpenGL, then and only then you should use OpenGL 3+. But the development would last very long. Using legacy (fixed function) OpenGL would be faster and can be executed virtually on everything. But, if you want to achieve results in an hour, use some 2D API. You just need drawing a bitmap and few simple primitives like lines and circles.

> but someone recommended me to use legacy OpenGL for such a simple project

Maybe someone recommended just what he/she just got used to. New OpenGL API is even simpler than the legacy immediate mode: you fill a buffer with vertices to draw, attach this buffer to the context and call the draw command.

You see, that is why I am confused. You both gave me great answers ( thanks for that ! ), but different ones. And it is same when I do research on ‘old’ vs ‘new’ OpenGL on my own - I can’t figure out the best option, and they both seem to be about equal with pros and cons. And I would like to use OpenGL because of its versatility and possible projects in the future. The part with " Using legacy (fixed function) OpenGL would be faster and can be executed virtually on everything " seems to be giving an edge.

Maybe you can give me additional comments if I let you know that next stage of my project ( after completing this simple one ) would be a Solar system simulation, resulting in something like this :


( again I did not produce and don’t own the image, I found it by image searching )

This is also fairly easy. Fixed functionality is easier (up to certain extent) but shader based approach is more flexible. If you are ready to learn, start with GL 3+, but be prepare to spend a long long time before achieving some result. But the next step to something more complicated would be much easier. Drawing a triangle or a pretty complicated mesh is almost the same in moder OpenGL. On the other hand, you can achieve same simple results much faster with legacy OpenGL, but maybe you’ll come to a point where it cannot be used any more (for example, per pixel lighting). Maybe it is best for you to find some examples in both legacy and moder OpenGL and compare the code. You’ll need a lot more accompanying libraries (or implement by yourself) if you follow the moder path. Everything you showed in the downloaded pictures can be quite easily implemented using legacy OpenGL.

And load new functions not exposed by windowing API, and make shaders for drawing, and make some shaders loading code, and make buffers for even the smallest primitives (or make them procedurally), and make and select VAO (even if you are not using it), and implement all maths for vector/matrix manipulation, and implement transformations, and … Sounds simple, isn’t it? :wink:

But, at the point when one has all this and achieves some skills, there will be no limitations. Shader-based approach is extremely powerful.

Alexandar thank you for your comments. I think this settles it, for now I will go with legacy OpenGL, and leave the modern one when I will complete these projects and have the luxury of more time. Now that you know what kind of results I would like to achieve with legacy OpenGL, can you ( or anyone else too ) point me to some resources that you recommend ( books & tutorials ) ? I have already been looking for them and found some, but as a beginner I may not do a good selection, and I probably missed some good ones too. I will be using C++ and CodeBlocks. Also, GLUT / FreeGLUT is used in most tutorials, but people recommend GLFW. Thank you for your help.

What books and tutorials have you found?
For the beginning I would recommend OpenGL Programming Guide (pre-8th edition). There is also online version of some of the earliest editions. You need to read just first four chapters to get basic skills and a half of ninth chapter for texturing (you need it to draw a map). For the second phase (the solar system), you may need also fifth chapter (lighting).

I have found these :

So far I have been checking swiftless tutorial. It seems ok, but texturing only shows how to load RAW images, and my map will be either JPEG / BMP / PNG / TIFF. And I will probably want to move from FreeGLUT to GLFW at some point. I would like my program to be able to run on Linux and Windows, with as little changes as possible before compilation.

Also I would like opinion from you about these two books I found, whether they would apply well for my project and which version would be more suitable :

As far as image loading goes, you could read up on each file format and make your own loader, or you could use a image loading library. A good lightweight, easy to use, cross platform one is SOIL, which can load BMP, JPG, PNG, and others more besides (though not TIFF). Another popular one is DevIL, which can load an even larger range of formats including TIFF, though it’s slightly larger than SOIL.

Thank you fiodis. I have already tried with SOIL ( I chose it over DevIL because I don’t need such big library with so many supported formats ). But I get a flawed texture rendering. I tried it on a swiftless tutorial example with creating a sphere and binding bitmap Earth texture on it. With SOIL I get only upper hemisphere textured , and on one “meridian” an ugly texture “stitch” appears.

I’m not sure which tutorial you’re using, but if you’re using this one then it looks like the bottom half has negative texture coordinates. Normally texture coordinates range from 0 to 1. To go beyond that you need to specifically enable texture wrapping. See glTexParameter; you’ll want to enable GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T. Swiftless has an example in their code following that tutorial.

Fiodis - yes that was the tutorial I was mentioning. And what you said was exactly what was missing in my code, thank you. If you are familiar with OpenGL literature, I would kindly like to ask you to give me your opinion on my post #9, while I am eagerly awaiting Alexandar’s opinion. If you feel like it that is, so no need to bother with it if you don’t =)

I would like to create a simple satellite tracking / visualization software with OpenGL, … someone recommended me to use legacy OpenGL …
I use legacy GL to do my satellite sims (which are animated). A screen grab is attached. Use gluSphere with textures activated to eliminate that ugly seam you’re running into. I load bmps and tga files using code I grabbed off the web. I also use Devil to load images. Legacy GL is capable enough to generate the graphics you are interested in. I haven’t tried to mess around with Modern GL. It looks like the learning curve is steep. If you were going to be a full time graphics application developer, it would be the way to go. If you’re primary interest is in some other area (such as engineering), and you are doing graphics on the side, I’d recommend Legacy GL. The NeHe Graphics Legacy tutorials are good. There are lots of them, but you only need to do the first 6 or so for your application.

[ATTACH=CONFIG]1268[/ATTACH]

Carmine, your project looks awesome. Close ( well, much better ) to what I expect to achieve some time. Is there a website with more information about your project available ? Also thank you for the extra tips in your post, much appreciated.

Carmine, your project looks awesome. Is there a website with more information about your project available?
Thanks. My work is not documented outside my company because it is being developed in a classified environment. But that should not discourage you. The ‘look’ of my graphics is result of practice, not graphics sophistication. It is done with basic, Legacy, GL - all of which is covered in the first 6 NeHe Tutorials. Orbit visualization software can be purchased from companies such as AGI (www.agi.com), which is one of the more sophisticated, thus expensive packages. A search of the web would probably yield less expensive packages.

If you have no budget and/or want to do it yourself, it is fairly straightforward. Everything in my image is lines, polygons, and textures. The primary light source is the sun, with a secondary source to fill in darker areas. All of the user interface stuff is done with FLTK, which is free software.

Good luck.

[QUOTE=thor36;1259026]I have found these :

So far I have been checking swiftless tutorial. It seems ok, but texturing only shows how to load RAW images, and my map will be either JPEG / BMP / PNG / TIFF. And I will probably want to move from FreeGLUT to GLFW at some point. I would like my program to be able to run on Linux and Windows, with as little changes as possible before compilation.

Also I would like opinion from you about these two books I found, whether they would apply well for my project and which version would be more suitable :

  • First one
  • Second one[/QUOTE]
    Use tutorials just to get quick start and make the first application running, but then spend some time in getting basic knowledge from the books.
    OpenGL Superbible is quite OK. It is more “tutorial” oriented, while OpenGL Programming Guide is more “reference” oriented. It would be probably good choice to start with any of these. When I started with OpenGL (about 17 years ago), the Red Book (in electronic form on SGI workstation) was everything I could get about OpenGL. Later I got several printed versions. They still collect dust on the self. :wink: Maybe that’s why I usually recommend the Red Book. Sentimentality or something like that… :slight_smile:
    Unfortunately, it seems that the latest versions of both books are not as good as they used to be, or my expectations grew very high.

Your project is quite simple. You should be able to do it without any of the shelf solution.
By the way, if you are trying to visualize real Earth, you should make an ellipsoid instead of sphere. The difference is small, but it would be more scientific like…

Considering loading pictures, I recommend stb_image.c. The whole “library” in a single file. You couldn’t get better portability. :slight_smile:
BUT, before go any further, consider using images in DXT1 format. Those format you mentioned is not good for 3D applications.
You’ll get significant speedup and reduction of memory space if you use some of the texture compression formats (like DXT1/S3TC).

Alexandar, I think I found the Red Book most suitable for me to start with as well. And I can see it has a very long tradition, close to my lifetime =) Do you ( or anyone ) have any idea where to get Red Book 5th and 6th edition code for download ?

Difference between equatorial and polar radius of Earth is about 20 km, it would take an XXL screen with super resolution to notice the difference =) I understand your point though, but my project really isn’t so much about details like that. Speaking of that, what algorithm do you recommend me to use to create a sphere that I can texture ( “create” Earth ), so that it will be efficient and decent looking ?

I will try stb_image.c “library”, thank you. But how do I go about using DXT1 / S3TC format ? How do I convert images from common formats to that one ? And what OpenGL functions use it for texturing ?

There is some sample code from the first edition, but I don’t think you need it. As I said, build some sample application (from tutorials) and then try to add/change functions according to examples from the books or other tutorials.

I know very well the shape of the Earth. :slight_smile:
I’ve spent years in implementing my algorithm for procedural completely shader based high accurate model of the WGS84 ellipsoid. Looking at the shape of the Earth solely one cannot distinguish it from the perfect sphere. But, since you want to visualize satellite paths, depending on the accuracy you need to achieve, an error sometimes is not negligible. Be aware of geodetic and geocentric latitude difference. I have no idea what formulae you are using, but they probably use latitude.

If you want to create a sphere, it is best to use two nested loops (through latitudes and longitudes), translate polar to Cartesian coordinates and use triangle strips to draw strips around the globe (each strip from Theta to Theta+dTheta in latitude and from 0 to 360 degrees in longitude). Steps should be chosen according to your needs. This is quite acceptable up to about several km above the surface If you want to implement ellipsoid, the equations are different. (By the way, my implementation is far more complicated and I wouldn’t start that topic right now. And it requires shaders heavily.)

OpenGL can compress textures automatically if internal format is set to GL_COMPRESSED_RGB_S3TC_DXT1_EXT (for DXT1/S3TC). Please read chapter 9 from the Red Book for details. Also, there are a lot of tools for offline compression.

Great to know that I am receiving help from an expert in the field :slight_smile: What you are telling about your work sounds very interesting. Do you mind if I ask for what purpose have you designed such an accurate model of Earth ?

Yes, the geodetic and geocentric latitude variance is another story and I will be careful about it. Whereas the exact shape of the Earth is not of essence for the orbit visualization. About the algorithm that you have just described me for creating a sphere - is it documented anywhere in terms of pseudo code or perhaps even better implemented in OpenGL already ? I can say honestly that I would like to save some sweat, time, nerves and errors with drawing a sphere, since the central point of my project are orbits and physical calculations of spacecraft motion - not to mention that I am beginner in OpenGL and that takes a lot of extra effort itself :slight_smile: