0
|
1 /* ============================================================================
|
|
2 * Freetype GL - A C OpenGL Freetype engine
|
|
3 * Platform: Any
|
|
4 * WWW: http://code.google.com/p/freetype-gl/
|
|
5 * ----------------------------------------------------------------------------
|
|
6 * Copyright 2011,2012,2013 Nicolas P. Rougier. All rights reserved.
|
|
7 *
|
|
8 * Redistribution and use in source and binary forms, with or without
|
|
9 * modification, are permitted provided that the following conditions are met:
|
|
10 *
|
|
11 * 1. Redistributions of source code must retain the above copyright notice,
|
|
12 * this list of conditions and the following disclaimer.
|
|
13 *
|
|
14 * 2. Redistributions in binary form must reproduce the above copyright
|
|
15 * notice, this list of conditions and the following disclaimer in the
|
|
16 * documentation and/or other materials provided with the distribution.
|
|
17 *
|
|
18 * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
|
|
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
21 * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28 *
|
|
29 * The views and conclusions contained in the software and documentation are
|
|
30 * those of the authors and should not be interpreted as representing official
|
|
31 * policies, either expressed or implied, of Nicolas P. Rougier.
|
|
32 * ----------------------------------------------------------------------------
|
|
33 */
|
|
34 #ifndef __SHADER_H__
|
|
35 #define __SHADER_H__
|
|
36
|
|
37 #include "opengl.h"
|
|
38
|
|
39 #ifdef __cplusplus
|
|
40 extern "C" {
|
|
41 #endif
|
|
42
|
|
43 /**
|
|
44 * @file shader.h
|
|
45 * @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
|
|
46 *
|
|
47 * @defgroup shader Shader
|
|
48 *
|
|
49 * Simple functions for loading/building a shader from sources.
|
|
50 *
|
|
51 * <b>Example Usage</b>:
|
|
52 * @code
|
|
53 * #include "shader.h"
|
|
54 *
|
|
55 * int main( int arrgc, char *argv[] )
|
|
56 * {
|
|
57 * GLuint shader = shader_load("shader.vert", "shader.frag");
|
|
58 *
|
|
59 * return 0;
|
|
60 * }
|
|
61 * @endcode
|
|
62 *
|
|
63 * @{
|
|
64 */
|
|
65
|
|
66 /**
|
|
67 * Read a fragment or vertex shader from a file
|
|
68 *
|
|
69 * @param filename file to read shader from
|
|
70 * @return a newly-allocated text buffer containing code. This buffer
|
|
71 * must be freed after usage.
|
|
72 *
|
|
73 */
|
|
74 char *
|
|
75 shader_read( const char *filename );
|
|
76
|
|
77
|
|
78 /**
|
|
79 * Compile a shader from a text buffer.
|
|
80 *
|
|
81 * @param source code of the shader
|
|
82 * @param type type of the shader
|
|
83 *
|
|
84 * @return a handle on the compiled program
|
|
85 *
|
|
86 */
|
|
87 GLuint
|
|
88 shader_compile( const char* source,
|
|
89 const GLenum type );
|
|
90
|
|
91
|
|
92 /**
|
|
93 * Load a vertex and fragment shader sources and build program
|
|
94 *
|
|
95 * @param vert_filename vertex shader filename
|
|
96 * @param frag_filename fragment shader filename
|
|
97 *
|
|
98 * @return a handle on the built program
|
|
99 *
|
|
100 */
|
|
101 GLuint
|
|
102 shader_load( const char * vert_filename,
|
|
103 const char * frag_filename );
|
|
104
|
|
105
|
|
106 /**
|
|
107 *
|
|
108 */
|
|
109 GLuint
|
|
110 shader_get( GLuint self,
|
|
111 const char * name );
|
|
112
|
|
113 /** @} */
|
|
114
|
|
115 #ifdef __cplusplus
|
|
116 }
|
|
117 #endif
|
|
118
|
|
119 #endif /* __SHADER_H__ */
|