Skip to content

Commit

Permalink
Merge pull request #106 from cerberusxdev/develop
Browse files Browse the repository at this point in the history
v2020-12-05
  • Loading branch information
Cerberus X Dev Team committed Dec 5, 2020
2 parents 2b0e0da + 1339730 commit 2a65fb6
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 120 deletions.
18 changes: 14 additions & 4 deletions VERSIONS.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
***** v2020-12-05 *****

FIX: [MOJO/MOJO2] Another try at fixing apps that don't scale right on retina displays. (Author: Phil7)
FIX: [HTTPREQUEST] Fixed compiling error on Linux about missing curl include file. (Author: MikeHart)
MOD: [MOJO/MOJO2] Renamed #GLFW_HIGH_DPI_ENABLED constant, to #GLFW_MACOS_RETINA_ENABLED. (Author: Phil7)
NEW: [MOJO/MOJO2] Added DeviceWindowWidth:Int() and DeviceWindowHeight:Int() to retrieve to retrieve the size of a windows in desktop unit sizes. (Author: Phil7)
NEW: [MOJO/MOJO2] Added DrawImageRect:Void( image:Image,tx:Float,ty:Float,sourceX:Int,sourceY:Int,sourceWidth:Int,sourceHeight:Int,rz:Float=0,sx:Float=1,sy:Float=1 ) (Author: Martin)


KNOWN ISSUES:
- Window dragging in 32 bit Release mode still crashes, need to figure out why that is.
- GLFW_APP_ICON doesn't work with OSX and Linux.


***** v2020-11-15 *****

FIX: [TRANSCC] With the GLFW target and MingW, you can build 32bit again. (Author: MikeHart)
Expand Down Expand Up @@ -31,10 +45,6 @@ NEW: [MOJO2] Added DrawList.DrawTextBox:Void( textLines:String[],x:Float,y:Float
NEW: [MOJO/MOJO2] Added #GLFW_HIGH_DPI_ENABLED=1 constant, so GLFW apps can use the full high DPI resolution. (Author: Phil7)
NEW: [Modules] Added the new brl.timer module. (Author: MikeHart)

KNOWN ISSUES:
- Window dragging in 32 bit Release mode still crashes, need to figure out why that is.
- GLFW_APP_ICON doesn't work with OSX and Linux.

***** v2020-05-09 *****

FIX: [DOCS/brl] Fixed missing entry for the admob, cerberusstore, gamecenter, filepath, filesystem, url, tween, pool, process and markdown modules. (Author: MikeHart)
Expand Down
2 changes: 2 additions & 0 deletions docs/cerberusdoc/Programming/App config settings.cerberusdoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ The following app config settings are currently supported:
#GLFW_WINDOW_SAMPLES=0 'Set to number of samples for multisampling (glfw3 only).
#GLFW_WINDOW_DECORATED=True 'Set to false to create a broderless window (glfw3 only).

#GLFW_MACOS_RETINA_ENABLED=False 'Set to True to make use of the whole resolution of the Retina display. Only recommended if content is scaled accordingly and no absolute pixel coordinates are used.

#GLFW_APP_ICON="" 'Set the name of a ico/png file which will be used as th apps icon. If not provided, Trans will use the standard icon file.
'PNG files will be converted to ICO files. Without a filepath, Trans will look in the folder where your .cxs source file is located at.

Expand Down
5 changes: 3 additions & 2 deletions modules/brl/gametarget.cxs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ Class BBGame Extends Null
Method SetClipboard:Void( _text:String )
Method GetClipboard:String()


Method GetDeviceWidth:Int()
Method GetDeviceHeight:Int()
Method GetFramebufferWidth:Int() ' At the moment this is only needed for GLFW on HighDPI Displays like Retina.
Method GetFramebufferHeight:Int()
Method GetDeviceWindowWidth:Int()
Method GetDeviceWindowHeight:Int()

Method SetDeviceWindow:Void( Width:Int,Height:Int,Flags:Int )
Method SetDeviceWindowIcon:Void( _path:String )
Expand Down
4 changes: 2 additions & 2 deletions modules/brl/native/gametarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class BBGame{

virtual int GetDeviceWidth(){ return 0; }
virtual int GetDeviceHeight(){ return 0; }
virtual int GetFramebufferWidth(){ return this->GetDeviceWidth(); }
virtual int GetFramebufferHeight(){ return this->GetDeviceHeight(); }
virtual int GetDeviceWindowWidth(){ return this->GetDeviceWidth(); }
virtual int GetDeviceWindowHeight(){ return this->GetDeviceHeight(); }
virtual void SetDeviceWindow( int width,int height,int flags ){}
virtual void SetDeviceWindowIcon( String _path ){}
virtual void SetDeviceWindowPosition( int _x, int _y ){}
Expand Down
6 changes: 3 additions & 3 deletions modules/brl/native/gametarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ public class BBGame{
return 0;
}

public virtual int GetFramebufferWidth(){
public virtual int GetDeviceWindowWidth(){
return this.GetDeviceWidth();
}

public virtual int GetFramebufferHeight(){
public virtual int GetDeviceWindowHeight(){
return this.GetDeviceHeight();
}

public virtual void SetDeviceWindow( int width,int height,int flags ){
}

Expand Down
4 changes: 2 additions & 2 deletions modules/brl/native/gametarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ int GetDeviceHeight(){
return 0;
}

int GetFramebufferWidth(){
int GetDeviceWindowWidth(){
return this.GetDeviceWidth();
}

int GetFramebufferHeight(){
int GetDeviceWindowHeight(){
return this.GetDeviceHeight();
}

Expand Down
4 changes: 2 additions & 2 deletions modules/brl/native/gametarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ BBGame.prototype.GetDeviceHeight=function(){
return 0;
}

BBGame.prototype.GetFramebufferWidth=function(){
BBGame.prototype.GetDeviceWindowWidth=function(){
return this.GetDeviceWidth();
}

BBGame.prototype.GetFramebufferHeight=function(){
BBGame.prototype.GetDeviceWindowHeight=function(){
return this.GetDeviceHeight();
}

Expand Down
1 change: 1 addition & 0 deletions modules/brl/native/httprequest.glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Libcurl for Linux will be from a system repository when installed
#ifdef __linux__
#include <curl/curl.h>
#include "curl/include/curl.h"
#else
#include "curl/include/curl.h"
#endif
Expand Down
23 changes: 11 additions & 12 deletions modules/mojo/app.cxs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Global _game:=BBGame.Game()
Global _delegate:GameDelegate
Global _devWidth:Int
Global _devHeight:Int
Global _framebufWidth:Int
Global _framebufHeight:Int
Global _devWinWidth:Int
Global _devWinHeight:Int
Global _updateRate:Int
Global _displayModes:DisplayMode[]
Global _desktopMode:DisplayMode
Expand Down Expand Up @@ -57,16 +57,15 @@ End

Function ValidateDeviceWindow:Void( notifyApp:Bool )
'Print("App.cxs:ValidateDeviceWindow")
Local fbW:=_game.GetFramebufferWidth()
'Print("fbW = " + fbW)
Local fbH:=_game.GetFramebufferHeight()
Local winW:=_game.GetDeviceWindowWidth()
Local winH:=_game.GetDeviceWindowHeight()
Local w:=_game.GetDeviceWidth()
Local h:=_game.GetDeviceHeight()
If w=_devWidth And h=_devHeight And fbW = _framebufWidth And fbH = _framebufHeight Return
If w=_devWidth And h=_devHeight And winW = _devWinWidth And winH = _devWinHeight Return
_devWidth=w
_devHeight=h
_framebufWidth = fbW
_framebufHeight = fbH
_devWinWidth=winW
_devWinHeight=winH
If notifyApp _app.OnResize
End

Expand Down Expand Up @@ -281,12 +280,12 @@ Function DeviceHeight:Int()
Return _devHeight
End

Function FramebufferWidth:Int()
Return _framebufWidth
Function DeviceWindowHeight:Int()
Return _devWinHeight
End

Function FramebufferHeight:Int()
Return _framebufHeight
Function DeviceWindowWidth:Int()
Return _devWinWidth
End

Function SetDeviceWindow:Void( width:Int,height:Int,flags:Int )
Expand Down
34 changes: 22 additions & 12 deletions modules/mojo/cerberusdoc/app.cerberusdoc
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Use with care!

# Function SetDeviceWindow:Void( width:Int,height:Int,flags:Int )

Sets the application's device window to the given width and height.
Sets the application's device window to the given width and height in Desktop units.

You can only change the device window on the desktop and xna targets.

Expand Down Expand Up @@ -364,7 +364,7 @@ Works only for GLFW target.

# Function SetDeviceWindowSize:Void( _width:Int, _height:Int )

Sets the size of the application's device window.
Sets the size of the application's device window in Desktop units.

Works only for GLFW target.

Expand Down Expand Up @@ -394,25 +394,35 @@ On targets other than desktop and xna, this returns an empty array.

Gets the display mode used by the desktop.

On targets other that desktop and xna, this returns a DisplayMode with width and height equal to [[DeviceWidth]] and [[DeviceHeight]].
On targets other that desktop and xna, this returns a DisplayMode with width and height equal to [[DeviceWindowWidth]] and [[DeviceWindowHeight]].


# Function DeviceWidth:Int()
# Function DeviceWindowWidth:Int()

Returns the width of the application's device window, in pixels.
Returns the width of the application's device window in desktop units. These units are the same as pixels unless your app runs on a Retina display.

On the desktop and xna targets, you can use [[SetDeviceWindow]] to alter the size of the device window.

On other targets, you cannot directly control the size of the graphics device via mojo. This must be done by editing the 'native' project code for the target.


# Function DeviceHeight:Int()
# Function DeviceWindowHeight:Int()

Returns the height of the application's device window, in pixels.
Returns the height of the application's device window in desktop units. These units are the same as pixels unless your app runs on a Retina display.

On the desktop and xna targets, you can use [[SetDeviceWindow]] to alter the size of the device window.

On other targets, you cannot directly control the size of the graphics device via mojo. This must be done by editing the 'native' project code for the target.

# Function DeviceWidth:Int()

Returns the width of the application's device in pixels.

You cannot directly control the size of the graphics device via mojo. If possible at all this has to be done by using config settings or by editing the 'native' project code for the target.


# Function DeviceHeight:Int()

Returns the height of the application's device in pixels.

You cannot directly control the size of the graphics device via mojo. If possible at all this has to be done by using config settings or by editing the 'native' project code for the target.


# Class mojo.app.DisplayMode
Expand All @@ -424,12 +434,12 @@ Links: [[DisplayModes]], [[DesktopMode]], [[SetDeviceWindow]]

# Method Width:Int() Property

Returns the width of the display mode.
Returns the width of the display mode in desktop units. These units are the same as pixels unless your app runs on a Retina display.


# Method Height:Int() Property

Returns the height of the display mode.
Returns the height of the display modein desktop units. These units are the same as pixels unless your app runs on a Retina display.‚


# Class mojo.app.App
Expand Down
24 changes: 6 additions & 18 deletions modules/mojo/native/mojo.glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class gxtkGraphics : public Object{
int width;
int height;

int fbWidth = 0;
int fbHeight = 0;
float highDPI_Factor = 1.0; // Needed to ensure proper scaling if #GLFW_HIGH_DPI_ENABLED is false.

int colorARGB;
float r,g,b,alpha;
float ix,iy,jx,jy,tx,ty;
Expand Down Expand Up @@ -128,8 +124,8 @@ gxtkGraphics::gxtkGraphics(){
vertCount=0;

#ifdef _glfw3_h_
GLFWwindow *window=BBGlfwGame::GlfwGame()->GetGLFWwindow();
if( window ) glfwGetWindowSize( BBGlfwGame::GlfwGame()->GetGLFWwindow(),&width,&height );
width = BBGlfwGame::GlfwGame()->GetDeviceWidth();
height = BBGlfwGame::GlfwGame()->GetDeviceHeight();
#else
glfwGetWindowSize( &width,&height );
#endif
Expand Down Expand Up @@ -203,15 +199,12 @@ int gxtkGraphics::Height(){
}

int gxtkGraphics::BeginRender(){
fbWidth=fbHeight=0;

width=height=0;

#ifdef _glfw3_h_
width = BBGlfwGame::GlfwGame()->GetDeviceWidth();
height = BBGlfwGame::GlfwGame()->GetDeviceHeight();
//bbPrint(String("mojo.glfw.cpp:GetDeviceWidth()") + width);
fbWidth = BBGlfwGame::GlfwGame()->GetFramebufferWidth();
fbHeight = BBGlfwGame::GlfwGame()->GetFramebufferHeight();
highDPI_Factor = float(fbWidth) / float(width) ;
#else
glfwGetWindowSize( &width,&height );
#endif
Expand All @@ -220,7 +213,7 @@ int gxtkGraphics::BeginRender(){
return 0;
#else

glViewport( 0,0,fbWidth, fbHeight );
glViewport( 0,0,width, height );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
Expand Down Expand Up @@ -308,12 +301,7 @@ int gxtkGraphics::SetScissor( int x,int y,int w,int h ){

if( x!=0 || y!=0 || w!=Width() || h!=Height() ){
glEnable( GL_SCISSOR_TEST );
x*=highDPI_Factor;
y*=highDPI_Factor;
w*=highDPI_Factor;
h*=highDPI_Factor;
//y=Height()-y-h;
y=fbHeight-y-h;
y=Height()-y-h;
glScissor( x,y,w,h );
}else{
glDisable( GL_SCISSOR_TEST );
Expand Down
5 changes: 5 additions & 0 deletions modules/mojo2/cerberusdoc/graphics.cerberusdoc
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,11 @@ The scaling is done via the 9-Patch method. The @patchSize determines the width
left-width and right-width of the image. These are not scaled. The rest is.


# Method DrawImageRect:Void( image:Image,tx:Float,ty:Float,sourceX:Int,sourceY:Int,sourceWidth:Int,sourceHeight:Int,rz:Float=0,sx:Float=1,sy:Float=1 )

Draw an image at @tx,@tx rotated by @rz and scaled by @sy,@sy.


# Method DrawText:Void( text:String,x:Float,y:Float,xhandle:Float=0,yhandle:Float=0 )

Draws a @text at coordinates @x, @y in the current font.
Expand Down
Loading

0 comments on commit 2a65fb6

Please sign in to comment.