Jump to content
  • Advertisement
rjhwinner03

In game image memset function not working...

Recommended Posts

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

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

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

 

Edited by Oberon_Command

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Posted (edited)
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?

Edited by Oberon_Command

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!