Note that there are some explanatory texts on larger screens.

plurals
  1. POSegmentation fault driving me insane
    primarykey
    data
    text
    <p>It's a particle system I'm using. I wanted to make a cube out of particles but it now seems to be getting seg faults though it worked before. I am guessing it's the array but I cannot after 2 days of looking figure out the problem. GDB has been no help.</p> <pre><code>#include "particles.h" using namespace std; GLfloat texture1[10]; particle parts[50][50][50]; GLfloat angle = 1.0; particles::particles() { addTextures(); cube(); } particles::particles(int O) { addTextures(); cube(); } void particles::addTextures() { texture1[0] = LoadTextureRAW("star_mask.bmp",256,256); //load texture texture1[1] = LoadTextureRAW("star.bmp",256,256); } void particles::cube() { // for(int i =0; i&lt;124999; i++) // { // parts[i] = particle(1,1,1,1,1,1,1); // } float x=-5; float y=-5; float z=-5; for(int i =0 ; i &lt;49 ;i++) { for(int k =0 ; k &lt;49 ;k++) { for(int j =0 ; j &lt;49 ;j++) { parts[i][k][j] = particle(i*0.01,k*0.01,j*0.01,1,1,1,0.09); } } } } GLuint particles::LoadTextureRAW( const char * filename, int width, int height ) { GLuint texture; unsigned char * data; FILE * file; file = fopen( filename, "rb" ); if ( file == NULL ) return 0; data = (unsigned char *)malloc( width * height * 3 ); fread( data, width * height * 3, 1, file ); fclose( file ); glGenTextures(1, &amp;texture ); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data); free( data ); return texture; } void particles::FreeTexture( GLuint texture ) { glDeleteTextures( 1, &amp;texture ); } GLuint particles::LoadTextureRAW( const char * filename, int width, int height); void particles::FreeTexture( GLuint texturez ); void particles::square (void) { glBindTexture( GL_TEXTURE_2D, texture1[0] ); glBegin (GL_QUADS); glTexCoord2d(0.0,0.0); glVertex2d(-1.0,-1.0); glTexCoord2d(1.0,0.0); glVertex2d(1.0,-1.0); glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0); glTexCoord2d(0.0,1.0); glVertex2d(-1.0,1.0); glEnd(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload