I’m trying to make this work but I’m not able to do it…
I’m using SDL 1.2.4, I’ve looked at the sources and I don’t understand
why it doesnt works. SDL always opens it’s window, also with a putenved,
valid, SDL_WINDOWID.
One problem maybe the fact that I cannot use SDL_main in this
application since it’s a DLL, but I’ve looked at the sources in
wincommon/, windib/ and windx5/ and really I don’t understand WHY that
window opens, the correct behaviour should be a crash IMHO, if SDL is
unable to hook to the window I specify since all the code does is a
SDL_Window = strtol(SDL_windowid)!
Here is a piece of the code, what I’m trying to do is an web browser
plugin that use SDL (with ActiveX interface for IE and the NS4 one for
netscape and other borwsers on linux…)
CWnd *w=pdc->GetWindow();
HWND hwnd = w->GetSafeHwnd();
/* this HWND is valid since I can draw in the correct place using
Windows calls like ::FillRect() */
RECT rect;
w->GetWindowRect(&rect);
if(!m_surface) {
char buffer[100];
log( “Window: %lx (%ld,%ld) -> (%ld,%ld)\n”, hwnd, rect.left,rect.top,
rect.right, rect.bottom);
log( “RcBounds (%ld,%ld) (%ldx%ld)\n”, rcBounds.left, rcBounds.top,
rcBounds.Width() , rcBounds.Height());
sprintf(buffer, “SDL_WINDOWID=%ld”, hwnd);
putenv(buffer);
putenv(“SDL_VIDEODRIVER=directx”); /* tried with windib too and
without this line */
log(“Variable SDL_WINDOWID = %s\n”,getenv(“SDL_WINDOWID”));
// tried to init it here or in the class constructor
if(SDL_Init(SDL_INIT_VIDEO)<0) {
log( “Unable to init SDL!\n”);
exit(0);
}
if(!(m_surface = SDL_SetVideoMode(rcBounds.Width(),
rcBounds.Height(), 0, 0))) {
log( “Impossibile aprire la surface SDL!!\n”);
exit(0);
}
}
Bye,
Gabry