26#ifndef __TGFCLIENT__H__
27#define __TGFCLIENT__H__
44extern unsigned char *
GfImgReadPng(
const char *filename,
int *widthp,
int *heightp,
float gamma);
45extern int GfImgWritePng(
unsigned char *img,
const char *filename,
int width,
int height);
50extern void GfScrInit(
int argc,
char *argv[]);
65#define GFUI_GRBUTTON 2
66#define GFUI_SCROLLIST 3
67#define GFUI_SCROLLBAR 4
71#define GFUI_ALIGN_HL_VB 0x00
72#define GFUI_ALIGN_HL_VC 0x01
73#define GFUI_ALIGN_HL_VT 0x02
74#define GFUI_ALIGN_HC_VB 0x10
75#define GFUI_ALIGN_HC_VC 0x11
76#define GFUI_ALIGN_HC_VT 0x12
77#define GFUI_ALIGN_HR_VB 0x20
78#define GFUI_ALIGN_HR_VC 0x21
79#define GFUI_ALIGN_HR_VT 0x22
82#define GFUI_MOUSE_UP 0
83#define GFUI_MOUSE_DOWN 1
87#define GFUI_KEY_DOWN 1
91#define GFUI_SB_RIGHT 1
94#define GFUI_SB_BOTTOM 4
97#define GFUI_HORI_SCROLLBAR 0
98#define GFUI_VERT_SCROLLBAR 1
238#define GFUI_VISIBLE 1
239#define GFUI_INVISIBLE 0
241#define GFUI_DISABLE 1
243extern int GfuiEnable(
void *scr,
int id,
int flag);
247#define GFUI_FONT_BIG 0
248#define GFUI_FONT_LARGE 1
249#define GFUI_FONT_MEDIUM 2
250#define GFUI_FONT_SMALL 3
251#define GFUI_FONT_BIG_C 4
252#define GFUI_FONT_LARGE_C 5
253#define GFUI_FONT_MEDIUM_C 6
254#define GFUI_FONT_SMALL_C 7
255#define GFUI_FONT_DIGIT 8
257 int font,
int x,
int y,
int align,
int maxlen);
258extern int GfuiLabelCreateEx(
void *scr,
const char *text,
float *fgColor,
int font,
int x,
int y,
int align,
int maxlen);
260extern int GfuiTipCreate(
void *scr,
const char *text,
int maxlen);
275extern void GfuiPrintString(
const char *text,
float *fgColor,
int font,
int x,
int y,
int align);
292#define GFUI_BTNSZ 300
294 int x,
int y,
int width,
int align,
int mouse,
304 int x,
int y,
int width,
int align,
int mouse,
314 int x,
int y,
int width,
int align,
int mouse,
324 int x,
int y,
int width,
int align,
int mouse,
337extern int GfuiButtonStateCreate(
void *scr,
const char *text,
int font,
int x,
int y,
int width,
int align,
int mouse,
340extern int GfuiGrButtonCreateAction(
void *scr,
const char *disabled,
const char *enabled,
const char *focused,
const char *pushed,
341 int x,
int y,
int align,
int mouse,
350extern int GfuiGrButtonCreate(
void *scr,
const char *disabled,
const char *enabled,
const char *focused,
const char *pushed,
351 int x,
int y,
int align,
int mouse,
366extern int GfuiEditboxCreate(
void *scr,
const char *text,
int font,
int x,
int y,
int width,
int maxlen,
402 int min,
int max,
int len,
int start,
478#define GFCTRL_JOY_UNTESTED -1
479#define GFCTRL_JOY_NONE 0
480#define GFCTRL_JOY_PRESENT 1
482#define GFCTRL_JOY_MAXBUTTON 32
Scalar min(Scalar x, Scalar y)
Scalar max(Scalar x, Scalar y)
static int onKeyAction(unsigned char key, int, int state)
static int onSKeyAction(int key, int, int state)
static void onPush(tCmdInfo *cmdInfo)
static void onActivate(void)
static void onFocusLost(void)
static tCtrlMouseInfo mouseInfo
static void onSelect(void *)
int GfctrlJoyGetCurrent(tCtrlJoyInfo *joyInfo)
Get the joystick current values.
tCtrlMouseInfo * GfctrlMouseInit(void)
Initialize the mouse control.
int GfctrlMouseGetCurrent(tCtrlMouseInfo *mouseInfo)
Get the mouse current values.
void GfctrlMouseRelease(tCtrlMouseInfo *mouseInfo)
Release the tCtrlMouseInfo structure.
void GfctrlGetRefByName(const char *name, tCtrlRef *ref)
Get a control reference by its name.
int GfctrlJoyIsPresent(void)
Check if a joystick is present.
const char * GfctrlGetNameByRef(GfCtrlType type, int index)
Get a control name by its reference.
tCtrlJoyInfo * GfctrlJoyInit(void)
Initialize the joystick control.
void GfctrlJoyRelease(tCtrlJoyInfo *joyInfo)
Release the tCtrlJoyInfo structure.
void GfuiMouseSetHWPresent(void)
Force the hardware mouse pointer.
bool GfctrlIsEventBlacklisted(void *parmHandle, const char *driversSection, const char *event)
Check if given event is blacklisted (used for buttons or axis which fire a button AND move event).
void GfctrlMouseInitCenter(void)
Get the reference position.
void GfctrlMouseCenter(void)
Recentre the mouse on the screen.
float tdble
Floating point type used in TORCS.
int GfuiMenuButtonCreateAction(void *menu, const char *text, const char *tip, const tGfuiAction &onpush)
Add a menu button with a focus tip.
int GfuiButtonGetFocused(void)
Get the Id of the button focused in the current screen.
void GfuiKeyEventRegisterCurrent(tfuiKeyCallback onKeyAction)
Set the ordinary-key interceptor on the currently active screen.
void * GfuiScreenCreateExAction(float *bgColor, const tGfuiAction &onActivate, const tGfuiAction &onDeactivate, int mouseAllowed)
Create a screen.
void GfuiMouseHide(void)
Disallow the software mouse cursor on the active screen.
int GfuiButtonStateCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a state button to a screen.
void GfuiHelpScreen(void *prevScreen)
Generate a help screen.
void GfuiHookRelease(void *hook)
Release the given hook.
void GfuiMenuDefaultKeysAdd(void *scr)
Add the default menu keyboard callback to a screen.
void GfuiLabelSetText(void *scr, int id, const char *text)
Change the text of a label.
void * GfuiHookCreate(void *userDataOnActivate, tfuiCallback onActivate)
Create a callback-only screen hook.
int GfuiMenuButtonCreate(void *menu, const char *text, const char *tip, void *userdata, tfuiCallback onpush)
Add a menu button using a callback with caller-supplied data.
int GfuiFontHeight(int font)
Get the height of an initialized GUI font.
void GfuiScreenRelease(void *screen)
Release the given screen.
int GfuiEditboxGetFocused(void)
Get the Id of the editbox focused in the current screen.
int GfuiScrollBarCreate(void *scr, int x, int y, int align, int width, int orientation, int min, int max, int len, int start, void *userData, tfuiSBCallback onScroll)
Create a new scroll bar.
int GfuiScrollListCreateAction(void *scr, int font, int x, int y, int align, int width, int height, int scrollbar, const tGfuiAction &onSelect)
Create a new scroll list.
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
void GfuiStaticImageSet(void *scr, int id, char *name)
Replace an image by another one.
int GfuiGrButtonCreate(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create an image button using callbacks with caller-supplied data.
void GfuiAddKeyAction(void *scr, unsigned char key, const char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Keyboard callback to a screen.
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
int GfuiFontWidth(int font, const char *text)
Measure text using an initialized GUI font.
int GfuiEditboxCreateAction(void *scr, const char *text, int font, int x, int y, int width, int maxlen, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost, int margin=10)
Add an edit box to a screen.
void GfuiSKeyEventRegisterCurrent(tfuiSKeyCallback onSKeyAction)
Set the special-key interceptor on the currently active screen.
void GfuiIdle(void)
Process held-mouse-button repeat actions on the active screen.
void * GfuiMenuScreenCreate(const char *title)
Create a new menu screen.
int GfuiScrollListInsertElement(void *scr, int Id, char *element, int index, void *userData)
Insert an element in a scroll list.
int GfuiScrollListCreate(void *scr, int font, int x, int y, int align, int width, int height, int scrollbar, void *userDataOnSelect, tfuiCallback onSelect)
Create a scrolling list using a callback with caller-supplied data.
int GfuiLeanButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Create a text button without horizontal margins.
int GfuiEditboxCreate(void *scr, const char *text, int font, int x, int y, int width, int maxlen, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost, int margin=10)
Create an edit box using callbacks with caller-supplied data.
int GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create a text button using callbacks with caller-supplied data.
int GfuiVisibilitySet(void *scr, int id, int visible)
Set/unset the visibility attribute of an object.
void GfuiDisplay(void)
Draw the active GUI screen and swap the GLUT buffers.
void GfuiAddSKeyAction(void *scr, int key, const char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Special Keyboard shortcut to the screen.
int GfuiMenuButtonCreateActionWithDisabledTip(void *menu, const char *text, const char *tip, const char *disabledTip, const tGfuiAction &onpush)
Add a button to a menu screen.
void * GfuiScreenCreateEx(float *bgColor, void *userDataOnActivate, tfuiCallback onActivate, void *userDataOnDeactivate, tfuiCallback onDeactivate, int mouseAllowed)
Create a screen using callbacks with caller-supplied data.
char * GfuiScrollListExtractElement(void *scr, int Id, int index, void **userData)
Extract the specified element from the scroll list.
void GfuiButtonSetText(void *scr, int id, const char *text)
Change the label of a button.
int GfuiEnable(void *scr, int id, int flag)
Enable / Disable an object.
int GfuiMenuBackQuitButtonCreate(void *menu, const char *text, const char *tip, void *userdata, tfuiCallback onpush)
Add the bottom Back/Quit menu button using a callback with caller-supplied data.
void GfuiRegisterKey(unsigned char key, char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Bind an ordinary key on the currently active screen.
void GfuiUnSelectCurrent(void)
Remove focus from the active screen's current widget.
void * GfuiHookCreateAction(const tGfuiAction &onActivate)
Create a callback hook.
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
char * GfuiScrollListGetSelectedElement(void *scr, int Id, void **userData)
Get the selected element from the scroll list.
char * GfuiEditboxGetString(void *scr, int id)
Get the current text of an edit box.
void GfuiScreenReplace(void *screen)
Activate a screen and make it current plus release the current screen.
char * GfuiScrollListExtractSelectedElement(void *scr, int Id, void **userData)
Extract the selected element from the scroll list (removed).
int GfuiTipCreate(void *scr, const char *text, int maxlen)
Add a Tip (generally associated with a button).
char * GfuiScrollListGetElement(void *scr, int Id, int index, void **userData)
Get the specified element from the scroll list.
void GfuiScrollBarPosSet(void *scr, int id, int min, int max, int len, int start)
Set new values for position.
void GfuiPrintString(const char *text, float *fgColor, int font, int x, int y, int align)
Draw text immediately in the current OpenGL context without creating a widget.
int GfuiLabelCreateEx(void *scr, const char *text, float *fgColor, int font, int x, int y, int align, int maxlen)
Create a new label (extended version).
int GfuiLabelCreate(void *scr, const char *text, int font, int x, int y, int align, int maxlen)
Add a label to a screen.
void GfuiLabelSetColor(void *scr, int id, float *color)
Change the color of a label.
void GfuiKeyEventRegister(void *scr, tfuiKeyCallback onKeyAction)
Set the ordinary-key event interceptor for a screen.
int GfuiButtonStateCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Create a text button that toggles between pressed and released while focused.
int GfuiGrButtonCreateAction(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a graphical button to a screen.
void GfuiAddKey(void *scr, unsigned char key, const char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Bind an ordinary key on a screen using callbacks with caller-supplied data.
tMouseInfo * GfuiMouseInfo(void)
Get the GUI's current mouse state.
void GfuiMouseShow(void)
Allow the software mouse cursor on the active screen.
void GfuiRegisterKeyAction(unsigned char key, char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Keyboard callback to the current screen.
void GfuiAddSKey(void *scr, int key, const char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Bind a GLUT special key, such as an arrow or function key, on a screen.
void * GfuiScreenCreate(void)
Create a new screen.
int GfuiScreenIsActive(void *screen)
Tell if the screen is active or not.
int GfuiScrollBarPosGet(void *scr, int id)
Get the current position of a scroll bar.
int GfuiMenuBackQuitButtonCreateAction(void *menu, const char *text, const char *tip, const tGfuiAction &onpush)
Add the "Back" or "Quit" button at the bottom of the menu screen.
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
void GfuiSKeyEventRegister(void *scr, tfuiSKeyCallback onSKeyAction)
Set the special-key event interceptor for a screen.
int GfuiButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a button to a screen.
int GfuiStaticImageCreate(void *scr, int x, int y, int w, int h, char *name)
Create a new static image.
void GfuiDisplayNothing(void)
GLUT display callback that performs no drawing or buffer swap.
int GfuiScrollListMoveSelectedElement(void *scr, int Id, int delta)
Move the selected element within the scroll list.
int GfuiLeanButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create a marginless text button using callbacks with caller-supplied data.
void GfuiScreenDeactivate(void)
Deactivate the current screen.
void GfuiMouseSetPos(int x, int y)
Set the mouse position.
int GfImgWritePngNoGamma(unsigned char *img, const char *filename, int width, int height)
Write a framebuffer capture to a png image on disk without gamma metadata.
unsigned char * GfImgReadPng(const char *filename, int *widthp, int *heightp, float gamma)
Load an image from disk to a buffer in RGBA mode.
void GfImgFreeTex(GLuint tex)
Free the texture.
GLuint GfImgReadTex(char *filename)
Read a png image into a texture.
int GfImgWritePng(unsigned char *img, const char *filename, int width, int height)
Write a buffer to a png image on disk.
void GfuiScreenShot(void *notused)
Save a screen shot in png format.
void GfTime2Str(char *result, int resultSize, tdble sec, int sgn)
Convert a time in seconds (float) to an ascii string.
int GfuiGlutExtensionSupported(const char *str)
Query an OpenGL extension through GLUT for the current rendering context.
void GfScrShutdown(void)
Shutdown the screen.
void * GfScrMenuInit(void *precMenu)
Create and activate the video options menu screen.
void GfScrGetSize(int *ScrW, int *ScrH, int *ViewW, int *ViewH)
Get the screen and viewport sizes.
Parameter set handle structure, multiple handles can reference the same parameter set.
Joystick Information Structure.
int edgedn[GFCTRL_JOY_MAXBUTTON *NUM_JOY]
Button transition from up to down.
int levelup[GFCTRL_JOY_MAXBUTTON *NUM_JOY]
Button state (1 = up)
int edgeup[GFCTRL_JOY_MAXBUTTON *NUM_JOY]
Button transition from down (pressed) to up.
float ax[_JS_MAX_AXES *NUM_JOY]
Axis values.
Mouse information structure.
float ax[4]
mouse axis position (mouse considered as a joystick)
int edgeup[3]
Button transition from down (pressed) to up.
int button[3]
Button state (1 = up)
int edgedn[3]
Button transition from up to down.
void(* tfuiCallback)(void *)
struct MouseInfo tMouseInfo
int(* tfuiKeyCallback)(unsigned char key, int modifier, int state)
return 1 to prevent normal key computing
void GfScrInit(int argc, char *argv[])
struct ScrollBarInfo tScrollBarInfo
Scroll bar call-back information.
@ GFCTRL_TYPE_NOT_AFFECTED
int(* tfuiSKeyCallback)(int key, int modifier, int state)
return 1 to prevent normal key computing
const char * GfctrlGetDefaultSection(GfCtrlType type)
std::function< void()> tGfuiAction
void(* tfuiSBCallback)(tScrollBarInfo *)
#define GFCTRL_JOY_MAXBUTTON