Getting statred in OpenGL

I’ve already learned how to program command prompt apps, so I’ve been looking for tutorials on programming in 2D in OpenGL with GLUT in Devc++. I’ve found a couple, but they start off in 3D or use Visual C++. I found a copy of redbook, but it’s about 11 years old or something and I don’t know if it’s compatible with the new versions or anything. So I was wondering if anyone had any very basic free opengl tutorials that involved using GLUT.

The redbook is the best OpenGL book, at least to me.
It does not matter how old this book is, and it gives you strong fundamental knowledge about OpenGL.

Please check this example with source code;
It is about drawing a 2D image using GLUT and Dev-C++.
imageRaw.zip

When you work on only 2D, disable all unused features for better performance, such as lighting, alpha/depth test. And Keep in mind the window orientation in OpenGL is bottom to top, opposite of traditional top-to-bottom.
==song==

There are lots of tutorials out there, you can find some links on this website, and if you search for “Opengl tutorials” on goggle you will find lots of hits.

It all depends a little on what OS you plan to use and so on…

Mikael

Originally posted by songho:
[b]The redbook is the best OpenGL book, at least to me.
It does not matter how old this book is, and it gives you strong fundamental knowledge about OpenGL.

Please check this example with source code;
It is about drawing a 2D image using GLUT and Dev-C++.
imageRaw.zip

When you work on only 2D, disable all unused features for better performance, such as lighting, alpha/depth test. And Keep in mind the window orientation in OpenGL is bottom to top, opposite of traditional top-to-bottom.
==song==[/b]
when i try to compile it in devc++ i get this errors

10 C:\cygwin\home\Lev\imageRaw\src\main.cpp In file included from main.cpp
50 C:\Dev-Cpp\include\GL\glut.h redeclaration of C++ built-in type short' C:\cygwin\home\Lev\imageRaw\src\main.cpp In function int main(int, char**)‘:
45 C:\cygwin\home\Lev\imageRaw\src\main.cpp `strcpy’ undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
C:\cygwin\home\Lev\imageRaw\src\Makefile.win [Build Error] [main.o] Error 1

<entheogen>,
Include <string.h> header for “strcpy” undeclaration error.

And I am not sure about “short” redeclaration error in glut.

Try first very simple code in your Dev-C++ like this;

#include <GL/glut.h>
int main()
{
return 0;
}

And try to find where the conflict came from.
==song==

Thanks for the replies. It looks like the link to that file is dead, songho. And I’m programiing on windows.

First, check if you have the following line in your glut.h in dev-cpp include folder;

ifndef _WCHAR_T_DEFINED

typedef unsigned short wchar_t;

define _WCHAR_T_DEFINED

endif

I don’t have wchar_t declaration in my glut.h. :confused:

A guy (Ricci) from geekstogo.com suggested 2 solutions; here
First, include <stdlib.h> before <GL/glut.h>.

#include <stdlib.h>
#include <GL/glut.h>

Second, insert “#define _WCHAR_T_DEFINED” before you include glut.h header.

#define _WCHAR_T_DEFINED
#include <GL/glut.h>

I cannot confirm those methods are going to work or not, because I don’t see a such error on my Dev-C++.

Try yourself and let me know.
==song==

Oh, one more;
My Dev-C++ Package Manager says that GLUT v3.7.6+ is installed.

bit late but it might help, might be worth taking a look at the windows programing setup on here. It looks scary and long but its worth while learning, GLUT is ok but is too simplified for my liking. Also I doubt its industry standard.

http://nehe.gamedev.net/

Hi <online>, you can try have a look at my website:
http://www.vrempire.com/ .
I put a small tutorial on OpenGL with GLUT.
Good luck
:slight_smile:

Hi vrempire,

I checked out your tutorial. It is nicely done, at least it gives something functional to start with. But it lacks thorough explanation of the functions involved (within the code) and no theoretical detail is given about what matrix operations the card is dealing with. Questions like “replacing with identity matrix? wow what were we multiplying it with?” arise rather easily. thats also because if i were soft rendering, i wouldn’t express anything as matrices up to a point(which may be till the end of my code indeed). anyway, i highly appreciate your effort, you’ve given a solid basis to work on… Build it up with more complex examples to work on and increase the depth of your in-code comments and explanations, and you’ll rock. :slight_smile: