i have a csv file with points, and i need to take that values and ploat within a cube using opengl in cuda . i already plot the points in the cube. but i dont no how it implement in cuda. i need help.
What I have tried:
# include <cstdlib>
# include <ctime>
# include <cmath>
# include <fstream>
# include <iostream>
# include <iomanip>
# include <GL/glut.h>
# include <string>
# include <sstream>
# include <vector>
# include <string>
using namespace std;
void display();
double rotate_y=0;
double rotate_x=0;
GLfloat xRotated, yRotated, zRotated;
double zoom=0.5;
void display(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glScalef(zoom, zoom, 1.0f);
glTranslatef(0.0,0.0,-10.5);
glRotatef(xRotated,1.0,0.0,0.0);
glRotatef(yRotated,0.0,1.0,0.0);
glRotatef(zRotated,0.0,0.0,1.0);
glColor3f( 1, 1, 1 );
glBegin(GL_LINE_LOOP);
glVertex3f( 0.1, -0.01, -0.01 );
glVertex3f( 0.1, 0.1, -0.01 );
glVertex3f( -0.01, 0.1, -0.01 );
glVertex3f( -0.01, -0.01, -0.01 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( 0.1, -0.01, 0.1 );
glVertex3f( 0.1, 0.1, 0.1 );
glVertex3f( -0.01, 0.1, 0.1 );
glVertex3f( -0.01, -0.01, 0.1 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( 0.1, -0.01, -0.01 );
glVertex3f( 0.1, 0.1, -0.01 );
glVertex3f( 0.1, 0.1, 0.1 );
glVertex3f( 0.1, -0.01, 0.1 );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( -0.01, -0.01, 0.1 );
glVertex3f( -0.01, 0.1, 0.1 );
glVertex3f( -0.01, 0.1, -0.01 );
glVertex3f( -0.01, -0.01, -0.01 );
glEnd();
float f1, f2, f3;
FILE *fp;
fp = fopen("golgi.csv", "r");
while (fscanf(fp, "%g,%g,%g\n", &f1, &f2, &f3) == 3)
{
glPointSize(7);
glColor3f( 0, 0, 1 );
glBegin(GL_POINTS);
glVertex3f( f1, f2, f3 );
glEnd();
}
fclose(fp);
glFlush();
glutSwapBuffers();
}
void animation(void)
{
yRotated += 0.70;
xRotated += 0.03;
display();
}
void reshape(int x, int y)
{
if (y == 0 || x == 0) return;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(3.0,(GLdouble)x/(GLdouble)y,0.8,50.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);
}
void mouse( int button, int state, int x, int y)
{
//Right arrow - increase rotation by 5 degree
if(state == GLUT_DOWN && button == GLUT_RIGHT_BUTTON)
{
zoom -= 2.5;
}
else if(state == GLUT_DOWN && button == GLUT_LEFT_BUTTON)
{
zoom += 2.5;
}
glutPostRedisplay();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(1500 , 1000);
glutCreateWindow("Awesome Cube");
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(animation);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}