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

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

Similar Threads

  1. White screen Flicker for rendering image
    By thilegl in forum OpenGL: Linux
    Replies: 0
    Last Post: 01-19-2019, 01:31 AM
  2. Need help, opengl games making my screen flicker black
    By Liamza2314 in forum OpenGL: User Software
    Replies: 0
    Last Post: 06-19-2018, 03:53 AM
  3. 2D images flicker on screen when comb. w OpenGL
    By Exaxis in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-27-2011, 12:40 PM
  4. Flicker with openGL and UpdateLayeredWindow
    By David Patte in forum OpenGL: Windows
    Replies: 1
    Last Post: 03-02-2011, 06:22 PM
  5. Drawing GDI object on OpenGL makes them flicker!
    By flare in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-05-2003, 02:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean