|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Direct3D 9.0 with SDL |
|
![]() cow_in_the_well GDNet+ Member since: 4/8/2000 From: Sydney, Australia |
||||
|
|
||||
There ARE actually functions in SDL to get the HWND of the main window. Using GetActiveWindow can fail in some situations (say if the user somehow manages to focus another application before the app starts up...that has happend with my application). In any case getting the HWND via SDL is probably a little cleaner. ![]() Look up SDL_GetWMInfo() in SDL_syswm.h. SDL_SysWMinfo wmInfo; SDL_GetWMInfo(&wmInfo); HWND hWnd = wmInfo.window; (just copied that from a googled page i found :)). - Thomas Cowell website | journal | engine video |
||||
|
||||
![]() Seriema Member since: 6/15/2001 From: Stockholm, Sweden |
||||
|
|
||||
| Besides the odd indenting problems with the first source snippet I reacted on how you use SDL's recommended error "handling" by returning 0, and then used D3Ds recommended error handling with MessageBox(alot_of_info). I think teaching good error handling is fundamental so you probably should stick to one way of handling errors, even in such a simple tutorial. cow_in_the_well's was pretty interesting, have you (the author) seen that before? It seems safer and more right. I did like the way the tutorial was written. Even though it was more of a DX tutorial. I think a Sweet Snippet explaining your and cow_in_the_well's method would be more appropriate, since the only actual surprising element is the using DX in SDL part. Both DX and SDL already have alot of tutorials, so the only interesting bit's are the part where you set up the SDL window - get a HWND - pass it to DX. [ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ] |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Very nice! I was looking for a way to use SDL with DX and this helps a lot! (Since some older Gfx cards implement OGL rather badly and my Gfx runs slow I have to support DX as well...) |
||||
|
||||
![]() MindWipe Member since: 3/23/2000 From: Helsinki, Finland |
||||
|
|
||||
| Cool article! Nice work! I might use that. And nice point Cowy! /MindWipe |
||||
|
||||
![]() ALH Member since: 8/22/1999 From: Sao Paulo, SP, Brazil |
||||
|
|
||||
| I found this article very useful. Simple and small, everything you need to get straight to the point. Regards, ALH |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| I don't get the point of setting up DirectX in SDL though. There seems to be almost as much trouble as setting up DirectX without SDL. Can you still use regular SDL API blitting functions etc.? |
||||
|
||||
![]() Drew_Benton GDNet+ Member since: 7/29/2004 From: Katy, TX, United States |
||||
|
|
||||
Quote: The reason you do that is because you can use SDL's event system, sound, networking, input, and everything else that you can add on. Alternatively, you would have to use the DirectX components or something else. Basically SDL is the framework shell that you stick the DX renderer into. As for using SDL's API blitting functions, no you cannot. It is the same with OpenGL as well. (Unless you specify the 'hack' flag - SDL_OPENGLBLIT ). Does that make sense? |
||||
|
||||
![]() Seriema Member since: 6/15/2001 From: Stockholm, Sweden |
||||
|
|
||||
| The reason the author mentioned was also the 5 line "geting up a window" with SDL VS Win32 API 105 lines version. [ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ] |
||||
|
||||
![]() lbmurali Member since: 6/6/2006 From: Hyderabad, India |
||||
|
|
||||
| Hi , I just want to know, is there any advantage or use by setting up DirectX using SDL. Does it make any change in terms of speed or so... |
||||
|
||||
![]() Sol462 Member since: 4/1/2005 |
||||
|
|
||||
Quote: And that would result in a weird flickering that shows what's underneath your window when you move the mouse, right? |
||||
|
||||
![]() coding penguin Member since: 2/4/2006 From: Slovakia |
||||
|
|
||||
| very nice! thank you a lot :) |
||||
|
||||
![]() Khaos Dragon GDNet+ Member since: 12/13/2002 From: Santa Monica, CA, United States |
||||
|
|
||||
Hey, this is the author of the article, and I just thought I'd take some time to address some of the questions here. Also, at the time I wrote this article, flexible vertex formats were in wide use. Though they are still good for beginner's, I would highly advise any intermediate to advanced direct3D programmers to use custom vertex formats.Quote: There would be no advantage in terms of speed. The advantage really as mentioned before, is a much cleaner and more elegant windowing and event framework. Another advantage is any SDL/OpenGL project that you wish to convert to Direct3D... doing it this way would reduce the work mainly to porting your opengl technology to functionally equivalent Direct3D technology without having to worry about massive changes in windowing and input logic. Quote: You can't use SDL Blits to blit directly to the screen buffer, but you could still use them for things like texture loading. In the case of OpenGL, this is useful but since with DirectX we have the D3DX library, the blitting and graphics loading capabilities of SDL are less useful. See my response above for what I think the main benefits of using SDL with Direct3D is. --Michael (Misha) Conway |
||||
|
||||
![]() Khaos Dragon GDNet+ Member since: 12/13/2002 From: Santa Monica, CA, United States |
||||
|
|
||||
| Also, for anyone who wishes to contact me, my primary email is no longer mconway@tulane.edu The email I use now is: stardustnova@gmail.com --Misha Conway |
||||
|
||||
![]() Kochol Member since: 10/13/2005 From: Tehran, Iran |
||||
|
|
||||
Quote: Hi Thanks for code. but it didn't work for me. The code on the next line worked for me. SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWMInfo(&wmInfo); HWND hWnd = wmInfo.window; |
||||
|
||||
![]() Overdrive Member since: 1/9/2006 From: Craiova, Romania |
||||
|
|
||||
| This is a nice idea to use SDL as a framework for DirectX initialization. There is only one problem. What if i would want to run the program in windowed mode? I will still see 2 windows: a normal window where the rendering takes place and the window from the console application. Can I get rid of the console window and keep only the other one? L.E: Problem solved. I just used WinMain(...) instead of int main(int argc, char** argv). [Edited by - Overdrive on January 18, 2008 8:39:13 AM] Blog |
||||
|
||||
![]() d h k Member since: 5/14/2005 From: Bonn, Germany |
||||
|
|
||||
| I just spend half-a-day checking and rechecking my compiler-, linker- and project-settings in MSVC++ 6 and wondering why the heck I couldn't get the sample code to work until I just found out that it had nothing to do with those settings, LPDirect3D9 just should be LPDIRECT3D9 (same applies for two other variables), that fixed it. Does this have some kind of reason behind it or is it just a big typo? In the latter case I strongly advise somebody to correct the article. [ INDIANA JONES and the Fountain of Youth ] - Play the DEMO now! |
||||
|
||||
![]() Khaos Dragon GDNet+ Member since: 12/13/2002 From: Santa Monica, CA, United States |
||||
|
|
||||
Quote: Hmm that would be a typo, I certainly never wrote my code that way (otherwise it would not have compiled!) :) I think someone at gamedev edited and polished up my original article and may have introduced some typos in the future. This article has gotten a lot of attention, but I feel it is outdated so I plan to post a more modern and correct article describing using SDL with Direct3D 9.0. |
||||
|
||||
![]() Khaos Dragon GDNet+ Member since: 12/13/2002 From: Santa Monica, CA, United States |
||||
|
|
||||
Quote: I assume you are using Microsoft Visual Studio? If so, open up the linker options in your project settings and change your project type from console to windows. Using WinMain is probably not ideal. Ideally, you want to restrict the non-portable parts of your game to just Direct3D so if you do find yourself wanting to support other platforms like Linux or Macintosh, all you need to do is port the Direct3D calls you use to OpenGL (which is a lot easier than both doing that and figuring out how to port the windows API). |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|