Do i have to use Win32 API if i want to use DirectX11?

Started by
10 comments, last by SeanMiddleditch 10 years, 3 months ago

I see, thanks for the help it helped me understand better.

Advertisement

As followup, since I started doing this to my own personal project in preparation for emscripten support, getting the native handle is quite easy as you just need to use SDL_GetWindowWMInfo():


// extra header needed for SDL_GetWindowWMInfo and SDL_SysWMInfo
#include <SDL_syswm.h> 

int main() {
  // initialize SDL and create window
  SDL_Init(0);
  SDL_Window* window = SDL_CreateWindow("", 0, 0, 0, 0, 0);

  // retrieve native handle info
  SDL_SysWMInfo info;
  SDL_VERSION(&info.version); // required before calling GetWindowWMInfo!
  SDL_GetWindowWMInfo(window, &info);

  // this bit is Win32-specific, but then so is D3D;
  // other OSes have different sub-structs here
  HWND handle = info.info.win.window;

  do_stuff_with_handle(handle);
}

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement