Advertisement

Questions about C++, VB6, Win32 and OpenGL

Started by September 12, 2000 05:33 PM
3 comments, last by mitchbb 24 years, 2 months ago
Hello, I''m a newbie at OpenGL and only a few months into my first job as a programmer, so maybe these questions will sound a little stupid. If the answer is something very simple, don''t worry, I won''t feel insulted I''ve noticed that there seem to be very few examples of OpenGL code in C++, with classes and so forth. Could anyone explain some the issues concerning C++, OpenGL, and Win32? And why it seems like almost nobody uses object oriented design for OpenGL? I''ve already tried converting the code from the 1st tutorial over to an object oriented format and some interesting things started to happen. My goal was to keep the WinMain() in the globals by itself and within it, instantiate my other objects and call the other functions from them. The reason for that was that, in the (admittedly few) classes which I''ve had in C++, I''ve always been taught that it''s a bad thing to have global functions and data. Anyone care to comment here? Well, after much trial and error, I fixed all the compiler and linker errors. In great anticipation I then executed the build only to be met with an anti-climactic "Illegal Access" run time error! Aggh! I''ve tried again and again to step through the program line by line and everytime it gets to : if (! (hWnd=CreateWindowEx())) in the CWnd::CreateGLWindow(), it fails. Any idea what might cause this? I''d be grateful for any and all responses Brad
Registered a good window class? Did this fail?
What parameters do you give CreateWindowEx(...)?


Advertisement
From my experience of my.......... 3 weeks or so visiting this forum, I have found that a few that use OOP. I have a feeling this is due to the fact that not a lot of people know how, and the people who do, don't usually ask. I have at least taken the things I have learned from this site and split it into header files and source files for some better organized code, however, I have not yet tried classes with it. (I have a feeling I will soon.) As far as the basic setup functions and the main render function goes, you should probably keep them global. There have been a few people I've seen that, when giving examples, have used structs or classes... It IS possible.
S.

Edited by - Strylinys on September 12, 2000 7:26:34 PM
I tried to use C++ & MFC too but any examples I found were way over the top and for a newbie, I think, a little too difficult.

I have the OpenGL SuperBible at home which is good for Win32/OpenGL. It also has a chapter on MFC (I think it also has a chapter for Borland''s OWL(?) too) but I found it a bit too hard to understand.

So after about 6 - 12 months of trying to understand C++/MFC/OpenGL I looked at NeHe''s stuff which was so simple that even I could understand it. So now I''m going through the tutes in C/OpenGL.

Also, I had a real hard time trying to find anything on MFC/C++/OpenGL. It appears everyone writes in C.
Baskuenen,

Yep, the window class registered just fine. Here is the segment of code that appears to be causing the problem:

if (!(hWnd=CreateWindowEx( dwExStyle, "OpenGL", title, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, hInstance, NULL)))

It''s the same as what''s in Nehe''s Windows tutorial. The interesting part is that the error handling doesn''t even work and it comes out as runtime error: "Unhandled Exception - Invalid Access".


Strylinys,

yeah, I''ve also looked at brian Tichler''s Particle Sim source code (BTW, Thanks Brian if you''re reading this, so it defintely can be done. Even so, I''ve noticed that program has a lot (at least to me) of global functions and variables. I would be interested to know why this style is popular in OpenGL.

>I have a feeling this is due to the fact that not a lot of people know how, and the people who do, don''t usually ask.

I suspect you''re right on that one

Firesoft,

>I tried to use C++ & MFC too but any examples I found were way over the top and for a newbie, I think, a little too difficult.

I tried this and gave up fairly quickly. It seems to me that the extra overhead involved with the MFC classes is just unnececesary burden on a CPU. I don''t know for sure, its just my impression.

Thanks all for the responses

Brad

This topic is closed to new replies.

Advertisement