Advertisement Jump to content
Sign in to follow this  

OpenGL Fullscreen OpenGL application for Linux

This topic is 4877 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! I try to write an OpenGL application for Linux. Now I want to switch into fullscreen mode, but I can not find any information about that. The problem is that I don't want to use GLUT or any other libraries but directly the Xlib. At the moment my code looks like that:
XVisualInfo *visualInfo; 
Colormap colorMap; 
XSetWindowAttributes setWindowAttributes; 
GLXContext openGLContext;
XEvent event; 
GLboolean needRedraw = GL_FALSE, recalcModelView = GL_TRUE; 
int32 tmp;

int32 attributes[] = {GLX_RGBA, GLX_DOUBLEBUFFER, None};
visualInfo = glXChooseVisual(displayHandle, DefaultScreen(displayHandle), attributes);
openGLContext = glXCreateContext(displayHandle, visualInfo, None, GL_TRUE);
colorMap = XCreateColormap(displayHandle, RootWindow(displayHandle, visualInfo->screen), visualInfo->visual, AllocNone);

setWindowAttributes.colormap = colorMap;
setWindowAttributes.border_pixel = 0;
setWindowAttributes.event_mask = ExposureMask | KeyPressMask | StructureNotifyMask;

// Create the window
XWindow openGLWindow = XCreateWindow(displayHandle, RootWindow(displayHandle, visualInfo->screen), 0, 0, resX, resY, 0, visualInfo->depth, InputOutput, visualInfo->visual, CWBorderPixel | CWColormap | CWEventMask, &setWindowAttributes);
XSetStandardProperties(displayHandle, openGLWindow, "ERC05 Engine", "OpenGL", None, NULL, 0, NULL);
glXMakeCurrent(displayHandle, openGLWindow, openGLContext);
XMapWindow(displayHandle, openGLWindow);

Who can help me? [Edited by - phantom on September 10, 2005 3:55:22 AM]

Share this post

Link to post
Share on other sites
I think the trick is probably just to create a fullscreen window with the relevant window manager hints to tell it to not add any decorations.

To change resolution however, you need to use something like the XF86VidMode extension.

I recommend you use a library to sort all this malarky out as it's going to be fairly difficult to get right otherwise - GLFW is my personal favourite.


Share this post

Link to post
Share on other sites
You can either take a look at GLFW mentioned above, or Daedalus (in my sig), which is somewhat based on the GLFW base code. I'm not sure off the top of my head if Daedalus supports fullscreen at a different resolution, but I think it does.

Share this post

Link to post
Share on other sites
Thank you. I used XF86VidMode which works well. I have just one more problem now: The title bar of the window is displayed even in fullscreen mode. How can I create a window without a title bar (and without any kind of border)?

Share this post

Link to post
Share on other sites
Unlike the others, I'm not going to ignore your request and suggest you use another library. Instead, I'm going to point you back to markr's post and explain it a little better. The 'decorations' is basically the window style. The Win32 API's windows and Java's windows require you to set the window's style to make it borderless, and I'm guessing Xlib is no different. Check the headers (or documentation) on changing the window style, and you should find a solution.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!