• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SeeForever

2D tutorial on OpenGL

7 posts in this topic

Greetings, I have been using SDL for quite a bit now. I really like that library, it's easy to use and has many functions and its sub-libraries are very handy. But I would like to try something more low-level. I thought of OpenGL, and found the NeHe tutorials, but those seem mainly aimed towards 3D applications. I am only interested in 2D at the moment. So I wanted to ask, is there a 2D-based tutorial on OpenGL that you would recommend? Thanks in advance.
0

Share this post


Link to post
Share on other sites
OpenGL in itself doesn't handle anything other than graphics for you, you need to create the window, and handle input, yourself through other APIs then OpenGL. Since you already have some familairity with SDL, you should use that with OpenGL, as it's fairly easy to do with only a little hassle involved.

Using SDL with OpenGL

Then I'd look at this here: (It uses OpenGL and SDL for graphics)
Complete 2D Engine Overview
Particularily this section: Core Graphics

And you can always look at NeHe or other sites for how to use certain features.
0

Share this post


Link to post
Share on other sites
I just can't seem to grasp OpenGL's ideology... Guess I'll have to take notes, but once I understand the basics, it'll be a piece of cake.

Anyway, here's another question: I have a very simple game in pure SDL. It uses my engine, which is basically a wrapper around the various SDL libraries. That version runs very well, but on one of my slower computers (a 400MHz P2 with ~300 megs'o'ram) it runs a bit... choppy. Will there be a speed increase if I implement OpenGL into the engine (and modify the game to use textures instead of surfaces)?

Thanks again.
0

Share this post


Link to post
Share on other sites
Depending on the video card and drivers, you may see a significant speedup (especially if you are using blending).

You'll have to keep the limitations of older hardware (and general 3d hardware) in mind, though: no per pixel manipulations, no readbacks to CPU, and some older hardware may not support 32bit color (pre Riva TNT, and all 3dfx cards prior to 4000).

Last but not least, many drivers were problematic those days, so keep that in mind.
0

Share this post


Link to post
Share on other sites
OpenGL is a 3D graphics API though it can manage 2D drawing there are others such as SDL which are designed for 2D.

The most difficult part of working with OpenGL is creating the window and rendering context and this can be different between OSes, a good rule of thumb is when reading through the code from OpenGL tutorials if it does not contain A statement beginning with gl or GL_ then it's not a OpenGL call but rather something to do with window set-up or input handling.

A easy to follow tutorial on openGL using glut to skip all the nasty parts such as setting up a window.

When I first encountered OpenGL I started by modifying source code generated by the IDE that copied with all the window set-up.

I also found because the main choice for choosing OpenGL a lot of books and tutorials skim over the window set-up section as it's different between OSes. The best source I found for tutorials on setting up a window on a windows platform was Direct3D (DirectX) as it is windows only they go into more detail on setting up a window.
0

Share this post


Link to post
Share on other sites
Quote:
The most difficult part of working with OpenGL is creating the window and rendering context
I find this semi true. My personal opinion is that the opengl states and using textures vs surfaces are more difficult coming from a 2d perspective than using any of the libraries such as GLFW, SDL or even GLUT for windowing as these use simple intuitive API calls whereas opengl can be a cruel mistress...

Some minor differences right off the bat that will take some fudging or getting used to coming from a pure 2d perspective:
1. screen coordinates are 0,0 in bottom left instead of upper left (easy fix).
2. texture mapping is not quite as easy (IMHO) as blitting (the benefits outweigh this though)
3. if you thought pixel manipulation was slow in SDL it gets worse in opengl however there are shaders and other workarounds that can make this multiples faster.
4. alpha blending vs colorkey - the different types of blending can be confusing and with scaling and rotation (although much faster fps wise) you will have to make some tweaks to your images and how you load them whereas colorkeys just ignored certain pixels so were never drawn when blitting

I totally made the move to 2d in 3d (via opengl however many concepts translate to any 3d API) and think the benefits far outweigh the pitfalls. I still don't understand vector math very well (you will want to learn at least some of this!) however even doing things in a very unoptimized way so you can feel more like old 2d there are noticeable performance boosts (especially when using alpha blending or rotation) to using a 3d API such as opengl on relatively modern hardware (modern = anything less than 5 or even 6 years old).

Sorry for the long post. Not sure why I replied in the first place. I must be really tired... :)
0

Share this post


Link to post
Share on other sites
No use, I can't understand it... probably because my math isn't that good.

I find myself copying code off tutorials without understanding a single line. No, I'll wait until I'm a bit more ready, I'll keep using SDL until then.

Thanks all very much for your replies!
0

Share this post


Link to post
Share on other sites
Quote:
Original post by evillive2
1. screen coordinates are 0,0 in bottom left instead of upper left (easy fix).

If you pass suitable arguments to glOrtho then you can position the screen origin either bottom left or bottom right depending on what you prefer (or even another corner if you're weird).
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0