Jump to content
  • Advertisement

Archived

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

markdezonia

LockRect problem

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

debuger says col-blue value CXX0030: Error : expression cannot be evaluated col-green value CXX0030: Error : expression cannot be evaluated col-red value CXX0030: Error : expression cannot be evaluated col-alpha value CXX0030: Error : expression cannot be evaluated p_width value 256 xx value 0 why am I geting an error in struct col? Is there someting wrong with this code? Any help Would be greatly appreciated. I have never used LockRect before if it's something silly. D3DSURFACE_DESC surf_desc; D3DLOCKED_RECT rect; hr=TEXTURE->GetLevelDesc(0,&surf_desc); if(FAILED(hr)){ FatalError("Error getting surface description"); } hr=TEXTURE->LockRect(0,&rect,NULL,D3DLOCK_NOSYSLOCK); if(FAILED(hr)){ FatalError("Error locking texture"); } struct my_colour{ unsigned char blue; unsigned char green; unsigned char red; unsigned char alpha; } *col; DWORD xx,yy; DWORD pitch_diff; DWORD p_width= surf_desc.Width; DWORD p_height = surf_desc.Height; D3DLOCKED_RECT *p_rect; pitch_diff=(p_rect->Pitch/4)- p_width ; col=(my_colour *)p_rect->pBits; for(yy=0;yy < p_height;yy++){ for(xx=0;xx < p_width; xx++){ col->red=255; col++; } col+=pitch_diff; } TEXTURE->UnlockRect(0); [edited by - markdezonia on September 15, 2002 1:41:05 PM]

Share this post


Link to post
Share on other sites
Advertisement
You are calling LockRect() with the "rect" variable, and then later in the code you create a new D3DLOCKED_RECT pointer named p_rect.

p_rect is never filled in via LockRect() so when you access it in the line
col=(my_colour *)p_rect->pBits;
you are getting garbage memory.

Keep in mind that memory addresses in the 0xC000000 through 0xFFFFFFFF range are reserved by Windows. So whenever you see that error message "Variable Name value C00000000: Error : expression cannot be evaluated" then you have not assinged the pointer correctly, or have not allocated memory for the pointer.

DLains

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!