medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 94c05bf59708e8a7bafcf9f92818e635a1af45b7
parent 65f715c3dafd919c64185a9a49711b9424c19b37
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu Aug 13 20:59:12 +0200

Check if stbi_load fails

Diffstat:
heightmap.cc | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/heightmap.cc b/heightmap.cc @@ -1,4 +1,5 @@ #include <stdio.h> +#include <err.h> #include <string> @@ -177,9 +178,12 @@ void Heightmap::init() { } void Heightmap::load( const std::string & image, const int ox, const int oy ) { - printf( "%s offset by %dx%d\n", image.c_str(), ox, oy ); pixels = stbi_load( image.c_str(), &w, &h, nullptr, 1 ); + if( !pixels ) { + err( 1, "stbi_load failed (%s)", stbi_failure_reason() ); + } + // printf( "begin lit calculations\n" ); float * const lit = new GLfloat[ w * h ]; @@ -223,7 +227,6 @@ void Heightmap::load( const std::string & image, const int ox, const int oy ) { // // printf( "sending data to gpu\n" ); - GLfloat * const vertices = new GLfloat[ w * h * 3 ]; GLfloat * const normals = new GLfloat[ w * h * 3 ]; GLuint * const indices = new GLuint[ w * h * 6 ];