Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: screen flicker openGL

  1. #1
    Newbie Newbie
    Join Date
    Jan 2014
    Posts
    1

    screen flicker openGL

    I am trying to use openGL to create a music visualization program. To start with I am just using one VU bar, to test it.
    The bar moves to the right position but flickers when it moves. This is the main part of the program:

    Code :
    void Analyse()
    {
            bool quit = false;
    	bool playing = true;
    	bool *playingPtr = &playing;
     
    	FMOD::Sound *sound;
    	result = system01->createStream("/home/djameson/Music/Hurts-Like-Heaven-Cold-Play.mp3", FMOD_SOFTWARE, 0, &sound);
    	FMODErrorCheck(result);
     
    	FMOD::Channel *channel;
    	result = system01->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
    	FMODErrorCheck(result);
     
    	result = channel->setVolume(0.5f);
    	FMODErrorCheck(result);
     
     
    		while(quit == false)
    		{
     
    			result = system01->update();
    			FMODErrorCheck(result);
    			int sampleSize = 64;
     
    			float *specLeft = new float[sampleSize];
    			float *specRight = new float[sampleSize];
     
    			channel->getSpectrum(specLeft, sampleSize, 0, FMOD_DSP_FFT_WINDOW_RECT);
    			channel->getSpectrum(specRight, sampleSize, 1, FMOD_DSP_FFT_WINDOW_RECT);
     
    			float *spec = new float[sampleSize];
     
    			for (int i = 0; i < sampleSize; i++)
    			{
    				spec[i] = (specLeft[i] + specRight[i]) / 2;
    			}
     
     
    			float * maxIterator = max_element(&spec[0], &spec[sampleSize]);
     
    			glClear( GL_COLOR_BUFFER_BIT );
     
    				glMatrixMode( GL_MODELVIEW );
    				glLoadIdentity();
     
    				glTranslatef( SCREEN_WIDTH / 2.f, SCREEN_HEIGHT , 0.f );
     
    				glBegin( GL_QUADS );
     
    				glVertex2f( -21.f, -spec[0] * 500);
    				glVertex2f( 21.f, -spec[0]*500);
    				glVertex2f( 21.f,  21.f);
    				glVertex2f( -21.f, 21.f);
    			glEnd();
    			glutSwapBuffers();
     
    			channel->isPlaying(playingPtr);
     
    			if(*playingPtr == false)
    			{
    				quit = true;
    			}
     
    			delete [] spec;
    			delete [] specLeft;
    			delete [] specRight;
     
    		}
    }

    I initialize openGL and stuff in other functions, let me know if you need to see them and I will post them. The code obviously needs alot of improving but this is just a test thing. Thanks for your help!

    I have v-sync enabled(i think) I did glxgears and got a fps rate of 60, I would post the thread in the fedora forum which I followed to check if I had v-sync enabled but It says there is a limit to the amount of URL's in a new post.

    I am using fedora 20

    using freeglut
    Last edited by Dandee; 01-24-2014 at 12:51 AM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    Are you using double buffering?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •