Jump to content
  • Advertisement
Sign in to follow this  
iterator

OpenGL Converting to OpenGL 3

This topic is 3210 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

This is a general question to the group. We've been looking at the OpenGL 3 specifications and it seems it's going to be a very large effort to convert our application. Our application is substantial and has been in development for many, many years. I've gone through many of the OpenGL 3 threads on this forum and have not found much on what it really takes to convert an application over. It seems not too bad for something that is small, but that's not the case for us. Although there are tutorials out there, there is really not all that much. As an example, I've tried to find how to create fonts without using glGenLists and could not find anything. I've seen the reviews of the Red Book, and they are not very positive. I know the card manufacturers are not going to remove support for the older version of OpenGL, so so my question is, are most people actually converting over, and if so, what kink of experiences are people having? Is it better to wait longer until there is enough really good books, documentation and tutorials available to help streamline the effort?

Share this post


Link to post
Share on other sites
Advertisement
Another source of information when you're trying to deal with APIs that have been deprecated/removed from OpenGL 3.0 is stuff on OpenGL|ES (particularly ES 2.0) since the API is more similar in many respects to 3.0 than previous versions of desktop GL.

There was an article on here (or perhaps it was a journal entry) about fonts in OpenGL ES not long ago that might be of interest to you. Unfortunately I can't seem to find it myself in my cursory search.

Do you necessarily have to have real-time font-loading? I'm assuming you're wanting .ttf or similar... would it be acceptable to generate a bitmap font and render it as textured quads? There are many tools freely available to render a .ttf or similar font to a texture and generate the texture atlas. Results look fine, however its not the greatest option if you have many fonts or require many different text sizes or multiple DPI since you have to pre-generate them all. Then again, its probably the best option around if you only need one (or a handful of) version(s).

Share this post


Link to post
Share on other sites
OpenGL 3 provides a compatibility profile that supports everything you've been using so far, so strictly speaking you don't really have to convert anything. If you do want to convert stuff over to core profile, I ported my (admittedly small) engine to OpenGL 3 core profile a couple of months ago and blogged about it - it's in Java but perhaps there is one or two ideas there that might help you.

As for drawing fonts, what I do right now is draw all glyphs of a font to a texture when parsing the font file. I then store the texture coordinates for each glyph. Then when it comes time to draw a String, I put each character's corresponding glyph into a VBO, like so:


private void drawGlyph(Glyph g, IntBuffer indices, FloatBuffer vertices, float x, float y) {

if (g == null) {
g = glyphs.get(0);
}

// put indices
int pos = vertices.position() / 4;
indices.put(pos);indices.put(pos+1);indices.put(pos+2); // first triangle 0-1-2
indices.put(pos+1);indices.put(pos+3);indices.put(pos+2); // second triangle 1-3-2

// put vertices
vertices.put(x);vertices.put(y);vertices.put(g.getS0());vertices.put(g.getT1()); // v0
vertices.put(x + g.width);vertices.put(y);vertices.put(g.getS1());vertices.put(g.getT1()); // v1
vertices.put(x);vertices.put(y +g.height );vertices.put(g.getS0());vertices.put(g.getT0()); // v2
vertices.put(x + g.width);vertices.put(y + g.height);vertices.put(g.getS1());vertices.put(g.getT0()); // v3

}



I believe it's worth it to convert, although perhaps it's not a top priority. The reason is that the core profile API is slimmer (d'oh, since most features are removed). Also, you are forced to use the path that cards should be theoretically optimized for, namely Vertex Buffer Objects. On the other hand, you lose the matrix stacks and are forced to deal with shaders, so there is a bit of a learning curve involved.

Share this post


Link to post
Share on other sites
For fonts, why reinvent the wheel? FTGL ftw.

What you can expect while porting:
1. you'll need to rewrite all your shaders into GLSL 1.3 (or higher) syntax
2. you'll need to write shaders to replace all fixed-function codepaths (e.g. your font code)
3. you'll need to rewrite everything that relies on immediate mode, display lists, the matrix stack, GLU, lighting, fog, the imaging subset, old-style picking and multitexturing (to name the most common snags for mature codebases)

My suggestion? Move to the compatibility 3.x profile and take advantage of new features without throwing away the time and money you invested into the current codebase. You can then start replacing old-style code with shaders gradually (maybe keeping fixed-function paths for Intel IGPs and other cards with bad drivers).

While OpenGL 3.x is indeed a great improvement over 1.x and 2.x, it doesn't really make sense to throw away perfectly fine code *and* alienate at least 50% of your potential users at the same time (probably more, OpenGL 3.x hardware and drivers are still in somewhat short supply.)

Share this post


Link to post
Share on other sites
hey there, I had the same... well let´s call it problem. Than I heard about the book 'Beginning OpenGL Game Programming' which (in its second edition) tells you exactly how to keep an app in a forward-compatible 3.x context - which was the one thing I just wasn´t able to find anywhere...

Please don´t take this as a sort of advertisement, but the book is doing a great job in explaining these things.

The point is to avoid using 'non-openGL 3.x' stuff because it will cause your application to fall back to a special backward-compatible context. This 'non-OpenGL 3.x' stuff is such as using raster-position, using quads, using bitmaps, using display-lists, using evaluators, immadiate-mode etc.

I strongly recommend that book, especially if you´re not new to OpenGL, it helped me a lot!

adios!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!