Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Tweener

Member Since 11 Jan 2012
Offline Last Active Jan 26 2012 07:32 AM

Posts I've Made

In Topic: a little help with tutorial 7 and SOIL

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;
	break;
  
   case 1:
	SOIL_flags = 16;
	mag_param = GL_LINEAR;
	min_param = GL_LINEAR;
	break;
  
   case 2:
	SOIL_flags = 16 | 2;   // SOIL_FLAG_INVERT_Y | SOIL_FLAG_MIPMAPS value
	mag_param = GL_LINEAR;
	min_param = GL_LINEAR_MIPMAP_NEAREST;
	break;
  
   default:
	return false;
  }

  texture[i]=SOIL_load_OGL_texture (
   "Data/Crate.bmp",
   SOIL_LOAD_AUTO,
   SOIL_CREATE_NEW_ID,
   SOIL_flags);
  
  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

PARTNERS