FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
gfx_screenlist.c
Go to the documentation of this file.
1
/* Function to get supported video modes. */
2
3
#include "
fb_gfx.h
"
4
5
6
static
int
*
list
=
NULL
,
list_size
,
current
;
7
8
9
/*:::::*/
10
static
void
add_mode
(
int
mode)
11
{
12
int
i;
13
14
if
(!
list
) {
15
list
= malloc(
sizeof
(
int
) * 2);
16
list
[0] = mode;
17
list
[1] = 0;
18
list_size
= 1;
19
}
20
else
{
21
for
(i = 0; i <
list_size
; i++) {
22
if
(
list
[i] == mode)
23
return
;
24
}
25
list
= (
int
*)realloc(
list
,
sizeof
(
int
) * (list_size + 1));
26
list
[
list_size
] = mode;
27
list_size++;
28
}
29
}
30
31
32
/*:::::*/
33
static
int
mode_sorter
(
const
void
*e1,
const
void
*e2)
34
{
35
int
m1 = *(
int
*)e1;
36
int
m2 = *(
int
*)e2;
37
38
if
((m1 >> 16) > (m2 >> 16))
39
return
1;
40
else
if
(((m1 >> 16) == (m2 >> 16)) && ((m1 & 0xFFFF) > (m2 & 0xFFFF)))
41
return
1;
42
else
if
(m1 == m2)
43
return
0;
44
else
45
return
-1;
46
}
47
48
/*:::::*/
49
FBCALL
int
fb_GfxScreenList
(
int
depth)
50
{
51
const
GFXDRIVER
*driver;
52
int
i, j, *temp,
size
;
53
54
if
(depth > 0) {
55
if
(
list
)
56
free(
list
);
57
list
=
NULL
;
58
for
(i = 0;
__fb_gfx_drivers_list
[i]; i++) {
59
driver =
__fb_gfx_drivers_list
[i];
60
if
(driver->
fetch_modes
) {
61
temp = driver->
fetch_modes
(depth, &size);
62
if
(temp) {
63
for
(j = 0; j <
size
; j++)
64
add_mode
(temp[j]);
65
free(temp);
66
}
67
}
68
}
69
if
(
list
)
70
qsort(
list
,
list_size
,
sizeof
(
int
),
mode_sorter
);
71
current
= 0;
72
}
73
74
current
++;
75
if
((!
list
) || (
current
>
list_size
))
76
return
0;
77
return
list
[
current
- 1];
78
}
gfxlib2
gfx_screenlist.c
Generated on Thu Jan 23 2014 19:40:06 for FreeBASIC by
1.8.4