Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


IPicture Problems

This topic is 5261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I run my program I get a fatal error (and naturally, it crashes). It compiles just fine. When I debug I find that the program has its problem at the glBindTexture(GL_TEXTURE_2D, texid); segment at the end. The error I get is "First-chance exception in Nexus.exe: 0xC0000005: Access Violation." I don''t know why this isn''t working; I have an image in the images folder of my program called test.bmp. This is the code I use to call the Ipicture functions: GLuint *test; BuildTexture("Images/test.bmp", *test); As mentioned before, it compiles with no errors but crashes in the BuildTexture(); function. Any help?

Share this post

Link to post
Share on other sites
GLuint *test;
BuildTexture("Images/test.bmp", *test);

You are deferencing an unitialised pointer.

I presume the fn() definition is

void BuildTexture(char *image, int *id);

If this is the case, you need to pass in the address of the integer like so

int IdThatWillBeSetByFunction;
BuildTexture("Images/test.bmp", &IdThatWillBeSetByFunction);

------------ Your example says --------
Create a pointer called "test" which "points to" a value of "unkown". And give that to the function

Hope this helps a little.. for a better understanding see the CFaq by Steve Summit.. Its explained very well in there.

Share this post

Link to post
Share on other sites

That helps, thanks, but the function is

int BuildTexture(char *szPathName, GLuint &texid).

I fixed it...I just declare GLuint test;, then I simply pass it off as test. No & or * operators . *hits self on head*

Thanks again.

Share this post

Link to post
Share on other sites
int BuildTexture(char *szPathName, GLuint &texid)

If that is the definition it must be C++, C doesnt support the reference declaration.

Note that,

int BuildTexture(char *szPathName, GLuint &texid) -- reference


int BuildTexture(char *szPathName, GLuint *texid) -- pointer

are *very* similar.

Both internally pass a pointer to the variable texid, but the reference declaration - automatically dereferences the variable in the funtion body thus eliminating the need for dereferences in the code.


int x(int &y) int x(int &*y)
{ {
y = 10; *y = 10;
} }

int x(int *y) int x(int **y)
{ {
*y = 10; **y = 10;
} }

Both work the same - albeit some subtle semantics. I suggest you read up on references and pointers and make sure you thoroughly understand them.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!