Textures and a Camera (and Newb Qs)

Hey guys,

Im a brand new user in this world of OpenGl coding with a basic background in java and a bit of c++.

My project deals with viewing 1000+(though I’m only going to start with 3) textures arranged one on top of the other.

I want to use the camera to scroll from the top of this virtual stack to the bottom with user input.

I’ve tried to sift through the muck of the internet in an effort to find some valuable information on the topic of texture uploading and display, but I feel like I’m looking at extremely outdated sites that are confusing to understand.

I’m having a hard time figuring out how to upload display the 3 .raw textures I made in photoshop and it’s the problem i’d like to tackle first. Could one of you perhaps guide me in a particular direction so I can figure out how to go about doing this?

A rough outline :

  • at loading time : read .raw file, bind the texture id integer with glBindTexture, upload to texture with glTexture2D call
  • at runtime : glTranslate around your list of textured quads
    You may start with the NeHe tutorials, old but still useful for starters :
    Try to download the GLUT / SDL based samples. Or even better, the JoGL base code, as you are more confident in java.

Then to deal efficiently with a big number of textures, you will have to use async PBO etc, but that will come later.

Don’t hesitate to post more precise questions.

Just some advice from another newb:
Working with AVI’s I’ve found sub-texture copies to be fastest and heard others saying the same, though that may be an outdated idea now. True with PBO’s??

invoke glTexSubImage2D, ;replage a region of existing tex w/bmp in sys ram
0,;LOD 0=base
1,;y ;dunno : 0 effects whole img w/border color
esi ; pointer to frame-data

;Display VBO routine

The NeHe Tutorial in the glut form is only valid for .tga images I believe.

Is there a preferred image format for taking up less space in memory? The textures I’m going to be manipulating may be as large as 1024x768.

I suppose the biggest problem I have with learning to manipulate textures is that while learning about making simple colored Polygons it was very straightforward, and while you read about manipulating textures all this other code is thrown in a rarely explained. (though a lot of that code disappeared when I started to look at the glut version[thanks for that])

Now unless it doesn’t matter, something tells me that .tga isn’t the most efficient picture format to use. So what would I be looking at doing to change the input format of the textures? (Right now all the pictures I have are .raw) The glut version of lesson 6 has quite a bit of header and .cpp code for dealing with a .tga .

Hey wingo, don’t put the cart before the horse :slight_smile:

Whatever the format, it is not very important. DXTC precompressed texture will take fewer disk space/memory/VRAM, but at the expense of some quality loss.

You should first make it work, then make it work faster.

And anyway, you will need some sort of “current texture pool” : no need to have 1000 texture in memory at the same time. You should be able to predict the 20 most probable textures that are needed (or will be soon) and load only those in the videocard.

Otherwise, worst case would be 10241024RGBA*1000 = 4 Gigs !

“almost all programming can be viewed as an exercise in caching”

Well, i’ve finally started to sit down and work on this thing again, and i’ve confronted an issue yielding the following errors:(and one warning)

warning C4244: ‘argument’ : conversion from ‘unsigned int’ to ‘GLfloat’, possible loss of data
error C3861: ‘malloc’: identifier not found
error C3861: ‘free’: identifier not found

I’m simply trying to get the NeHe (Glut version) lesson06 to compile in my MSVS. I added the lesson06 files into my project and tried to compile. I received an error saying that i needed to include mem.h (one of the .cpp files used it)

I found mem.h via google and no i get the above 2 errors and warning. Did I perhaps use the wrong mem.h? Im posting this here because searching the error on google didn’t help out as much as it usually does.

malloc is used here:

unsigned char *tgaAllocMem ( tgaHeader_t info )
unsigned char *block;

block = (unsigned char*) malloc ( info.bytes );

if ( block == NULL )
return 0;

memset ( block, 0x00, info.bytes );

return block;

and free is used here:

void tgaFree ( image_t *p )
if ( p->data != NULL )
free ( p->data );

Any help would be greatly appreciated.

Try including <stdlib.h>

Sorry for not replying to you before -Nico-, but that was exactly my problem >.<!

I’ve also got my camera program working with the textures :D!

So far i’m using 3 but i’ll start to expand that soon.

However, i’ve got one more question. Im not sure how to phrase this properly, so i’ll describe it.

Say i’ve got a cube. Each side is a different color.

I want to map some buttons on my keyboard to view each side of the cube.

Is there an OpenGL function that allows me to enter coordinates as parameters that will end up displaying my environment from that plane?

You guys have been a huge help to me, thanks so much for all of this.