Skip to content

Commit

Permalink
Window resize is now working again, added -f flag for fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
ataulien committed Sep 21, 2016
1 parent 37cdde6 commit 44806dd
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/ZenLib
2 changes: 1 addition & 1 deletion lib/bullet3
Submodule bullet3 updated 42 files
+1 −17 build_visual_studio.bat
+0 −1 data/cube_small.urdf
+ data/gripper/meshes/l_gripper_tip_scaled.stl
+16 −0 data/jenga/jenga.mtl
+113 −0 data/jenga/jenga.obj
+ data/jenga/jenga.png
+31 −0 data/jenga/jenga.urdf
+ data/l_finger_collision.stl
+1 −1 data/plane.urdf
+23 −20 data/pr2_gripper.urdf
+0 −3 data/samurai.urdf
+0 −8 data/samurai_monastry.obj
+5 −0 data/sphere2.urdf
+32 −0 data/teddy_vhacd.urdf
+2 −0 examples/ExampleBrowser/OpenGLGuiHelper.cpp
+112 −22 examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
+19 −6 examples/Importers/ImportURDFDemo/URDF2Bullet.cpp
+1 −1 examples/Importers/ImportURDFDemo/UrdfParser.cpp
+1 −1 examples/Importers/ImportURDFDemo/UrdfParser.h
+3 −2 examples/OpenGLWindow/GLPrimitiveRenderer.cpp
+2 −1 examples/OpenGLWindow/SimpleOpenGL3App.cpp
+21 −13 examples/RoboticsLearning/KukaGraspExample.cpp
+6 −3 examples/RoboticsLearning/b3RobotSimAPI.cpp
+3 −2 examples/RoboticsLearning/b3RobotSimAPI.h
+49 −17 examples/SharedMemory/IKTrajectoryHelper.cpp
+5 −2 examples/SharedMemory/IKTrajectoryHelper.h
+7 −2 examples/SharedMemory/PhysicsClientC_API.cpp
+1 −2 examples/SharedMemory/PhysicsClientC_API.h
+96 −36 examples/SharedMemory/PhysicsServerCommandProcessor.cpp
+9 −5 examples/SharedMemory/PhysicsServerExample.cpp
+2 −1 examples/SharedMemory/SharedMemoryCommands.h
+69 −27 examples/StandaloneMain/hellovr_opengl_main.cpp
+44 −1 examples/ThirdPartyLibs/BussIK/Jacobian.cpp
+2 −0 examples/ThirdPartyLibs/BussIK/Jacobian.h
+4 −0 examples/ThirdPartyLibs/BussIK/Node.h
+3 −1 examples/pybullet/pybullet.c
+2 −2 src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
+3 −2 src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
+2 −0 src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp
+4 −1 src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
+5 −4 src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
+2 −2 src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
2 changes: 1 addition & 1 deletion lib/glfw
36 changes: 31 additions & 5 deletions src/engine/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# include <GLFW/glfw3native.h>
#endif
#include <bgfx/bgfxplatform.h>
#include <bgfx-cmake/bx/include/bx/commandline.h>



Expand Down Expand Up @@ -51,6 +52,9 @@

using namespace Engine;

int Platform::m_WindowWidth;
int Platform::m_WindowHeight;

inline void glfwSetWindow(GLFWwindow* _window)
{
bgfx::PlatformData pd;
Expand All @@ -72,19 +76,41 @@ inline void glfwSetWindow(GLFWwindow* _window)
setPlatformData(pd);
}

int32_t Platform::run(int argc, char** argv)

void Platform::windowSizeEvent(GLFWwindow* window, int width, int height)
{
constexpr int width = 1280;
constexpr int height = 720;
Input::windowSizeEvent(window, width, height);

GLFWwindow* window;
m_WindowHeight = height;
m_WindowWidth = width;
}

int32_t Platform::run(int argc, char** argv)
{
int width = 1280;
int height = 720;

/* Initialize the library */
if (!glfwInit())
return -1;

bx::CommandLine cmd(argc, (const char**)argv);

bool fullscreen = false;
if(cmd.hasArg('f'))
{
fullscreen = true;

// Get native resolution
const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
width = mode->width;
height = mode->height;
}

GLFWwindow* window;

/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(width, height, "REGoth", NULL, NULL);
window = glfwCreateWindow(width, height, "REGoth", fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL);
if (!window)
{
glfwTerminate();
Expand Down
14 changes: 14 additions & 0 deletions src/engine/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ class Platform : public Input
int32_t run(int argc, char** argv);
void mainLoop(std::promise<int32_t> && returnValue, int argc, char** argv);

/**
* Accessors to windows height/width
* @return height/width
*/
static int getWindowWidth(){ return m_WindowWidth; }
static int getWindowHeight(){ return m_WindowHeight; }
private:

static void windowSizeEvent(GLFWwindow *window, int width, int height);

GLFWwindow* window;

/**
* Size of the current window
*/
static int m_WindowWidth, m_WindowHeight;
};
}
29 changes: 20 additions & 9 deletions src/target/REGoth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform



bgfx::setViewRect(1, 0, 0, m_width, m_height);
bgfx::setViewRect(1, 0, 0, (uint16_t)getWindowWidth(), (uint16_t)getWindowHeight());

// Set view and projection matrix for view 0.
bgfx::setViewTransform(1, NULL, proj);
Expand Down Expand Up @@ -207,14 +207,15 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform
// Args args(_argc, _argv);

axis = 0;
m_width = 1280;
m_height = 720;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_MAXANISOTROPY | BGFX_RESET_MSAA_X8;

m_Width = getWindowWidth();
m_Height = getWindowHeight();

// bgfx::init(args.m_type, args.m_pciId);
bgfx::init();
bgfx::reset(m_width, m_height, m_reset);
bgfx::reset((uint32_t)m_Width, (uint32_t)m_Height, m_reset);

// Enable debug text.
bgfx::setDebug(m_debug);
Expand Down Expand Up @@ -278,6 +279,17 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform
{
Engine::Input::fireBindings();


// Check for resize
if(m_Width != getWindowWidth() || m_Height != getWindowHeight())
{
m_Width = getWindowWidth();
m_Height = getWindowHeight();

// Notify bgfx about framebuffer resize
bgfx::reset((uint32_t)m_Width, (uint32_t)m_Height);
}

int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
Expand All @@ -296,8 +308,8 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform
| (ms.m_buttons[1] ? IMGUI_MBUT_RIGHT : 0)
| (ms.m_buttons[2] ? IMGUI_MBUT_MIDDLE : 0)
, ms.m_mz
, m_width
, m_height
, (uint16_t)getWindowWidth()
, (uint16_t)getWindowHeight()
);

// Use debug font to print information about this example.
Expand All @@ -318,7 +330,7 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform

ddBegin(0);

m_pEngine->frameUpdate(dt, m_width, m_height);
m_pEngine->frameUpdate(dt, (uint16_t)getWindowWidth(), (uint16_t)getWindowHeight());
// Draw and process all UI-Views
// Set render states.

Expand Down Expand Up @@ -356,10 +368,9 @@ class ExampleCubes : public /*entry::AppI*/ Engine::Platform
}

Engine::GameEngine* m_pEngine;
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
int m_Width, m_Height;
int64_t m_timeOffset;
float axis;
int32_t m_scrollArea;
Expand Down

0 comments on commit 44806dd

Please sign in to comment.