hud.c
TriKster Abacus <[email protected]> Tue, 03 Aug 2004 20:18:38 -0500
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
Sorry to reintroduce the old hud.c back into the foray, but this is a temp fix till someone else does the full fix. Thank you Sincerely, TriKster Abacus -- http://www.linux-militia.net looking for me: http://www.trikster.homelinux.org/contact.html
hud.c
(text/x-csrc, 24 KB)
/*
* Direct3D FPS counter
*
* Copyright 2003 TransGaming Technologies, Inc.
*/
#include "config.h"
#include "wine/port.h"
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include "x11drv.h"
#include "bitmap.h"
#include "wine/debug.h"
#include "wine/profile.h"
#ifdef HAVE_OPENGL
#include "wine/wine_gl.h"
#include "glx_private.h"
#endif
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
/* hm... perhaps font design is not my forte. */
static const char numbers[48][80] = {
/* 0 .. 1 .. 2 .. 3 .. 4 .. */
" XXXXX X XXXXXXX XXXXXXX X ",
" XX XX XX XX XX XX XX XX ",
" X X X X X X X X X X ",
" X X X X X X X X X ",
"X X X X X X X X ",
"X X X X X X X ",
"X X X X XX X X ",
"X X X XX XXXXXX X X ",
"X X X XX XX X X ",
"X X X XX X X X ",
"X X X XX X X X ",
" X X X XX X XXXXXXXXXXXXXX ",
" X X X XX X X X ",
" XX XX X X XX XX X ",
" XXXXX XXXXXXXXX XXXXXXXXXXXXXXX XXXXXXX X ",
" ",
/* 5 .. 6 .. 7 .. 8 .. 9 .. */
"XXXXXXXXXXXXXXX XXXXXX XXXXXXXXXXXXXXX XXXXX XXXXXXX ",
"X XX XX X X XX XX XX XX ",
"X X X X X X X X ",
"X X X X X X X ",
"X X X X X X X ",
"XXXXXXXXXXX X XXXXXXX X X X X X ",
" XX X XX XX X XXXXXXXXX X X ",
" X XX X X X X X XX ",
" X X X X X X XX XX X ",
" X X X X X X XXXXXXX X ",
" X X X X X X X ",
"X X X X X X X X ",
" X X X X X X X X X ",
" XX XX XX XX X XX XX XX XX ",
" XXXXXXX XXXXXXX X XXXXXXX XXXXXX ",
" ",
/* FPS .. RAM .. SWAP .. ?? .. / .. */
" X ",
"XXXXX X ",
"X X ",
"XXXX X ",
"X XXX XX X X XX X X XXX X ",
"X XXXX X X X X XX XX X X X X X X X ",
"X X X X X X X X X X X X X X X X ",
" XXXX XXX XXXX X X X XX X X XXX X ",
" X X X X X X X X X X X X X ",
" X XXX X X X X X X X X X X X X X ",
" X X X X X X X X XX X X X X ",
" XXX X ",
" X X ",
" X X X ",
" XXX X ",
" "
};
#define FPS_GLYPH 10
#define RAM_GLYPH 11
#define SWAP_GLYPH 12
#define SLASH_GLYPH 14
#define FPS_COUNTS 5
#define FPS_INTERVAL 200
#define BEAT_INTERVAL 500
#define CYCLE_INTERVAL 5000
#define MEM_INTERVAL 1000
#define PROFILE_INTERVAL 100
GLubyte profile_font[128][13] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* NULL */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* controls */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* space */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x07, 0x65, 0x67, 0x30, 0x30, 0x18, 0x0c, 0x0c, 0xe6, 0xa6, 0xe0}, /* % */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x30, 0x60, 0x60, 0xc0, 0xc0, 0xc0, 0x60, 0x60, 0x30, 0x18}, /* ( */
{0x00, 0x00, 0x18, 0x0c, 0x06, 0x06, 0x03, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x18}, /* ) */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00}, /* - */
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* period */
{0x00, 0x00, 0xc0, 0x60, 0x60, 0x30, 0x30, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03}, /* slash */
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, /* digits */
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x58, 0x38, 0x18},
{0x00, 0x00, 0xff, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0x7e, 0xc3, 0x03, 0x03, 0x06, 0x1e, 0x06, 0x03, 0x03, 0xc3, 0x7e},
{0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0xff, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0x03, 0x03, 0xc3, 0xf7, 0xdc, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0xc3, 0xe6, 0x7c, 0x30, 0x18, 0x0c, 0x06},
{0x00, 0x00, 0x30, 0x30, 0x18, 0x18, 0x3e, 0x0c, 0x0c, 0x06, 0x06, 0xc3, 0xff},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0x66, 0x3c, 0x66, 0xc3, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0x03, 0x03, 0x3f, 0x67, 0xc3, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, /* colon */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* semi */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* @ */
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, /* upper case */
{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},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c3, 0xc3, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* [ */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* _ */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* ` */
/* the lower case are copies of the upper case for now */
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, /* lower case */
{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e},
{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc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 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* { */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /* DEL */
};
static DWORD last_fps, last_time, last_beat, last_cycle, cur_count, cur_time, beat, cycle;
static DWORD count_ptr, count_list[FPS_COUNTS], time_list[FPS_COUNTS];
static DWORD last_mem_update;
static MEMORYSTATUS mem_status;
static DWORD last_profile;
static query_info prof_timers[50];
static query_info prof_counters[50];
static int num_timers, num_counters;
extern int show_fps, show_mem;
extern const int tglogo_imgwidth, tglogo_imgheight;
extern const int tglogo_width, tglogo_height;
extern const float tglogo_x0, tglogo_y0, tglogo_x1, tglogo_y1;
extern const unsigned char tglogo_data[];
static void compute_fps(void)
{
DWORD ctime = GetTickCount(), delta;
count_list[count_ptr]++;
delta = ctime - last_time;
if (delta > FPS_INTERVAL) {
/* time to update fps */
time_list[count_ptr] = delta;
cur_count += count_list[count_ptr];
cur_time += time_list[count_ptr];
last_fps = cur_count * 1000 / cur_time;
last_time = ctime;
if (++count_ptr >= FPS_COUNTS) count_ptr = 0;
cur_count -= count_list[count_ptr];
cur_time -= time_list[count_ptr];
count_list[count_ptr] = 0;
time_list[count_ptr] = 0;
}
delta = ctime - last_beat;
if (delta > BEAT_INTERVAL) {
/* "heartbeat" */
#if 0 /* this currently flashes the "FPS" glyph, which is annoying */
beat = !beat;
#else
beat = TRUE;
#endif
last_beat = ctime;
}
cycle = ctime - last_cycle;
while (cycle > CYCLE_INTERVAL) {
last_cycle += CYCLE_INTERVAL;
cycle -= CYCLE_INTERVAL;
}
delta = ctime - last_mem_update;
if (delta > MEM_INTERVAL) {
/* time to update memory status */
GlobalMemoryStatus(&mem_status);
last_mem_update = ctime;
}
#ifdef WINE_PROFILE_ON
delta = ctime - last_profile;
if (delta > PROFILE_INTERVAL) {
/* update the profile stats */
num_timers = wine_query_timers( prof_timers, 50, HUD_FLAG | RESET_FLAG );
num_counters = wine_query_counters( prof_counters, 50, HUD_FLAG | RESET_FLAG );
last_profile = ctime;
} else {
wine_query_timers( NULL, 0, HUD_FLAG | RESET_FLAG );
wine_query_counters( NULL, 0, HUD_FLAG | RESET_FLAG );
}
#endif
}
static DWORD ConvMB(DWORD b)
{
return (b+512*1024)/(1024*1024);
}
#ifdef HAVE_OPENGL
static void GLX_render_glyph(unsigned char ch, unsigned x, unsigned y)
{
unsigned r;
unsigned c;
switch (ch) {
case ' ':
return;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
ch -= '0';
break;
case '/':
ch = SLASH_GLYPH;
break;
}
r = ch/5;
c = ch - r*5;
glTexCoord2f(c/8.0, r/4.0); glVertex2f(x , y );
glTexCoord2f((c+1)/8.0, r/4.0); glVertex2f(x+16, y );
glTexCoord2f((c+1)/8.0, (r+1)/4.0); glVertex2f(x+16, y+16);
glTexCoord2f(c/8.0, (r+1)/4.0); glVertex2f(x , y+16);
}
static unsigned GLX_render_text(char*text, unsigned x, unsigned y)
{
unsigned u;
for (u=0; text[u]; u++, x+=16)
GLX_render_glyph(text[u], x, y);
return x;
}
void printString(char *text, int x, int y)
{
unsigned i;
for( i=0; text[i]; i++, x+=10 ) {
glTexCoord2f( (text[i]%16)/16.0, (text[i]/16)/8.0 ); glVertex2f(x , y);
glTexCoord2f( ((text[i]%16)+1)/16.0, (text[i]/16)/8.0 ); glVertex2f(x+8, y);
glTexCoord2f( ((text[i]%16)+1)/16.0, ((text[i]/16)+1)/8.0); glVertex2f(x+8, y+16);
glTexCoord2f( (text[i]%16)/16.0, ((text[i]/16)+1)/8.0); glVertex2f(x , y+16);
}
}
void X11DRV_GLX_DisplayFPS(LPD3DCONTEXT ctx, LPD3DTARGET tgt)
{
char fps_text[16], ram_text[64], swap_text[64];
unsigned x, y, w, mw, pass, ofs;
if (!show_fps) return;
compute_fps();
sprintf(fps_text, "%c%3ld", beat ? FPS_GLYPH : ' ', last_fps);
sprintf(ram_text, "%c%4ld/%4ld", RAM_GLYPH,
ConvMB(mem_status.dwTotalPhys - mem_status.dwAvailPhys),
ConvMB(mem_status.dwTotalPhys));
sprintf(swap_text, "%c%4ld/%4ld", SWAP_GLYPH,
ConvMB(mem_status.dwTotalPageFile - mem_status.dwAvailPageFile),
ConvMB(mem_status.dwTotalPageFile));
X11DRV_GLX_StartDraw(ctx, tgt, GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT, GL_CLIENT_VERTEX_ARRAY_BIT);
glEnable(GL_TEXTURE_2D);
if (ctx->hud_font) glBindTexture(GL_TEXTURE_2D, ctx->hud_font);
else {
BYTE *conv;
conv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128*64);
for (y=0; y<48; y++) {
for (x=0; x<80; x++) {
conv[y*128+x] = (numbers[y][x] == 'X') ? 255 : 0;
}
}
glGenTextures(1, &ctx->hud_font);
glBindTexture(GL_TEXTURE_2D, ctx->hud_font);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 128, 64, 0, GL_ALPHA, GL_UNSIGNED_BYTE, conv);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
HeapFree(GetProcessHeap(), 0, conv);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ofs = 0; x = tglogo_width; y = 0;
glBegin(GL_QUADS);
for (pass=0; pass<2; pass++) {
switch (pass) {
case 0:
glColor4f(0.0, 0.0, 0.0, 0.75);
ofs = 1;
break;
case 1:
glColor4f(0.5, 1.0, 0.5, 1.0);
ofs = 0;
break;
}
mw = w = GLX_render_text(fps_text, ofs + x, ofs + y);
if (show_mem) {
w = GLX_render_text(ram_text, ofs + x, ofs + y + 16);
if (w > mw) mw = w;
w = GLX_render_text(swap_text, ofs + x, ofs + y + 32);
if (w > mw) mw = w;
}
}
x = 0; y = 0;
glEnd();
if (ctx->hud_logo) glBindTexture(GL_TEXTURE_2D, ctx->hud_logo);
else {
glGenTextures(1, &ctx->hud_logo);
glBindTexture(GL_TEXTURE_2D, ctx->hud_logo);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tglogo_imgwidth, tglogo_imgheight, 0, GL_BGRA, GL_UNSIGNED_BYTE, &tglogo_data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
}
glBegin(GL_QUADS);
glColor4f(1.0, 1.0, 1.0, 0.75);
{
float x0, y0, x1, y1, hc, c;
x0 = x; y0 = y; x1 = x + tglogo_width; y1 = y + tglogo_height;
#if 1 /* rotate around Y axis */
hc = (float)tglogo_width/2;
c = sin(cycle*2*M_PI/CYCLE_INTERVAL)*hc;
x0 = x + hc - c;
x1 = x + hc + c;
#endif
glTexCoord2f(tglogo_x0, tglogo_y0); glVertex2f(x0, y0);
glTexCoord2f(tglogo_x1, tglogo_y0); glVertex2f(x1, y0);
glTexCoord2f(tglogo_x1, tglogo_y1); glVertex2f(x1, y1);
glTexCoord2f(tglogo_x0, tglogo_y1); glVertex2f(x0, y1);
}
glEnd();
#ifdef WINE_PROFILE_ON
if( num_timers+num_counters > 0 ) {
if (ctx->hud_profile_font) glBindTexture(GL_TEXTURE_2D, ctx->hud_profile_font);
else {
BYTE *conv;
/* each character is 8 pixels wide and 16 pixels high */
/* the texture is 16 chars wide and 8 chars high */
int charwpix = 8, charhpix = 16;
int texwchar = 16, texhchar = 8;
int texw = texwchar*charwpix, texh = texhchar*charhpix;
int bits;
conv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, texw*texh);
for (y=0; y<128; y++) {
for (x=0; x<13; x++) {
for( bits=0; bits<8; bits++ ) {
conv[(y/texwchar)*charhpix*(texw) +
(y%texwchar)*charwpix +
x*(texw) +
bits] = (profile_font[y][12-x] & (1<<(7-bits))) ? 255 : 0;
}
}
}
glGenTextures(1, &ctx->hud_profile_font);
glBindTexture(GL_TEXTURE_2D, ctx->hud_profile_font);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texw, texh, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, conv);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
HeapFree(GetProcessHeap(), 0, conv);
}
glBegin(GL_QUADS);
for( pass=0; pass<2; pass++ ) {
switch (pass) {
case 0:
glColor4f(0.0, 0.0, 0.0, 0.75);
ofs = 1;
break;
case 1:
ofs = 0;
break;
}
x = 10; y = 80;
for( w=0; w<num_timers; w++ ) {
if( pass ) glColor4f(0.5, (w%2)?1.0:0.85, 0.5, 1.0);
printString(prof_timers[w].data, ofs+x, ofs+y+w*13);
}
x = 10; y = 80+num_timers*13+10;
for( w=0; w<num_counters; w++ ) {
if( pass ) glColor4f(0.2, (w%2)?1.0:0.85, 0.5, 1.0);
printString(prof_counters[w].data, ofs+x, ofs+y+w*13);
}
} /* pass */
glEnd();
}
#endif
X11DRV_GLX_EndDraw(ctx, GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT, GL_CLIENT_VERTEX_ARRAY_BIT);
}
#endif