locked
Strange problem with different screen resolutions.

    Question

  • 	CoreWindow^ m_window = CoreWindow::GetForCurrentThread();
    	Rect bounds = m_window->Bounds;
    	
    	actualscreenwidth = (int) bounds.Width;
    	actualscreenheight = (int) bounds.Height;
    
    	//screen width/height must be rounded up by mod 32 !!!! or else doesnt display right !!!!
    	if (actualscreenwidth % 32 !=0)
    		actualscreenwidth=((actualscreenwidth/32))*32;
    	else
    		actualscreenwidth=((actualscreenwidth/32)+1)*32;
    
    	if (actualscreenheight % 32!=0)
    		actualscreenheight=((actualscreenheight/32))*32;
    	else
    		actualscreenheight=((actualscreenheight/32)+1)*32;

    I have just finished a game that uses the full screen.

    Just for completeness I tested it with the Win 8 simulator and all the screen resolutions.

    I was shocked to find it didn't work with some resolutions.

    My software gets the screen resolution by

    CoreWindow^ m_window = CoreWindow::GetForCurrentThread();

    This gives width and height so I shouldn't be able to go wrong.

    Looking at the resolutions my software failed with was widths or heights that werent exact multiples of 8.

    I found I had to round up the width and height by mod 32 to get my software to work.

    I am displaying a 2d texture on the screen and the problem occurs if the texture is similar to the size of the screen.

    Not sure if there is still a bug in my software or this is a funny with Windows 8.


    n.Wright



    Saturday, October 12, 2013 1:17 AM

Answers

  • Apparently opengl demands texture widths of 32 pixels.

    Just wondering if directx is the same.

    	//textures must be multiple of 32 pixels wide and same for height
    	//screen width/height must be rounded up by mod 32 !!!! or else doesnt display right !!!!
    	actualscreenwidth = ((int)(bounds.Width/32)) *32;
    	actualscreenheight = ((int)(bounds.Height/32))*32;
    


    n.Wright

    Saturday, October 12, 2013 10:08 PM

All replies

  • A dependency on window sizes divisible by 8 is a bug in the app. This is not a limit promised to apps, and in the real world you will need to deal with windows which do not have sizes divisible by 8. For example, there are 1200 pixel high screens. On Windows 8.1 the user can resize the window smoothly, so the app will need to be able to handle arbitrary widths not just specific known aspect ratios.

    That said, what were the unexpected results that you received and what results did you expect?

    What was the DPI in the unexpected resolutions? High DPI modes can change the logical size reported by CoreWindow::Bounds.

    --Rob

    Saturday, October 12, 2013 1:37 AM
    Moderator
  • My app displays a background based on 16 by 16 bit sprites.

    When I made my texture the next width/height down divisible by 16 the app just displayed rubbish.

    i.e. if screen width was say 1050 then I would make my texture 1040 to fit in with 16 bit sprites.

    It looked like it was displacing the screen data horizontally on some resolutions. One that stood out badly wrong was 1680 by 1050. My software worked fine on screen widths/heights divisible by 8.

    To start with what worked fine with 1900*1200 didn't work on 1680*1050 and vice versa.

    My fix of rounding up the screen to mod 32 works with all resolutions.

    This means my texture on none div 8 screens has a small border around it as my texture has been forced to be smaller than the screen. 

    My previous game that was 1024 by 768 works with all resolutions. So it looks like rendering a texture close to the screen size is causing problems.

     


    n.Wright


    Saturday, October 12, 2013 1:57 AM
  • I did some more experimentation tonight.

    I found if the texture I am using doesn't have a width that is a multiple of 32 then the screen gets corrupted.

    The texture can be bigger or smaller than full screen size and the problem is still there.

    I thought at first this was due to 16 bit wide sprites but making a multiple of 16 fails each time the screenwidth is not a multiple of 32.


    n.Wright


    Saturday, October 12, 2013 8:24 PM
  • Apparently opengl demands texture widths of 32 pixels.

    Just wondering if directx is the same.

    	//textures must be multiple of 32 pixels wide and same for height
    	//screen width/height must be rounded up by mod 32 !!!! or else doesnt display right !!!!
    	actualscreenwidth = ((int)(bounds.Width/32)) *32;
    	actualscreenheight = ((int)(bounds.Height/32))*32;
    


    n.Wright

    Saturday, October 12, 2013 10:08 PM