multisampling ubuntu


I want to use multisampling on ubuntu linux but the glut solution of using glutInitDisplayString( "rgb double depth alpha samples>=4 "); does not seem to work (it throws errors for the sampling part), any other ideas about how to get multisampling on ubuntu/linux?


You can use GLFW instead of glut, there’s a main example on how to setup fsaa + the ofAppGLFWWinwdow class in the attached file.

you need to install glfw library and headers:

sudo apt-get install libglfw-dev

and add the library to your project, you can add it in the linker settings or in the project properties > libraries search for libglfw



thanks arturo, I will try that in a few minutes!

Hey, I get an error in libglfw.a referring to _glfwPlattformGetVideoModes() and some errors about undefined referenes to alot of XRR related things. are there any other dependencies? thanks!

edit: think i got it, mixed something up with the linking >:), though I don"t see any antialiasing, do I have to use glEnable(GL_MULTISAMPLE) maybe?

i usually don’t need glEnable(GL_MULTISAMPLE), just this in main.cpp:

    ofAppGLFWWindow window;  
ofSetupOpenGL(&window, 1280,800, OF_WINDOW);	  

also what videocard are u using, some drivers in linux have some problems with some features.

hmm I am using geforce 6200 which should have MSAA. I also have the nvidia drivers installed, but something is wrong, also if I try to return GL_SAMPLES i get 0 even though I tried to set it to 4. any ideas on that?

If I force MSAA with the driver window, it works, but I dont really want to depend on that :slight_smile:

Just out of curiosiy, glfw seems to be slightly slower (not seriously though) than glut, in an emtpy 400x400 window without FSAA i get ca. 1050fps with glut and ca. 930 with glfw. as i said its not dramatic, just asking out of curiosity :slight_smile:

hi moka

just remembered i changed the depth buffer resolution in the file i posted, perhaps that’s what’s making it slower. it’s in ofAppGLFWWindow.cpp line 86. try lowering it

otherwise for what i’ve seen glfw is even a little bit faster than glut. in an application in particular i saw a great enhancement in fps (like 5 to 10 times) with depth test enabled.

also it’s usually faster in full screen mode.


wow thats great news! I will also try to use GLFW on the mac in the future since I could not get SDL to work with OF, GLFW seems to be a better alternative than glut!!

sweet, managed to compile a glfw universal under osx, I will play around with it and see if it works ok. maybe GLFW would be a good alternative for glut as the default window and openGL context tool for OF generally, since it at least gets maintained while glut is pretty much dead?

yes, we considered it while finishing 006, but glfw doesn’t have 2 things that glut has: toggle fullscreen (although glut fullscreen is not real fullscreen but window without decorations) and know the position of the window. although it’s not super important, it can break some code so we decided to go with glut and you can always use other alternatives.


I have managed to compile and run my app using glfw however nothing is drawn to the screen, or at least I can’t see anything being drawn.

Below is what I am doing in main.cpp

	int screenmode = OF_WINDOW;  
	if(args->contains("--window-mode")) {  
		screenmode = args->getInt("--window-mode");  
	int samples = 4;  
	if(args->contains("--samples")) {  
		samples = args->getInt("--samples");  
	ofSetupOpenGL(&window, 1920, 1080, screenmode);  

Note I am using Ubuntu Karmic 9.10 on a Dell Inspiron 9400 with ATI Technologies Inc Radeon Mobility X1400 graphics.

I am using only ofImage.draw for all drawing.

If i swap the above out and use Glut my app works as expected. Also I have a lot of logging going on and its behaving normally when using glfw but it no output comes up on the screen.

Any ideas?

Figured it out, seems the following doesn’t play nice with my setup:


Removing it fixed the issue.

Hey all - first off thanks for an awesome post and code sample! and sorry if i am bringing the thread back from the dead…
I needed to use GLFW for joystick input as the GLUT handler was too limited. I got it all to work by putting the following code in update() :

    if((ofGetElapsedTimeMillis() - last_sample) >= JOY_SAMPLE_PERIOD_MS)  
        last_sample = ofGetElapsedTimeMillis();  
        glfwGetJoystickPos( GLFW_JOYSTICK_1, joyAxes , 4 ); // joystick #1, array to put values into,  
        glfwGetJoystickButtons(GLFW_JOYSTICK_1, joyButtons, 14); //joystick #1 , button array, 14  
        printf("Axis 1: %f Axis 2: %f Axis 3: %f Axis 4: %f \nButton vector", joyAxes[0],joyAxes[1],joyAxes[2],joyAxes[3]);  
        for(int i = 0; i<14; i++)  

is there a better way to do this? I would love to get all this tucked away into ofAppGLFWWindow, and have the input processed by a callback (as is normal for keyboard/mouse input in OF) but it seems that joystick data has to be polled in GLFW- so the only way to do this would be totally bassackward. -or am i wrong?

thanks in advance!