No, that’s not what SDL_CreateWindowFrom does.
SDL_CreateWindowFrom allows you to take a native window and turn it into a
SDL rendering context that you can render SDL_Surfaces to. It does not
turn the existing window into an SDL_Surface. I use it to embed a
rendering area into a normal GUI app, for example.
If you’re looking to make screen grab software, this isn’t the way to do
it. Try looking at the OS’s APIs. I’m sure there’s something that already
exists for that purpose.
From: Gadi Dor <@Gadi_Dor>
To: SDL Development List
Sent: Saturday, January 26, 2013 12:22 AM
Subject: Re: [SDL] simple example for SDL_CreateWindowFrom
Dear Jonny,
I am trying to make screen grab software with SDL , I want to capture
desktop and add it into SDL Surface, is it possible?
Best Regards
Gadi
On Thu, Jan 24, 2013 at 4:30 PM, Jonathan Dearborn wrote:
What exactly are you trying to do? SDL_CreateWindowFrom() is for creating
an SDL window from a native window, so you would need a program that is
already using the platform-specific windowing APIs (and then I don’t see
why you’re using SDL…). testnativex11.c is exactly what it says: a test
to make sure native x11 calls work. To create an SDL window from this,
pass the “window” variable to SDL_CreateWindowFrom().
What is it that you want to save to BMP? It almost sounds like you’re
trying to do a window/screen grab. OpenGL is not really related to all
this, as far as I can see.
Jonny D
On Thu, Jan 24, 2013 at 4:19 AM, Gadi Dor <@Gadi_Dor> wrote:
Hi All
I am looking for simple example to use SDL_CreateWindowFrom() , I have
found testnativex11.c,
Is there simple example that uses SDL_CreateWindowFrom with
testnativex11.c and can save it to BMP? Also Do I need to use OpenGL?
here is testnativex11.c code:
/*
Copyright © 1997-2011 Sam Lantinga
This software is provided ‘as-is’, without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.
*/
#include “testnative.h”
#ifdef TEST_NATIVE_X11
static void *CreateWindowX11(int w, int h);
static void DestroyWindowX11(void *window);
NativeWindowFactory X11WindowFactory = {
“x11”,
CreateWindowX11,
DestroyWindowX11
};
static Display *dpy;
static void *
CreateWindowX11(int w, int h)
{
Window window = 0;
dpy = XOpenDisplay(NULL);
if (dpy) {
window =
XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h,
0, 0,
0);
XMapRaised(dpy, window);
XSync(dpy, False);
}
return (void *) window;
}
static void
DestroyWindowX11(void *window)
{
if (dpy) {
XDestroyWindow(dpy, (Window) window);
XCloseDisplay(dpy);
}
}
#endif
ThankYou
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org