|
|
@@ -23,6 +23,7 @@ namespace rack { |
|
|
static GLFWwindow *window = NULL; |
|
|
static GLFWwindow *window = NULL; |
|
|
std::shared_ptr<Font> gGuiFont; |
|
|
std::shared_ptr<Font> gGuiFont; |
|
|
NVGcontext *gVg = NULL; |
|
|
NVGcontext *gVg = NULL; |
|
|
|
|
|
float gPixelRatio = 0.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void windowSizeCallback(GLFWwindow* window, int width, int height) { |
|
|
void windowSizeCallback(GLFWwindow* window, int width, int height) { |
|
|
@@ -136,6 +137,7 @@ static int lastWindowX, lastWindowY, lastWindowWidth, lastWindowHeight; |
|
|
void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { |
|
|
void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { |
|
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) { |
|
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) { |
|
|
if (key == GLFW_KEY_F11 || key == GLFW_KEY_ESCAPE) { |
|
|
if (key == GLFW_KEY_F11 || key == GLFW_KEY_ESCAPE) { |
|
|
|
|
|
/* |
|
|
// Toggle fullscreen |
|
|
// Toggle fullscreen |
|
|
GLFWmonitor *monitor = glfwGetWindowMonitor(window); |
|
|
GLFWmonitor *monitor = glfwGetWindowMonitor(window); |
|
|
if (monitor) { |
|
|
if (monitor) { |
|
|
@@ -151,6 +153,7 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods |
|
|
const GLFWvidmode *mode = glfwGetVideoMode(monitor); |
|
|
const GLFWvidmode *mode = glfwGetVideoMode(monitor); |
|
|
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); |
|
|
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); |
|
|
} |
|
|
} |
|
|
|
|
|
*/ |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if (gSelectedWidget) { |
|
|
if (gSelectedWidget) { |
|
|
@@ -163,16 +166,20 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods |
|
|
void renderGui() { |
|
|
void renderGui() { |
|
|
int width, height; |
|
|
int width, height; |
|
|
glfwGetFramebufferSize(window, &width, &height); |
|
|
glfwGetFramebufferSize(window, &width, &height); |
|
|
// glfwGetWindowSize(window, &width, &height); |
|
|
|
|
|
|
|
|
int windowWidth, windowHeight; |
|
|
|
|
|
glfwGetWindowSize(window, &windowWidth, &windowHeight); |
|
|
|
|
|
gPixelRatio = (float)width / windowWidth; |
|
|
|
|
|
|
|
|
// Update and render |
|
|
// Update and render |
|
|
glViewport(0, 0, width, height); |
|
|
glViewport(0, 0, width, height); |
|
|
glClearColor(0.0, 0.0, 0.0, 1.0); |
|
|
glClearColor(0.0, 0.0, 0.0, 1.0); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
|
|
|
|
|
|
|
|
nvgBeginFrame(gVg, width, height, 1.0); |
|
|
|
|
|
|
|
|
nvgBeginFrame(gVg, width, height, gPixelRatio); |
|
|
|
|
|
|
|
|
nvgSave(gVg); |
|
|
nvgSave(gVg); |
|
|
|
|
|
nvgReset(gVg); |
|
|
|
|
|
nvgScale(gVg, gPixelRatio, gPixelRatio); |
|
|
gScene->draw(gVg); |
|
|
gScene->draw(gVg); |
|
|
nvgRestore(gVg); |
|
|
nvgRestore(gVg); |
|
|
|
|
|
|
|
|
@@ -220,7 +227,7 @@ void guiInit() { |
|
|
// GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here. |
|
|
// GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here. |
|
|
glGetError(); |
|
|
glGetError(); |
|
|
|
|
|
|
|
|
glfwSetWindowSizeLimits(window, 240, 160, GLFW_DONT_CARE, GLFW_DONT_CARE); |
|
|
|
|
|
|
|
|
glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); |
|
|
|
|
|
|
|
|
// Set up NanoVG |
|
|
// Set up NanoVG |
|
|
gVg = nvgCreateGL2(NVG_ANTIALIAS); |
|
|
gVg = nvgCreateGL2(NVG_ANTIALIAS); |
|
|
|