The following is the code for drawing a vertex data
from a external. I have the following code.It is reading data from the file. But nothing is being rendered on the screen.kindly tell me what is problem
#include <stdio.h>
#include <GL/glut.h>
#include <GL/gl.h>
float a[24];
void fileread();
void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_SMOOTH);
fileread();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.0f,0.0f,1.0f);
glTranslatef(0.0,0.0,4.0f);
glBegin(GL_POINTS);
glVertex3fv(a);
glEnd();
glFlush();
}
void reshape(int w,int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-3.5, 3.5, -3.5*(GLfloat)h/(GLfloat)w,
3.5*(GLfloat)h/(GLfloat)w, -3.5, 3.5);
else
glOrtho (-3.5*(GLfloat)w/(GLfloat)h,
3.5*(GLfloat)w/(GLfloat)h, -3.5, 3.5, -3.5, 3.5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void fileread()
{
int i,j;
FILE fp;
fp = fopen(“test.dat”,“r”);
for(i=0;i<24;i++)
{
fscanf(fp,"%f",&a[i]);
}
for(i=0;i<24;i++)
{
printf("a[%d] = %f
",i,a[i]);
}
}
int main(int argc, charargv[])
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(512,512);
glutInitWindowPosition(50,50);
glutInit(&argc, argv);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
With regards
RAJESH.R