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

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