FreeBASIC  0.91.0
gfx_control.c
Go to the documentation of this file.
1 /* Screen states getter/setter routines. */
2 
3 #include "fb_gfx.h"
4 #include "fb_gfx_gl.h"
5 
6 FBCALL void fb_GfxControl_s( int what, FBSTRING *param )
7 {
8  FBSTRING *src;
9 
10  if (!param)
11  return;
12 
13  switch ( what ) {
14  case GET_WINDOW_TITLE:
15  if (!__fb_window_title )
16  src = &__fb_ctx.null_desc;
17  else
19  fb_StrAssign( param, -1, src, -1, FB_FALSE );
20  break;
21 
22  case GET_DRIVER_NAME:
23  if (!__fb_gfx)
24  src = &__fb_ctx.null_desc;
25  else
26  src = fb_StrAllocTempDescF( __fb_gfx->driver->name, strlen(__fb_gfx->driver->name) + 1 );
27  fb_StrAssign( param, -1, src, -1, FB_FALSE );
28  break;
29 
30  case GET_GL_EXTENSIONS:
31  if ((!__fb_gfx) || (!(__fb_gfx->flags & OPENGL_SUPPORT)))
32  src = &__fb_ctx.null_desc;
33 #ifndef DISABLE_OPENGL
34  else
36 #endif
37  fb_StrAssign( param, -1, src, -1, FB_FALSE );
38  break;
39 
40  case SET_WINDOW_TITLE:
41  fb_GfxSetWindowTitle(param);
42  break;
43 
44  case SET_DRIVER_NAME:
48  if (strlen(param->data) > 0)
49  __fb_gfx_driver_name = strdup(param->data);
50  break;
51  }
52 }
53 
54 FBCALL void fb_GfxControl_i( int what, ssize_t *param1, ssize_t *param2, ssize_t *param3, ssize_t *param4 )
55 {
57  int res = 0;
58  ssize_t res1 = 0, res2 = 0, res3 = 0, res4 = 0;
59  ssize_t temp1, temp2, temp3, temp4;
60 
61  if (!param1) param1 = &temp1;
62  if (!param2) param2 = &temp2;
63  if (!param3) param3 = &temp3;
64  if (!param4) param4 = &temp4;
65 
66  switch ( what ) {
67  case GET_WINDOW_POS:
69  res = __fb_gfx->driver->set_window_pos(0x80000000, 0x80000000);
70  res1 = (short)(res & 0xFFFF);
71  res2 = res >> 16;
72  break;
73 
74  case GET_WINDOW_HANDLE:
75  if (__fb_gfx)
76  res1 = fb_hGetWindowHandle();
77  break;
78 
79  case GET_DESKTOP_SIZE:
80  {
81  ssize_t w = 0, h = 0, depth = 0, refresh = 0;
82  fb_hScreenInfo( &w, &h, &depth, &refresh );
83  res1 = w;
84  res2 = h;
85  }
86  break;
87 
88  case GET_SCREEN_SIZE:
89  if (__fb_gfx) {
90  res1 = __fb_gfx->w;
91  res2 = __fb_gfx->h;
92  }
93  break;
94 
95  case GET_SCREEN_DEPTH:
96  if (__fb_gfx)
97  res1 = __fb_gfx->depth;
98  break;
99 
100  case GET_SCREEN_BPP:
101  if (__fb_gfx)
102  res1 = __fb_gfx->bpp;
103  break;
104 
105  case GET_SCREEN_PITCH:
106  if (__fb_gfx)
107  res1 = __fb_gfx->pitch;
108  break;
109 
110  case GET_SCREEN_REFRESH:
111  if (__fb_gfx)
112  res1 = __fb_gfx->refresh_rate;
113  break;
114 
116  if ((__fb_gfx) && (__fb_gfx->bpp > 1))
117  res1 = MASK_COLOR_32;
118  break;
119 
120  case GET_VIEWPORT:
121  if (__fb_gfx) {
122  res1 = context->view_x;
123  res2 = context->view_y;
124  res3 = context->view_x + context->view_w - 1;
125  res4 = context->view_y + context->view_h - 1;
126  }
127  break;
128 
129  case GET_PEN_POS:
130  if (__fb_gfx) {
131  res1 = context->last_x;
132  res2 = context->last_y;
133  }
134  break;
135 
136  case GET_COLOR:
137  if (__fb_gfx) {
138  res1 = context->fg_color;
139  res2 = context->bg_color;
140  }
141  break;
142 
144  if (__fb_gfx)
146  break;
147 
148  case GET_HIGH_PRIORITY:
149  if (__fb_gfx)
150  res1 = (__fb_gfx->flags & HIGH_PRIORITY) ? FB_TRUE : FB_FALSE;
151  break;
152 
153  case SET_WINDOW_POS:
154  if ((__fb_gfx) && (__fb_gfx->driver->set_window_pos))
155  __fb_gfx->driver->set_window_pos(*param1, *param2);
156  break;
157 
158  case SET_PEN_POS:
159  if (__fb_gfx) {
160  if (*param1 != 0x80000000)
161  context->last_x = *param1;
162  if (*param2 != 0x80000000)
163  context->last_y = *param2;
164  }
165  break;
166 
168  if ((__fb_gfx) && (*param1 != 0x80000000)) {
169  if (*param1)
171  else
173  }
174  break;
175 
176 #ifndef DISABLE_OPENGL
177  case SET_GL_COLOR_BITS:
178  __fb_gl_params.color_bits = *param1;
179  break;
180 
182  __fb_gl_params.color_red_bits = *param1;
183  break;
184 
187  break;
188 
191  break;
192 
195  break;
196 
197  case SET_GL_DEPTH_BITS:
198  __fb_gl_params.depth_bits = *param1;
199  break;
200 
201  case SET_GL_STENCIL_BITS:
202  __fb_gl_params.stencil_bits = *param1;
203  break;
204 
205  case SET_GL_ACCUM_BITS:
206  __fb_gl_params.accum_bits = *param1;
207  break;
208 
210  __fb_gl_params.accum_red_bits = *param1;
211  break;
212 
215  break;
216 
219  break;
220 
223  break;
224 
225  case SET_GL_NUM_SAMPLES:
226  __fb_gl_params.num_samples = *param1;
227  break;
228 #endif
229 
230  case POLL_EVENTS:
231  if ((__fb_gfx) && (__fb_gfx->driver->poll_events))
233  break;
234 
235  }
236 
237  if (what < SET_FIRST_SETTER) {
238  *param1 = res1;
239  *param2 = res2;
240  *param3 = res3;
241  *param4 = res4;
242  }
243 }