OLD | NEW |
1 // | 1 // |
2 // Book: OpenGL(R) ES 2.0 Programming Guide | 2 // Book: OpenGL(R) ES 2.0 Programming Guide |
3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner | 3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner |
4 // ISBN-10: 0321502795 | 4 // ISBN-10: 0321502795 |
5 // ISBN-13: 9780321502797 | 5 // ISBN-13: 9780321502797 |
6 // Publisher: Addison-Wesley Professional | 6 // Publisher: Addison-Wesley Professional |
7 // URLs: http://safari.informit.com/9780321563835 | 7 // URLs: http://safari.informit.com/9780321563835 |
8 // http://www.opengles-book.com | 8 // http://www.opengles-book.com |
9 // | 9 // |
10 | 10 |
11 // ESUtil.c | 11 // ESUtil.c |
12 // | 12 // |
13 // A utility library for OpenGL ES. This library provides a | 13 // A utility library for OpenGL ES. This library provides a |
14 // basic common framework for the example applications in the | 14 // basic common framework for the example applications in the |
15 // OpenGL ES 2.0 Programming Guide. | 15 // OpenGL ES 2.0 Programming Guide. |
16 // | 16 // |
17 | 17 |
18 /// | 18 /// |
19 // Includes | 19 // Includes |
20 // | 20 // |
21 #include <stdio.h> | 21 #include <stdio.h> |
22 #include <stdlib.h> | 22 #include <stdlib.h> |
23 #include <stdarg.h> | 23 #include <stdarg.h> |
24 #include <string.h> | 24 #include <string.h> |
25 | 25 |
26 #include <GLES2/gl2.h> | 26 #include <GLES2/gl2.h> |
27 | 27 |
28 #include "esUtil.h" | 28 #include "esUtil.h" |
29 #include "esUtil_win.h" | |
30 | 29 |
31 /// | 30 /// |
32 // esInitContext() | 31 // esInitContext() |
33 // | 32 // |
34 // Initialize ES utility context. This must be called before calling any o
ther | 33 // Initialize ES utility context. This must be called before calling any o
ther |
35 // functions. | 34 // functions. |
36 // | 35 // |
37 void esInitContext ( ESContext *esContext ) | 36 void esInitContext ( ESContext *esContext ) |
38 { | 37 { |
39 if ( esContext != NULL ) | 38 if ( esContext != NULL ) |
40 { | 39 { |
41 memset( esContext, 0, sizeof( ESContext) ); | 40 memset( esContext, 0, sizeof( ESContext) ); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 /// | 44 /// |
46 // esLogMessage() | 45 // esLogMessage() |
47 // | 46 // |
48 // Log an error message to the debug output for the platform | 47 // Log an error message to the debug output for the platform |
49 // | 48 // |
50 void esLogMessage ( const char *formatStr, ... ) | 49 void esLogMessage ( const char *formatStr, ... ) |
51 { | 50 { |
52 va_list params; | 51 va_list params; |
53 char buf[BUFSIZ]; | 52 char buf[BUFSIZ]; |
54 | 53 |
55 va_start ( params, formatStr ); | 54 va_start ( params, formatStr ); |
56 vsprintf_s ( buf, sizeof(buf), formatStr, params ); | 55 vsprintf ( buf, formatStr, params ); |
57 | 56 |
58 printf ( "%s", buf ); | 57 printf ( "%s", buf ); |
59 | 58 |
60 va_end ( params ); | 59 va_end ( params ); |
61 } | 60 } |
62 | 61 |
63 /// | |
64 // esLoadTGA() | |
65 // | |
66 // Loads a 24-bit TGA image from a file | |
67 // | |
68 char* esLoadTGA ( char *fileName, int *width, int *height ) | |
69 { | |
70 char *buffer; | |
71 | |
72 if ( WinTGALoad ( fileName, &buffer, width, height ) ) | |
73 { | |
74 return buffer; | |
75 } | |
76 | |
77 return NULL; | |
78 } | |
OLD | NEW |