summaryrefslogtreecommitdiff
path: root/src/glut/fbdev/internal.h
blob: 082cd4f6f3a1f40dc0223d19d05428437819415d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
 * Mesa 3-D graphics library
 * Version:  6.5
 * Copyright (C) 1995-2006  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * Library for glut using mesa fbdev driver
 *
 * Written by Sean D'Epagnier (c) 2006
 */

#include <sys/time.h>
#include <linux/fb.h>
#include <GL/glfbdev.h>

#define MULTIHEAD   /* enable multihead hacks,
		       it allows the program to continue drawing
		       without reading input when a second fbdev
		       has keyboard focus it can cause
		       screen corruption that requires C-l to fix */
#define HAVE_GPM

#define MAX_VSYNC 200

/* this causes these symbols to not be exported */
#pragma GCC visibility push(hidden)


/* --------- fbdev ------------ */
extern int Redisplay;
extern int Visible;
extern int VisibleSwitch;
extern int Active;
extern int VisiblePoll;
extern int Swapping, VTSwitch;

void TestVisible(void);
int ParseFBModes(int, int, int, int, int, int);
void CreateVisual(void);

extern int FrameBufferFD;
extern unsigned char *FrameBuffer;
extern unsigned char *BackBuffer;
extern int DisplayMode;

extern char exiterror[256];

extern struct fb_fix_screeninfo FixedInfo;
extern struct fb_var_screeninfo VarInfo;

extern GLFBDevContextPtr Context;
extern GLFBDevBufferPtr Buffer;
extern GLFBDevVisualPtr Visual;

/* --- colormap --- */
#define REVERSECMAPSIZELOG 3
#define REVERSECMAPSIZE (1<<REVERSECMAPSIZELOG)

extern unsigned short RedColorMap[256],
                        GreenColorMap[256],
                        BlueColorMap[256];
extern unsigned char ReverseColorMap[REVERSECMAPSIZE]
                                    [REVERSECMAPSIZE]
                                    [REVERSECMAPSIZE];
void LoadOldColorMap(void);
void LoadColorMap(void);
void UnloadColorMap(void);
void RestoreColorMap(void);

/* --- mouse --- */
extern int MouseX, MouseY;
extern int CurrentCursor;
extern int MouseEnabled;
extern int NumMouseButtons;

void InitializeCursor(void);
void EraseCursor(void);
void DrawCursor(void);
void SwapCursor(void);

/* --- menus --- */
struct GlutMenu {
    int NumItems;
    int x, y;
    int width;
    int selected;
    struct {
	int value;
	int submenu;
	char *name;
    } *Items;
    void (*func)(int);
};

extern struct GlutMenu *Menus;

extern int ActiveMenu;
extern int CurrentMenu;

void InitializeMenus(void);
void FreeMenus(void);
void DrawMenus(void);

int TryMenu(int, int);
void OpenMenu(void);
void CloseMenu(void);

/* --- state --- */
extern int AccumSize, DepthSize, StencilSize, NumSamples;
extern struct timeval StartTime;
extern int KeyboardModifiers;

/* --- input --- */
#ifdef HAVE_GPM
extern int GpmMouse;
#endif

extern int CurrentVT;
extern int ConsoleFD;

extern double MouseSpeed;

extern int KeyRepeatMode;

void InitializeVT(int);
void RestoreVT(void);
void CloseMouse(void);
void InitializeMouse(void);

void ReceiveInput(void);

/* --- callback --- */
extern void (*DisplayFunc)(void);
extern void (*ReshapeFunc)(int width, int height);
extern void (*KeyboardFunc)(unsigned char key, int x, int y);
extern void (*KeyboardUpFunc)(unsigned char key, int x, int y);
extern void (*MouseFunc)(int key, int state, int x, int y);
extern void (*MotionFunc)(int x, int y);
extern void (*PassiveMotionFunc)(int x, int y);
extern void (*VisibilityFunc)(int state);
extern void (*SpecialFunc)(int key, int x, int y);
extern void (*SpecialUpFunc)(int key, int x, int y);
extern void (*IdleFunc)(void);
extern void (*MenuStatusFunc)(int state, int x, int y);
extern void (*MenuStateFunc)(int state);

/* --- timers --- */
struct GlutTimer {
    int time;
    void (*func)(int);
    int value;
    struct GlutTimer *next;
};

extern struct GlutTimer *GlutTimers;

/* ------- Game Mode -------- */
extern int GameMode;

#pragma GCC visibility pop