Hi everybody,
i need your help. I have to program a 3D-Scene in Stereo. But it doesn't work. I tried so much, but i don't know where the problem is. Here is the Code. Can somebody look if he can find anything. I give you the part where the Scene is getting drawn:
void Cube_test:aintGL()
{
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
const float camPos[3] = { 10.0f, 10.0f, 10.0f };
glTranslatef(-camPos[0], -camPos[1], -camPos[2]);
const int numIndices = 24;
const int numVertices = 8;
const int indices[numIndices] = { 3, 2, 1, 0, 2, 6, 5, 1, 2, 3, 7, 6, 4, 7, 3, 0, 5, 4, 0, 1, 7, 4, 5, 6};
const float vertices[numVertices][3] =
{
{-1.0f, -1.0f, -1.0f},
{-1.0f, -1.0f, 1.0f},
{1.0f, -1.0f, 1.0f},
{1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f},
{-1.0f, 1.0f, 1.0f},
{1.0f, 1.0f, 1.0f},
{1.0f, 1.0f, -1.0f},
};
const QColor vertexColors[numVertices] =
{
Qt::red,
Qt::green,
Qt::blue,
Qt::white,
Qt::black,
Qt::yellow,
Qt::darkRed,
Qt::darkGreen
};
// draw Cube_test
glDrawBuffer(GL_BACK_LEFT);
//glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set left-eye perspective
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// render objects in scene for left-eye view
glMatrixMode(GL_MODELVIEW);
drawGrid();
drawAxis();
glBegin(GL_QUADS);
for(int i = 0; i < numIndices; ++i)
{
const int currentIndex = indices[i];
qglColor(vertexColors[currentIndex]);
glVertex3f(vertices[currentIndex][0], vertices[currentIndex][1], vertices[currentIndex][2]);
}
glEnd();
glFlush();
glDrawBuffer(GL_BACK_RIGHT);
// clear separate draw buffer for right eye rendering
//glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set right-eye perspective
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// render scene again for right-eye view
glMatrixMode(GL_MODELVIEW);
drawGrid();
drawAxis();
glBegin(GL_QUADS);
for(int i = 0; i < numIndices; ++i)
{
const int currentIndex = indices[i];
qglColor(vertexColors[currentIndex]);
glVertex3f(vertices[currentIndex][0], vertices[currentIndex][1], vertices[currentIndex][2]);
}
glEnd();
glFlush();
swapBuffers();
}
i hope somebody can help me. Thank you.
Bookmarks