You are not logged in.
Pages: 1
What follows is an unholy marriage between two or three online tutorials, basically. I'm trying to see if it's feasible to embed sdl in a gtk window. Am I doing something wrong here? The image is not displaying for me, but I wont have access to my Arch machine until this weekend. I'm using cygwin/X in the meantime, and I'm not sure of the gotchas.
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
//#include <gtk/gtk.h>
#include <gtk/gtkx.h>
static void delete_event(GtkWidget *, gpointer);
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
char *id = malloc(sizeof(char) * 30);
GtkWidget *window = NULL;
SDL_Surface *hello = NULL;
GtkWidget *socket = gtk_socket_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(window), socket);
g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);
gtk_widget_show(window);
sprintf(id, "SDL_WINDOWID=%d", gtk_socket_get_id(socket));
// SDL init
putenv(id);
SDL_Surface *screen = NULL;
SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
hello = SDL_LoadBMP("hello.bmp");
SDL_BlitSurface(hello, NULL, screen, NULL);
SDL_Flip (screen);
gtk_main();
SDL_FreeSurface(hello);
free(id);
return EXIT_SUCCESS;
}
static void delete_event(GtkWidget *widget, gpointer data)
{
SDL_Quit();
gtk_main_quit();
}
Offline
your going to want to read the SDL API and see what each function is doing and what the expeted output or result should be. Im not so sure its possible to set the sdl video mode without SDL creating its own window for display.
GTK has gtkpixbuf,cairo and openGL support. you can do what you with one of those libs. or create your own GUI widgets and draw them yourself with SDL. there are also libs for SDL made for that very reason.
Offline
your going to want to read the SDL API and see what each function is doing and what the expeted output or result should be. Im not so sure its possible to set the sdl video mode without SDL creating its own window for display.
GTK has gtkpixbuf,cairo and openGL support. you can do what you with one of those libs. or create your own GUI widgets and draw them yourself with SDL. there are also libs for SDL made for that very reason.
I'm not sure if that's true or not, but I've read that it is possible. Though, it seems to have been written some time ago. Also, it's a hack. A workaround. I don't think it's documented, and it probably isn't reliable. I might break down and try to learn some ogl instead.
Offline
mate anything is possible. but you got to ask yourself why ?
Offline
Pages: 1