-
Notifications
You must be signed in to change notification settings - Fork 3
/
glv.h
154 lines (122 loc) · 4.2 KB
/
glv.h
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
/*
* glv.h
* Copyright (C) 2006, Tomasz Koziara (t.koziara AT gmail.com)
* --------------------------------------------------------------
* simple opengl viewer
*/
/* This file is part of Solfec.
* Solfec is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Solfec 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Solfec. If not, see <http://www.gnu.org/licenses/>. */
#ifndef __glv__
#define __glv__
#if __cplusplus
extern "C" { /* C */
#endif
typedef int (*View_Menu) (char***, int**); /* menu set up (CALLED FIRST) */
typedef void (*View_Init) (void); /* initialisation (CALLED SECOND) */
typedef int (*View_Idle) (void); /* idle callback => return != 0 to cose view update */
typedef void (*View_Quit) (void); /* on viewer exit */
typedef void (*View_Render) (void); /* window rendering */
typedef void (*View_Key) (int key, int x, int y); /* keyboard */
typedef void (*View_Keyspec) (int key, int x, int y); /* special keyboard */
typedef void (*View_Mouse) (int button, int state, int x, int y); /* mouse */
typedef void (*View_Motion) (int x, int y); /* mouse motion */
typedef void (*View_Passive_Motion) (int x, int y); /* passive mouse motion */
/* create main window */
void GLV (
int *argc,
char **argv,
char *title,
int width,
int height,
double *extents,
View_Menu menu,
View_Init init,
View_Idle idle,
View_Quit quit,
View_Render render,
View_Key key,
View_Keyspec keyspec,
View_Mouse mouse,
View_Motion motion,
View_Passive_Motion passive);
/* redraw all */
void GLV_Redraw_All (void);
/* reset scene extents */
void GLV_Reset_Extents (double *extents);
/* update scene extents */
void GLV_Update_Extents (double *extents);
/* get minimal view extent */
double GLV_Minimal_Extent ();
/* get main window sizes */
void GLV_Sizes (int *w, int *h);
/* open a 2D window with 1-to-1
* coordinate-to-pixel mapping;
* window's content is not exported
* in BMP and AVI format */
int GLV_Open_Window (
int x,
int y,
int w,
int h,
View_Render render);
/* close window */
void GLV_Close_Window (int window);
/* open a viewport whose content
* is exported in BMP and AVI format */
int GLV_Open_Viewport (
int x, /* negtive => maintain relative position when resizing */
int y, /* -||- */
int w, /* negative => maintain aspect ratio when resizing */
int h, /* -||- */
int is3D,
View_Render render);
/* move viewport */
void GLV_Move_Viewport (int viewport, int x, int y, int w, int h);
/* resize viewport */
void GLV_Resize_Viewport (int viewport, int w, int h);
/* close window */
void GLV_Close_Viewport (int viewport);
/* show tiled text intput window
* and return read text by callback */
void GLV_Read_Text (char *title, void (*done) (char *text));
/* check whether the last text reading is still active */
int GLV_Reading_Text ();
/* output text at specified coordinates */
enum {GLV_FONT_8_BY_13 = 8, GLV_FONT_9_BY_15 = 9,
GLV_FONT_10 = 10, GLV_FONT_12 = 12, GLV_FONT_18 = 18};
void GLV_Print (double x, double y, double z, int font, char *fmt, ...);
/* get width of printed text in pixels */
int GLV_Print_Width (int font, char *fmt, ...);
/* output screen shot bitmap */
void GLV_Screen_Bitmap (char *path);
/* take over mouse */
void GLV_Hold_Mouse ();
/* release mouse takeover */
void GLV_Release_Mouse ();
/* viewer specific projection matrix (useful for picking) */
void GLV_SetProjectionMatrix (int w, int h);
/* enable drawing rectangle in screen coordinates */
void GLV_Rectangle_On (int x1, int y1, int x2, int y2);
/* disable drawing rectangle */
void GLV_Rectangle_Off ();
/* stop filming */
void GLV_AVI_Stop ();
/* set window title */
void GLV_Window_Title (char *fmt, ...);
/* set trackball center */
void GLV_Trackball_Center (double *point);
#if __cplusplus
} /* extern C */
#endif
#endif