PDA

View Full Version : Graphic card for stereo images!



pran1
02-23-2004, 07:43 AM
Hi I am using a Nvidia Geforce4 MX440 64MB graphic card to dusplay stereo images. The program compiles well but when I try to execute it, it comes up with an error message saying - GLUT: Fatal error in H:\code\Debug\stereo.exe: pixel format with necessary capabilities not found.

I was wondering if anyone could help me to solve this problem, whether there is somethins wrong with the code or I need to do enable some settings for the graphic card.

Thanks alot
Pran

pran1
02-23-2004, 08:17 AM
This is the code.. so I am wrong in the code !!!!!!!

#include <glut.h>
#include<stdlib.h>
#include <math.h>

#define KEY_ESC 27

#define DTOR 0.0174532925 /* degree of radians*/


/*
Enumerations
*/
typedef enum{LEFT,RIGHT} EyeMode;


GLvoid drawScene( EyeMode eyeMode);

void setStereoPerspective( GLdouble fovy, GLdouble aspect, GLdouble n, GLdouble f,
GLdouble focalLenght, GLdouble eyeSep, EyeMode eyeMode);

void setStereoLookAt( GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ,
GLdouble centreX, GLdouble centreY, GLdouble centreZ,
GLdouble upX, GLdouble upY, GLdouble upZ, GLdouble eyeSep,
EyeMode eyeMode);
GLvoid render(EyeMode eyeMode);
GLvoid display(GLvoid);

GLvoid keyboard (GLubyte key, GLint x, GLint y);


/* Multiply the current matrix by a stereo perspective projection matrix.
Parameteres are mostly the same as gluPerspective */

void setStereoPerspective( GLdouble fovy, GLdouble aspect, GLdouble n, GLdouble f,
GLdouble focalLenght, GLdouble eyeSep, EyeMode eyeMode)
{
/* The trick is to implement the " parallel axis asymmetric frustum perspective projection"
*/

GLdouble left;
GLdouble right;
GLdouble stereoAdjustment;

GLdouble top =n*tan(DTOR * fovy/2);
GLdouble bottom = -top;

GLdouble nearWidth =aspect*top;
stereoAdjustment =eyeSep/2*n/focalLenght;

if(RIGHT == eyeMode)
{
left = -nearWidth - stereoAdjustment;
right = nearWidth - stereoAdjustment;
}
else
{
left = -nearWidth + stereoAdjustment;
right = nearWidth + stereoAdjustment;
}

glFrustum(left, right, bottom, top, n, f);
}

/*
Parameters are mostly the same as for gluLookAt.
Notes:
eye represents the centre of the left, right eye
eyeSep is the distance between the left and right eye
eyeMode is either LEFT (eye) of RIGHT (eye)
*/

void setStereoLookAt( GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ,
GLdouble centreX, GLdouble centreY, GLdouble centreZ,
GLdouble upX, GLdouble upY, GLdouble upZ, GLdouble eyeSep,
EyeMode eyeMode)
{
GLdouble inX = centreX - eyeX;
GLdouble inY = centreY - eyeY;
GLdouble inZ = centreZ - eyeZ;

GLdouble factor = (eyeMode==RIGHT)?1:-1;

GLdouble realEyeCorX = factor * (inY*upZ - upY*inZ);
GLdouble realEyeCorY = factor * (inZ*upX - upZ*inX);
GLdouble realEyeCorZ = factor * (inX*upY - upX*inY);

GLdouble lenght = sqrt( realEyeCorX*realEyeCorX
+ realEyeCorY*realEyeCorY
+ realEyeCorZ*realEyeCorZ);

gluLookAt( eyeX+realEyeCorX, eyeY+realEyeCorY, eyeZ+realEyeCorZ,centreX,centreY,centreZ,upX,upY,u pZ);
}

GLvoid drawScene( EyeMode eyeMode)
{
/*
if(eyeMode== LEFT)
{
glColor3f(1.0,0.0,0.0);
}
else
{
glColor3f(0.0,1.0,0.0);
}*/
glPushMatrix();
{
glRotatef(-45.0,0.0,0.0,0.0);
glutSolidTeapot(1.0);
}
glPopMatrix();
}

GLvoid render(EyeMode eyeMode)
{
double fovy = 50;
double aspect = 4/3;
double n = 1.0;
double f = 5.0;
double focalLenght = 1.5;
double eyeSep = 0.03;

double eyeX = 0.0;
double eyeY = 0.0;
double eyeZ = 4.0;
double centreX = 0.0;
double centreY = 0.0;
double centreZ = -100;
double upX = 0.0;
double upY = 1.0;
double upZ = 0.0;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
setStereoPerspective(fovy, aspect, n, f, focalLenght, eyeSep, eyeMode);
glMatrixMode(GL_MODELVIEW);

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
{

setStereoLookAt(eyeX,eyeY,eyeZ,centreX,centreY,cen treZ,upX,upY,upZ,eyeSep,eyeMode);
drawScene(eyeMode);
}
glPopMatrix();
}

GLvoid display(GLvoid)
{
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT);

glDrawBuffer(GL_BACK_LEFT);
render(LEFT);

glDrawBuffer(GL_BACK_RIGHT);
render(RIGHT);

glutSwapBuffers();
}

GLvoid keyboard (GLubyte key, GLint x, GLint y)
{
switch(key)
{
case ' ':
glutPostRedisplay();
case KEY_ESC:
exit(0);
break;

default:
break;
}
}

int main( int argc, char *argv[])
{
glutInit( &argc, argv);

glutInitDisplayMode( GLUT_RGB|GLUT_DOUBLE|GLUT_STEREO);
glutCreateWindow( argv[0]);

glutKeyboardFunc(keyboard);
glutDisplayFunc(display);

glutMainLoop();

return 0;
}

Honk
02-23-2004, 12:18 PM
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/011640.html