PDA

View Full Version : API Internal ID's, and my ID's


Jones
2006.07.04, 02:30 PM
When I give an API (for example SDL or OpenGL) a name for a surface/texure, like this:

SDL_Surface foo;
GLuint foo;

Would that be different from say... this:

typedef struct {
SDL_Surface foo;
GLuint foo;
} fooTypeStruct;

What I mean is, if I make several fooTypeStructs, would GL or SDL see all the surfs as one, or would they tell the difference between all the foo's?

Thanks!

Taxxodium
2006.07.04, 02:46 PM
You can't have 2 variables with the same name and different type. That's just asking for trouble!

Jones
2006.07.04, 04:18 PM
You can't have 2 variables with the same name and different type. That's just asking for trouble!

I know, but that's not exactly what I meant.

Do OpenGL or SDL (for example) differentiate between variables named the same in different cases of structs?

OneSadCookie
2006.07.04, 06:45 PM
a) this is absolutely nothing to do with OpenGL or SDL
b) you can't have two fields of a struct with the same name

Jones
2006.07.05, 02:53 PM
a) this is absolutely nothing to do with OpenGL or SDL
b) you can't have two fields of a struct with the same name


I must be explaining very poorly, for that is not what I meant. A GLuint is not actually texture data, nor is it a picture. It is an ID with which OpenGL can access corresponding data and sizes, etc. Now, if I have two named the same, even if they are in different cases of a struct, would that compose OpenGL at all?

Thanks!

ThemsAllTook
2006.07.05, 04:07 PM
When you pass a texture ID to an OpenGL function (or any other function), it has no knowledge whatsoever of where that ID came from - all it knows is that there are 32 bits of data on the stack, and it will expect them to represent a texture ID. Variable names in particular are a high-level concept that goes away entirely once your code is compiled.

So, if you're talking about something like this:

struct myStruct {
GLuint textureID;
};

struct myStruct struct1;
struct myStruct struct2;

...then storing unique values in struct1.textureID and struct2.textureID isn't a problem. Each one has its own storage space in memory within the bounds of the storage space for the entire struct. So, given that, and given that functions know nothing about their parameters other than their type and value, I think that should answer your question?

Jones
2006.07.05, 05:37 PM
When you pass a texture ID to an OpenGL function (or any other function), it has no knowledge whatsoever of where that ID came from - all it knows is that there are 32 bits of data on the stack, and it will expect them to represent a texture ID. Variable names in particular are a high-level concept that goes away entirely once your code is compiled.

So, if you're talking about something like this:

struct myStruct {
GLuint textureID;
};

struct myStruct struct1;
struct myStruct struct2;

...then storing unique values in struct1.textureID and struct2.textureID isn't a problem. Each one has its own storage space in memory within the bounds of the storage space for the entire struct. So, given that, and given that functions know nothing about their parameters other than their type and value, I think that should answer your question?

YES! Thank you. :D