source: project/wiki/eggref/4/opengl-glew @ 30705

Last change on this file since 30705 was 30705, checked in by acharlton, 7 years ago

Update docs to v 0.2.0

File size: 4.0 KB
Line 
1[[tags: egg]]
2[[toc:]]
3
4== opengl-glew
5
6Bindings to OpenGL with GLEW extension loading.
7
8Chicken's other [[opengl]] bindings are based on the old fixed function pipeline OpenGL. These bindings generated by [[bind]] with the OpenGL [[http://www.opengl.org/registry/api/GL/glcorearb.h|core header file]]. Additionally, bindings to [[http://glew.sourceforge.net/|GLEW]] are provided for extension management.
9
10=== Requirements
11* [[make]]
12* [[bind]]
13
14=== Documentation
15All functions and constants from the OpenGL [[http://www.opengl.org/registry/api/GL/glcorearb.h|core header file]] are exported. Scheme style names are provided (underscores and camelCase replaced with hyphens), the {{gl}} prefix is removed from names, {{is}} functions are given question marks, and constants are bookended by {{+}}s (e.g. {{tex-image2d}}, {{enabled?}}, {{+arb-viewport-array+}}).
16
17==== GLEW functions
18Two GLEW functions are exposed:
19
20===== init
21  (init)
22
23Required to initialize GLEW/OpenGL. An OpenGL context must be created before this is called.
24
25===== is-supported?
26  (supported? EXTENSION-NAME)
27
28Query whether the OpenGL extension, given as a string, is supported.
29
30==== GL helper functions
31
32===== make-shader
33  (make-shader TYPE SOURCE)
34
35Creates and compiles a shader object given the shader's type (e.g. {{+vertex-shader+}}, {{+geometry-shader+}}, {{+fragment-shader}}), and a string containing the GLSL source. Returns an integer representing the ID of the shader.
36
37===== make-program
38  (make-program SHADER-LIST)
39
40Creates and links a program object, given a list of shader objects (i.e. the integers returned by {{make-shader}}. Returns an integer representing the ID of the program.
41
42
43=== Example
44This example depends on the [[glfw3]] egg for window and context creation.
45
46<enscript highlight="scheme">
47(import chicken scheme)
48(use (prefix glfw3 glfw:) (prefix opengl-glew gl:))
49
50(glfw:init)
51(define *window* (glfw:create-window 640 480 "Example" #f #f))
52(glfw:make-context-current *window*)
53(gl:init)
54
55(print (gl:is-supported "GL_ARB_framebuffer_object"))
56
57(define *vertex* (gl:make-shader gl:+vertex-shader+
58#<<END
59#version 330
60in vec2 vertex;
61in vec3 color;
62out vec3 c;
63uniform mat4 viewMatrix;
64
65void main(){
66   gl_Position = (viewMatrix * vec4(vertex, 0.0, 1.0));
67   c = color;
68}
69END
70))
71
72(define *fragment* (gl:make-shader gl:+fragment-shader+
73#<<END
74#version 330
75in vec3 c;
76out vec4 fragColor;
77void main(){
78  fragColor = vec4(c, 1.0);
79}
80END
81))
82
83;If this is not zero, then everything is working
84(print
85 (gl:make-program (list *vertex* *fragment*)))
86
87(glfw:destroy-window *window*)
88(glfw:terminate)
89</enscript>
90
91=== Author
92Alex Charlton
93
94=== Source
95Available on [[https://github.com/AlexCharlton/chicken-opengl-glew|GitHub]]
96
97=== Changelog
98* 0.2.0: Add glcorearb.h - no longer downloaded at install time
99* 0.1.0
100
101=== Licence
102Copyright (c) 2014, Alexander Charlton
103All rights reserved.
104
105Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
106
107Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
108Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
109THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.