Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Best arrangement of texture data...

SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
OK, I'm looking to streamline my GL texturing setup. Before I had given each object a texture, but that didn't allow for more than one texture per object, a pain in the butt. I now modified my triangle struct to hold the texture name, but GL references textures by number. How can I do this effectivly without killing frames?
[code]
typedef struct tagTRIANGLE
{
char TexName[16];
VERTEX Vertex[3];
} TRIANGLE;
[/code]
In the end, I may change the "TexName" variable to a "char *const" for emmory optimizations, and the use of different length texture filenames. Anyways, any ideas here?

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • gautamgautam Member Posts: 642
    : OK, I'm looking to streamline my GL texturing setup. Before I had given each object a texture, but that didn't allow for more than one texture per object, a pain in the butt. I now modified my triangle struct to hold the texture name, but GL references textures by number. How can I do this effectivly without killing frames?
    : [code]
    : typedef struct tagTRIANGLE
    : {
    : char TexName[16];
    : VERTEX Vertex[3];
    : } TRIANGLE;
    : [/code]
    : In the end, I may change the "TexName" variable to a "char *const" for emmory optimizations, and the use of different length texture filenames. Anyways, any ideas here?
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :

    Hi,

    Dont do this because then every call to TRIANGLE would make you open a char array of 16. Keep the name and object seperate and vertex seperate so that multiple copies of texture names will not be created. I am not sure here, but STL maps might be of some use ?

    Regarding the optimization, are you using vertex arrays to speed up performance when rendering large amount of data ? Also are you prioritizing textures that will be used very often using glPrioritizeTextures and are you by any chance using glBitmap(try not to).
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : Hi,
    :
    : Dont do this because then every call to TRIANGLE would make you open a char array of 16. Keep the name and object seperate and vertex seperate so that multiple copies of texture names will not be created. I am not sure here, but STL maps might be of some use ?
    :
    : Regarding the optimization, are you using vertex arrays to speed up performance when rendering large amount of data ? Also are you prioritizing textures that will be used very often using glPrioritizeTextures and are you by any chance using glBitmap(try not to).
    :
    Not using glBitmap. If I don't use a char array, how would I identify the texture? This is what is driving me fraggin' nuts. I have to identify a texture to GL with an unsigned integer, but the texture may be loaded in a different order, so a list would do no good. What can I do here?

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • gautamgautam Member Posts: 642
    Not a very elegant solution but your could make use of the enum keyword here to identify the textures ?

    [code]
    typedef enum {
    TEXTURE_1
    TEXTURE_2
    ...
    ...
    } Something;
    [/code]

    Secondly to keep away from duplicating char arrays, this is what you could do

    [code]
    typedef struct tagTEXTURES{
    char name[16];
    GLuint texture;
    } TEXTURES;

    typedef struct tagTRIANGLES {
    VERTEX Vertex[3];
    } TRIANGLES;
    [/code]

    Now you have 2 seperate structs to keep the vertex coordinates and textures. So call the right TEXTURE_n when you need to bind a texture to the triangle.




    : : Hi,
    : :
    : : Dont do this because then every call to TRIANGLE would make you open a char array of 16. Keep the name and object seperate and vertex seperate so that multiple copies of texture names will not be created. I am not sure here, but STL maps might be of some use ?
    : :
    : : Regarding the optimization, are you using vertex arrays to speed up performance when rendering large amount of data ? Also are you prioritizing textures that will be used very often using glPrioritizeTextures and are you by any chance using glBitmap(try not to).
    : :
    : Not using glBitmap. If I don't use a char array, how would I identify the texture? This is what is driving me fraggin' nuts. I have to identify a texture to GL with an unsigned integer, but the texture may be loaded in a different order, so a list would do no good. What can I do here?
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

Sign In or Register to comment.