Jump to content
  • Advertisement

Archived

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

snisarenko

Need Help with Nehe IPicture

This topic is 5190 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

Why is it when I do this:
if ((BuildTexture("test2.bmp", testTexture2.TextureID)==FALSE)&&
(BuildTexture("test3.bmp", testTexture1.TextureID)==FALSE))
{
		// Failure

	MessageBox (HWND_DESKTOP, "Error Loading Texture", "Error", MB_OK | MB_ICONEXCLAMATION);
	return -1;
}
testTexture2 is loaded and displayed properly, but testTexture1 is displayed as a white square But if i do this
    if(BuildTexture("test2.bmp", testTexture2.TextureID)==FALSE) return -1;
if(BuildTexture("test3.bmp", testTexture1.TextureID)==FALSE) return -1;  
Both textures are loaded and displayed correctly Thanx [edited by - snisarenko on March 6, 2004 3:26:57 AM] [edited by - snisarenko on March 6, 2004 3:27:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
as far as logic the only deifrence between the to is the message box":"(its ms propaganda again) muhohahahaha

cant help ya buddy maybe past more code

Share this post


Link to post
Share on other sites
Because in the first case the expression is short circuited, so the second texture is never loaded. The expression A && B can only be true is A is true. If A is false then there is no point in evaluating B, because the expression will be false regardless. So in your code you have:
(BuildTexture("test2.bmp", testTexture2.TextureID)==FALSE)&&
(BuildTexture("test3.bmp", testTexture1.TextureID)==FALSE)

First
(BuildTexture("test2.bmp", testTexture2.TextureID)==FALSE) 

is evaluated. The BuildTexture call succeeds and returns TRUE, which is not equal to FALSE, so the first part of the expression evaluates to FALSE. Your expression now looks like:
(FALSE)&&
(BuildTexture("test3.bmp", testTexture1.TextureID)==FALSE)

The expression can never be true, so the second BuildTexture call is never evaluated.
Similar rules work for A || B. If A is true then the expression is true regardless of B, so B does not need to be evaluated.

In this case your logic is wrong anyway. You are saying ''If both textures fail to load then show an error message, but if only one texture fails to load then continue as normal''. You want to use || instead of &&, so you are saying ''If either texture fails to load, or if both textures fail to load, then show an error message, otherwise continue as normal''.

Enigma

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!