Advertisement

Why does just making a window to run an OpenGL program gotta be so complicated?

Started by July 19, 2003 09:26 PM
12 comments, last by Ekim_Gram 21 years, 7 months ago
I just finished going through the first lesson on NeHe''s site. I took a break from the book for now because I wasn''t able to try my own programs like just making simple polygons until I got the code from NeHe''s site. I''ve been printing out pieces of the pdf version and I just hate how you need about 350 lines of Win32 code just to set up a simple window. I don''t see how people can program Win32 like that.
There''s no town drunk here, we all take turns. Velocity Gaming Force
Most window initialization code is same on every project.
You could write a template file, or perhaps c++ class, so you don''t have to write the common startup routines everytime.

kind rgds,
Nik

Niko Suni

Advertisement
quote:
Original post by Nik02
Most window initialization code is same on every project.
You could write a template file, or perhaps c++ class, so you don''t have to write the common startup routines everytime.

kind rgds,
Nik


What do you mean by c++ class? I haven''t learned templates or macros yet in c++ so I couldn''t use a template but a class for it?



There''s no town drunk here, we all take turns.
Velocity Gaming Force
For a template just write a function that creates a basic openGL window for you and returns a handle for it, and save that in a separate file. Then just always include that file in your openGL projects.

At least, I''m pretty sure that''s what he meant. He wasn''t talking about STL templates.
WNDCLASSEX Reality;......Reality.lpfnWndProc=ComputerGames;......RegisterClassEx(&Reality);Unable to register Reality...what's wrong?---------Dan Uptonhttp://0to1.orghttp://www20.brinkster.com/draqza
Would anybody be kind enough to give me a demonstration of this or some type of tutorial that can help? It would be greatly appreciated.



There''s no town drunk here, we all take turns.
Velocity Gaming Force
Eh... macros are just #defines, so you should know those, but C++ templates won''t help. What the person means is just to put the window code in a header file and use it for all of your projects.
-~-The Cow of Darkness-~-
Advertisement
So I''m guessing it would be a good idea to keep Lesson 1 saved somewhere and just include it in any openGL programs I make?



There''s no town drunk here, we all take turns.
Velocity Gaming Force
quote:
Original post by Ekim_Gram
So I''m guessing it would be a good idea to keep Lesson 1 saved somewhere and just include it in any openGL programs I make?



I personally base most of my stuff off of Lesson 7 . Although it''s better to load the bitmaps without GLAUX for professional games because GLAUX isn''t 1337 enough for "real programmers" (actually it''s just getting old and people aren''t working on it any more) so you might want to use your own bitmap loading function.
-~-The Cow of Darkness-~-
quote:
Original post by Ekim_Gram
Would anybody be kind enough to give me a demonstration of this or some type of tutorial that can help? It would be greatly appreciated.


As far as I know, most NeHe tuts already provide a func to create the window. You''ll notice this func is hte same in a lot of his examples.
For this reason, you can save it in a file and just #include it in your porjects. Solve the problem once and reuse.

Using C++ classes (why the templates have been named here?) provides better abstraction while keepeng your namespace clean. They also come out useful when you have to add input or sound management, which in win32 is window-specific.

Previously "Krohm"

Actually creating the window isn''t that many lines of code, and I have no idea why it would take you 350 lines of code, hell D3D doesn''t even take 350 lines to setup a basic window.

Win32 is a pain in the a$$ usually, but I kind of like it because it gives you alot to work with. And once you have some good window base code, you can just reuse it in every program that you write so that you don''t have to type it out or cut/paste everytime.

And you mentioned you don''t know what a c++ class is, I personally strongly advise you to go and learn c++ classes(i don''t mean some classes in a college or something, i''m talking about the c++ languages object oriented programming features called classes). There is a thread around here, I think it was either in the lounge, general programming, or for beginners that had alot of links to c++ books and some really good resources for both beginners to c++ as well as people that know c++ well. I''d suggest trying to find that thread, it''s only a few days old so if you look fast it shouldn''t be buried that far under newer threads, and it''s topic title is descriptive of its contents so you''ll know what it is when you see it.

This topic is closed to new replies.

Advertisement