Programming X Windows
Hi, basically i''m looking for any information I can get about creating a window in X Windows in fullscreen mode and then connecting opengl to it so I can draw. Here''s what I have so far as test code:
int main(int argc, char *argv[])
{
Display *dpy = XOpenDisplay(0);
MS_INT nBlack = BlackPixel(dpy, DefaultScreen(dpy));
MS_INT nWhite = WhitePixel(dpy, DefaultScreen(dpy));
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1280, 1024, 0, nBlack, nBlack);
XMapWindow(dpy, w);
GC gc = XCreateGC(dpy, w, 0, 0);
XSetForeground(dpy, gc, nWhite);
XSelectInput(dpy, w, StructureNotifyMask);
for(; {
XEvent e;
XNextEvent(dpy, &e);
if(e.type==MapNotify)
break;
}
XDrawLine(dpy, w, gc, 10, 60, 180, 20);
XFlush(dpy);
sleep(10);
return EXIT_SUCCESS;
}
How would I make this fullscreen and connect it to OpenGL? Thanks
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
quote:
Use SDL
And the problem with X11 programming is what? It really isn''t that much more difficult than Win32 (with the possible exclusion of changing the display mode, which I''ve yet to look into properly). If all he''s doing is creating a gl context and using that then SDL really is overkill. He could also simply be doing for the experience too...
Anyway, this will create an opengl context for you. This is just ripped from my current project so it won''t compile as is, but it should give you the idea.
// Find the set of GLXFBConfig''s that match // the required parameters int attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, True, GLX_BUFFER_SIZE, (int)Get("BitDepth"), GLX_DEPTH_SIZE, (int)Get("ZDepth"), GLX_STENCIL_SIZE, (int)Get("StencilDepth"), None }; int numConfigs = 0; GLXFBConfig *fbConfigs = glXChooseFBConfig(GetXDisplay(),DefaultScreen(GetXDisplay()),attributes,&numConfigs); if(fbConfigs==NULL) THROW1(DisplayInitFailed,this); // Get the visual for the GLXFBConfig XVisualInfo *vInfo = glXGetVisualFromFBConfig(GetXDisplay(),fbConfigs[0]); XFree(fbConfigs); if(vInfo==NULL) THROW1(DisplayInitFailed,this); // Create the context glcontext = glXCreateContext(GetXDisplay(),&vInfo[0],NULL,True); XFree(vInfo); if(!glcontext) THROW1(DisplayInitFailed,this);
One thing I''m not too sure about is the GLX_BUFFER_SIZE attribute. Does this set the total bits for colour information or do I have to use GLX_RED_SIZE, GLX_BLUE_SIZE and GLX_GREEN_SIZE (or whatever they are)>
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
Thanks for the replies! I''ll be sure to try your code out in just a moment, that is if I can get glx working heh.
I actually tried using SDL but SDL + KDevelop + FreeBSD != Easy. For some reason its really hard to setup, so oh well.
Besides I don''t really care about my windowing code because I believe that I''m going to leave windowing out of my 3d engine and leave it up to the user to figure out.
I actually tried using SDL but SDL + KDevelop + FreeBSD != Easy. For some reason its really hard to setup, so oh well.
Besides I don''t really care about my windowing code because I believe that I''m going to leave windowing out of my 3d engine and leave it up to the user to figure out.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
By the way, what about all of the x functions? How am I going to manage keyboard input and stuff?
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
Are you insane??? GLUT sucks!
Seriously, though, I''ve never directly used X for two reasons: First, I''ve heard it''s not a wonderful interface. Second, and most important, I like my programs to be cross platform. Using any OS-specific code (even if it would still work on various OSes, in this case any UNIX-based system) is not acceptable for me if it is avoidable.
The Artist Formerly Known as CmndrM
http://chaos.webhop.org
Seriously, though, I''ve never directly used X for two reasons: First, I''ve heard it''s not a wonderful interface. Second, and most important, I like my programs to be cross platform. Using any OS-specific code (even if it would still work on various OSes, in this case any UNIX-based system) is not acceptable for me if it is avoidable.
The Artist Formerly Known as CmndrM
http://chaos.webhop.org
Thats why I''m going to write code for X and Windows which incompasses the only platforms I''m shooting for, UNIX and Window$.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
i''ve been trying to do the same thing (see http://www.gamedev.net/community/forums/topic.asp?topic_id=171431 for a rather unproductive thread on the subject. I just (5 min ago) found out that on nehe''s site most of the tutorials also have a ''linux/glx'' port, which appears to be what we''re looking for, and appears to support full-screen mode. I have not really tested them yet though, but you might want to look into it.
Marijn
Marijn
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement