hello,
i am new hear. my name is michael and i am programming visual feedback for a neurofeedback (braintraining) software. brainwaves are measured with an eeg machine, the software ( bioexplorer) sends the values via tcp/ip to my little programm. i am still beginner, especially with opengl. the first version had two rotating cubes and it worked fine. now i want to have more rotating cubes and problems start. i can draw them and they turn, but if there are more then 2 cubes the lower two cubes turn always in the same direction and at the same speed, although they should turn seperately. any help would be appreciated, here the code:
rquad1 += rot1;
rquad2 -= rot2;
rquad3 += rot3;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-10.0f); // Move Right 1.5 Units And Into The Screen 7.0
glRotatef(rquad1,0.0f,1.0f,0.0f); // Rotate The Quad On The X axis ( NEW )
glBegin(GL_QUADS); // Draw A Quad
glColor3f(col1*1.0f, col1*1.0f, col1*1.0f);
glVertex3f( 6.0f, 4.0f,-1.0f); // Top Right Of The Quad (Top)
glVertex3f(-6.0f, 4.0f,-1.0f); // Top Left Of The Quad (Top)
glVertex3f(-6.0f, 4.0f, 1.0f); // Bottom Left Of The Quad (Top)
glVertex3f( 6.0f, 4.0f, 1.0f); // Bottom Right Of The Quad (Top)
glColor3f(col1 * 1.0f, col1 * 1.0f, col1 * 1.0f); // Set The Color To Orange
glVertex3f( 6.0f, 3.0f, 1.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-6.0f, 3.0f, 1.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-6.0f, 3.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 6.0f, 3.0f,-1.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(col1 * 1.0f, col1 * 1.0f, col1 * 1.0f); // Set The Color To Red
glVertex3f( 6.0f, 4.0f, 1.0f); // Top Right Of The Quad (Front)
glVertex3f(-6.0f, 4.0f, 1.0f); // Top Left Of The Quad (Front)
glVertex3f(-6.0f,3.0f, 1.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 6.0f,3.0f, 1.0f); // Bottom Right Of The Quad (Front)
glColor3f(col1 * 1.0f, col1 * 1.0f, col1 * 1.0f); // Set The Color To Yellow
glVertex3f( 6.0f,3.0f,-1.0f); // Top Right Of The Quad (Back)
glVertex3f(-6.0f,3.0f,-1.0f); // Top Left Of The Quad (Back)
glVertex3f(-6.0f, 3.0f,-1.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 6.0f, 3.0f,-1.0f); // Bottom Right Of The Quad (Back)
glColor3f(col1 * 1.0f, col1 * 1.0f, col1 * 1.0f); // Set The Color To Blue
glVertex3f(-6.0f, 4.0f, 1.0f); // Top Right Of The Quad (Left)
glVertex3f(-6.0f, 4.0f,-1.0f); // Top Left Of The Quad (Left)
glVertex3f(-6.0f,3.0f,-1.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-6.0f,3.0f, 1.0f); // Bottom Right Of The Quad (Left)
glColor3f(col1 * 1.0f, col1 * 1.0f, col1 * 1.0f); // Set The Color To Violet
glVertex3f( 6.0f, 4.0f,-1.0f); // Top Right Of The Quad (Right)
glVertex3f( 6.0f, 4.0f, 1.0f); // Top Left Of The Quad (Right)
glVertex3f( 6.0f,3.0f, 1.0f); // Bottom Left Of The Quad (Right)
glVertex3f( 6.0f,3.0f,-1.0f); // Bottom Right Of The Quad (Right)
glEnd();
//second quad:
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(0.0f,0.0f,-10.0f); // Move Right 1.5 Units And Into The Screen 7.0
glRotatef(rquad2,0.0f,1.0f,0.0f); // Rotate The Quad On The X axis ( NEW )
glBegin(GL_QUADS); // Draw A Quad
glColor3f(col2*1.0f, col2*1.0f, col2*1.0f);
glVertex3f( 6.0f, 0.5f,-1.0f); // Top Right Of The Quad (Top)
glVertex3f(-6.0f, 0.5f,-1.0f); // Top Left Of The Quad (Top)
glVertex3f(-6.0f, 0.5f, 1.0f); // Bottom Left Of The Quad (Top)
glVertex3f( 6.0f, 0.5f, 1.0f); // Bottom Right Of The Quad (Top)
glColor3f(col2 * 1.0f, col2 * 1.0f, col2 * 1.0f); // Set The Color To Orange
glVertex3f( 6.0f, -0.5f, 1.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-6.0f, -0.5f, 1.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-6.0f, -0.5f,-1.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 6.0f, -0.5f,-1.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(col2 * 1.0f, col2 * 1.0f, col2 * 1.0f); // Set The Color To Red
glVertex3f( 6.0f, 0.5f, 1.0f); // Top Right Of The Quad (Front)
glVertex3f(-6.0f, 0.5f, 1.0f); // Top Left Of The Quad (Front)
glVertex3f(-6.0f,-0.5f, 1.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 6.0f,-0.5f, 1.0f); // Bottom Right Of The Quad (Front)
glColor3f(col2 * 1.0f, col2 * 1.0f, col2 * 1.0f); // Set The Color To Yellow
glVertex3f( 6.0f,-0.5f,-1.0f); // Top Right Of The Quad (Back)
glVertex3f(-6.0f,-0.5f,-1.0f); // Top Left Of The Quad (Back)
glVertex3f(-6.0f, -0.5f,-1.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 6.0f, -0.5f,-1.0f); // Bottom Right Of The Quad (Back)
glColor3f(col2 * 1.0f, col2 * 1.0f, col2 * 1.0f); // Set The Color To Blue
glVertex3f(-6.0f, 0.5f, 1.0f); // Top Right Of The Quad (Left)
glVertex3f(-6.0f, 0.5f,-1.0f); // Top Left Of The Quad (Left)
glVertex3f(-6.0f,-0.5f,-1.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-6.0f,-0.5f, 1.0f); // Bottom Right Of The Quad (Left)
glColor3f(col2 * 1.0f, col2 * 1.0f, col2 * 1.0f); // Set The Color To Violet
glVertex3f( 6.0f, 0.5f,-1.0f); // Top Right Of The Quad (Right)
glVertex3f( 6.0f, 0.5f, 1.0f); // Top Left Of The Quad (Right)
glVertex3f( 6.0f,-0.5f, 1.0f); // Bottom Left Of The Quad (Right)
glVertex3f( 6.0f,-0.5f,-1.0f); // Bottom Right Of The Quad (Right)
//third quad:
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(0.0f,0.0f,-10.0f); // Move Right 1.5 Units And Into The Screen 7.0
glRotatef(rquad3,0.0f,1.0f,0.0f); // Rotate The Quad On The X axis ( NEW )
glBegin(GL_QUADS); // Draw A Quad
glColor3f(col3*1.0f, col3*1.0f, col3*1.0f);
glVertex3f( 6.0f, -4.0f,-1.0f); // Top Right Of The Quad (Top)
glVertex3f(-6.0f, -4.0f,-1.0f); // Top Left Of The Quad (Top)
glVertex3f(-6.0f, -4.0f, 1.0f); // Bottom Left Of The Quad (Top)
glVertex3f( 6.0f, -4.0f, 1.0f); // Bottom Right Of The Quad (Top)
glColor3f(col3 * 1.0f, col3 * 1.0f, col3 * 1.0f); // Set The Color To Orange
glVertex3f( 6.0f, -3.0f, 1.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-6.0f, -3.0f, 1.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-6.0f, -3.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 6.0f, -3.0f,-1.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(col3 * 1.0f, col3 * 1.0f, col3 * 1.0f); // Set The Color To Red
glVertex3f( 6.0f, -4.0f, 1.0f); // Top Right Of The Quad (Front)
glVertex3f(-6.0f, -4.0f, 1.0f); // Top Left Of The Quad (Front)
glVertex3f(-6.0f,-3.0f, 1.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 6.0f,-3.0f, 1.0f); // Bottom Right Of The Quad (Front)
glColor3f(col3 * 1.0f, col3 * 1.0f, col3 * 1.0f); // Set The Color To Yellow
glVertex3f( 6.0f,-3.0f,-1.0f); // Top Right Of The Quad (Back)
glVertex3f(-6.0f,-3.0f,-1.0f); // Top Left Of The Quad (Back)
glVertex3f(-6.0f, -4.0f,-1.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 6.0f, -4.0f,-1.0f); // Bottom Right Of The Quad (Back)
glColor3f(col3 * 1.0f, col3 * 1.0f, col3 * 1.0f); // Set The Color To Blue
glVertex3f(-6.0f, -4.0f, 1.0f); // Top Right Of The Quad (Left)
glVertex3f(-6.0f, -4.0f,-1.0f); // Top Left Of The Quad (Left)
glVertex3f(-6.0f,-3.0f,-1.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-6.0f,-3.0f, 1.0f); // Bottom Right Of The Quad (Left)
glColor3f(col3 * 1.0f, col3 * 1.0f, col3 * 1.0f); // Set The Color To Violet
glVertex3f( 6.0f, -4.0f,-1.0f); // Top Right Of The Quad (Right)
glVertex3f( 6.0f, -4.0f, 1.0f); // Top Left Of The Quad (Right)
glVertex3f( 6.0f,-3.0f, 1.0f); // Bottom Left Of The Quad (Right)
glVertex3f( 6.0f,-3.0f,-1.0f); // Bottom Right Of The Quad (Right)
glEnd();
win1->display();
the window is done with sfml library. the variables rot1, rot2 and rot3 i get from the neurofeedback software, they are between 0 and +6. if i uncomment one of the cubes it works fine.
thanks, michael