Problem with flickering Texture, is it code or my Computer?

While practicing with textures, I wrote the program below. I was trying to implement a “white noise” like texture on one side of the rotating cube, and found a nasty flickering effect on all other faces of my cube, which becomes even worse flickering vertical bars and tears if I disable vertsync. I can’t screen shot this problem, and have experimented with the code with no luck.

The reason I wonder if this is hardware related is that I actually have seen a similar problem in (fluxus) for me when I do enable blend… And also, I am unable to take a screenshot, they all come out normal.

I am running:

MacBook Pro
Model Identifier: MacBookPro3,1
Processor Name: Intel Core 2 Duo
Graphics Card: NVIDIA GeForce 8600M GT

Can someone compile my and see if they have the same flicker? Or is there something I am doing wrong? Seems odd that it happens in two completely different programming languages…

Header:

  
  
#ifndef _TEST_APP  
#define _TEST_APP  
  
  
#include "ofMain.h"  
  
class testApp : public ofBaseApp{  
  
	public:  
		void setup();  
		void update();  
		void draw();  
  
		void keyPressed  (int key);  
		void keyReleased(int key);  
		void mouseMoved(int x, int y );  
		void mouseDragged(int x, int y, int button);  
		void mousePressed(int x, int y, int button);  
		void mouseReleased(int x, int y, int button);  
		void windowResized(int w, int h);  
		  
		ofTexture		texGray;  
		  
		unsigned char 	* grayPixels;  
  
	  
};  
  
#endif  
  

CPP file:

  
  
#include "testApp.h"  
  
GLfloat		rtri;						// Angle For The Triangle ( NEW )  
GLfloat		rquad;						// Angle For The Quad     ( NEW )  
  
//--------------------------------------------------------------  
void testApp::setup(){  
	ofSetVerticalSync(TRUE);  
	ofBackground(0, 0, 0);  
	  
	texGray.allocate(400, 400, GL_RGB);  
	  
	grayPixels = new unsigned char [400*400*3];  
	  
	for (int i = 0; i < 400; i++){  
		for (int j = 0; j < 400; j++) {  
			  
			grayPixels[(j*400+i)*3 + 0] = (unsigned char)(ofRandomuf() * 255);  
			  
			grayPixels[(j*400+i)*3 + 1] = (unsigned char)(ofRandomuf() * 255);  
  
			grayPixels[(j*400+i)*3 + 2] = (unsigned char)(ofRandomuf() * 255);  
  
		}  
	}  
	  
	texGray.loadData(grayPixels, 400,400, GL_RGB);   
  
	glEnable(GL_DEPTH_TEST);  
	glDepthFunc(GL_LEQUAL);	// set the type of depth testing  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	  
	for (int i = 0; i < 400; i++){  
		for (int j = 0; j < 400; j++){  
			grayPixels[(j*400+i)*3 + 0] = (unsigned char)(ofRandomuf() * 255);  
			  
			grayPixels[(j*400+i)*3 + 1] = (unsigned char)(ofRandomuf() * 255);  
			  
			grayPixels[(j*400+i)*3 + 2] = (unsigned char)(ofRandomuf() * 255);  
		}  
	}  
	texGray.loadData(grayPixels, 400,400, GL_RGB);   
	  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	  
	glTranslated(ofGetScreenWidth()/2, ofGetScreenHeight()/2, 0);  
	  
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer  
	glPushMatrix();  
		glTranslatef(-((ofGetScreenWidth()/2)/2), 0.0f, -60.0f);	  
		glRotatef(rtri,0.0f,1.0f,0.0f);				// Rotate The Triangle On The Y axis ( NEW )  
		glBegin(GL_TRIANGLES);	// Drawing Using Triangles  
			glColor3f(1.0f,0.0f,0.0f);			// Red  
			glVertex3f( 0.0f, -200.0f, 0.0f);			// Top Of Triangle (Front)  
			glColor3f(0.0f,1.0f,0.0f);			// Green  
			glVertex3f(-200.0f, 200.0f, 200.0f);			// Left Of Triangle (Front)  
			glColor3f(0.0f,0.0f,1.0f);			// Blue  
			glVertex3f( 200.0f,200.0f, 200.0f);			// Right Of Triangle (Front)  
		  
			glColor3f(0.0f,1.0f,0.0f);			// Red  
			glVertex3f( 0.0f, -200.0f, 0.0f);			// Top Of Triangle (Right)  
			glColor3f(0.0f,1.0f,0.0f);			// Blue  
			glVertex3f( 200.0f, 200.0f, 200.0f);			// Left Of Triangle (Right)  
			glColor3f(0.0f,1.0f,0.0f);			// Green  
			glVertex3f( 200.0f, 200.0f, -200.0f);			// Right Of Triangle (Right)  
		  
			glColor3f(0.0f,0.0f,1.0f);			// Red  
			glVertex3f( 0.0f, -200.0f, 0.0f);			// Top Of Triangle (Back)  
			glColor3f(0.0f,0.0f,1.0f);			// Green  
			glVertex3f( 200.0f, 200.0f, -200.0f);			// Left Of Triangle (Back)  
			glColor3f(0.0f,0.0f,1.0f);			// Blue  
			glVertex3f(-200.0f, 200.0f, -200.0f);			// Right Of Triangle (Back)  
		  
			glColor3f(1.0f,0.0f,1.0f);			// Red  
			glVertex3f( 0.0f, -200.0f, 0.0f);			// Top Of Triangle (Left)  
			glColor3f(1.0f,0.0f,1.0f);			// Blue  
			glVertex3f(-200.0f, 200.0f,-200.0f);			// Left Of Triangle (Left)  
			glColor3f(1.0f, 0.0f,1.0f);			// Green  
			glVertex3f(-200.0f, 200.0f, 200.0f);			// Right Of Triangle (Left)  
	  
		glEnd();  
	  
	glPopMatrix();  
	  
	glTranslatef((ofGetScreenWidth()/2)/2,0.0f, -60.0f);	  
	glRotatef(rquad, 0.5f, 1.0f,0.1f);			// Rotate The Quad On The X axis ( NEW )  
	glColor3f(1.0f, 1.0f, 1.0f);		// Set The Color To Blue One Time Only  
	glEnable(texGray.getTextureData().textureTarget);  
	glEnable(GL_BLEND);  
  
	glBegin(GL_QUADS);					// Start Drawing Quads  
		glTexCoord2f(0.0f, 0.0f);       glVertex3f(-200.0f, 200.0f, 200.0f);			// Left And Up 1 Unit (Top Left)  
		glTexCoord2f(400.0f, 0.0f);     glVertex3f( 200.0f, 200.0f, 200.0f);			// Right And Up 1 Unit (Top Right)  
		glTexCoord2f(400.0f, 400.0f);   glVertex3f( 200.0f,-200.0f, 200.0f);			// Right And Down One Unit (Bottom Right)  
		glTexCoord2f(0.0f, 400.0f);     glVertex3f(-200.0f,-200.0f, 200.0f);			// Left And Down One Unit (Bottom Left)  
  
	    glColor3f(1.0f, 0.0f, 0.0f);  
		glVertex3f(-200.0f, 200.0f,-200.0f);			// Left And Up 1 Unit (Top Left)  
		glVertex3f( 200.0f, 200.0f,-200.0f);			// Right And Up 1 Unit (Top Right)  
		glVertex3f( 200.0f, 200.0f, 200.0f);			// Right And Down One Unit (Bottom Right)  
		glVertex3f(-200.0f, 200.0f, 200.0f);			// Left And Down One Unit (Bottom Left)  
	  
		glColor3f(0.0f, 0.0f, 1.0f);  
		glVertex3f(-200.0f, 200.0f, -200.0f);			// Left And Up 1 Unit (Top Left)  
		glVertex3f( 200.0f, 200.0f, -200.0f);			// Right And Up 1 Unit (Top Right)  
		glVertex3f( 200.0f,-200.0f, -200.0f);			// Right And Down One Unit (Bottom Right)  
		glVertex3f(-200.0f,-200.0f, -200.0f);			// Left And Down One Unit (Bottom Left)  
	  
		glColor3f(0.0f, 1.0f, 0.0f);  
		glVertex3f( 200.0f, -200.0f, 200.0f);			// Left And Up 1 Unit (Top Left)  
		glVertex3f(-200.0f, -200.0f, 200.0f);			// Right And Up 1 Unit (Top Right)  
		glVertex3f(-200.0f, -200.0f,-200.0f);			// Right And Down One Unit (Bottom Right)  
		glVertex3f( 200.0f, -200.0f,-200.0f);			// Left And Down One Unit (Bottom Left)  
		  
	    glColor3f(0.0f, 1.0f, 1.0f);  
		glVertex3f(-200.0f, -200.0f, 200.0f);  
		glVertex3f(-200.0f,  200.0f, 200.0f);  
		glVertex3f(-200.0f,  200.0f, -200.0f);  
		glVertex3f(-200.0f, -200.0f, -200.0f);  
	  
		glColor3f(0.2f, 0.5f, 3.0f);  
		glVertex3f( 200.0f, -200.0f, 200.0f);  
		glVertex3f( 200.0f,  200.0f, 200.0f);  
		glVertex3f( 200.0f,  200.0f, -200.0f);  
		glVertex3f( 200.0f, -200.0f, -200.0f);  
	  
	glDisable(GL_BLEND);  
  
	glEnd();						// Done Drawing A Quad  
	  
	rtri= mouseX;						// Increase The Rotation Variable For The Triangle ( NEW )  
	rquad-=0.15f;						// Decrease The Rotation Variable For The Quad     ( NEW )  
	  
	  
}  
  

Hi, psykel,
just compiled your code here: MacBook, GeForce9400M, Mac OS 10.5.8, Xcode 3.1.2, OF 0.061

The pyramid draws ok.
The cube has one size with noise, ok. All other solid color sides have a fast flicker black.

If setting ofSetFrameRate(5) on the app setup, what I do see is the faces of the cubes changing slowily.

So, maybe, what’s really happeing with the original app is that colors are randomly changing 60 times a second, creating the flickering behaviour…