Code::Blocks
User forums => Using Code::Blocks => Topic started by: FlyingIsFun1217 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
-
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.
-
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/ (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. :?)
-
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
-
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
-
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
-
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
-
: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 :)
-
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
-
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. :)
-
How stupid of me to think that the editor had an include folder :P
Thanks so much! I really appreciate your help!
FlyingIsFun1217
-
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
#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:
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
-
Try the following:
#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;
}
-
error: `main' must return `int'
Sounds explicit to me ;)
-
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:
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
-
Now you forgot to include the glut library. Add libglut.a (or libglut32.a). I don't know their difference. :)
-
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
-
Type the following command to create the file libglut32.a
dlltool -d glut.def -l libglut32.a
Now use this file to link. Your app will depend upon glut32.dll :)
-
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
-
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
-
Cool, thanks for telling me :)
Now, after doing this, I seem to just get the error that:
mingw32-g++.exe: GL\libglut32.a: No such file or directory
After adding GL\libglut32.a to the project build options' linker tab.
-
It says it can't find the library. Just provide the full path to it. Example: C:/MinGW/Lib/GL/libglut32.a
-
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:
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
-
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.
dlltool -U -d glut.def -l libglut32.a
-
DEF File (Sorry in advance):
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
-
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.
-
Heh! Glad to know...
But right now my biggest problem is that it needs a.. null?!?!... dynamic link library : /
FlyingIsFun1217 :)
-
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
-
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
-
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
-
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
-
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 (http://wiki.codeblocks.org/index.php?title=Using_GLFW_with_Code::Blocks), over at our wiki (http://wiki.codeblocks.org).
Thank you.
-
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
-
(never mind that... did not see there was a page 2)