Author Topic: Stupid Question  (Read 15941 times)

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Stupid Question
« on: March 16, 2007, 01:05:15 am »
Hey, I'm back to bother again! :P

This time my question is simple. The answer isn't though, I'm sure.
What I am interested in doing is learning openGL, preferably using Code::Blocks to learn. What needs to be done before I can create my first app using OGL? Is there anything in particular that I need to download? Is there a way I need to set it up in C::B to compile right?
Also, are there any good tutorials that anybody knows of? I prefer anything without use of the Win32 API. I'm a wxWidgets kinda guy :)

Please don't consider this spam or off-topic. I just want to know this stuff before diving into OGL :)

Thanks!
FlyingIsFun1217

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Stupid Question
« Reply #1 on: March 16, 2007, 02:41:34 am »
You need to install OpenGL (duh! i'm being helpful :p ) and some windowing toolkit (GLUT, GLFW, SDL, wxWidgets, etc.) depending on your needs.

For Code::Blocks... just learn how to add header include paths and libs to it, should work the same with pretty much all libs.
« Last Edit: March 16, 2007, 03:03:59 am by Auria »

Offline courage

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: Stupid Question
« Reply #2 on: March 16, 2007, 03:04:35 am »
Also, are there any good tutorials that anybody knows of? I prefer anything without use of the Win32 API. I'm a wxWidgets kinda guy :)

NeHe OpenGL tutorials is the best tutorials I ever seen!
http://nehe.gamedev.net/

However, I consider you don't need to install OpenGL,
if you have an OpenGL accelerator video card or you don't use Win95/98.
Then, you could download any toolkit you like to instead of Win32 API.
I recommend SDL, because it supports the most platforms and has many optional packs to use.
(But in my early experience, glut seems to flip the video buffer more smoothly then SDL.
It's very strange. :?)

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #3 on: March 16, 2007, 05:32:48 pm »
So really, everything that I need for coding in OGL is the machine I already have? I assume that there would be more setup to it than that... :)

I did see the NeHe tutorials, and they seemed great! The only problem I saw with them was that they all had refrences to the win32 API, which of course I wouldn't want to use.

I guess I can look more into using wxWidgets to display the OGL stuff. From what I've heard, it's not that easy though (Auria, can you say whether or not it's very difficult?), but nontheless, I will look into it :)

Thanks!
FlyingIsFun1217

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Stupid Question
« Reply #4 on: March 16, 2007, 05:53:31 pm »
So really, everything that I need for coding in OGL is the machine I already have? I assume that there would be more setup to it than that... :)

I did see the NeHe tutorials, and they seemed great! The only problem I saw with them was that they all had refrences to the win32 API, which of course I wouldn't want to use.

I guess I can look more into using wxWidgets to display the OGL stuff. From what I've heard, it's not that easy though (Auria, can you say whether or not it's very difficult?), but nontheless, I will look into it :)

Thanks!
FlyingIsFun1217

Take a look here http://wxforum.shadonet.com/viewtopic.php?t=13195 at the bottom of the page i gave a sample of how to do it to a guy. Of course it depends what you want to do. I would recommend wxWidgets for applications, but if you want to make a game then GLFW or SDL would be more appropriate
« Last Edit: March 16, 2007, 05:55:34 pm by Auria »

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #5 on: March 16, 2007, 08:43:39 pm »
Ok, I'll look in-depth on that information.
To me, it doesn't matter whether or not I use wxWidgets, or some other windowing toolkit, as at this point I just want to learn OGL. Nothing more, Nothing less. Learn how to use it, that is all.
Eventually I of course want to do something with it (hopefully learn how to do culling and all the other stuff needed to make a simple landscape engine and what not), but like I said, easiest road is what I'm looking for :)

Thanks again for your help!
FlyingIsFun1217

Offline courage

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: Stupid Question
« Reply #6 on: March 17, 2007, 03:31:51 am »
So really, everything that I need for coding in OGL is the machine I already have? I assume that there would be more setup to it than that... :)

It's really, you can see your include and lib directories
if there are gl.h, glext.h, libgl.a or libopengl.a or opengl32.lib...etc, and it's the part of libraries.

And if you have a cheap nVidia or ATI video card and install the official hardware driver,
there is the hardware driver support for OpenGL.
If you use win95/98, you have to download opengl95.exe to setup.
If you don't use win95/98, you have to do nothing to setup.

I did see the NeHe tutorials, and they seemed great! The only problem I saw with them was that they all had refrences to the win32 API, which of course I wouldn't want to use.

There are many samples with different toolkits to download after each tutorial.
If you look at three or more sample codes,
you will find the principle of coding is the same. :)

but like I said, easiest road is what I'm looking for :)

I think there is no royal road to program RAW OpenGL program.  :wink:
But there are surely some frameworks like Ogre to help you to make a application quickly.
Nothing but you have to learn how to use these frameworks. :D
« Last Edit: March 17, 2007, 01:10:03 pm by courage »

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #7 on: March 17, 2007, 02:23:21 pm »
 :D
Glad everybody is so helpful :)
I think what I will try to do is use GLUT to do the windowing, and from there, it'll be easy to learn OGL.
Thanks for the help everybody! If I find anymore troubles... well, I'll be back ;P

FlyingIsFun1217 :)

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #8 on: March 17, 2007, 02:54:47 pm »
Ok, went and downloaded the GLUT stuff, but... I'm not quite sure where to put it!
I read that you need to put it in your include directory, but C::B doesn't seem to have one. Where can I put these files so that I can use GLUT by including <GL/glut.h>?

Thanks again!
FlyingIsFun1217

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #9 on: March 17, 2007, 03:06:03 pm »
It's simple. Simply paste your those files inside C:\MinGW\include folder. So after pasting, glut.h file should be inside C:\MinGW\include\GL folder. :)
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #10 on: March 17, 2007, 03:14:55 pm »
How stupid of me to think that the editor had an include folder :P

Thanks so much! I really appreciate your help!

FlyingIsFun1217

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #11 on: March 17, 2007, 04:00:28 pm »
Ok, I seem to be able to get it set up fairly well, except for one thing.
In some sample code provided by a tutorial at lighthouse3d.com, the following code

Code: [Select]
#include <GL/glut.h>

void main(int argc, char **argv)
 {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("3D Tech- GLUT Tutorial");
}

Gives me the error:

Quote
C:\Documents and Settings\tanner\Desktop\CodeBlocks\Projects\GLUT-Test\GLUT-Test.cpp:4: error: `main' must return `int'
C:\Documents and Settings\tanner\Desktop\CodeBlocks\Projects\GLUT-Test\GLUT-Test.cpp:4: error: return type for `main' changed to `int'
:: === Build finished: 2 errors, 0 warnings ===

I assume that this is a code error? If it's a setup error, how do I fix this?

Thanks!
FlyingIsFun1217

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #12 on: March 17, 2007, 04:10:10 pm »
Try the following:

Code: [Select]
#include <GL/glut.h>

int main(int argc, char **argv)
 {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("3D Tech- GLUT Tutorial");
        return 0;
}
Be a part of the solution, not a part of the problem.

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Stupid Question
« Reply #13 on: March 17, 2007, 04:11:56 pm »
error: `main' must return `int'

Sounds explicit to me ;)

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #14 on: March 17, 2007, 04:43:25 pm »
Yes, it seems that I pasted code without thinking first. Forgot the return statement!
After replacing my glut files and restarting codeblocks, I seem to have everything right, but now I get:

Quote
objects\main.o:main.c:(.text+0x2f):: undefined reference to `__glutInitWithExit'
objects\main.o:main.c:(.text+0x3b):: undefined reference to `glutInitDisplayMode'
objects\main.o:main.c:(.text+0x50):: undefined reference to `glutInitWindowPosition'
objects\main.o:main.c:(.text+0x65):: undefined reference to `glutInitWindowSize'
objects\main.o:main.c:(.text+0x7a):: undefined reference to `__glutCreateWindowWithExit'
:: === Build finished: 5 errors, 0 warnings ===

This sure seems to be something with minGW not recognizing something of glut's?

Thanks again for your help!
FlyingIsFun1217