Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


about XWindow programming

This topic is 6167 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I create a window with 24 depth in color . I have tried the following code , but it doesn't work. who can help me!!!! " /* ---- XGraph.c ---- */ #include #include #include #include main() { Display *display; Window window; XSetWindowAttributes attr; Colormap colormap; XGCValues gcvalue; GC gc; XSizeHints *sz; unsigned long lBlackPixel, lWhitePixel; int i; XColor color; int depth, class; XVisualInfo visulInfo; Status stat; display = XOpenDisplay("0:0"); //create true color colormap depth = 24; class = TrueColor; stat = XMatchVisualInfo( display, DefaultScreen(display), depth, class , &visulInfo ); if( 0 == stat ) printf("could not create true color visual !!!\n"); colormap = XCreateColormap( display, XDefaultRootWindow(display), visulInfo.visual, AllocNone); lBlackPixel = BlackPixel( display, DefaultScreen(display) ); lWhitePixel = WhitePixel( display, DefaultScreen(display) ); /* build and set window attribute */ attr.background_pixel = lWhitePixel; /* background color */ window = XCreateWindow(display, XDefaultRootWindow(display), 100, 100, 300, 300, 8, visulInfo.depth, InputOutput, visulInfo.visual, CWBackPixel, &attr); XStoreName(display, window, "hello!! world!!"); /* show */ printf("Map window\n"); XMapWindow(display, window); XFlush(display); /* build and set GC */ gc = XCreateGC(display, window, 0, &gcvalue); XSetForeground(display, gc, lBlackPixel); XSetBackground(display, gc, lWhitePixel); XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinRound); for( i = 0 ; i < 256 ; i ++ ) { color.red = 0; color.green = i * 256 ; color.blue = 0; color.flags = DoRed | DoGreen | DoBlue; stat = XAllocColor( display , colormap, &color ); if( 0 == stat ) { printf("error alloc color for %d \n",i ); continue; } XSetForeground( display, gc, color.pixel ); XDrawLine( display , window, gc , i , 0 , i , 300 ); } XFlush(display); getchar(); /* close window */ printf("Destory Window\n"); XDestroyWindow(display, window); XFlush(display); printf("close display\n"); XCloseDisplay(display); //getchar(); } /* how to compile gcc -o XTest XTest.c -L/usr/X11R6/lib -lX11 */ Edited by - gyh on November 1, 2001 7:05:22 AM

Share this post

Link to post
Share on other sites
You can change between the resolutions that you have in your XF86Config file but I do not think that you can change color depth. If this is in the config file does X starts in 24 bit colors
DefaultDepth 24
Subsection "Display"
Depth 24
Modes "1024x768" "800x600" "640x480"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!