Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-24-2008, 09:16 PM   #1
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default Window message function is a killer :(

You might be wondering, whats with the title! Well, its been two days and this bug is killing me

I am trying to learn openGL and am trying to learn and use native windows code rather than GLUT handling everything for me. Thus, I thought i'll write a general window wrapper around the openGL stuff, without really mixing the two functionalities.

Thus, I made two modules:
-myWin
-Application

For beginning, I needed a window in which I could render my openGL stuff. Thus, I tried learning setting up my window in the myWin class. I followed some tutorials online, and have been able to get a basic framework done. "But", there are some bugs which I still dont understand in their entirety and that is what is messing me up.

Following are the errors to which I could not even understand the solutions posted online (found em via searching on the web):
(If you open the attached files, it would really become very clear to you. Anyways, here are my problems
1.
Code:
LRESULT myWin::WndMsgProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM  lParam)
I have this as a function member definition in my header file and defined in my code .cpp file. When I try to assign this method to the window :
Code:
	wc.lpfnWndProc = (WNDPROC)WndMsgProc;
I get an error:
Code:
error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'WNDPROC'
None of the functions with this name in scope match the target type
I dont understand since the method signature is exactly the same as it expects. After a lot of gOOgling, I found that making WndMsgProc static would solve my problem and the reason for that has got something to do with function pointers wrt classes. I don't understand how that works, but i'd like to know.. Also, if I make it static, I end up making all my other members static since it calls and accesses other members. I am really interested in finding another way of doing this. I think making things static is a bad thing to do and it breaches the OOPs idea. Its like making everything global.. Anyways, I would really appreciate if someone could tell me the right way to do things..

2. There are more issues, like toggling between unicode and multiset character base, but i want to solve one problem at a time here.
Attached Files
File Type: zip buggy code.zip (3.9 KB, 2 views)
brainydexter is offline   Reply With Quote
Old 12-27-2008, 10:12 PM   #2
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
1/11 sssss2270
Location: UK
Default

You can't assign non-static class functions to function pointers due to way classes work (i.e all class non-static functions have a this pointer variable).

The Win32 API is a C library, not a C++ one which can make it very hard to use.
yaustar is offline   Reply With Quote
Old 12-29-2008, 12:39 PM   #3
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

So, is the best way to go about things..

(PS: Please see the attached files)
Attached Files
File Type: zip basicWin.zip (3.8 KB, 2 views)
brainydexter is offline   Reply With Quote
Old 12-29-2008, 08:18 PM   #4
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
1/11 sssss2270
Location: UK
Default

Making all the member variables static? Differently not.
yaustar is offline   Reply With Quote
Old 12-30-2008, 07:32 PM   #5
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Soo..then how should i do it??? Some leads ??
brainydexter is offline   Reply With Quote
Old 01-01-2009, 12:07 PM   #6
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
1/11 sssss2270
Location: UK
Default

Google: lpfnWndProc
Result: http://www.gamedev.net/reference/art...rticle1810.asp
yaustar is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 08:49 PM.






UBM Tech