Fixed Mac OSX High Sierra Desktop mode Graphics Size incorrect

Matt

New member
Joined
Feb 17, 2018
Messages
3
Hi, I'm getting an issue when compiling to the desktop target on Mac osx. Rendering to an imagecanvas only draws to the bottom left quarter of the window even a full imageCanvas.clear r,g,b will only fill up the bottom left quarter with the colour. But compiling to HTML5 it works fine. Is this a bug, possibly to do with how the mac deals with half-pixels, or is there something I'm missing that I should be doing?

Code:
Import mojo2

Class MyApp Extends App

Field image:Image
Field imageCanvas:Canvas
Field windowCanvas:Canvas 

Method OnCreate()
image=New Image( DeviceWidth,DeviceHeight,0,0 )
imageCanvas=New Canvas( image )
windowCanvas=New Canvas
SetUpdateRate 30
End

Method OnRender()
imageCanvas.PushMatrix()
imageCanvas.Clear 128,0,255
imageCanvas.Flush
imageCanvas.PopMatrix
windowCanvas.Clear
windowCanvas.DrawImage image
windowCanvas.Flush
End

End

Function Main()
New MyApp
Return True
End
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
What values does DeviceWidth/Height report back? Did you use a config file to set the window?
What machine do you run it on?
 

Matt

New member
Joined
Feb 17, 2018
Messages
3
I'm running it on:
MacBook Pro (Retina, 15-inch, Late 2013)
2.6 GHz Intel Core i7
16 GB 1600 MHz DDR3
NVIDIA GeForce GT 750M 2 GB
Intel Iris Pro 1536 MB

I'm running Cerberus V2017-10-24.

I haven't edited the config file for either the HTML5 or the Desktop version.

In HTML5 it reports back DeviceWidth 640 and DeviceHeight 480 and displays correctly.
In Desktop (Glfw3) it also reports back DeviceWidth 640 and DeviceWidth 480 and the window is that size when compared to other software but the only part draw in is the bottom left at a size of 320x240. See the screenshot below for the comparison:
Cerberus_Screenshot.jpeg
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
I will setup my El Capitan Imac in the next days to see if I can recreate this behaviour. I have a feeling that it is another quirk of High Sierra.
 

York

New member
Patreon Bronze
Joined
Jul 5, 2017
Messages
24
The problem is that the viewport was set incorrectly. I think that has something to do with the retina display from iMac. (4k)


We are currently using glfwGetWindowSize() in gxtkGraphics::BeginRender() to determine the widht and height of the screen, but we need to use glfwGetFramebufferSize instead.

I have changed the file mojo.glfw.cpp

C++:
int gxtkGraphics::BeginRender(){

   width=height=0;
 
#ifdef _glfw3_h_
   glfwGetWindowSize( BBGlfwGame::GlfwGame()->GetGLFWwindow(),&width,&height );
#else
   glfwGetWindowSize( &width,&height );
#endif

#if CFG_OPENGL_GLES20_ENABLED
   return 0;
#else

   glViewport( 0,0,width,height );

   .......
 
 
   return 1;
 
#endif
}

to this

C++:
int gxtkGraphics::BeginRender(){

   int newWidth=0;
   int newHeight=0;
 
   width=height=0;
 
#ifdef _glfw3_h_
   glfwGetFramebufferSize(BBGlfwGame::GlfwGame()->GetGLFWwindow(),&newWidth,&newHeight );
#else
   glfwGetWindowSize( &width,&height );
#endif

#if CFG_OPENGL_GLES20_ENABLED
   return 0;
#else

   glViewport( 0,0,newWdth,newHeight );

   .......
 
 
   return 1;
 
#endif
}
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
Awesoem that you have found and fixed the problem. I will test it under El Capitan. If that fix works there too, I will add it to the repository.
 

Matt

New member
Joined
Feb 17, 2018
Messages
3
I've copied the edits suggested above into my mojo.glfw.cpp file but it doesn't seem to make any difference in High Sierra unless there's something I'm doing wrong.
 

York

New member
Patreon Bronze
Joined
Jul 5, 2017
Messages
24
I diddn´t saw that you are using mojo2. This fix only works with mojo1.

I have checked your code quickly and I have currently not enough time. But if you open your compiled main.cpp check for "glViewport" in the
Code:
c_Canvas::_Validate
method.

If you change

Code:
glViewport(m__vpx,m__vpy,m__vpw,m__vph)

to

Code:
glViewport(m__vpx,m__vpy,m__vpw*2,m__vph*2)

it works. If you want to run on other devices you need to use glfwGetFramebufferSize().


Mojo2 also use the DeviceWidth/DeviceHeight to set the viewport.
 
Last edited:
Top Bottom