Skip to content

Commit 551ec42

Browse files
committed
update
1 parent d6c9fc7 commit 551ec42

10 files changed

Lines changed: 14 additions & 13 deletions

File tree

CppMode.zip

-16.5 MB
Binary file not shown.

cache/linux-x64/Processing.o

761 KB
Binary file not shown.
952 Bytes
Binary file not shown.

cache/windows-x64/Processing.o

609 KB
Binary file not shown.
442 Bytes
Binary file not shown.

hello.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,5 @@ extern KEYWORD6
370370
typedef KEYWORD6
371371
sizeof KEYWORD6
372372
delete KEYWORD6
373+
_frameRate KEYWORD4
374+
deltaTime KEYWORD4

src/Processing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ char key = 0;
9999
// Frame timing
100100
int frameCount = 1;
101101
float currentFrameRate = 60.0f;
102+
float _frameRate = 60.0f;
103+
float deltaTime = 0.0f;
102104
bool looping = true;
103105
static bool redrawOnce = false;
104106
float measuredFrameRate = 0.0f;
@@ -2848,6 +2850,11 @@ void run(){
28482850
glfwWindowHint(GLFW_SAMPLES,4); // 4x MSAA for crisp P3D rendering; 2D noSmooth() disables at runtime
28492851
glfwWindowHint(GLFW_STENCIL_BITS,8); // needed for concave shape fill
28502852
gWindow=glfwCreateWindow(winWidth,winHeight,g_sketchName.c_str(),nullptr,nullptr);
2853+
// Prevent freeze when dragging title bar on Windows
2854+
glfwSetWindowRefreshCallback(gWindow,[](GLFWwindow* w){
2855+
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
2856+
glfwSwapBuffers(w);
2857+
});
28512858
if(!gWindow){
28522859
#ifdef _WIN32
28532860
MessageBoxA(NULL, "Window creation failed.\nCheck that your GPU supports OpenGL 2.0+", "processing-cpp Error", MB_OK|MB_ICONERROR);
@@ -3130,6 +3137,8 @@ void run(){
31303137
auto now=std::chrono::steady_clock::now();
31313138
double elapsed=std::chrono::duration<double>(now-last).count();
31323139
if(elapsed>0) measuredFrameRate=measuredFrameRate*0.9f+(float)(1.0/elapsed)*0.1f;
3140+
_frameRate=(float)(1.0/elapsed);
3141+
deltaTime=(float)elapsed;
31333142
double sl=targetFrameTime-elapsed;
31343143
if(sl>0)std::this_thread::sleep_for(std::chrono::duration<double>(sl));
31353144
last=std::chrono::steady_clock::now();

src/Processing.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ extern char key; // ASCII character, or CODED (0xFF) for special keys
611611

612612
extern int frameCount;
613613
extern float currentFrameRate;
614+
extern float _frameRate; // measured fps (read-only)
615+
extern float deltaTime; // seconds since last frame
614616
extern bool looping;
615617
extern float measuredFrameRate;
616618

src/main.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
#include "Processing.h"
2-
#include <cstdlib>
3-
#include <string>
4-
5-
// Forward declare so we can set it before run()
6-
// It's defined in Processing.cpp at global scope
7-
namespace Processing { extern std::string g_sketchName; }
82

93
#ifdef _WIN32
104
#include <windows.h>
115
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
12-
#ifdef PROCESSING_SKETCH_NAME
13-
Processing::g_sketchName = PROCESSING_SKETCH_NAME;
14-
#endif
156
Processing::run();
167
return 0;
178
}
189
#else
10+
#include <string>
1911
int main(int argc, char** argv) {
20-
#ifdef PROCESSING_SKETCH_NAME
21-
Processing::g_sketchName = PROCESSING_SKETCH_NAME;
22-
#endif
2312
for (int i = 1; i < argc; i++)
2413
if (std::string(argv[i]) == "--debug")
2514
Processing::enableDebugConsole();

0 commit comments

Comments
 (0)