Jump to content

  • Log In with Google      Sign In   
  • Create Account


We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

a little help with tutorial 7 and SOIL

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Enerjak   Members   -  Reputation: 235


Posted 05 January 2012 - 05:30 AM

Hmm, im having a bit of a problem getting tutorial 7 since it uses gluax rather then SOIL and there's a few things that need the teture width/height and data like this line:

glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

now of course SOIL doesn't seem to have a way of getting the width/height of the texture so as to allow the creation of this type of texture. Maybe im missing something i don't know.


#2 Sauzer89   Members   -  Reputation: 100


Posted 11 January 2012 - 03:55 AM

I have same problems with lesson 7 and SOIL...

have you solved?

#3 swiftcoder   Senior Moderators   -  Reputation: 10396


Posted 11 January 2012 - 08:15 AM

Are you following the instructions given in the Lesson 6 Update? As long as you use SOIL_load_OGL_texture(), you shouldn't be calling at glTexImage2D() all - SOIL does it for you.

(you can instead call SOIL_load_image, to load the image data into a temporary buffer, and then manually glTexImage2D() it into OpenGL, but that's a lot of extra work, which you don't need to do here)

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]

#4 Tweener   Members   -  Reputation: 100


Posted 11 January 2012 - 07:50 PM

This is what I've come up with using MinGW:

First remove #include <gl\glaux.h> and add #include "SOIL.h".
#include <stdio.h> can also be removed.
Remove the bmp loading function as in Lesson 06 then change LoadGLTextures() in the following manner
(different code posted 1-14-12 for a more flexible framework)
int LoadGLTextures()
unsigned int SOIL_flags;
GLint mag_param;
GLint min_param;

for (int i=0; i<3; i++) {

  switch(i) {
   case 0:
	/* SOIL.h uses enum instead of #define for named flag values; easiest just to look them up */
	SOIL_flags = 16;	// SOIL_FLAG_INVERT_Y value
	mag_param = GL_NEAREST;
	min_param = GL_NEAREST;
   case 1:
	SOIL_flags = 16;
	mag_param = GL_LINEAR;
	min_param = GL_LINEAR;
   case 2:
	SOIL_flags = 16 | 2;   // SOIL_FLAG_INVERT_Y | SOIL_FLAG_MIPMAPS value
	mag_param = GL_LINEAR;
	return false;

  texture[i]=SOIL_load_OGL_texture (
  if (texture[i] == 0)
   return false;

  // Define Texture Parameters
  glBindTexture(GL_TEXTURE_2D, texture[i]);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_param);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_param);


return true;
Also, I have been removing GLvoid from all function parameter lists leaving empty parenthesis as it is evidently not valid C++ to pass a void type as a parameter and MinGW complains.
Finally, the first parameter of CreateGLWindow should be changed from "char* title" to "const char* title".
With SOIL.h and libSOIL.a in the same directory as the lesson7.cpp file, MinGW compiles and links fine using:
g++ -mwindows lesson7.cpp -o lesson7.exe -L. -lSOIL -lopengl32 -lglu32

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.