OpenGL Win32 Application to Console???

Started by
7 comments, last by Shiny 17 years, 6 months ago
Hi! I've been using Win32 application for a while. Does anyone here have a version of the NeHe tutorials but not using a Win32 application, but instead using the usual console application? I'm very new to OpenGL and the window application nakes it all so complex to me. I appreciate kind replies. Thanks! [Edited by - keikei_c on October 3, 2006 1:51:13 AM]
Advertisement
It is doubtful that you will find one to be honest since you can't draw images with a console application.

It is possible to create a Win32 window from a console application but you end up just replicating all the code you would use in a WinMain application and your program will annoy you by opening a console first, then a normal window.

There is no benefit to this approach. In fact it is actually slightly more complicated than writing a WinMain style program since additional steps are needed to create the window.

I'm a bit confused - why would you want to do this anyway?
hi there! thanks for the abrupt reply!

at school, we've been using console applications writing the programs. I don't really learn much in school and often sorted to tutorials like NeHe. We are to make a project in OpenGL using what we've learned in school, that's why I wanted to learn how to adjust win32 apps to the console ones so the people in school could understand me - I also want to understand the difference. Personally, I find the Win32 apps easier because it is easier for me to draw..i just have to add details in the drawGLScene and that's all.

Im enjoying the NeHe tutorials so far, and I won't want to shift to another tutorial just to learn about the console stuff..that's why I asked if there's some way to adjust it.

I'm really just new to this stuff, so I hope you'd be kind enough to answer to my ignorance. HiHiHi :D
Well, as I'm sure you're aware, you need a normal window, not a console window in order to have a target to render an OpenGL scene to, since a console window can only display text.

[doubts own memory on this]
From memory, I think the only difference between creating a window with WinMain and int main() is that with int main() you need to call GetModuleHandle() to get the HMODULE which I think (if memory serves) you can use in the place of the HINSTANCE passed to WinMain to call CreateWindow.
[/doubts own memory on this]

You still need to register a window class and set up a WndProc and as I say your app will open a console window first. You can close this with FreeConsole but it will still appear then vanish when your application starts.

If your class is planning to teach OpenGL, I find it doubtful that they would expect you to start with a console application.
Hi,
If you don't like the windows window (eek!) code and don't understand it much you can use a library called SDL which has been designed to work alongside OpenGL. Setting up a window is very easy in SDL and can be done in a console application. Another advantage to SDL is the same code can be modified (ever so slightly) to run on other operating system such as linux. I'll try find some links and edit this post for you.
Good luck

Edit: here is a link to some recommended OpenGL/SDL tutorials on the official SDL site.

[Edited by - BoReDoM_Inc on October 3, 2006 4:00:14 AM]
Most OpenGL classes use Glut to setup a window. Is that what you mean by "the usual console application"? If so, most of the NeHe tutorials have glut ports for download.
Thanks guys for all your answers..I really appreciate them..:D

yeah, it was the Glut that I was looking for..but I wish I could have my teacher approve the other course..it was easier :D

Thanks again!
Yep most NeHe lessons have the source code available with GLUT. See Lesson 2 as an example. Just look for "DOWNLOAD GLUT Code For This Lesson" down the bottom.
Latest project: Sideways Racing on the iPad
And for the ones that don't...it is trivial to adapt the code into your own projects -- or, if you don't want to use the oldish GLUT, check out freeglut. It does the same thing only a little updated and opensourced. That said, last time I checked there wasn't a binary install -- you had to do some meddling (which is annoying, IMO -- a mature project shouldn't require users to mess about configuring crap by hand) but that was a while ago (when I checked) so may be better now.

[EDIT] I checked, turns out a nice fella cranked out a Dev-C++ devpak :)

Either way, learning the ins-and-outs of OS window code isn't such a bad idea anyway: any real world situation you may have to learn to deal with it -- most places already have nice window class wrappers -- but if you write your own stuff and you don't want code bloat...writing your own can be the answer :) There's a good tutorial by Oluseyi in the reference area if you want to give it a go.

~Shiny
------------'C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, it blows away your whole leg.' -Bjarne Stroustrup

This topic is closed to new replies.

Advertisement