Advertisement

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

Started by September 20, 2018 08:21 AM
30 comments, last by suliman 6 years, 3 months ago

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

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?

Omae Wa Mou Shindeiru

Advertisement

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

 

.:vinterberg:.

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.

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)

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.

Advertisement

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!

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?

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?

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

 

This topic is closed to new replies.

Advertisement