API Internal ID's, and my ID's

Jones
Unregistered
 
Post: #1
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!
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #2
You can't have 2 variables with the same name and different type. That's just asking for trouble!

"When you dream, there are no rules..."
Quote this message in a reply
Jones
Unregistered
 
Post: #3
Taxxodium Wrote: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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
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
Quote this message in a reply
Jones
Unregistered
 
Post: #5
OneSadCookie Wrote: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!
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #6
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:

Code:
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?
Quote this message in a reply
Jones
Unregistered
 
Post: #7
ThemsAllTook Wrote: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:

Code:
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. Grin
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Internal Error on XCode softengg 1 2,652 Jan 23, 2008 11:40 PM
Last Post: OneSadCookie
  Engine Internal Fundamental Design Jones 6 3,254 Nov 1, 2006 07:37 AM
Last Post: Jones