In game image memset function not working...

Started by
48 comments, last by L. Spiro 5 years, 4 months ago
16 hours ago, rjhwinner03 said:

All of this stuff worked like a charm in Windows XP through Windows 8... I had no errors... Windows 10 is and has been a big obstacle for me in the past and the present...

Okay...

...and what of the given advice have you tried?  What has changed?  What remains unchanged?  Nothing about your reply proves your code is correct (and if this is exactly the code you had on Windows XP etc. then I can assure you it did not work like a charm—it barely managed to hold together and gave you the false impression it was working, basically out of luck).

Why is everyone guessing whether you still have pitch*pitch?  Did you lock the texture yet (this is not optional)?  Why aren't you helping us help you?

How am I going to make further suggestions until you have replied saying, "I tried this, this is my new code, I get X results"?


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

Advertisement
16 hours ago, Oberon_Command said:

Attach the debugger and put a breakpoint at the line with the memset. What are the contents of sRect?

 

The debugger says: (Directly Quoted)

sRect = {Pitch=128 pBits=0x05bc7000 }

 

The Pitch is equal to 128, and the value pBits is located at 0x05bc7000

 

 

What is the actual size of the texture? How many bits per pixel? And how do you know?

 

44 minutes ago, L. Spiro said:

Why is everyone guessing whether you still have pitch*pitch?  Did you lock the texture yet (this is not optional)

...

 Why aren't you helping us help you?
 

Ok... I will divide this answer into 3 answers.

 

(1) I am still using pitch * pitch in the code because it is essential in the usage of memset for the drawing of the texture which is saved in memory (the minimap texture). This texture is checked every frame to make sure that the player's troops and their view radii are visible on the minimap, allowing for easy viewing, such as games like Age of Empires, Civilization, and Total War do.

(2) I am sorry that I have provided too little information for your, and some other peoples' liking... Just tell me what other information you would need, and I will provide it... After all, this whole project was just based on random techniques (mostly old ones from the late '90s) that seemed to do exactly what I wanted them to.

(3)I do know, actually, that the texture HAS to be locked in order for everything to work correctly, and I just forgot to uncomment it in the main question.  

Here is a few more lines of code: (I am extremely sorry that I forgot to post them in the starting code!)

 


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

 

I did uncomment the locking texture code... I changed that in the first question...

3 minutes ago, rjhwinner03 said:

I am still using pitch * pitch in the code because it is essential

Essential not to do, you mean?  It's pitch * height, not pitch * pitch.

7 minutes ago, rjhwinner03 said:

Just tell me what other information you would need

We can't move on until you prove you took the given advice and correctly implemented it via a code dump.  Just because we gave advice doesn't mean you implemented it, and just because you implemented it doesn't mean it was done correctly.  The only way to be sure of both at once is to see the new code.


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

1 hour ago, L. Spiro said:

Essential not to do, you mean?  It's pitch * height, not pitch * pitch.

No, I mean essential... the image height is 64, and the pitch is 128... 

It may be essential not to do, but that is how it supposed to work. Anyway, it worked in older Windows Versions that could run DX 9.0c.

Yes.  Hence you use pitch * height.  What are you misunderstanding about this math?

The size of a texture in bytes is pitch * height.  Pitch = bytes in a row, height = number of rows.  Those are the 2 separate factors you need to determine how many bytes in a flat 2D texture.  Why are you looking at your error repeatedly and calling it good?


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

10 minutes ago, L. Spiro said:

What are you misunderstanding about this math?

Why are you looking at your error repeatedly and calling it good?
 

(1) The pitch multiplied by the height give a lesser value than the pitch squared... thus giving an image that is not complete.

For some reason, as I have seen, the member values for the 3rd variable in the function are not supposed to be greater than the width or height...

 

Why would I settle for half an image?

 

-rjhwinner03

12 minutes ago, rjhwinner03 said:

 

Why would I settle for half an image?

Because it probably isn't. The pitch is not the width in pixels! It might be, if the hardware surface is one byte per pixel and there's no extra padding added to the end of each row of pixels. But that seems unlikely to me, given that you're getting this crash.

What is the width of the texture, in pixels? Is it 64, or 128?

So, are you going to argue or are you going to see the problem with your math and fix this so we can move on?

You have a 64x64 texture with 1 byte per pixel (L8).  The texture size would be W*H = 64*64 except that, for GPU reasons, they padded each row out to 128 bytes (pitch) instead of 64, which makes the texture size 128*64 (pitch * height).  You are passing 128*128, which is entirely arbitrary.  Just because you have a square texture doesn't mean the row width and height are the same.  That doesn't even begin to make sense as you could tell by trying to figure out what I just said because "bytes-per-height" isn't even a concept.
Since you're overwriting double the image size it can be assumed that this is causing other bugs as well.

You're the one making the mistake of thinking that just because you have a square texture you have to pass in the squared "pitch," so you can't just sit there and ignore this over and over as it is being pointed out to you.  Stop arguing and fix it.


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

This topic is closed to new replies.

Advertisement