Jump to content
  • Advertisement
suliman

Horizontal lines of pixels "missing" in windowed mode...

Recommended Posts

Hi!

Im using an old 2d engine called "HGE" for rendering (the engine forum is now dead). My problem is that some pixels (it seems like horizontal lines) is cut (not drawn). This happens ONLY in windowed mode; in fullscreen mode this doesnt happen.

Any idea how to fix this? Or what its called? See a screenie below (the rectangle next to "fullscreen" checkbox is messed up: pixels in bottom is missing).

err1.png

Edited by suliman

Share this post


Link to post
Share on other sites
Advertisement

If it only happens with text, it might be some rounding problem with font metrics at different sizes. If it happens to anything, it can be nearest-neighbour scaling of something that is unaffected in fullscreen mode but ruined when shrunk (or enlarged).

Can you render something sensitive to line removal (e.g. a whole screen of checkerboard with 1px by 1px squares) as a test?

Edited by LorenzoGatti

Share this post


Link to post
Share on other sites

I think this is the classical "Window is not set to the proper dimensions, so canvas will be scaled slightly" 😀
When creating a window, you must account for bordersize etc., there's some functions that can help you calculate it properly :)

 

Share this post


Link to post
Share on other sites

Suliman, can you post the code you're using to create your window?

 

It sounds like you are forgetting to call AdjustWindowRect on your window rect with the appropriate create flags before creating the window.

Edited by pindrought

Share this post


Link to post
Share on other sites

Thanks all for tips to test!

@pindrought
This seems to be a built-in windows function. Does it work with all engines? I've never been recommended to use it before :) Would you use it in all applications?
(also im not home so cannot test this for a while)

Share this post


Link to post
Share on other sites
1 minute ago, suliman said:

Thanks all for tips to test!

@pindrought
This seems to be a built-in windows function. Does it work with all engines? I've never been recommended to use it before :) Would you use it in all applications?
(also im not home so cannot test this for a while)

I had assumed you were using Windows. If you're not using windows, i'm not sure what the approach would be.

 

If you are using windows, and you create a 800x600 window for example, the window will be 800x600 INCLUDING THE BORDER. Your actual content of the window will be less though. This is what the AdjustWindowRect function is for - to adjust the window so that the actual rendering area matches the dimensions due to the borders or other window styles throwing it off.

 

If you are not using windows, I am not sure what the solution may be.

Share this post


Link to post
Share on other sites

Yes it's windows, but as I'm using a game engine I was not sure that function can be applied (lots of low-level stuff is handled automatically by the engine).

But i'll try it when I get the chance, thanks!

Edited by suliman

Share this post


Link to post
Share on other sites

Update. Yes it skips!. This is how it looks when drawing horizontal lines every two pixels in windowed mode (its the same problem with vertical lines):

image.png.9207bf196e31edc32033a960eee4363c.png

I try this from an internet tutorial:

	// settings for the window
	RECT wr = { 0, 0, gfx.screenX, gfx.screenY };    // set the size, but not the position
	AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);    // adjust the size

	inHGE->System_SetState(HGE_WINDOWED, !fullScreen);
	inHGE->System_SetState(HGE_SCREENWIDTH, wr.right - wr.left);
	inHGE->System_SetState(HGE_SCREENHEIGHT, wr.bottom - wr.top);

And it does correct the width and height (was 1600x900 but changed it into 1616x939 pixels) but still the same problem. 
I also try it with the style WS_BORDER but the same problem persists.

Any ideas?

Edited by suliman

Share this post


Link to post
Share on other sites

Are you sure your window is just WS_OVERLAPPEDWINDOW?  Have you tried getting the window flags from the window itself first, to make sure you are adjusting to the correct ones?

Share this post


Link to post
Share on other sites

@xycsoscyx

How can I do that? These are the calls I think can be relevant:
 

	hge = hgeCreate(HGE_VERSION);
	hge->System_SetState(HGE_FRAMEFUNC, frameFunc);

	hge->System_SetState(HGE_TITLE, tempT);
	hge->System_SetState(HGE_HIDEMOUSE, true);
	if (runAtFPS != -1)
		hge->System_SetState(HGE_FPS, runAtFPS);
	else
		hge->System_SetState(HGE_FPS, HGEFPS_VSYNC);
	hge->System_SetState(HGE_DONTSUSPEND, runAlways); //run even when not active window

	// settings for the window
	RECT wr = { 0, 0, gfx.screenX, gfx.screenY };    // set the size, but not the position
	AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);    // adjust the size
	hge->System_SetState(HGE_WINDOWED, !fullScreen);
	hge->System_SetState(HGE_SCREENWIDTH, wr.right - wr.left);
	hge->System_SetState(HGE_SCREENHEIGHT, wr.bottom - wr.top);

	hge->System_Initiate();

 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!