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

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