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.


Snouty

Member Since 17 Mar 2012
Offline Last Active Mar 31 2012 11:27 AM

Topics I've Started

Problems with loading a jpg-image...

23 March 2012 - 08:14 AM

Hey guys,

last week, I had the problem, that I could not load jpeg-Files with devil (and with no other library). This problem is solved, but today I run into a new problem.
I have 2 jpg-files tex1.jpg and tex2.jpg

When I want to load tex1.jpg, everything is fine. But when ! want to load the second texture, I get an assertion fault. I checked the textures, both are ok, in the right folder and I could open them with GIMP without any problems.
I also tried to load a different texture (tex3.jpg) which is twice as large as tex2.jpg and everything was fine. So my problem is: I dont know why, but I can load several jpg-files, without any problems. But when I try to load tex2.jpg, everything crashes. Are there differences between jpg-files? Even when they are created by the same program (i.e. GIMP)?

I tried different libraries as DevIL, SOIL, etc.

Everytime I get the same error.

Does anybody know what that might be?


Thanks a lot Posted Image

Here is a piece of code:

bool loadTexture(GLuint* tex_id, const char* filename){
// load image file as opengl texture
cout << "Texture " << filename;
*tex_id = SOIL_load_OGL_texture(filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
if(*tex_id == 0){
  cout <<  " could not be loaded!" << endl;
  return false;
}
else{
  cout << "...ok" << endl;
}
....
return true;
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
// init display mode:
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
center();
glutInitWindowSize (mainw_w, mainw_h);
glutInitWindowPosition (mainw_x, mainw_y);
glutCreateWindow(mainw_title);
// init OpenGL
initGL();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);

glutMainLoop();
return 0;
}

DevIL - Problems with loading a jpg-image

17 March 2012 - 05:43 PM

Hey,

I have problems to load an jpg-image. I googled for a while and in general, using DevIL seems to be a good way to do this. But unfortunately, everytime I call ilLoadImage("texture.jpg"), IL reports the error 1291 (IL_INVALID_EXTENSION) and I just don't know why. Does anybody know, where the problem in my code is? Now, I'm really at a loss and would be grateful for any hint.

Thanks a lot for your help Posted Image


#include "stdafx.h"
#include <cmath>
#include <iostream>
#include <fstream>
#include <string>
#include <assert.h>
#include "Terrain.h"
#include <GL\SDL.h>
#include <SDL_image.h>
#include <GL\glext.h>
#include <IL\il.h>
#include <IL\ilu.h>
#include <IL\ilut.h>
using namespace std;

//#define NO_VBOS			// If Defined, VBOs Will Be Forced Off

bool g_vbo_supp = false;		  // ARB_vertex_buffer_object support
bool g_multitex_supp = false;		 // ARB_multitexture support
bool g_texcombine_supp = false;		 // ARB_texture_env_combine support

//global variables for the heightmap
...
GLuint map_tex;
...

ILuint maptex_id;


void initGL(void){
	 LoadGLTextures();
...
}

int LoadGLTextures(){
	 ilGenImages(1, &maptex_id);
	 ilBindImage(maptex_id);
	 if(!ilLoadImage("texture.jpg")){
	   	 ilDeleteImages(1, &maptex_id);
	   	 ILenum error = ilGetError();
	   	 std::cout << "Image load failed - IL reports error: " << error << " - " << iluErrorString(error) << std::endl;
	   	 return false;
	 }
	 else{
	 ...
	 }// Return Success
}

int main(int argc, char** argv)
{
	 ilutRenderer(ILUT_OPENGL);
	 ilInit();
	 iluInit();
	 ilutInit();
	 ilutRenderer(ILUT_OPENGL);
	 glutInit(&argc, argv);
	 // init display mode:
	 glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	 glutInitWindowSize (mainw_w, mainw_h);
	 glutInitWindowPosition (mainw_x, mainw_y);
	 glutCreateWindow (mainw_title);
	 // init OpenGL
	 initGL();
	 glutDisplayFunc(display);
	 glutReshapeFunc(reshape);
	 glutKeyboardFunc(keyboard);

	 glutMainLoop();
	 //Quit SDL
	 SDL_Quit();
	 return 0;
}

PARTNERS