Jump to content
  • Advertisement
Sign in to follow this  
Znooteh

All pixels not drawing?

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

Hello!
I'm making a game(obviously, GAMEdev.net hehe), but I'm having some problems.
When drawing, everything is not shown.

Here is an example: 

e75763427250caab43a3f3e77d80258b.png

 

Code:
 

void MenuButton(int x1, int y1, int x2, int y2, const char *fmt)
{
	DrawFilledBox(x1, y1, 200, 50, LightGray1);
	DrawLinedBox(x1, y1, 200, 50, 2, Black);

	DrawShadowString(x1 + x2, y1 + y2, White, pFont_20, fmt);
}

void Menu()
{
	MenuButton(300, 175, 75, 15, "Play");

	MenuButton(300, 250, 50, 15, "Options");
}
void Render()
{
	d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1, 0);
	d3ddev->BeginScene();

	Menu();

	d3ddev->EndScene();
	d3ddev->Present(NULL, NULL, NULL, NULL);
} 

Why is this happening?

Edited by Znooteh

Share this post


Link to post
Share on other sites
Advertisement

First, welcome to gamedev!

 

Second, please read the Beginner's FAQ, as it will help you ask questions in a better way.

 

From a logic standpoint: programs are comprised of code, and the data that the code uses. If your buttons are rendered using the same code, then the data must be different. Assuming the "play" button renders as you desire, have you looked at the actual values being used to render the "options" button to determine if they're correct?

Share this post


Link to post
Share on other sites

First, welcome to gamedev!

 

Second, please read the Beginner's FAQ, as it will help you ask questions in a better way.

 

From a logic standpoint: programs are comprised of code, and the data that the code uses. If your buttons are rendered using the same code, then the data must be different. Assuming the "play" button renders as you desire, have you looked at the actual values being used to render the "options" button to determine if they're correct?

Edited in the code used.
Resolution of the window is 800x600, if that matters.

Share this post


Link to post
Share on other sites


have you looked at the actual values being used to render the "options" button to determine if they're correct?

 

To make it a little clearer, if the data used by the code does not provide the results you want, either the data is incorrect, the code is incorrect, or both. What have done to determine where the problem occurs?

 

Just a guess, without knowing how DrawLinedBox is coded (your own function?), it appears that's the place where the problem occurs. Do you have the same problem if you draw only the lines? Do you have the same problem if you don't draw the text? Or the filled rectangle?

Share this post


Link to post
Share on other sites

Resolution of the window is 800x600, if that matters.

Lucky guess, a common beginner pitfall: Mismatch between backbuffer and windows client size. Also check viewport and projection.

Share this post


Link to post
Share on other sites

Could you post the code behind the three Draw functions you invoke in MenuButton? Perhaps that gives more insight in possible error causes.

 

@unbird: If he uses D2D draw functions in there projection shouldn't matter, should it?

Share this post


Link to post
Share on other sites

He's using D3D9 so unlikely D2D at work here :wink:

 

Yes you don't have an explicit projection in D2D (one can use a global transformation though), but if your backbuffer (D3D11: swapchain) doesn't match then you will have such distortions. If there's such a mismatch, chances are the projection and viewport are also amiss, that's why I suggested a look.

 

If he's using ID3DXSprite and -Font he's probably fine, though.

 

But yeah, a look at actual setup and draw code should reveal more.

Share this post


Link to post
Share on other sites
This type of thing is often caused by having an orthogonal projection matrix 1 pixel too small in each direction (or other rounding errors).
Expand the projection matrix by 1 in each direction.

You may also add a half-pixel shift to account for the fact that Direct3D 9 addresses pixel corners rather than pixel centers.


L. Spiro

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!