•      Sign In
• Create Account

## Fullscreen mode not working with signle buffer

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1MoHammaD_93  Members

Posted 24 August 2012 - 02:46 PM

My program is simple: Clearing screen with a color changing smoothly with time.

I'm using freeglut, and no drawing occurs while using glutFullScreen and GLUT_SINGLE together. (neither glFlush nor glFinish made it work)

A second phenomenon is that using GLUT_DOUBLE does my intended drawing but produces FLICKERING, even though I used delay functions after and before glutSwapBuffers.

The second case is also a problem that I need to solve.

.. thanks in advance ..

### #2JTippetts  Moderators

Posted 24 August 2012 - 03:01 PM

Might want to post some code so we can see what you're doing. Also...

even though I used delay functions after and before glutSwapBuffers.

... this statement makes me very uneasy. It makes me suspect you are doing something wrong; like, say, putting some kind of sleep() or busy-wait before and after swapping. Which probably isn't what you really want to do.

### #3MoHammaD_93  Members

Posted 24 August 2012 - 03:31 PM

even though I used delay functions after and before glutSwapBuffers.

... this statement makes me very uneasy. It makes me suspect you are doing something wrong; like, say, putting some kind of sleep() or busy-wait before and after swapping. Which probably isn't what you really want to do.

well, of course that's not what I want to do. but it's somehow for error-investigation sake, that is, I wanted to make sure that the drawing commands are complete.

Here's my simple program:

#include <GL/glew.h>
#include <GL/freeglut.h>
#pragma comment(lib, "glew32.lib")
#include <iostream>
using namespace std;

void display(void);
void reshape(int w, int h);

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(1366, 768);
glutCreateWindow("Tests");
glutFullScreen();

if( glewInit() != GLEW_OK){
cout << "Failed to initilize GLEW" << endl;
return -1;
}

glutIdleFunc(display);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void display(void)
{
GLclampf c = glutGet(GLUT_ELAPSED_TIME)/300.0;
c = fmodf(c, 1.0f);
glClearColor(c, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
//glutSwapBuffers();
}

void reshape(int w, int h)
{
glViewport(0, 0, w, h);
}


### #4MoHammaD_93  Members

Posted 25 August 2012 - 05:18 PM

!!people?? I need your help.

### #5V-man  Members

Posted 25 August 2012 - 06:33 PM

The code looks fine. It is probably some system issue. BTW, what OS, gpu are you using. Do you have the latest graphics drivers?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

### #6MoHammaD_93  Members

Posted 25 August 2012 - 08:21 PM

The code looks fine. It is probably some system issue. BTW, what OS, gpu are you using. Do you have the latest graphics drivers?

Yes, thank you. Your view is basically right, I didn't change anything on my computer though.

I tested the code on another PC and it went the way I want.

I'll work on getting my PC on the right path.

Thanks

### #7l0calh05t  Members

Posted 26 August 2012 - 05:55 AM

Try glFinish instead of glFlush.

And why are you using single buffering in the first place? It is highly unlikely that you actually want that...

### #8Erik Rufelt  Members

Posted 26 August 2012 - 09:07 AM

If you actually use a single buffer you can't swap, as you need two buffers to be able to swap one out with the other.

What type of flickering do you get with double-buffering?
I'm not very familiar with freeglut, but are you even supposed to swap manually, doesn't glut do that by default?
If so, you might be swapping twice per frame, which will likely cause a lot of flickering.

Also, I wouldn't be surprised if fullscreen mode requires double buffering, which would explain why you can't use fullscreen single buffer.

Edited by Erik Rufelt, 26 August 2012 - 09:08 AM.

### #9V-man  Members

Posted 26 August 2012 - 09:19 AM

If you actually use a single buffer you can't swap, as you need two buffers to be able to swap one out with the other.

What type of flickering do you get with double-buffering?
I'm not very familiar with freeglut, but are you even supposed to swap manually, doesn't glut do that by default?
If so, you might be swapping twice per frame, which will likely cause a lot of flickering.

Also, I wouldn't be surprised if fullscreen mode requires double buffering, which would explain why you can't use fullscreen single buffer.

No, GLUT and also freeGLUT don't swap. You have to call glutSwapBuffers (in the case of double buffering of course).
In the case if single buffer, you must call glFlush. In any case, why use single buffer? It will give graphical gliches and flashing.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.