Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL and Win32

Started by nullsquared Feb 11, 2006 at 5:41 PM 6 replies 7.4k views
Original Post
nullsquared
nullsquared
Ok. Say that I have a window made from pure win32 code. Is it possible to let SDL use the existing HWND and draw onto that? This would allow for some cool things like menues and stuff from win32, and yet SDL drawing [grin]. I know it's possible to get the HWND from SDL's window, but I don't know about what I said above. EDIT: I searched google, but saw nothing about this...
rip-off
rip-off
Quote:
Original post by agi_shi
Ok. Say that I have a window made from pure win32 code. Is it possible to let SDL use the existing HWND and draw onto that?

This would allow for some cool things like menues and stuff from win32, and yet SDL drawing [grin].

I know it's possible to get the HWND from SDL's window, but I don't know about what I said above.

EDIT: I searched google, but saw nothing about this...


There is a thing called the SDL_WINDOWID hack. Its not pretty, nor portable( 2 of the main advantages of using SDL IMO).

see here.

(tip: its the one called SDL_WINDOWID [grin])
nullsquared
nullsquared
Quote:
Original post by rip-off
Quote:
Original post by agi_shi
Ok. Say that I have a window made from pure win32 code. Is it possible to let SDL use the existing HWND and draw onto that?

This would allow for some cool things like menues and stuff from win32, and yet SDL drawing [grin].

I know it's possible to get the HWND from SDL's window, but I don't know about what I said above.

EDIT: I searched google, but saw nothing about this...


There is a thing called the SDL_WINDOWID hack. Its not pretty, nor portable( 2 of the main advantages of using SDL IMO).

see here.

(tip: its the one called SDL_WINDOWID [grin])


Umm.... Thanks for the 'tip' [grin].

So, if I understand correctly then I need to set the SDL environment variable called SDL_WINDOWID to the correct window id....

How would one go about getting the win32 window 'id'? I'm not sure what they mean by 'id'...

Thanks for the quick reply.
rip-off
rip-off
The HWND is the value to set SDL_WINDOWID to I think.
nullsquared
nullsquared
Quote:
Original post by rip-off
The HWND is the value to set SDL_WINDOWID to I think.


Hmm... That's what I thought. It was just a typedef'ed pointer, right?
nullsquared
nullsquared
Quote:
Original post by rip-off
The HWND is the value to set SDL_WINDOWID to I think.


Wow, what an interesting effect!

After setting everything up, and setting up the SDL_SetVideoMode (it fails without that), two windows appear. The SDL one which has my example on it, and a win32 window. It seems, though, that the SDL window events are sent to the same event system as the win32 window. Clicking close on the SDL one closes both, and clicking close on the win32 closes both aswell....

Does anyone have any ideas on this? Have two windows wasn't my idea...

Interesting: Not "ShowWindow(...)"ing the win32 window makes only the SDL window show...
rip-off
rip-off
Quote:
Original post by agi_shi
Quote:
Original post by rip-off
The HWND is the value to set SDL_WINDOWID to I think.


Wow, what an interesting effect!

After setting everything up, and setting up the SDL_SetVideoMode (it fails without that), two windows appear. The SDL one which has my example on it, and a win32 window. It seems, though, that the SDL window events are sent to the same event system as the win32 window. Clicking close on the SDL one closes both, and clicking close on the win32 closes both aswell....

Does anyone have any ideas on this? Have two windows wasn't my idea...

Interesting: Not "ShowWindow(...)"ing the win32 window makes on the SDL window show...


I don't know. You set the environmental variable before your first call to SetVideoMode?

I have 0 experience with winAPI BTW, i use SDL so i don't need to know about it...
nullsquared
nullsquared
Quote:
Original post by rip-off
Quote:
Original post by agi_shi
Quote:
Original post by rip-off
The HWND is the value to set SDL_WINDOWID to I think.


Wow, what an interesting effect!

After setting everything up, and setting up the SDL_SetVideoMode (it fails without that), two windows appear. The SDL one which has my example on it, and a win32 window. It seems, though, that the SDL window events are sent to the same event system as the win32 window. Clicking close on the SDL one closes both, and clicking close on the win32 closes both aswell....

Does anyone have any ideas on this? Have two windows wasn't my idea...

Interesting: Not "ShowWindow(...)"ing the win32 window makes on the SDL window show...


I don't know. You set the environmental variable before your first call to SetVideoMode?

I have 0 experience with winAPI BTW, i use SDL so i don't need to know about it...


Yup.... Quite interesting. Let's hear some of the WINAPI gurus that roam GDnet. [grin]

As for experience, me neither. All I know is that a HWND is a 'handle' to the window. [smile]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.