123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|208|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> OpenGl Linking Woes...

Sat, 17 May 2008, 08:36
Dragostar
Hi, I'm new here, and I heard about socoder through Shroom Monk quite a while ago, and it seems the perfect place to see if anyone can help me out with some C++ code I have been trying to fix for months (I'm using Dev C++).
Basically, I'm trying to link the Windows API in with OpenGl, the reason being I need the Windows functionality for input and sound- its for an RPG-style game I'm making. I have a faior amount of experience with C++, but Windows programming is all a bit new to me, having been making webpages and simpler apps for the past few years... hehe.
Anyway, if anyone can see whats wrong with the code I've used here, I'd be really grateful for any help!



It doesn't do anything at the moment... but hey!
Sat, 17 May 2008, 09:10
mike_g
What errors do you get? I havent used OpenGL myself yet, but are you sure you are linking it to your project in the ide?
Its in something like:
Project->Project Options->Parameters
Then you have to add one or more lines to the linker. Its has to start with '-l' then the name of what you want to link, I'm not sure exactly what it is for OpenGL.

Also, you could use SDL with OpenGL. The library is fairly easy to use and handles input, sound, setting up a window, double buffering, and 2d graphics. Its also portable, so if you make a game w/ SDL+OGL you could run it on Linux or a Mac. If you have the latest version of DevC++ you can easily install the development files through the package manager, somewhere in the dropdown menu.
Sat, 17 May 2008, 09:20
Dragostar
I'm not actually getting errors, but OpenGL simply refuses to work in the window, which annoys me, as the debugger doesn't say anything helpful.
All I get is teh blank window, which, while it can be resized and has all window functionality, won't show the OpenGL
And I think I've got the right linkers, but thanks anyway...
Sat, 17 May 2008, 09:32
mike_g
First off, its really hard for other people to read your code if you dont indent properly. In this section of code:

You seem to be setting up open gl in somewhere in a switch statement thats never going to be reached. If I were you I'd break your code down into a set of smaller functions, and indent it properly so its easier to see whats going on.

|edit| And try not to mix spaces with tabs - that can screw up the indentation too |edit|
Sat, 17 May 2008, 09:53
Dragostar
Thanks, and I'm sorry my code is hard to read- it usually is unfortunately. I'll edit it.

If I wanted to make sure that the message was reached, is there anything you would recommend? I can't seem to find why it isn't reached...
Sat, 17 May 2008, 10:19
mike_g
The when you reach the 'break' keyword it causes it to exit from the switch statement. What you are doing at the moment is something like:

Sat, 17 May 2008, 10:42
Dragostar
oh thanks! I see now- great!
Sun, 18 May 2008, 05:00
mike_g
No worries. So, did you get it working in the end?
Sun, 18 May 2008, 06:01
Dragostar
Well... I tried removing the break statement and repositioning the function, and it still came up blank. I then tried to rearrange the GL code, and that didn't work... so basically I didn't really get anywhere.

Wed, 21 May 2008, 06:02
mike_g
Actually, you will need a break statement at the end of each of switch branch, except the last one. So if you removed it completely I think the code would run on to the WM_DESTROY case. Still, you might have other problems. I'm kinda busy atm and I dont really know anything about OGL so I guess I'm not much help here. If you are just starting out making games with C++ I would recommend using something simpler. Perhaps an all in one games development library such as SDL, or allegro, or if youre bent on 3D then DirectX. From what I have heard OpenGL can be tricky to use so it might be best to get some more experience with C++ first.