Jump to content
  • Advertisement
rjhwinner03

In game image memset function not working...

Recommended Posts

I have already tried the pitch time 64... It gave me only a little chunk of the image that I need to have a full minimap.

Share this post


Link to post
Share on other sites
Advertisement

So you fixed one issue and you have more remaining.  Waiting for updated code.  Or at the very least screenshots of before and after this change.


L. Spiro

Share this post


Link to post
Share on other sites

Pitch * Height * NumBytesPerPixel .... What format is your texture? I think maybe your texture isn't 8bpp...

 

 

Share this post


Link to post
Share on other sites
3 hours ago, vinterberg said:

Pitch * Height * NumBytesPerPixel .... What format is your texture? I think maybe your texture isn't 8bpp...

 

 

He did post this information, and it is 8bpp:

	m_pDevice->CreateTexture(64, 64, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &sightTexture, NULL);

 

Share this post


Link to post
Share on other sites
51 minutes ago, alvaro said:

He did post this information, and it is 8bpp:


	m_pDevice->CreateTexture(64, 64, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &sightTexture, NULL);

 

Is D3D allowed to ignore that if the driver doesn't support 8-bit textures?

Share this post


Link to post
Share on other sites
2 hours ago, alvaro said:

He did post this information, and it is 8bpp:

Ah yes, overlooked that one ^^

.. Do you test LockRect() against D3D_OK, to see if it actually succeeds in locking?

Share this post


Link to post
Share on other sites
8 hours ago, vinterberg said:

.. Do you test LockRect() against D3D_OK, to see if it actually succeeds in locking?

No, I have not...

15 hours ago, vinterberg said:

Pitch * Height * NumBytesPerPixel .... What format is your texture? I think maybe your texture isn't 8bpp...

 

 

Memset(bytes, 0, sRect.Pitch*64 * 8);

Do you mean this?

Share this post


Link to post
Share on other sites
47 minutes ago, rjhwinner03 said:

Memset(bytes, 0, sRect.Pitch*64 * 8);

Do you mean this?

You have the general idea, but no. Think about what memset does:

Quote

Parameters

dest-pointer to the object to fill

ch-fill byte

count-number of bytes to fill

The count parameter is already in bytes. 8bpp commonly means "8 bits per pixel", so that would be 1 byte per pixel. But what we're asking is for you to verify (or have your code deduce) the actual number of bytes per pixel on your texture. D3D itself should be able to tell you this somehow, if I'm not mistaken.

Edited by Oberon_Command

Share this post


Link to post
Share on other sites

https://docs.microsoft.com/en-us/windows/desktop/direct3d9/width-vs--pitch

Furthermore, something I wasn't fully aware of .. according to this page I'm getting the impression that strictly speaking, memsetting the entire area is not something that should be done:

Quote

When accessing surfaces directly, take care to stay within the memory allocated for the dimensions of the surface and stay out of any memory reserved for cache. Additionally, when you lock only a portion of a surface, you must stay within the rectangle you specify when locking the surface. Failing to follow these guidelines will have unpredictable results. 

This page seems to suggest that the use of the extra bytes at the end of rows could be used for any purpose, and writing over them is not ok.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!