looking for textures in OpenGL tutorial (2d or 3d)

Hello, I'm looking for a good tutorial on how to make a texture and attach it to an object WITHOUT using glaux or someone else's header (this is mainly targeted at VideoTutorialsRock). The file type does NOT have to be Bitmap, but if it's the easiest, that would change things. Any help is appreciated.
I could dig up my old TGA loader code... but you just said that's not what you want.
Anyway, I suggest you go with TGA. There are several types for TGA's, the easiest being the uncompressed BGR 24-bit and BGRA 32-bit (the latter has transparency "Alpha" which will come in handy).

http://local.wasp.uwa.edu.au/~pbourke/dataformats/tga/

After you load the file in an std::vector<char> you can feed it to gluBuild2DMipmaps() or whatever.

http://www.opengl.org/sdk/docs/man/xhtml/gluBuild2DMipmaps.xml

Edit: also, http://nehe.gamedev.net/tutorial/lessons_06__10/17010/
Last edited on
Thanks, but I'm looking for something that I could download to see if it works THEN try to understand it. NeHe includes glaux, which is outdated and filled with issues, according to many websites. Then the second link doesn't work... And plus I've already tried something else and ran into even more issues. Thanks anyways.
closed account (o1vk4iN6)
It works by loading raw pixel data. Really the only issue is reading the header file of the images and setting the appropriate parameters for glTexImage2D(). It depends on the image format, png would need to be decompressed for example so using a raw pixel format would easiest (as suggest TGA, BMP as well). So it would be easier on your to use one of those. Although BMP is quite dynamic and thus has a lot of options for raw pixel formats (from what i can remember). You'd be better off creating your own image format and only support specific pixel formats, than creating a tool which would take image files and convert to your image format along with the pixels you want (depending on your target hardware). Either way you'd be better off using a library to load images to get the raw pixels, either for the conversion tool or your opengl program.
Last edited on
It's easier DRAWING an image in something like paint and saving it in an already existing format than it is defining the color of each pixel in Notepad or something.
As for using libraries, I REALLY would like to make most of what I make by myself, as I would like to be able to stand alone, not have libraries take the shortcuts, and I like being in FULL control (which is one of the reasons I started to learn x86 Assembly) (I gave up pretty quickly).
You can use BMP image format. it has very esay structure. (in uncompressed format)
search the google "BMP specification".
As for using libraries, I REALLY would like to make most of what I make by myself, as I would like to be able to stand alone, not have libraries take the shortcuts, and I like being in FULL control


Thanks, but I'm looking for something that I could download to see if it works THEN try to understand it.


Make up your mind, please. The TGA specification "works", you just need to write a loader for the format, which puts the RGB/RGBA data into an array, which OpenGL will then be able to use, to create a texture.

I like being in FULL control (which is one of the reasons I started to learn x86 Assembly) (I gave up pretty quickly).

When you're ready to try again, check this PDF: http://www.drpaulcarter.com/pcasm/
Wow, didn't know there was actually ANOTHER tutorial, Thanks. I also don't really know how loaders work (and I only bothered to learn fstream in file input/output), so writing my own isn't going to be a snap.

Make up your mind, please

I do not want to download a library (.lib file), because I don't know how to read/understand them (I haave a horrible time understanding headers for some reason, too). I'd much rather download some code, implement it into my make THEN understand it and try to write my own.

However, i have not yet found a piece of code that works, so I have been forced to use SOIL.
I found my TGA loader. It can be compiled with Dev-C++ 5.2.0.2 MinGW32. Be sure that is what you use, and all you have to do is Build the project for a test drive.

There's really not much more I can do for you, and you fail with this too, well you need more time, to put it gently.

http://www.filefactory.com/file/1esdhote1xuh/n/Texture_zip

Edit: new link.
Last edited on
Thanks, works perfectly.
The Texture.hpp file is the essence.
In Texture_TEST.cpp, lines 96 and 112, you'll see how the class is used.

It's supposed be dead easy to just use. Good luck.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "Texture.hpp"
using namespace dog;

// {

Texture t1, t2, t3;

t1.LOAD("img1.tga");
t2.LOAD("img2.tga");
t3.LOAD("background.tga");

t2.bind(); // tell OpenGL we want to use texture t2 for now

// } 
I know what a class and struct is, and I've used them before.
Topic archived. No new replies allowed.