Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/macx
diff options
context:
space:
mode:
authorStefan Hacker <dd0t@users.sourceforge.net>2010-04-30 00:09:07 +0400
committerStefan Hacker <dd0t@users.sourceforge.net>2010-04-30 00:45:25 +0400
commit11fda9bfcd0406c14791e113689fac71ebbca194 (patch)
tree0ad63d6911d29dcbd7663fced0c80422c7ca80c4 /macx
parent58bf724a3f0fea9f2e5c7e0125b44ac1f6a8891c (diff)
Fix *nix OpenGL overlay and add FPS counter code to OSX overlay.m
Diffstat (limited to 'macx')
-rw-r--r--macx/overlay/overlay.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/macx/overlay/overlay.m b/macx/overlay/overlay.m
index 485d1f20f..f67e1925e 100644
--- a/macx/overlay/overlay.m
+++ b/macx/overlay/overlay.m
@@ -40,6 +40,7 @@
#include <time.h>
#include <fcntl.h>
#include <errno.h>
+#include <time.h>
#include <string.h>
#include <mach/mach_init.h>
#include <mach/task.h>
@@ -73,6 +74,9 @@ typedef struct _Context {
unsigned char *a_ucTexture;
unsigned int uiMappedLength;
+ clock_t timeT;
+ unsigned int frameCount;
+
} Context;
static const char vshader[] = ""
@@ -115,6 +119,8 @@ static void newContext(Context * ctx) {
ctx->iSocket = -1;
ctx->omMsg.omh.iLength = -1;
ctx->texture = ~0;
+ ctx->timeT = clock();
+ ctx->frameCount = 0;
char *home = getenv("HOME");
if (home == NULL) {
@@ -389,6 +395,22 @@ static void drawOverlay(Context *ctx, unsigned int width, unsigned int height) {
}
static void drawContext(Context * ctx, int width, int height) {
+ clock_t t = clock();
+ float elapsed = (float)(t - ctx->timeT) / CLOCKS_PER_SEC;
+ ++(ctx->frameCount);
+ if (elapsed > OVERLAY_FPS_INTERVAL) {
+ struct OverlayMsg om;
+ om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
+ om.omh.uiType = OVERLAY_MSGTYPE_FPS;
+ om.omh.iLength = sizeof(struct OverlayMsgFps);
+ om.omf.fps = ctx->frameCount / elapsed;
+
+ sendMessage(ctx, &om);
+
+ ctx->frameCount = 0;
+ ctx->timeT = t;
+ }
+
GLint program;
GLint viewport[4];
int i;