Jump to content
  • Advertisement

Archived

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

31337

Programming X Windows

This topic is 5542 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

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

Share this post


Link to post
Share on other sites
Advertisement
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)>

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
By the way, what about all of the x functions? How am I going to manage keyboard input and stuff?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Thats why I''m going to write code for X and Windows which incompasses the only platforms I''m shooting for, UNIX and Window$.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
I recommend that you get Linux 3D Graphics Programming by Norman Lin. It covers everything you want. There''s also a sequel called Advanced Linux 3D Graphics Programming also by Norman Lin. Maybe you should get them both.

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!