0
\$\begingroup\$

I'm trying to use SDL2 in a panel (VS2015/C++) and cannot find solid examples of how to connect the two. Anyone know how this is done?

I've tried some code found in various places, but no luck yet. The code below was my latest attempt. I'm using latest version of SDL2.

SDL_Window* sdlWnd = SDL_CreateWindowFrom((void*)mapPanel->Handle);
SDL_SetWindowTitle(sdlWnd, "SDL Window - Set by SDL");
SDL_Surface* s = SDL_GetWindowSurface(sdlWnd);
SDL_FillRect(s, &s->clip_rect, 0xffff00ff);
SDL_UpdateWindowSurface(sdlWnd);
SDL_ShowWindow(sdlWnd);
\$\endgroup\$
7
  • \$\begingroup\$ What is currently happening? \$\endgroup\$ – Tyyppi_77 Jul 2 '16 at 16:04
  • \$\begingroup\$ Well, nothing. I have no indication of anything happening in the panel. I should see a magenta SDL window... \$\endgroup\$ – RetiredNavyVet Jul 2 '16 at 22:53
  • \$\begingroup\$ Any SDL_GetError()s? Does the title not change either? \$\endgroup\$ – Tyyppi_77 Jul 2 '16 at 23:02
  • \$\begingroup\$ Wow...it would help if I actually called the function that I created to test the SDL window. So, "operator error" strikes again..../facepalm \$\endgroup\$ – RetiredNavyVet Jul 4 '16 at 15:35
  • \$\begingroup\$ You should post your solution as an answer and accept it. And these things happen. \$\endgroup\$ – Tyyppi_77 Jul 4 '16 at 20:22
1
\$\begingroup\$

Think of SDL_Window as physical pixels, and SDL_Renderer and a place to store settings/context.

So you create a bunch of resources, and hang them off of the renderer; and then when its ready, you tell renderer to put it all together and send the results to the window.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for replying. See my comment above; professional humor only... \$\endgroup\$ – RetiredNavyVet Jul 4 '16 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.