|
楼主 |
发表于 2005-7-20 14:18:33
|
显示全部楼层
因为项目本身的要求,现在开发环境和工具已经确定下来,不能改变.
按照applepie兄的提示,我到s d l 主页找了一个de mo ,仿照写了一段测试代码,编译通过.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <gdk/gdkx.h>
#ifdef USE_XSHAPE
#include <X11/Xlib.h>
#include <X11/extensions/shape.h>
#endif
#include "SDL.h"
#define WINSIZEX 320
#define WINSIZEY 200
#include <gtk/gtk.h>
int main( int argc,
char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *frame;
SDL_Surface *screen = NULL;
/* Initialise GTK */
gtk_init (&argc, &argv);
/* Create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Frame Example");
/* Here we connect the "destroy" event to a signal handler */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_set_size_request (window, 300, 300);
/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/* Create a Frame */
frame = gtk_frame_new ("hi");
gtk_container_add (GTK_CONTAINER (window), frame);
/* Set the frame's label */
//gtk_frame_set_label (GTK_FRAME (frame), "GTK Frame Widget");
/* Align the label at the right of the frame */
//gtk_frame_set_label_align (GTK_FRAME (frame), 1.0, 0.0);
/* Set the style of the frame */
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
{ char SDL_windowhack[32];
sprintf(SDL_windowhack,"SDL_WINDOWID=%ld",
GDK_WINDOW_XWINDOW(window->window));
putenv(SDL_windowhack);
}
/* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
gtk_main_quit();
}
screen = SDL_SetVideoMode(100, 100, 0, 0);
gtk_widget_show (frame);
/* Display the window */
gtk_widget_show (window);
/* Enter the event loop */
gtk_main ();
SDL_Quit();
return 0;
}
但是注册环境变量 { char SDL_windowhack[32];
sprintf(SDL_windowhack,"SDL_WINDOWID=%ld",
GDK_WINDOW_XWINDOW(window->window));
putenv(SDL_windowhack);
}这段似乎有问题,运行的时候提示:
(frame:3373): Gdk-WARNING **: gdkdrawable-x11.c:912 drawable is not apixmap or window
The program 'frame' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 42 error_code 3 request_code 3 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
是s d l 还是g t k 运行的时候自动调用SDL_windowhack这个参数?我g t k 的版本是2.4.13的,和g t k 1.2是不兼容的.s d l 的版本是1.2.7的.
如果把注册环境这段去除,程序是对的,就是在一个随机的地方弹出播放窗口. |
|