Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

Truely OO DirectX?

This topic is 3658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just spent 15 minutes writing a camera class, and it got me thinking, considering i'm gonna be handling input through my wndProc, is it possible to not globally declare my camera class? i can't pass my camera to my wndProc can I?

Share this post


Link to post
Share on other sites
Advertisement
As above, you should see Window's window procedure as a side-effect of Win32 API and try to keep your code independant.

LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
// upon creating your window you could pass your InputQueue (or similar class via lParam in CreateWindow()
case WM_CREATE:
SetWindowLongPtr (hWnd, GWL_USERDATA, (LONG_PTR) lParam);
break;

case WM_KEYDOWN:
{
InputQueue* iq = (InputQueue*) GetWindowLongPtr (hWnd, GWL_USERDATA);
iq->PushWindowMessage (uMsg, wParam, lParam);
return TRUE;
}
}
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}

class Camera
{
public:
void ProcessInput (InputQueue* iq);
};


This is one possible solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by thre3dee
As above, you should see Window's window procedure as a side-effect of Win32 API and try to keep your code independant.

*** Source Snippet Removed ***

This is one possible solution.


that is what i was thinking, but I already use the userdata as part of keeping my WndProc within the class(it holds a pointer to the window)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!