In game image memset function not working...

Started by
48 comments, last by L. Spiro 5 years, 4 months ago

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.

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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

 

 

.:vinterberg:.

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);

 

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?

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?

.:vinterberg:.

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?

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.

20 hours ago, vinterberg said:

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

This is incorrect. Pitch is already in bytes, as per the docs I linked on page 1:

https://docs.microsoft.com/en-us/windows/desktop/direct3d9/d3dlocked-rect

Quote

Pitch: Number of bytes in one row of the surface.

 

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.

This topic is closed to new replies.

Advertisement