Tested some desktop stuff and added projection matrix updates for window resizing.
This commit is contained in:
parent
3e8d52b0ff
commit
ff33e12ee5
|
|
@ -28,6 +28,8 @@ int main(int argc, char* argv[])
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ int main(Platform::Array<Platform::String^>^)
|
|||
App::App()
|
||||
{
|
||||
//This does not work... need to fix this.
|
||||
SetConfigFlags(FLAG_SHOW_LOGO);
|
||||
SetConfigFlags(0);
|
||||
}
|
||||
|
||||
static int posX = 100;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,16 @@ public:
|
|||
|
||||
virtual void Run()
|
||||
{
|
||||
//Get display dimensions
|
||||
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView();
|
||||
Vector2 screenSize = { dInfo->ScreenWidthInRawPixels, dInfo->ScreenHeightInRawPixels };
|
||||
|
||||
//Send display dimensions
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = SetDisplayDims;
|
||||
msg->Vector0 = screenSize;
|
||||
UWPSendMessage(msg);
|
||||
|
||||
while (!mWindowClosed)
|
||||
{
|
||||
if (mWindowVisible)
|
||||
|
|
@ -285,7 +295,12 @@ protected:
|
|||
void OnResuming(Platform::Object^ sender, Platform::Object^ args) {}
|
||||
|
||||
// Window event handlers.
|
||||
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args) {}
|
||||
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args)
|
||||
{
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = HandleResize;
|
||||
UWPSendMessage(msg);
|
||||
}
|
||||
|
||||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
|
||||
{
|
||||
|
|
@ -416,8 +431,8 @@ private:
|
|||
bool mWindowClosed = false;
|
||||
bool mWindowVisible = true;
|
||||
|
||||
int width = 800;
|
||||
int height = 450;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
};
|
||||
|
||||
//Application source for creating the program
|
||||
|
|
|
|||
38
src/core.c
38
src/core.c
|
|
@ -626,13 +626,11 @@ void InitWindow(int width, int height, const char *title)
|
|||
mousePosition.y = (float)screenHeight/2.0f;
|
||||
|
||||
// raylib logo appearing animation (if enabled)
|
||||
#if !defined(PLATFORM_UWP)
|
||||
if (showLogo)
|
||||
{
|
||||
SetTargetFPS(60);
|
||||
LogoAnimation();
|
||||
}
|
||||
#endif //defined(PLATFORM_UWP)
|
||||
#endif // defined(PLATFORM_ANDROID)
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +885,6 @@ int GetScreenHeight(void)
|
|||
// Get native window handle
|
||||
void *GetWindowHandle(void)
|
||||
{
|
||||
//TODO: See if we can do UWP?
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
// NOTE: Returned handle is: void *HWND (windows.h)
|
||||
return glfwGetWin32Window(window);
|
||||
|
|
@ -2764,6 +2761,8 @@ static bool InitGraphicsDevice(int width, int height)
|
|||
eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth);
|
||||
eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight);
|
||||
|
||||
//SetupFramebuffer(displayWidth, displayHeight); //Borked
|
||||
|
||||
#else // PLATFORM_ANDROID, PLATFORM_RPI
|
||||
EGLint numConfigs;
|
||||
|
||||
|
|
@ -3263,6 +3262,39 @@ static void PollInputEvents(void)
|
|||
break;
|
||||
}
|
||||
|
||||
case SetDisplayDims:
|
||||
{
|
||||
displayWidth = msg->Vector0.x;
|
||||
displayHeight = msg->Vector0.y;
|
||||
break;
|
||||
}
|
||||
|
||||
case HandleResize:
|
||||
{
|
||||
eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth);
|
||||
eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight);
|
||||
|
||||
// If window is resized, viewport and projection matrix needs to be re-calculated
|
||||
rlViewport(0, 0, screenWidth, screenHeight); // Set viewport width and height
|
||||
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
||||
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
||||
rlOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); // Orthographic projection mode with top-left corner at (0,0)
|
||||
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
||||
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
||||
rlClearScreenBuffers(); // Clear screen buffers (color and depth)
|
||||
|
||||
// Window size must be updated to be used on 3D mode to get new aspect ratio (BeginMode3D())
|
||||
// NOTE: Be careful! GLFW3 will choose the closest fullscreen resolution supported by current monitor,
|
||||
// for example, if reescaling back to 800x450 (desired), it could set 720x480 (closest fullscreen supported)
|
||||
currentWidth = screenWidth;
|
||||
currentHeight = screenHeight;
|
||||
|
||||
// NOTE: Postprocessing texture is not scaled to new size
|
||||
|
||||
windowResized = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeleteUWPMessage(msg); //Delete, we are done
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ typedef enum
|
|||
MarkGamepadActive, //Int0 (gamepad), Bool0 (active or not)
|
||||
MarkGamepadButton, //Int0 (gamepad), Int1 (button), Char0 (status)
|
||||
MarkGamepadAxis, //Int0 (gamepad), int1 (axis), Float0 (value)
|
||||
SetDisplayDims, //Vector0 (display dimensions)
|
||||
HandleResize, //Vector0 (new dimensions) - Onresized event
|
||||
} UWPMessageType;
|
||||
|
||||
typedef struct UWPMessage {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user