Jump to content
  • Advertisement
Sign in to follow this  
Shadowwoelf

OpenGL Texture loader?

This topic is 3585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering what is the most simple texture loader to implement/use? On a side note I was wondering how come OpenGL doesn't come with a standard texture loader?

Share this post


Link to post
Share on other sites
Advertisement
I like DevIL.

Khronos maintains OpenGL and a few other open spec solutions.
GL itself is an API for dealing with the GPU. It doesn't bother with file formats.
Also, there are so many file loaders that it's not worth making another one by Khronos.

Share this post


Link to post
Share on other sites
Besides glTexImage2D and glTexSubImage2D are designed to be fun for programmers to figure out, with their random non-sensical error messages and twisted reasons for failing... Who said Khronos don't have a sense of humour!

Share this post


Link to post
Share on other sites
Well by simple I mean simple to install/use. Devil doesn't have enough documentations for me to get started with it.

edit: Well Opengl is a graphic library so I was just wondering why a graphics library doesn't at least come with a standard loader...

Share this post


Link to post
Share on other sites
Quote:
Original post by Shadowwoelf
edit: Well Opengl is a graphic library so I was just wondering why a graphics library doesn't at least come with a standard loader...


They could have added it to GLU but like I said, there are so many other libraries that the cost of paying people to create it and maintain is a big waste.
If it was available, most companies would not even use it.

Think of GL as a stand alone library for only talking to your GPU.

Share this post


Link to post
Share on other sites
The best texture loader that I've seen so far is NeHe's IPicture code (Win32 dependent).

Basically he has a single function that will load a wide variety of formats and even images from the web. It supports transparency as well. It's definitely worth taking a look at; I used it all the time over other gfx libs due to how simple it is. Assuming you are developing for the Win32 platform only, it might be your best bet for now.

Share this post


Link to post
Share on other sites
What are you using? SDL, Win32? OSX? A bit more info is really needed.

If you use SDL, SDL will load many image formats and you can just dump that data into GL. If you are learning OpenGL then get the "Beginning OpenGL game Programming book" they cover .bmp and .tga files and really are simple to load once you work through the code.

Share this post


Link to post
Share on other sites
DevIL is officially driving me crazy. I cannot figure out how to get it to run.

I followed the websites instructions to install and I "think" I did everything right. (Only thing that I couldn't do was add the debug.lib since it wasn't in the zip file)

Then I used this to try and somehow make a patch work of whats going on. Wiki example

And I get 11 linking errors.


Linking...
GameState.obj : error LNK2019: unresolved external symbol __imp__ilDeleteImages@8 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilGetInteger@4 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilGetData@0 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilConvertImage@8 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilLoadImage@4 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilBindImage@4 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilGenImages@8 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp__ilInit@0 referenced in function "public: __thiscall WORLD_STATE::WORLD_STATE(void)" (??0WORLD_STATE@@QAE@XZ)
GameState.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator<class baseGameState *,class std::allocator<class baseGameState *> >::_Vector_const_iterator<class baseGameState *,class std::allocator<class baseGameState *> >(class baseGameState * *,class std::_Container_base_secure const *)" (??0?$_Vector_const_iterator@PAVbaseGameState@@V?$allocator@PAVbaseGameState@@@std@@@std@@QAE@PAPAVbaseGameState@@PBV_Container_base_secure@1@@Z)
Lesson33.obj : error LNK2001: unresolved external symbol __imp___CrtDbgReportW
.\Debug/Lesson33.exe : fatal error LNK1120: 9 unresolved externals
Build log was saved at "file://d:\Projects\Lesson33\Debug\BuildLog.htm"
Lesson33 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Headers

#include <windows.h> // Header File For Windows
#include <stdio.h> // Header File For Standard Input/Output
#include <IL/il.h>
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include "texture.h" // Header File Containing Our Texture Structure ( NEW )
#include "GameState.h"
#include "globalvariables.h"
#include <vector>
#include <string>




Actually using the library

WORLD_STATE::WORLD_STATE(){
ilInit();
ilGenImages(1, &texid);
ilBindImage(texid);
success = ilLoadImage("town01_a.tga");
if (success)
{
success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
if (!success)
{
/* Error occured */
done=true;
}
glGenTextures(1, &#8465;);
glBindTexture(GL_TEXTURE_2D, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData());
ilDeleteImages(1, &texid);
}
}



These three variables are declared private

ILuint texid;
ILboolean success;
GLuint image;

On a side note Wiki example does not actually bind any texture to the quad being drawn which is odd.

So what am I doing wrong?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!