PDA

View Full Version : Getting statred in OpenGL



12-14-2005, 09:35 AM
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.

songho
12-14-2005, 01:08 PM
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 (http://www.songho.ca/opengl/files/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==

mikael_aronsson
12-15-2005, 03:38 AM
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

12-15-2005, 08:07 PM
Originally posted by songho:
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 (http://www.songho.ca/opengl/files/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==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

songho
12-16-2005, 06:56 AM
<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==

12-16-2005, 10:54 AM
Thanks for the replies. It looks like the link to that file is dead, songho. And I'm programiing on windows.

songho
12-16-2005, 12:02 PM
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 (http://www.geekstogo.com/forum/index.php?s=64f4e433bb88f10f8babf1261749175c&showtopic=82569&pid=473140&st=0&#entry473140)
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==

songho
12-16-2005, 12:25 PM
Oh, one more;
My Dev-C++ Package Manager says that GLUT v3.7.6+ is installed.

jaymystro
12-23-2005, 05:35 PM
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/

01-10-2006, 07:45 PM
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
:)

01-13-2006, 03:00 AM
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. :)