开发者

GLFW window fails to open (Ubuntu)

When compiling and running my GLFW-based C program under Ubuntu (9.04), it fails when trying to open the window (it compiles fine, having installed the latest GLFW). I've tried varying resolutions, going as low as 300x300, and left the bit depths to zeros, hoping a default will catch on.

The relevant piece of code reads (directly snipped from the top of my main file, based on the example file gears.c):

// File: main.c
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw.h>

#ifndef PI
#define PI 3.141592654
#endif

int main(int argc, char* argv[])
{
    // Initialize GLFW:
    glfwInit();

    if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) // Yo failure!
    {
        printf("Window open failed.\n");
        glfwTerminate();
        return 0;
    }

    glfwSetWindowTitle("...");

    ...

    // Clean up:
    glfwTerminate();

    return 0;
}

Other noteworthy facts are:

  • Running Ubuntu inside VirtualBox 3.0.2, config'd w/ 512 MB RAM, 3D acceleration enabled, 64 MB VRAM, Guest Additions successfully installed
  • glxgears works fine, even > 300 FPS
  • built GLFW using make-x11
  • makefile command line:

    gcc `pkg-config --cflags libglfw` main.c -开发者_Go百科o program `pkg-config --libs libglfw` -lglfw -lGLU -lGL -lm

  • Mark's tip on C - GLFW window doesn't open on Debian does not seem to alleviate the situation

Edit:

Are there any way to extract a more fancy error message? Any getLastErrorDesc() or debug log files?


Are you using the version packaged in Ubuntu or some version from the GLFW Subversion repository? The GLXFBConfig selection in the Subversion repo was broken for quite a while, due to the removal of the custom Visual selection, so you may have received bad code.

If that's the case, you should either revert to the version bundled with Ubuntu or pull a fresh tree from Subversion.


Hey I've been suffering from the same problem.

At last I figured out how to solve this one. I was using "make x11-install" to install the library.

The procedure would be as following:

  1. run "make x11-clean" (not necessary)

  2. use vim or whatever editor to edit Makefile.x11.in in glfw/lib/x11 folder (and Makefile.x11 if you don't run process 1), change the PREFIX from "/usr/local" to "/user"

  3. run "make x11-dist-install" for installation

I haven't tried if its "dist-install" that matters or the location, but it works for me perfectly.


You are trying to open a window with 0bpp, of course it's going to fail :)

Try this:

    glfwOpenWindow(
                   800, 600,   // Window size
                   8, 8, 8, 8, // bitdepth per channel (RGBA)
                   24,         // Z buffer bitdepth
                   0,          // Aux buffer bitdepth
                   GLFW_WINDOW // Window
                  );

Also, on latest Ubuntu, there's actually a package called libglfw-dev you can install, just in case you forgot to link any extra libraries (like librandr).


I had this same problem with GLFW 2.7.7, pulled as a .tar.bz2 directly from the GLFW website. glfwOpenWindow always returned false, even with no hints and no bit depths specified.

I was building libglfw myself, and loading it from the working directory using the rpath link flag. I did not have the Ubuntu libglfw installed.

Using the Ubuntu repository version (sudo apt-get install libglfw-dev), the window opens as expected.

One of the significant differences between the two library versions is the result of calling glfwGetVideoModes. On the broken GLFW 2.7.7, this returned only the desktop resolution and depth. On the working version, Ubuntu package 2.7.2-1, this returned the expected variety of modes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜