Results 1 to 8 of 8

Thread: Textures and a Camera (and Newb Qs)

  1. #1
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    10

    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?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures and a Camera (and Newb Qs)

    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 :
    http://nehe.gamedev.net/data/lessons....asp?lesson=06
    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.

  3. #3
    Junior Member Newbie fldz's Avatar
    Join Date
    Mar 2007
    Posts
    11

    Re: Textures and a Camera (and Newb Qs)

    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
    GL_TEXTURE_2D,\;
    0,\;LOD 0=base
    0,\;x
    1,\;y ;dunno : 0 effects whole img w/border color
    psi.dwFrameRight,\;width
    psi.dwFrameBottom,\;height
    GL_BGR_EXT,\;
    GL_UNSIGNED_BYTE,\;
    esi ; pointer to frame-data

    ;Display VBO routine

  4. #4
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    10

    Re: Textures and a Camera (and Newb Qs)

    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 .

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures and a Camera (and Newb Qs)

    Hey wingo, don't put the cart before the horse

    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 1024*1024*RGBA*1000 = 4 Gigs !


    "almost all programming can be viewed as an exercise in caching"




  6. #6
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    10

    Re: Textures and a Camera (and Newb Qs)

    Well, i've finally started to sit down and work on this thing again, and i've confronted an issue yielding the following errorsand 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.

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Textures and a Camera (and Newb Qs)

    Try including <stdlib.h>

  8. #8
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    10

    Re: Textures and a Camera (and Newb Qs)

    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 !

    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.

Similar Threads

  1. camera and textures
    By nib in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-21-2008, 07:13 PM
  2. newb - where to begin
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-15-2005, 01:49 AM
  3. opengl newb
    By ESBrennan21 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-17-2004, 03:34 PM
  4. Absolute Newb
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-05-2003, 09:13 AM
  5. Newb
    By Nial in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-26-2002, 02:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean