Quadtree addition to root node now functions (w/out Qt)
[ipdf/code.git] / src / screen.cpp
1 #include "common.h"
2 #include "screen.h"
3
4 #include "gl_core44.h"
5 #include <fcntl.h> // for access(2)
6 #include <unistd.h> // for access(2)
7
8 #include "bufferbuilder.h"
9 #include "shaderprogram.h"
10
11 #define BASICTEX_VERT "shaders/basictex_vert.glsl"
12 #define BASICTEX_FRAG "shaders/basictex_frag.glsl"
13
14 using namespace IPDF;
15 using namespace std;
16
17 #ifndef __MINGW32__
18 static void opengl_debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* msg, const void *data)
19 {
20         // Don't print out gl Errors we generated.
21         if (source == GL_DEBUG_SOURCE_APPLICATION) return;
22         //Error("OpenGL Error (%d): %s", id, msg);
23         // Spams this message on fglrx, disabling for now because it's damn annoying.
24         // ERROR: opengl_debug_callback (screen.cpp:21) - OpenGL Error (1011): glObjectLabel failed because (depending on the operation) a referenced binding point is empty; a referenced name is not the name of an object; or the given name is otherwise not valid to this operation (GL_INVALID_VALUE)
25 }
26 #endif
27
28 Screen::Screen(bool visible)
29 {
30
31         SDL_Init(SDL_INIT_VIDEO);
32         uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
33         if (!visible)
34                 flags |= SDL_WINDOW_HIDDEN;
35         
36         m_window = SDL_CreateWindow("IPDF", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
37                         800, 600, flags);
38
39         if (!m_window)
40         {
41                 Error("Couldn't create window!");
42                 return;
43         }
44
45         SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
46         SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
47         SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
48         SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
49
50         m_gl_context = SDL_GL_CreateContext(m_window);
51
52         ogl_LoadFunctions();
53
54         // Why is this so horribly broken?
55         if (ogl_IsVersionGEQ(3,0))
56         {
57                 Error("We require OpenGL 3.1, but you have version %d.%d!",ogl_GetMajorVersion(), ogl_GetMinorVersion());
58         }
59
60         if (!SDL_GL_ExtensionSupported("GL_ARB_shading_language_420pack"))
61         {
62                 Error("Your system does not support the ARB_shading_language_420pack extension, which is required.");
63         }
64
65         if (!SDL_GL_ExtensionSupported("GL_ARB_explicit_attrib_location"))
66         {
67                 Error("Your system does not support the ARB_explicit_attrib_location extension, which is required.");
68         }
69
70         m_frame_begin_time = SDL_GetPerformanceCounter();
71         m_last_frame_time = 0;
72         m_last_frame_gpu_timer = 0;
73         glGenQueries(1, &m_frame_gpu_timer);
74         glBeginQuery(GL_TIME_ELAPSED, m_frame_gpu_timer);
75
76         #ifndef __MINGW32__
77         glDebugMessageCallback(opengl_debug_callback, 0);
78         #endif
79
80         GLuint default_vao;
81         glGenVertexArrays(1, &default_vao);
82         glBindVertexArray(default_vao);
83
84         m_texture_prog.InitialiseShaders(BASICTEX_VERT, BASICTEX_FRAG);
85         m_texture_prog.Use();
86
87         // We always want to use the texture bound to texture unit 0.
88         GLint texture_uniform_location = m_texture_prog.GetUniformLocation("tex");
89         glUniform1i(texture_uniform_location, 0);
90
91         m_font_prog.InitialiseShaders(BASICTEX_VERT, "shaders/fonttex_frag.glsl");
92         m_font_prog.Use();
93
94         // We always want to use the texture bound to texture unit 0.
95         GLint font_texture_uniform_location = m_font_prog.GetUniformLocation("tex");
96         glUniform1i(font_texture_uniform_location, 0);
97         m_colour_uniform_location = m_font_prog.GetUniformLocation("colour");
98
99         m_viewport_ubo.SetUsage(GraphicsBuffer::BufferUsageDynamicDraw);
100         m_viewport_ubo.SetType(GraphicsBuffer::BufferTypeUniform);
101
102         m_debug_font_atlas = 0;
103         m_no_quit_requested = true;
104         m_show_debug_font = true;
105         m_view = NULL;
106         ResizeViewport(800, 600);
107         
108         
109         
110         Clear();
111         Present();
112         
113
114 }
115
116 Screen::~Screen()
117 {
118         if (!Valid())
119                 return;
120         SDL_GL_DeleteContext(m_gl_context);
121         SDL_DestroyWindow(m_window);
122         SDL_Quit();
123 }
124
125 void Screen::Clear(float r, float g, float b, float a)
126 {
127         if (!Valid())
128                 return;
129         glClearColor(r,g,b,a);
130         glClear(GL_COLOR_BUFFER_BIT);
131         DebugFontClear();
132 }
133
134 void Screen::ResizeViewport(int width, int height)
135 {
136         glViewport(0, 0, width, height);
137         m_viewport_width = width;
138         m_viewport_height = height;
139         GLfloat viewportfloats[] = {(float)width, (float)height};
140         m_viewport_ubo.Upload(sizeof(float)*2, viewportfloats);
141 }
142
143 bool Screen::PumpEvents()
144 {
145         if (!Valid())
146                 return true;
147
148         SDL_Event evt;
149         
150         while (SDL_PollEvent(&evt))
151         {
152                 switch (evt.type)
153                 {
154                 case SDL_QUIT:
155                         m_no_quit_requested = false;
156                         break;
157                 case SDL_WINDOWEVENT:
158                         switch (evt.window.event)
159                         {
160                         case SDL_WINDOWEVENT_RESIZED:
161                         case SDL_WINDOWEVENT_SIZE_CHANGED:
162                                 ResizeViewport(evt.window.data1, evt.window.data2);
163                                 break;
164                         }
165                         break;
166                 case SDL_MOUSEMOTION:
167                         m_last_mouse_x = evt.motion.x;
168                         m_last_mouse_y = evt.motion.y;
169                         if (m_mouse_handler)
170                         {
171                                 m_mouse_handler(evt.motion.x, evt.motion.y,evt.motion.state, 0, this, m_view);
172                         }
173                         break;
174                 case SDL_MOUSEBUTTONDOWN:
175                 case SDL_MOUSEBUTTONUP:
176                         m_last_mouse_x = evt.button.x;
177                         m_last_mouse_y = evt.button.y;
178                         if (m_mouse_handler)
179                         {
180                                 m_mouse_handler(evt.button.x, evt.button.y, evt.button.state?evt.button.button:0, 0, this, m_view);
181                         }
182                         break;
183                 case SDL_MOUSEWHEEL:
184                         if (m_mouse_handler)
185                         {
186                                 m_mouse_handler(m_last_mouse_x, m_last_mouse_y, 0, evt.wheel.y, this, m_view);
187                         }
188                         break;
189                 case SDL_KEYDOWN:
190                 {
191                         Debug("Key %c down", (char)evt.key.keysym.sym);
192                         if (isalnum((char)evt.key.keysym.sym))
193                         {
194                                 char filename[] = "0.bmp";
195                                 filename[0] = (char)evt.key.keysym.sym;
196                                 ScreenShot(filename);
197                         }
198                         break;
199                 }
200                 default:
201                         break;
202                 }
203         }
204         return m_no_quit_requested;
205 }
206
207 void Screen::SetMouseCursor(Screen::MouseCursors cursor)
208 {
209         SDL_SystemCursor system_cursor_id = SDL_SYSTEM_CURSOR_ARROW;
210         switch (cursor)
211         {
212         case CursorArrow: system_cursor_id = SDL_SYSTEM_CURSOR_ARROW; break;
213         case CursorWait: system_cursor_id = SDL_SYSTEM_CURSOR_WAIT; break;
214         case CursorWaitArrow: system_cursor_id = SDL_SYSTEM_CURSOR_WAITARROW; break;
215         case CursorMove: system_cursor_id = SDL_SYSTEM_CURSOR_SIZEALL; break;
216         case CursorHand: system_cursor_id = SDL_SYSTEM_CURSOR_HAND; break;
217         default: break;
218         }
219         SDL_Cursor *system_cursor = SDL_CreateSystemCursor(system_cursor_id);
220         SDL_SetCursor(system_cursor);
221         //TODO: Check if we need to free the system cursors.
222 }
223
224 void Screen::Present()
225 {
226         if (!Valid())
227                 return;
228         if (m_debug_font_atlas)
229                 DebugFontFlush();
230         m_last_frame_time = SDL_GetPerformanceCounter() - m_frame_begin_time;
231         glEndQuery(GL_TIME_ELAPSED);
232         SDL_GL_SwapWindow(m_window);
233         m_frame_begin_time = SDL_GetPerformanceCounter();
234         if (m_last_frame_gpu_timer)
235                 glDeleteQueries(1, &m_last_frame_gpu_timer);
236         m_last_frame_gpu_timer = m_frame_gpu_timer;
237         glGenQueries(1, &m_frame_gpu_timer);
238         glBeginQuery(GL_TIME_ELAPSED, m_frame_gpu_timer);
239 }
240
241 double Screen::GetLastFrameTimeGPU() const
242 {
243         if (!Valid() || !m_last_frame_gpu_timer)
244                 return 0;
245         uint64_t frame_time_ns;
246         glGetQueryObjectui64v(m_last_frame_gpu_timer, GL_QUERY_RESULT, &frame_time_ns);
247         return frame_time_ns/1000000000.0;
248 }
249
250 void Screen::RenderPixels(int x, int y, int w, int h, uint8_t *pixels) const
251 {
252         GLenum texture_format = GL_RGBA;
253
254         m_texture_prog.Use();
255         GraphicsBuffer quad_vertex_buffer;
256         quad_vertex_buffer.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
257         quad_vertex_buffer.SetType(GraphicsBuffer::BufferTypeVertex);
258         //rectangular texture == 2 triangles
259         GLfloat quad[] = { 
260                 0, 0, (float)x, (float)y,
261                 1, 0, (float)(x+w), (float)y,
262                 0, 1, (float)x, (float)(y+h),
263                 1, 1, (float)(x+w), (float)(y+h)
264         };
265         quad_vertex_buffer.Upload(sizeof(GLfloat) * 16, quad);
266         quad_vertex_buffer.Bind();
267         m_viewport_ubo.Bind();
268
269         glUniform4f(m_colour_uniform_location, 1.0f, 1.0f, 1.0f, 1.0f);
270
271         GLuint texID;
272         glGenTextures(1, &texID);
273         glBindTexture(GL_TEXTURE_2D, texID);
274
275         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
276         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
277         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
278         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
279
280         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, texture_format, GL_UNSIGNED_BYTE, pixels);
281
282         glEnableVertexAttribArray(0);
283         glEnableVertexAttribArray(1);
284         glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), (void*)(2*sizeof(float)));
285         glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), 0);
286         glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
287         glDisableVertexAttribArray(1);
288         glDisableVertexAttribArray(0);
289
290 }
291
292 void Screen::ScreenShot(const char * filename) const
293 {
294         if (!Valid()) return;
295         Debug("Attempting to save BMP to file %s", filename);
296
297         int w = ViewportWidth();
298         int h = ViewportHeight();
299         unsigned char * pixels = new unsigned char[w*h*4];
300         if (pixels == NULL)
301                 Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4);
302
303         for (int y = 0; y < h; ++y)
304         {
305                 glReadPixels(0,h-y-1,w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[y*w*4]);
306         }
307
308 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
309         SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
310 #else
311         SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0xff000000,0x00ff0000,0x0000ff00,0x000000ff);
312 #endif
313         if (surf == NULL)
314                 Fatal("Failed to create SDL_Surface from pixel data - %s", SDL_GetError());
315
316         GLenum texture_format = (surf->format->Rmask == 0x000000FF) ? GL_RGBA : GL_BGRA;
317         Debug("SDL_Surface %d BytesPerPixel, format %d (RGB = %d, BGR = %d, RGBA = %d, BGRA = %d)", surf->format->BytesPerPixel, texture_format, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA);
318
319         if (SDL_SaveBMP(surf, filename) != 0)
320                 Fatal("SDL_SaveBMP failed - %s", SDL_GetError());
321         
322         SDL_FreeSurface(surf);
323         delete [] pixels;
324         Debug("Succeeded!");
325 }
326
327 /**
328  * Render a BMP
329  * NOT PART OF THE DOCUMENT FORMAT
330  */
331 void Screen::RenderBMP(const char * filename) const
332 {
333         if (!Valid()) return;
334         if (access(filename, R_OK) == -1)
335         {
336                 Error("No such file \"%s\" - Nothing to render - You might have done this deliberately?", filename);
337                 return;
338         }
339         SDL_Surface * bmp = SDL_LoadBMP(filename);
340         if (bmp == NULL)
341                 Fatal("Failed to load BMP from %s - %s", filename, SDL_GetError());
342
343         int w = bmp->w;
344         int h = bmp->h;
345
346         GLenum texture_format = GL_RGBA;
347         switch (bmp->format->BytesPerPixel)
348         {
349                 case 4: //contains alpha
350                         texture_format = (bmp->format->Rmask == 0x000000FF) ? GL_RGBA : GL_BGRA;
351                         break;
352                 case 3: //does not contain alpha
353                         texture_format = (bmp->format->Rmask == 0x000000FF) ? GL_RGB : GL_BGR;  
354                         break;
355                 default:
356                         Fatal("Could not understand SDL_Surface format (%d colours)", bmp->format->BytesPerPixel);
357                         break;  
358         }
359
360         //Debug("SDL_Surface %d BytesPerPixel, format %d (RGB = %d, BGR = %d, RGBA = %d, BGRA = %d)", bmp->format->BytesPerPixel, texture_format, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA);
361
362         m_texture_prog.Use();
363         GraphicsBuffer quad_vertex_buffer;
364         quad_vertex_buffer.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
365         quad_vertex_buffer.SetType(GraphicsBuffer::BufferTypeVertex);
366         GLfloat quad[] = { 
367                 0, 0, 0, 0,
368                 1, 0, (float)ViewportWidth(), 0,
369                 1, 1, (float)ViewportWidth(), (float)ViewportHeight(),
370                 0, 1, 0, (float)ViewportHeight()
371         };
372         quad_vertex_buffer.Upload(sizeof(GLfloat) * 16, quad);
373         quad_vertex_buffer.Bind();
374         m_viewport_ubo.Bind();
375
376         glUniform4f(m_colour_uniform_location, 1.0f, 1.0f, 1.0f, 1.0f);
377
378         GLuint texID;
379         glGenTextures(1, &texID);
380         glBindTexture(GL_TEXTURE_2D, texID);
381
382         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
383         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
384         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
385         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
386
387         glTexImage2D(GL_TEXTURE_2D, 0, bmp->format->BytesPerPixel, w, h, 0, texture_format, GL_UNSIGNED_BYTE, bmp->pixels);
388
389         glEnableVertexAttribArray(0);
390         glEnableVertexAttribArray(1);
391         glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), (void*)(2*sizeof(float)));
392         glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), 0);
393         glDisableVertexAttribArray(1);
394         glDisableVertexAttribArray(0);
395         glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
396
397         SDL_FreeSurface(bmp);   
398 }
399
400 void Screen::DebugFontInit(const char *name, float font_size)
401 {
402         if (!Valid()) return;
403
404         unsigned char font_atlas_data[1024*1024];
405         FILE *font_file = fopen(name, "rb");
406         fseek(font_file, 0, SEEK_END);
407         size_t font_file_size = ftell(font_file);
408         fseek(font_file, 0, SEEK_SET);
409         unsigned char *font_file_data = (unsigned char*)malloc(font_file_size);
410         SDL_assert(fread(font_file_data, 1, font_file_size, font_file) == font_file_size);
411         fclose(font_file);
412         stbtt_BakeFontBitmap(font_file_data,0, font_size, font_atlas_data,1024,1024, 32,96, m_debug_font_rects);
413         free(font_file_data);
414         glGenTextures(1, &m_debug_font_atlas);
415         glBindTexture(GL_TEXTURE_2D, m_debug_font_atlas);
416         glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1024,1024, 0, GL_RED, GL_UNSIGNED_BYTE, font_atlas_data);
417         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
418         m_debug_font_size = font_size;
419
420         m_debug_font_vertices.SetUsage(GraphicsBuffer::BufferUsageStreamDraw);
421         m_debug_font_vertices.SetType(GraphicsBuffer::BufferTypeVertex);
422         m_debug_font_vertices.SetName("m_debug_font_vertices");
423         m_debug_font_vertices.Upload(8192,NULL);
424         m_debug_font_vertex_head = 0;
425
426         m_debug_font_indices.SetUsage(GraphicsBuffer::BufferUsageStreamDraw);
427         m_debug_font_indices.SetType(GraphicsBuffer::BufferTypeIndex);
428         m_debug_font_indices.SetName("m_debug_font_indices");
429         m_debug_font_indices.Resize(500);
430         m_debug_font_index_head = 0;
431 }
432
433 void Screen::DebugFontClear()
434 {
435         if (!Valid()) return;
436         m_debug_font_x = m_debug_font_y = 0;
437         if (!m_debug_font_atlas) return;
438         DebugFontPrint("\n");
439 }
440
441 void Screen::DebugFontFlush()
442 {
443         if (!Valid()) return;
444         glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 40, -1, "Screen::DebugFontFlush()");      
445                 
446         glEnable(GL_BLEND);
447         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
448         glBindTexture(GL_TEXTURE_2D, m_debug_font_atlas);
449
450         m_font_prog.Use();
451         m_viewport_ubo.Bind();
452         m_debug_font_vertices.Bind();
453         m_debug_font_indices.Bind();
454         glUniform4f(m_colour_uniform_location, 0,0,0,1);
455         glEnableVertexAttribArray(0);
456         glEnableVertexAttribArray(1);
457         glEnable(GL_PRIMITIVE_RESTART);
458         glPrimitiveRestartIndex(65535);
459         glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), 0);
460         glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*sizeof(float), (void*)(2*sizeof(float)));
461         glDrawElements(GL_TRIANGLE_STRIP, m_debug_font_index_head, GL_UNSIGNED_SHORT, 0);
462         glDisable(GL_PRIMITIVE_RESTART);
463         glDisableVertexAttribArray(1);
464         glDisableVertexAttribArray(0);
465
466         glDisable(GL_BLEND);
467
468         m_debug_font_vertices.Invalidate();
469         m_debug_font_indices.Invalidate();
470         m_debug_font_vertex_head = 0;
471         m_debug_font_index_head = 0;
472
473         glPopDebugGroup();
474 }
475
476 struct fontvertex
477 {
478         float x, y, s, t;
479 };
480
481 void Screen::DebugFontPrint(const char* str)
482 {
483         if (!Valid()) return;
484         if (!m_debug_font_atlas || !m_show_debug_font) return;
485
486         glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 41, -1, "Screen::DebugFontPrint()");
487
488         BufferBuilder<fontvertex> vertexData(m_debug_font_vertices.MapRange(m_debug_font_vertex_head*sizeof(float), m_debug_font_vertices.GetSize() - m_debug_font_vertex_head*sizeof(float), false, true, true), m_debug_font_vertices.GetSize() - m_debug_font_vertex_head*sizeof(float));
489         BufferBuilder<uint16_t> indexData(m_debug_font_indices.MapRange(m_debug_font_index_head*sizeof(uint16_t), m_debug_font_indices.GetSize() - m_debug_font_index_head*sizeof(uint16_t), false, true, true), m_debug_font_indices.GetSize() - m_debug_font_index_head*sizeof(uint16_t));
490
491         size_t baseVertex = m_debug_font_vertex_head/4;
492         while (*str) {
493                 if (!vertexData.Free(4) || !indexData.Free(5))
494                 {
495                         m_debug_font_indices.UnMap();
496                         m_debug_font_vertices.UnMap();
497                         DebugFontFlush();
498                         DebugFontPrint(str);
499                         glPopDebugGroup();
500                         return;
501                 }
502                 if (*str >= 32 && (unsigned char)(*str) < 128) {
503                         stbtt_aligned_quad q;
504                         stbtt_GetBakedQuad(m_debug_font_rects, 1024,1024, *str-32, &m_debug_font_x,&m_debug_font_y,&q,1);
505                         size_t index = vertexData.Add({q.x0, q.y0, q.s0, q.t0});
506                         index += baseVertex;
507                         indexData.Add(index);
508                         index = vertexData.Add({q.x1, q.y0, q.s1, q.t0});
509                         index += baseVertex;
510                         indexData.Add(index);
511                         index = vertexData.Add({q.x0, q.y1, q.s0, q.t1});
512                         index += baseVertex;
513                         indexData.Add(index);
514                         index = vertexData.Add({q.x1, q.y1, q.s1, q.t1});
515                         index += baseVertex;
516                         indexData.Add(index);
517                         indexData.Add(65535);
518
519                         m_debug_font_vertex_head += 16;
520                         m_debug_font_index_head += 5;
521
522                 }
523                 else if (*str == '\n')
524                 {
525                         m_debug_font_x = 0;
526                         m_debug_font_y += m_debug_font_size;
527                 }
528                 ++str;
529         }
530         m_debug_font_indices.UnMap();
531         m_debug_font_vertices.UnMap();
532         glPopDebugGroup();
533         //DebugFontFlush();
534 }
535
536 void Screen::DebugFontPrintF(const char *fmt, ...)
537 {
538         char buffer[BUFSIZ];
539         va_list va;
540         va_start(va, fmt);
541         vsnprintf(buffer, BUFSIZ, fmt,va);
542         va_end(va);
543         DebugFontPrint(buffer);
544 }

UCC git Repository :: git.ucc.asn.au