#include "timestamp.h"
#define GL_GLEXT_PROTOTYPES
#include <cstdlib>
#include <GL/glut.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <cmath>
#include <sys/time.h>
#include <string>
using namespace std;
using std::string;
GLint loc1,loc2,loc3,loc4;
GLhandleARB vertexShader, fragmentShader, geometryShader, shader;
GLdouble transformt[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.847826, -0.0869565, -18.1358, 1.0};
float initpoint[3];
float line=0.0;
float angler = 0.0;
float anglerx= 0.0;
float mx=0,my=0,mz=0;
//Subdivision Parameter
int kdiv = 4;
int numpatches;
float **gx,**gy,**gz;
GLuint Vboid;
GLfloat* vertices;
int vCount=0;
void VboInitialize()
{
vCount=kdiv*kdiv*6;
vertices=new float[vCount*3];
int index=0;
float dx=1.0/kdiv;
float dy=1.0/kdiv;
for(int i=0;i<kdiv;i++)
for(int j=0;j<kdiv;j++)
{
vertices[index]=j*dx;index++;
vertices[index]=i*dy;index++;
vertices[index]=1.0;index++;
vertices[index]=(j+1)*dx;index++;
vertices[index]=i*dy;index++;
vertices[index]=1.0;index++;
vertices[index]=j*dx;index++;
vertices[index]=(i+1)*dy;index++;
vertices[index]=1.0;index++;
vertices[index]=(j+1)*dx;index++;
vertices[index]=i*dy;index++;
vertices[index]=1.0;index++;
vertices[index]=(j+1)*dx;index++;
vertices[index]=(i+1)*dy;index++;
vertices[index]=1.0;index++;
vertices[index]=j*dx;index++;
vertices[index]=(i+1)*dy;index++;
vertices[index]=1.0;index++;
}
glGenBuffersARB(1,&Vboid);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,Vboid);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,vCount*3*sizeof float),vertices,GL_STATIC_DRAW_ARB);
//delete [] vertices;
}
//global field of view
char *textFileRead(char *fn) {
FILE *fp;
char *content = NULL;
int f,count;
f = open(fn, O_RDONLY);
count = lseek(f, 0, SEEK_END);
close(f);
if (fn != NULL) {
fp = fopen(fn,"rt");
if (fp != NULL) {
if (count > 0) {
content = (char *)malloc(sizeof(char) * (count+1));
count = fread(content,sizeof(char),count,fp);
content[count] = '\0';
}
fclose(fp);
}
}
return content;
}
void printInfoLog(GLhandleARB obj, char * shadername){
int infologLength = 0;
int charsWritten = 0;
char *infoLog;
glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB,
&infologLength);
if (infologLength > 0)
{
infoLog = (char *)malloc(infologLength);
glGetInfoLogARB(obj, infologLength, &charsWritten, infoLog);
printf("%s\n",shadername);
printf("%s\n",infoLog);
free(infoLog);
}
}
//Initializing the shaders
void initShaders() {
char *vs,*fs,*gs;
vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
geometryShader = glCreateShaderObjectARB(GL_GEOMETRY_SHADER_EXT);
vs = textFileRead("vertexshader.glsl");
fs = textFileRead("fragmentshader.glsl");
gs = textFileRead("subdivisiongs.glsl");
const char * ff = fs;
const char * vv = vs;
const char * gg = gs;
glShaderSourceARB(vertexShader, 1, &vv,NULL);
glShaderSourceARB(fragmentShader, 1, &ff,NULL);
glShaderSourceARB(geometryShader, 1, ≫,NULL);
free(vs);free(fs);free(gs);
glCompileShaderARB(vertexShader);
printInfoLog( vertexShader,"vertexshader.glsl" );
glCompileShaderARB(fragmentShader);
printInfoLog( fragmentShader, "fragmentshader.glsl" );
glCompileShaderARB(geometryShader);
printInfoLog( geometryShader, "subdivisionshader.glsl" );
shader = glCreateProgramObjectARB();
glAttachObjectARB( shader, vertexShader);
glAttachObjectARB( shader, fragmentShader);
glAttachObjectARB( shader, geometryShader);
//Input type primitive and Output type primitive Last line is essential to specify the maximum number of output vertices
glProgramParameteriEXT( shader, GL_GEOMETRY_INPUT_TYPE_EXT , GL_TRIANGLES );
glProgramParameteriEXT( shader, GL_GEOMETRY_OUTPUT_TYPE_EXT , GL_TRIANGLE_STRIP );
printf("%s\n",gluErrorString(glGetError()));
glProgramParameteriEXT( shader, GL_GEOMETRY_VERTICES_OUT_EXT, 1024);
printf("%s\n",gluErrorString(glGetError()));
glLinkProgramARB( shader );
printf("%s\n",gluErrorString(glGetError()));
glUseProgramObjectARB( shader );
printf("%s\n",gluErrorString(glGetError()));
loc1 = glGetUniformLocation(shader,"gx1");
loc2 = glGetUniformLocation(shader,"gy1");
loc3 = glGetUniformLocation(shader,"gz1");
}
// Displaying the Patch
void displaypatch(int m)
{
glPushMatrix();
//glMultMatrixd(transformt);
//glTranslatef(0.847826, -0.0869565, -18.1358);
glTranslatef(0, 0, -18.1358);
glTranslatef(mx,my,mz);
glRotatef(angler,0,1,0);
glRotatef(anglerx,1,0,0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glColor3f(1.0,0.875,0.575);
glUniformMatrix4fv(loc1,1,0,gx[m]);
glUniformMatrix4fv(loc2,1,0,gy[m]);
glUniformMatrix4fv(loc3,1,0,gz[m]);
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,Vboid);
glVertexPointer(3,GL_FLOAT,0,0 );
glDrawArrays(GL_TRIANGLES,0,vCount);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,0);
glPopMatrix();
}
//Initializing OpenGL Variables
void setupGL( )
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glFrustum(-3.38394, 3.38394, -3.38394,3.38394, 13.67, 30.5098);
gluPerspective(45.0f,(2*3.38394) /(2*3.38394) , 13.67, 30.5078);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat light0_position[] = {0 ,0, 30.0, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
GLfloat mat_diffuse[4] = { 1, 1, 1, 1 };
GLfloat mat_specular[4] = { 0.88, 0.88, 0.88, 0.88 };
GLfloat mat_shininess[] = { 100 };
GLfloat global_ambient[] = { 0.2, 0.2, 0.5, 1.0 };
GLfloat light0_ambient[] = { 0.2, 0.2, 0.2, 0.2 };
GLfloat light0_diffuse[] = { 0.85, 0.85, 0.85, 1.0 };
GLfloat light1_diffuse[] = { -0.01, -0.01, -0.03, -0.03 };
GLfloat light0_specular[] = { 0.85, 0.85, 0.85, 0.85 };
GLfloat light_position[] = {0,0,0,1};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light0_specular);
glLightfv(GL_LIGHT2, GL_SPECULAR, light0_specular);
glLightfv(GL_LIGHT3, GL_SPECULAR, light0_specular);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHT2);
glEnable(GL_LIGHT3);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
}
// Display Function
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgramObjectARB( shader );
if(line==1.0)glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
else glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glFinish();
timestamp t1=timenow();
for(int i=0;i<numpatches;i++)
{
//if(i==31)
displaypatch(i);
}
glFinish();
float time=timenow()-t1;
printf("render speed %f\n" , 1/time);
glutSwapBuffers();
}
// Keyboard Function
void keyboardfunc(unsigned char key, int x, int y)
{
switch (key) {
case 'a': mx+=0.1;
break;
case 'd': mx-=0.1;
break;
case 'w': mz+=0.1;
break;
case 's': mz-=0.1;
break;
case 'r': my-=0.1;
break;
case 'f': my+=0.1;
break;
case 'z':
kdiv++;
break;
case 'x':
kdiv--;
break;
case 'l':
if(line==0)line+=1.0;
else line=0;
break;
case 27:
exit(0);
}
glutPostRedisplay();
}
void speckey(int c,int x,int y){
if(c==GLUT_KEY_LEFT){
angler+=10.0;
}
if(c==GLUT_KEY_UP){
anglerx+=10.0;
}
if(c==GLUT_KEY_RIGHT){
angler-=10.0;
}
if(c==GLUT_KEY_DOWN){
anglerx-=10.0;
}
glutPostRedisplay();
}
void usage(const char *myname)
{
fprintf(stderr, "Usage: %s geometryvectorfile\n", myname);
exit(1);
}
int main(int argc, char *argv[])
{
initpoint[0] = -0.847826;
initpoint[1] = 0.0869565;
initpoint[2] = 1.04435;
if( argc < 2 )
usage(argv[0]);
const char * gfilename = argv[1];
FILE * gf = fopen(gfilename,"r");
fscanf(gf,"%d",&numpatches);
//Allocating memory to geometry vectors
gx = new float* [numpatches];
gy = new float* [numpatches];
gz = new float* [numpatches];
for(int i=0;i<numpatches;i++)
{
gx = new float[16];
gy = new float[16];
gz = new float[16];
}
//Reading Geometry Vectors
for(int i=0;i<numpatches;i++)
{
for(int j=0;j<16;j++)
fscanf(gf,"%f",&gx[j]);
for(int j=0;j<16;j++)
fscanf(gf,"%f",&gy[j]);
for(int j=0;j<16;j++)
fscanf(gf,"%f",&gz[j]);
}
VboInitialize();
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInit(&argc, argv);
if (argc < 2)
usage(argv[0]);
glutCreateWindow("Subdivision Shader");
glutDisplayFunc(display);
glutIdleFunc(display);
glutKeyboardFunc(keyboardfunc);
glutSpecialFunc(speckey);
setupGL();
initShaders();
glutMainLoop();
}
🔒 Locked
Problem using VBOs
Advertisement
Original Post
Hi all, I have just started using vbos(vertex buffer objects) and I am getting seg fault in glDrawArrays.I am using glsl for shaders . Can any tell me where did i go wrong.... here is the code
If you are on windows, did you load the extensions? or does glut handle that itself these days? If you are using an extension loader, did you remember to call the init function?
Quote:
Original post by speciesUnknown
If you are on windows, did you load the extensions? or does glut handle that itself these days? If you are using an extension loader, did you remember to call the init function?
I agree... in my VBO code we have function pointers for glext... do you have those?
Judging from the header files he is including, I imagine he is on a Unix-based system. srinivasareddyp, I can't imagine what your problem is; I've never had a seg fault from within a GL function.
I was going to test this out on my machine. Could you post a sample geometryvectorfile?
[Edited by - Simian Man on August 22, 2008 1:56:22 PM]
I was going to test this out on my machine. Could you post a sample geometryvectorfile?
[Edited by - Simian Man on August 22, 2008 1:56:22 PM]
yes I am running it on fc7.I think I dont need to load extensions..
here is geometry vector file
here is geometry vector file
32-0.064001 0.264001 0.000000 -0.200000 0.156001 -0.643501 0.000000 0.487500 -0.060000 0.247500 0.000000 -0.187500 0.448000 -1.848000 0.000000 1.400000 -0.064000 -0.072000 0.336000 0.000000 0.156000 0.175499 -0.818999 0.000000 -0.060000 -0.067500 0.315000 0.000000 0.448000 0.504000 -2.352000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.393750 0.000000 0.000000 0.000000 0.393750 0.000000 0.000000 0.000000 2.400000 -0.064000 -0.072000 0.336000 0.000000 0.156000 0.175499 -0.818999 0.000000 -0.060000 -0.067500 0.315000 0.000000 0.448000 0.504000 -2.352000 0.000000 0.064001 -0.264001 0.000000 0.200000 -0.156001 0.643501 0.000000 -0.487500 0.060000 -0.247500 0.000000 0.187500 -0.448000 1.848000 0.000000 -1.400000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.393750 0.000000 0.000000 0.000000 0.393750 0.000000 0.000000 0.000000 2.400000 0.064001 -0.264001 0.000000 0.200000 -0.156001 0.643501 0.000000 -0.487500 0.060000 -0.247500 0.000000 0.187500 -0.448000 1.848000 0.000000 -1.400000 0.064000 0.072000 -0.336000 0.000000 -0.156000 -0.175499 0.818999 0.000000 0.060000 0.067500 -0.315000 0.000000 -0.448000 -0.504000 2.352000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.393750 0.000000 0.000000 0.000000 0.393750 0.000000 0.000000 0.000000 2.400000 0.064000 0.072000 -0.336000 0.000000 -0.156000 -0.175499 0.818999 0.000000 0.060000 0.067500 -0.315000 0.000000 -0.448000 -0.504000 2.352000 0.000000 -0.064001 0.264001 0.000000 -0.200000 0.156001 -0.643501 0.000000 0.487500 -0.060000 0.247500 0.000000 -0.187500 0.448000 -1.848000 0.000000 1.400000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.393750 0.000000 0.000000 0.000000 0.393750 0.000000 0.000000 0.000000 2.400000 -0.080000 0.330000 0.000000 -0.250000 0.000000 0.000000 0.000000 0.000000 0.240000 -0.990000 0.000000 0.750000 0.480000 -1.980000 0.000000 1.500000 -0.080000 -0.090000 0.420000 0.000000 0.000000 0.000000 0.000000 0.000000 0.240000 0.270000 -1.260000 0.000000 0.480000 0.540000 -2.520000 0.000000 -0.000000 0.000000 0.000000 0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.575000 0.000000 0.000000 0.000000 2.400000 -0.080000 -0.090000 0.420000 0.000000 0.000000 0.000000 0.000000 0.000000 0.240000 0.270000 -1.260000 0.000000 0.480000 0.540000 -2.520000 0.000000 0.080000 -0.330000 0.000000 0.250000 0.000000 0.000000 0.000000 0.000000 -0.240000 0.990000 0.000000 -0.750000 -0.480000 1.980000 0.000000 -1.500000 -0.000000 0.000000 0.000000 0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.575000 0.000000 0.000000 0.000000 2.400000 0.080000 -0.330000 0.000000 0.250000 0.000000 0.000000 0.000000 0.000000 -0.240000 0.990000 0.000000 -0.750000 -0.480000 1.980000 0.000000 -1.500000 0.080000 0.090000 -0.420000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.240000 -0.270000 1.260000 0.000000 -0.480000 -0.540000 2.520000 0.000000 -0.000000 0.000000 0.000000 0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.575000 0.000000 0.000000 0.000000 2.400000 0.080000 0.090000 -0.420000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.240000 -0.270000 1.260000 0.000000 -0.480000 -0.540000 2.520000 0.000000 -0.080000 0.330000 0.000000 -0.250000 0.000000 0.000000 0.000000 0.000000 0.240000 -0.990000 0.000000 0.750000 0.480000 -1.980000 0.000000 1.500000 -0.000000 0.000000 0.000000 0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.575000 0.000000 0.000000 0.000000 2.400000 0.320000 -1.320000 0.000000 1.000000 -0.480000 1.980000 0.000000 -1.500000 0.000000 0.000000 0.000000 0.000000 0.640000 -2.640000 0.000000 2.000000 0.320000 0.360001 -1.680000 0.000000 -0.480000 -0.540001 2.520000 0.000000 0.000000 0.000000 0.000000 0.000000 0.640000 0.720000 -3.360000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.675000 0.000000 0.000000 0.000000 -1.350000 0.000000 0.000000 0.000000 0.900000 0.320000 0.360001 -1.680000 0.000000 -0.480000 -0.540001 2.520000 0.000000 0.000000 0.000000 0.000000 0.000000 0.640000 0.720000 -3.360000 0.000000 -0.320000 1.320000 0.000000 -1.000000 0.480000 -1.980000 0.000000 1.500000 0.000000 0.000000 0.000000 0.000000 -0.640000 2.640000 0.000000 -2.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.675000 0.000000 0.000000 0.000000 -1.350000 0.000000 0.000000 0.000000 0.900000 -0.320000 1.320000 0.000000 -1.000000 0.480000 -1.980000 0.000000 1.500000 0.000000 0.000000 0.000000 0.000000 -0.640000 2.640000 0.000000 -2.000000 -0.320000 -0.360001 1.680000 0.000000 0.480000 0.540001 -2.520000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.640000 -0.720000 3.360000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.675000 0.000000 0.000000 0.000000 -1.350000 0.000000 0.000000 0.000000 0.900000 -0.320000 -0.360001 1.680000 0.000000 0.480000 0.540001 -2.520000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.640000 -0.720000 3.360000 0.000000 0.320000 -1.320000 0.000000 1.000000 -0.480000 1.980000 0.000000 -1.500000 0.000000 0.000000 0.000000 0.000000 0.640000 -2.640000 0.000000 2.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.675000 0.000000 0.000000 0.000000 -1.350000 0.000000 0.000000 0.000000 0.900000 0.200003 -0.300002 0.000000 0.100001 -1.200006 1.800004 0.000000 0.899999 1.800003 -2.700002 0.000000 -2.099999 -0.200000 0.300000 0.000000 -1.600000 0.000000 -0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.900000 -0.900000 0.000000 0.450000 -0.675000 0.000000 -0.225000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.450000 0.675000 0.000000 2.025000 -0.200002 0.300002 0.000000 0.000000 1.200003 -1.800004 0.000000 1.500000 -1.800002 2.700002 0.000000 -3.000000 0.200000 -0.300000 0.000000 -1.500000 0.000000 0.000000 -0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.900000 0.900000 0.000000 -0.450000 0.675000 0.000000 -0.450000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.450000 -0.675000 0.000000 2.250000 0.099998 -0.149998 0.000000 0.099999 -0.899998 1.349998 0.000000 0.600000 0.000000 0.000000 0.000000 0.000000 0.599999 -0.900000 0.000000 -2.700000 0.000000 -0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.900000 -0.900000 0.000000 0.825000 -1.237500 0.000000 0.450000 -1.575001 2.362501 0.000000 -0.675001 1.350001 -2.025001 0.000000 -0.674999 0.000000 0.000000 0.000000 1.800000 -0.099998 0.149998 0.000000 0.050000 0.899998 -1.349998 0.000000 1.050000 0.000000 0.000000 0.000000 0.000000 -0.600000 0.900000 0.000000 -3.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.900000 0.900000 0.000000 -0.825000 1.237500 0.000000 0.037500 1.575000 -2.362501 0.000000 0.112499 -1.350000 2.025001 0.000000 -1.349999 0.000000 0.000000 0.000000 1.800000 -3.599995 5.399996 0.000000 1.900000 5.399995 -8.099995 0.000000 -3.599999 -2.999999 4.499999 0.000000 2.699999 0.000000 0.000000 0.000000 1.700000 0.000000 2.460000 -2.460000 0.000000 0.000000 -3.690000 3.690000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.980000 -1.980000 0.000000 1.500001 -2.250001 0.000000 -1.050000 -1.800001 2.700002 0.000000 2.025000 -1.349999 2.024999 0.000000 0.000000 1.650000 -2.474999 0.000000 1.425000 3.599996 -5.399996 0.000000 3.699999 -5.399996 8.099995 0.000000 -6.299998 2.999999 -4.499999 0.000000 4.199999 0.000000 0.000000 0.000000 1.700000 0.000000 -2.460000 2.460000 0.000000 0.000000 3.690000 -3.690000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.980000 1.980000 0.000000 -1.500001 2.250001 0.000000 -1.800000 1.800001 -2.700002 0.000000 2.925001 1.349999 -2.024999 0.000000 0.675000 -1.650000 2.474999 0.000000 0.600000 -0.650007 0.975006 0.000000 -0.200001 1.800011 -2.700010 0.000000 0.000002 -0.750006 1.125006 0.000000 0.299999 -1.199999 1.799999 0.000000 2.700000 0.000000 0.600000 -0.600000 0.000000 0.000000 -0.900000 0.900000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.750000 -0.750000 0.000000 0.112500 -0.168750 0.000000 0.000000 0.000001 -0.000001 0.000000 -0.224999 -0.112501 0.168752 0.000000 0.224999 0.000000 0.000000 0.000000 2.400000 0.650005 -0.975006 0.000000 0.125000 -1.800009 2.700010 0.000000 -0.900002 0.750006 -1.125006 0.000000 0.675001 1.199999 -1.799999 0.000000 3.300000 0.000000 -0.600000 0.600000 0.000000 0.000000 0.900000 -0.900000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.750000 0.750000 0.000000 -0.112501 0.168750 0.000000 -0.056250 0.000000 0.000001 0.000000 -0.225000 0.112501 -0.168752 0.000000 0.281250 0.000000 0.000000 0.000000 2.400000 0.814001 -3.414001 0.000000 2.600000 -1.500001 6.300001 0.000000 -4.800000 0.750001 -3.150001 0.000000 2.400000 0.000000 0.000000 0.000000 0.000000 0.814001 0.971999 -4.386000 0.000000 -1.500001 -1.799998 8.099999 0.000000 0.750001 0.899999 -4.050000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.450001 0.000000 0.000000 0.000000 -0.900002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 3.150000 0.814001 0.971999 -4.386000 0.000000 -1.500001 -1.799998 8.099999 0.000000 0.750001 0.899999 -4.050000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.814001 3.414001 0.000000 -2.600000 1.500001 -6.300001 0.000000 4.800000 -0.750001 3.150001 0.000000 -2.400000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.450001 0.000000 0.000000 0.000000 -0.900002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 3.150000 -0.814001 3.414001 0.000000 -2.600000 1.500001 -6.300001 0.000000 4.800000 -0.750001 3.150001 0.000000 -2.400000 0.000000 0.000000 0.000000 0.000000 -0.814001 -0.971999 4.386000 0.000000 1.500001 1.799998 -8.099999 0.000000 -0.750001 -0.899999 4.050000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.450001 0.000000 0.000000 0.000000 -0.900002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 3.150000 -0.814001 -0.971999 4.386000 0.000000 1.500001 1.799998 -8.099999 0.000000 -0.750001 -0.899999 4.050000 0.000000 0.000000 0.000000 0.000000 0.000000 0.814001 -3.414001 0.000000 2.600000 -1.500001 6.300001 0.000000 -4.800000 0.750001 -3.150001 0.000000 2.400000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.450001 0.000000 0.000000 0.000000 -0.900002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 3.150000 -0.512000 2.112000 0.000000 -1.600000 0.672000 -2.772000 0.000000 2.100000 0.192000 -0.792000 0.000000 0.600000 0.064000 -0.264000 0.000000 0.200000 -0.512000 -0.576000 2.688000 0.000000 0.672000 0.756000 -3.528000 0.000000 0.192000 0.216000 -1.008000 0.000000 0.064000 0.072000 -0.336000 0.000000 -0.000000 0.000000 0.000000 -0.300000 0.000001 0.000000 0.000000 0.450001 -0.000001 0.000000 0.000000 -0.450001 0.000000 0.000000 0.000000 2.700000 -0.512000 -0.576000 2.688000 0.000000 0.672000 0.756000 -3.528000 0.000000 0.192000 0.216000 -1.008000 0.000000 0.064000 0.072000 -0.336000 0.000000 0.512000 -2.112000 0.000000 1.600000 -0.672000 2.772000 0.000000 -2.100000 -0.192000 0.792000 0.000000 -0.600000 -0.064000 0.264000 0.000000 -0.200000 -0.000000 0.000000 0.000000 -0.300000 0.000001 0.000000 0.000000 0.450001 -0.000001 0.000000 0.000000 -0.450001 0.000000 0.000000 0.000000 2.700000 0.512000 -2.112000 0.000000 1.600000 -0.672000 2.772000 0.000000 -2.100000 -0.192000 0.792000 0.000000 -0.600000 -0.064000 0.264000 0.000000 -0.200000 0.512000 0.576000 -2.688000 0.000000 -0.672000 -0.756000 3.528000 0.000000 -0.192000 -0.216000 1.008000 0.000000 -0.064000 -0.072000 0.336000 0.000000 -0.000000 0.000000 0.000000 -0.300000 0.000001 0.000000 0.000000 0.450001 -0.000001 0.000000 0.000000 -0.450001 0.000000 0.000000 0.000000 2.700000 0.512000 0.576000 -2.688000 0.000000 -0.672000 -0.756000 3.528000 0.000000 -0.192000 -0.216000 1.008000 0.000000 -0.064000 -0.072000 0.336000 0.000000 -0.512000 2.112000 0.000000 -1.600000 0.672000 -2.772000 0.000000 2.100000 0.192000 -0.792000 0.000000 0.600000 0.064000 -0.264000 0.000000 0.200000 -0.000000 0.000000 0.000000 -0.300000 0.000001 0.000000 0.000000 0.450001 -0.000001 0.000000 0.000000 -0.450001 0.000000 0.000000 0.000000 2.700000 0.407999 -1.682999 0.000000 1.275000 -1.295998 5.345997 0.000000 -4.049999 1.367999 -5.642999 0.000000 4.275000 0.000000 0.000000 0.000000 0.000000 -0.407999 -0.459002 2.142000 0.000000 1.295998 1.458003 -6.804000 0.000000 -1.367999 -1.539001 7.182000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.225000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.407999 0.459002 -2.142000 0.000000 -1.295998 -1.458003 6.804000 0.000000 1.367999 1.539001 -7.182000 0.000000 0.000000 0.000000 0.000000 0.000000 0.407999 -1.682999 0.000000 1.275000 -1.295998 5.345997 0.000000 -4.049999 1.367999 -5.642999 0.000000 4.275000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.225000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.407999 1.682999 0.000000 -1.275000 1.295998 -5.345997 0.000000 4.049999 -1.367999 5.642999 0.000000 -4.275000 0.000000 0.000000 0.000000 0.000000 0.407999 0.459002 -2.142000 0.000000 -1.295998 -1.458003 6.804000 0.000000 1.367999 1.539001 -7.182000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.225000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.407999 -0.459002 2.142000 0.000000 1.295998 1.458003 -6.804000 0.000000 -1.367999 -1.539001 7.182000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.407999 1.682999 0.000000 -1.275000 1.295998 -5.345997 0.000000 4.049999 -1.367999 5.642999 0.000000 -4.275000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -0.075000 0.000000 0.000000 0.000000 0.225000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
I think your problem is these two lines of code in your displaypatch function:
Here you pass 0 as the current vertex pointer (the NULL pointer) then you attempt to draw the vertices here. Of course glDrawArrays will segfault. You should probably pass the address of the array you loaded your data into. I don't know enough about VBOs to help, but hopefully that will help some.
glVertexPointer(3,GL_FLOAT,0,0 );glDrawArrays(GL_TRIANGLES,0,vCount);Here you pass 0 as the current vertex pointer (the NULL pointer) then you attempt to draw the vertices here. Of course glDrawArrays will segfault. You should probably pass the address of the array you loaded your data into. I don't know enough about VBOs to help, but hopefully that will help some.
Quote:
Original post by joachim_n
If VBOs are enabled, the address becomes an offset. ;)
Ah, sorry nevermind then :|
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement