Texture loading only happens at init()

This commit is contained in:
Yoz Grahame 2012-11-12 17:48:28 -08:00
parent ee0c614482
commit b774d833e4
2 changed files with 7 additions and 5 deletions

View file

@ -112,7 +112,7 @@ ParticleSystem balls(1000,
#define RENDER_FRAME_MSECS 10 #define RENDER_FRAME_MSECS 10
#define SLEEP 0 #define SLEEP 0
#define NUM_TRIS 10 #define NUM_TRIS 100000
struct { struct {
float vertices[NUM_TRIS * 3]; float vertices[NUM_TRIS * 3];
// float normals [NUM_TRIS * 3]; // float normals [NUM_TRIS * 3];
@ -259,7 +259,10 @@ void initDisplay(void)
void init(void) void init(void)
{ {
int i, j; int i, j;
load_png_as_texture(texture_filename);
printf("Texture loaded.\n");
Audio::init(); Audio::init();
printf( "Audio started.\n" ); printf( "Audio started.\n" );
@ -578,9 +581,7 @@ void display(void)
glTranslatef(location[0], location[1], location[2]); glTranslatef(location[0], location[1], location[2]);
/* Draw Point Sprites */ /* Draw Point Sprites */
load_png_as_texture(texture_filename);
//glActiveTexture(GL_TEXTURE0); //glActiveTexture(GL_TEXTURE0);
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );

View file

@ -34,6 +34,7 @@ int load_png_as_texture(char* filename)
unsigned int width = 1, height = 1; unsigned int width = 1, height = 1;
unsigned error = lodepng::decode(image, width, height, filename); unsigned error = lodepng::decode(image, width, height, filename);
if (error) { if (error) {
std::cout << "Error loading texture" << std::endl;
return (int) error; return (int) error;
} }