Author Topic: Stupid Question  (Read 15939 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

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #15 on: March 17, 2007, 04:55:00 pm »
Now you forgot to include the glut library. Add libglut.a (or libglut32.a). I don't know their difference. :)
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #16 on: March 17, 2007, 04:59:58 pm »
Seems I don't have libglut.a (or libglut32.a), all I seem to have is glut32.lib
Where should I tell C::B about this? In Project->Build Options (Linker Tab?)

Thanks again!
FlyingIsFun1217

----------Edit----------
Here are the files that came with my download of glut:
-README-win32.txt
-glut.h
-glut32.lib
-glut32.dll
-glut.def
« Last Edit: March 17, 2007, 05:01:40 pm by FlyingIsFun1217 »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #17 on: March 17, 2007, 05:09:38 pm »
Type the following command to create the file libglut32.a

Code: [Select]
dlltool -d glut.def -l libglut32.a
Now use this file to link. Your app will depend upon glut32.dll :)
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #18 on: March 17, 2007, 05:23:02 pm »
Thank you, that seems to work very well. :)
For future reference, what does that actually do? Make a library to link to instead of a dll?

Thanks again!
FlyingIsFun1217
« Last Edit: March 17, 2007, 05:28:55 pm by FlyingIsFun1217 »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #19 on: March 17, 2007, 05:28:03 pm »
For future reference, what does that actually do? Make a library to link to instead of a dll?

That actually creates an import library file which a linker uses during linking process and this is true for all compilers. You can link against dll directly with GCC (I heard), but I don't know how to do that. You may search this forum for some more details. :)

Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #20 on: March 17, 2007, 05:29:29 pm »
Cool, thanks for telling me :)

Now, after doing this, I seem to just get the error that:

Quote
mingw32-g++.exe: GL\libglut32.a: No such file or directory

After adding GL\libglut32.a to the project build options' linker tab.
« Last Edit: March 17, 2007, 05:37:33 pm by FlyingIsFun1217 »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #21 on: March 17, 2007, 05:38:08 pm »
It says it can't find the library. Just provide the full path to it. Example: C:/MinGW/Lib/GL/libglut32.a
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #22 on: March 17, 2007, 05:56:28 pm »
It says it can't find the library. Just provide the full path to it. Example: C:/MinGW/Lib/GL/libglut32.a

Yeah, that works. Needed to restart C::B for some reason...
So now I have a working executable! Kind of, again!
Upon startup, it says:

Quote
This application has failed to start because (null).dll was not found. Re-installing the application may fix this problem.

It says this even with glut32.dll next to it :(

Something I'll have to figure out on my own?

Thanks!
FlyingIsFun1217

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #23 on: March 17, 2007, 05:58:46 pm »
Can you post me first few lines of def file? I think the calling convention is different.

Just try recreating the import library using the following command.
Code: [Select]
dlltool -U -d glut.def -l libglut32.a
« Last Edit: March 17, 2007, 06:10:22 pm by Biplab »
Be a part of the solution, not a part of the problem.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #24 on: March 17, 2007, 06:22:53 pm »
DEF File (Sorry in advance):

Quote
DESCRIPTION 'OpenGL Utility Toolkit for Win32'

VERSION 3.7

EXPORTS

   glutAddMenuEntry
   glutAddSubMenu
   glutAttachMenu
   glutBitmapCharacter
   glutBitmapLength
   glutBitmapWidth
   glutButtonBoxFunc
   glutChangeToMenuEntry
   glutChangeToSubMenu
   glutCopyColormap
   glutCreateMenu
   __glutCreateMenuWithExit
   glutCreateSubWindow
   glutCreateWindow
   __glutCreateWindowWithExit
   glutDestroyMenu
   glutDestroyWindow
   glutDetachMenu
   glutDeviceGet
   glutDialsFunc
   glutDisplayFunc
   glutEnterGameMode
   glutEntryFunc
   glutEstablishOverlay
   glutExtensionSupported
   glutForceJoystickFunc
   glutFullScreen
   glutGameModeGet
   glutGameModeString
   glutGet
   glutGetColor
   glutGetMenu
   glutGetModifiers
   glutGetWindow
   glutHideOverlay
   glutHideWindow
   glutIconifyWindow
   glutIdleFunc
   glutIgnoreKeyRepeat
   glutInit
   __glutInitWithExit
   glutInitDisplayMode
   glutInitDisplayString
   glutInitWindowPosition
   glutInitWindowSize
   glutJoystickFunc
   glutKeyboardFunc
   glutKeyboardUpFunc
   glutLayerGet
   glutLeaveGameMode
   glutMainLoop
   glutMenuStateFunc
   glutMenuStatusFunc
   glutMotionFunc
   glutMouseFunc
   glutOverlayDisplayFunc
   glutPassiveMotionFunc
   glutPopWindow
   glutPositionWindow
   glutPostOverlayRedisplay
   glutPostRedisplay
   glutPostWindowOverlayRedisplay
   glutPostWindowRedisplay
   glutPushWindow
   glutRemoveMenuItem
   glutRemoveOverlay
   glutReportErrors
   glutReshapeFunc
   glutReshapeWindow
   glutSetColor
   glutSetCursor
   glutSetIconTitle
   glutSetKeyRepeat
   glutSetMenu
   glutSetWindow
   glutSetWindowTitle
   glutSetupVideoResizing
   glutShowOverlay
   glutShowWindow
   glutSolidCone
   glutSolidCube
   glutSolidDodecahedron
   glutSolidIcosahedron
   glutSolidOctahedron
   glutSolidSphere
   glutSolidTeapot
   glutSolidTetrahedron
   glutSolidTorus
   glutSpaceballButtonFunc
   glutSpaceballMotionFunc
   glutSpaceballRotateFunc
   glutSpecialFunc
   glutSpecialUpFunc
   glutStopVideoResizing
   glutStrokeCharacter
   glutStrokeLength
   glutStrokeWidth
   glutSwapBuffers
   glutTabletButtonFunc
   glutTabletMotionFunc
   glutTimerFunc
   glutUseLayer
   glutVideoPan
   glutVideoResize
   glutVideoResizeGet
   glutVisibilityFunc
   glutWarpPointer
   glutWindowStatusFunc
   glutWireCone
   glutWireCube
   glutWireDodecahedron
   glutWireIcosahedron
   glutWireOctahedron
   glutWireSphere
   glutWireTeapot
   glutWireTetrahedron
   glutWireTorus
;    __glutSetFCB
;    __glutGetFCB

Recreating the import library just gives me the same results. :(

Thanks for your continued support!
FlyingIsFun1217

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Stupid Question
« Reply #25 on: March 17, 2007, 06:33:51 pm »
For future reference, what does that actually do? Make a library to link to instead of a dll?

That actually creates an import library file which a linker uses during linking process and this is true for all compilers. You can link against dll directly with GCC (I heard), but I don't know how to do that. You may search this forum for some more details. :)

Regards,

Biplab

Actually this is a Windows feature. No need for that stuff on Mac or Linux.

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #26 on: March 17, 2007, 06:36:07 pm »
Heh! Glad to know...
But right now my biggest problem is that it needs a.. null?!?!... dynamic link library : /

FlyingIsFun1217 :)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Stupid Question
« Reply #27 on: March 17, 2007, 07:20:55 pm »
But right now my biggest problem is that it needs a.. null?!?!... dynamic link library : /

Just checked it and I'm getting same error. I believe there is some mismatch. glut.h also includes gl.h and glu.h. So there could be cross-dependencies. I'm not very sure, but it's my guess.

Sorry I've reached my limits. Both with respect to knowledge and time. It's time to sleep. Will post you updates if I get any solution. :)

Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Stupid Question
« Reply #28 on: March 17, 2007, 07:26:32 pm »
I can't help you with any Windows problem, sorry.

But why don't you try GLFW? As far as i have used it, it was better than GLUT - and since you can build it from source it is less likely that there will be mismatches

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #29 on: March 17, 2007, 09:52:37 pm »
Well, after all of this confusion, I think I will try GLFW.
I remember stumbling across it at one point, but for some reason did not consider it : /
Thanks for the hint! While I try and get it set up, can you tell me if you have ever had any experience with it?

Thanks again!
FlyingIsFun1217 :)

----------Edit----------
Yeah, I'm spoiled. I'm not used to command-line building.
How can I go about building the glfw lib with minGW?

Thanks!
FlyingIsFun1217

----------Edit----------
I need to stop posting first.
Compiled it, working on installing it.

Thanks for the continued support!
FlyingIsFun1217
« Last Edit: March 17, 2007, 10:22:48 pm by FlyingIsFun1217 »

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #30 on: March 17, 2007, 10:36:53 pm »
Now that I've got it compiled, I still don't have the two files needed, glfw.dll, and libglfwdll.a.
Should I just recompile it?

FlyingIsFun1217

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Stupid Question
« Reply #31 on: March 17, 2007, 11:40:23 pm »
Now that I've got it compiled, I still don't have the two files needed, glfw.dll, and libglfwdll.a.
Should I just recompile it?

FlyingIsFun1217

Besides the fact that these forums here are NOT general programming help forums (as stated clearly at their description), I pretended not to have seen this topic for a while.

So, just to avoid locking this topic, please read the very well written instructions on using GLFW with Code::Blocks, over at our wiki.

Thank you.
Be patient!
This bug will be fixed soon...

Offline FlyingIsFun1217

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: Stupid Question
« Reply #32 on: March 18, 2007, 12:18:42 am »
Have done, and like I said, the directions posted did not work.
I will try posting this at the wxWidgets forum.
The reason it was posted here in the first place was to get it set up w/C::B. I realize that this has gone off topic.

FlyingIsFun1217

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Stupid Question
« Reply #33 on: March 19, 2007, 09:43:39 am »
(never mind that... did not see there was a page 2)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."