1 /*
2  * Copyright (c) 2002-2008 LWJGL Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of 'LWJGL' nor the names of
17  *   its contributors may be used to endorse or promote products derived
18  *   from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 package org.lwjgl.opengl;
33 
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.Alternate;
36 import org.lwjgl.util.generator.opengl.*;
37 
38 import java.nio.ByteBuffer;
39 import java.nio.FloatBuffer;
40 import java.nio.IntBuffer;
41 
42 public interface ARB_shader_objects {
43 
44 	/** Accepted by the <pname> argument of GetHandleARB: */
45 	int GL_PROGRAM_OBJECT_ARB = 0x8B40;
46 
47 	/** Accepted by the <pname> parameter of GetObjectParameter{fi}vARB: */
48 	int GL_OBJECT_TYPE_ARB = 0x8B4E;
49 	int GL_OBJECT_SUBTYPE_ARB = 0x8B4F;
50 	int GL_OBJECT_DELETE_STATUS_ARB = 0x8B80;
51 	int GL_OBJECT_COMPILE_STATUS_ARB = 0x8B81;
52 	int GL_OBJECT_LINK_STATUS_ARB = 0x8B82;
53 	int GL_OBJECT_VALIDATE_STATUS_ARB = 0x8B83;
54 	int GL_OBJECT_INFO_LOG_LENGTH_ARB = 0x8B84;
55 	int GL_OBJECT_ATTACHED_OBJECTS_ARB = 0x8B85;
56 	int GL_OBJECT_ACTIVE_UNIFORMS_ARB = 0x8B86;
57 	int GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = 0x8B87;
58 	int GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = 0x8B88;
59 
60 	/** Returned by the <params> parameter of GetObjectParameter{fi}vARB: */
61 	int GL_SHADER_OBJECT_ARB = 0x8B48;
62 
63 	/** Returned by the <type> parameter of GetActiveUniformARB: */
64 	int GL_FLOAT_VEC2_ARB = 0x8B50;
65 	int GL_FLOAT_VEC3_ARB = 0x8B51;
66 	int GL_FLOAT_VEC4_ARB = 0x8B52;
67 	int GL_INT_VEC2_ARB = 0x8B53;
68 	int GL_INT_VEC3_ARB = 0x8B54;
69 	int GL_INT_VEC4_ARB = 0x8B55;
70 	int GL_BOOL_ARB = 0x8B56;
71 	int GL_BOOL_VEC2_ARB = 0x8B57;
72 	int GL_BOOL_VEC3_ARB = 0x8B58;
73 	int GL_BOOL_VEC4_ARB = 0x8B59;
74 	int GL_FLOAT_MAT2_ARB = 0x8B5A;
75 	int GL_FLOAT_MAT3_ARB = 0x8B5B;
76 	int GL_FLOAT_MAT4_ARB = 0x8B5C;
77 	int GL_SAMPLER_1D_ARB = 0x8B5D;
78 	int GL_SAMPLER_2D_ARB = 0x8B5E;
79 	int GL_SAMPLER_3D_ARB = 0x8B5F;
80 	int GL_SAMPLER_CUBE_ARB = 0x8B60;
81 	int GL_SAMPLER_1D_SHADOW_ARB = 0x8B61;
82 	int GL_SAMPLER_2D_SHADOW_ARB = 0x8B62;
83 	int GL_SAMPLER_2D_RECT_ARB = 0x8B63;
84 	int GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64;
85 
glDeleteObjectARB(@LhandleARB int obj)86 	void glDeleteObjectARB(@GLhandleARB int obj);
87 
88 	@GLhandleARB
glGetHandleARB(@Lenum int pname)89 	int glGetHandleARB(@GLenum int pname);
90 
glDetachObjectARB(@LhandleARB int containerObj, @GLhandleARB int attachedObj)91 	void glDetachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int attachedObj);
92 
93 	@GLhandleARB
glCreateShaderObjectARB(@Lenum int shaderType)94 	int glCreateShaderObjectARB(@GLenum int shaderType);
95 
96 	/**
97 	 * The ARB_shader_objects extension allows multiple, optionally null-terminated, source strings to define a shader program.
98 	 * <p/>
99 	 * This method uses just a single string, that should NOT be null-terminated.
100 	 */
glShaderSourceARB(@LhandleARB int shader, @Constant(R) @GLsizei int count, @Indirect @Const @GLcharARB @Check ByteBuffer string, @AutoSize(R) @Indirect @Const @GLint int length)101 	void glShaderSourceARB(@GLhandleARB int shader, @Constant("1") @GLsizei int count,
102 	                       @Indirect @Const @GLcharARB @Check ByteBuffer string,
103 	                       @AutoSize("string") @Indirect @Const @GLint int length);
104 
105 	@Alternate("glShaderSourceARB")
glShaderSourceARB2(@LhandleARB int shader, @Constant(R) @GLsizei int count, CharSequence string, @Constant(R) @Indirect @Const int length)106 	void glShaderSourceARB2(@GLhandleARB int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length);
107 
108 	@Alternate(value = "glShaderSourceARB", nativeAlt = true)
glShaderSourceARB3(@LhandleARB int shader, @Constant(R) @GLsizei int count, @Const @PointerArray(value = R, lengths = R) CharSequence[] strings, @Constant(R) @Const IntBuffer length)109 	void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count,
110 	                        @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
111 	                        @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length);
112 
glCompileShaderARB(@LhandleARB int shaderObj)113 	void glCompileShaderARB(@GLhandleARB int shaderObj);
114 
115 	@GLhandleARB
glCreateProgramObjectARB()116 	int glCreateProgramObjectARB();
117 
glAttachObjectARB(@LhandleARB int containerObj, @GLhandleARB int obj)118 	void glAttachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int obj);
119 
glLinkProgramARB(@LhandleARB int programObj)120 	void glLinkProgramARB(@GLhandleARB int programObj);
121 
glUseProgramObjectARB(@LhandleARB int programObj)122 	void glUseProgramObjectARB(@GLhandleARB int programObj);
123 
glValidateProgramARB(@LhandleARB int programObj)124 	void glValidateProgramARB(@GLhandleARB int programObj);
125 
glUniform1fARB(int location, float v0)126 	void glUniform1fARB(int location, float v0);
127 
glUniform2fARB(int location, float v0, float v1)128 	void glUniform2fARB(int location, float v0, float v1);
129 
glUniform3fARB(int location, float v0, float v1, float v2)130 	void glUniform3fARB(int location, float v0, float v1, float v2);
131 
glUniform4fARB(int location, float v0, float v1, float v2, float v3)132 	void glUniform4fARB(int location, float v0, float v1, float v2, float v3);
133 
glUniform1iARB(int location, int v0)134 	void glUniform1iARB(int location, int v0);
135 
glUniform2iARB(int location, int v0, int v1)136 	void glUniform2iARB(int location, int v0, int v1);
137 
glUniform3iARB(int location, int v0, int v1, int v2)138 	void glUniform3iARB(int location, int v0, int v1, int v2);
139 
glUniform4iARB(int location, int v0, int v1, int v2, int v3)140 	void glUniform4iARB(int location, int v0, int v1, int v2, int v3);
141 
142 	@StripPostfix("values")
glUniform1fvARB(int location, @AutoSize(R) @GLsizei int count, @Const FloatBuffer values)143 	void glUniform1fvARB(int location, @AutoSize("values") @GLsizei int count, @Const FloatBuffer values);
144 
145 	@StripPostfix("values")
glUniform2fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const FloatBuffer values)146 	void glUniform2fvARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const FloatBuffer values);
147 
148 	@StripPostfix("values")
glUniform3fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const FloatBuffer values)149 	void glUniform3fvARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const FloatBuffer values);
150 
151 	@StripPostfix("values")
glUniform4fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const FloatBuffer values)152 	void glUniform4fvARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const FloatBuffer values);
153 
154 	@StripPostfix("values")
glUniform1ivARB(int location, @AutoSize(value = R) @GLsizei int count, @Const IntBuffer values)155 	void glUniform1ivARB(int location, @AutoSize(value = "values") @GLsizei int count, @Const IntBuffer values);
156 
157 	@StripPostfix("values")
glUniform2ivARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const IntBuffer values)158 	void glUniform2ivARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const IntBuffer values);
159 
160 	@StripPostfix("values")
glUniform3ivARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const IntBuffer values)161 	void glUniform3ivARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const IntBuffer values);
162 
163 	@StripPostfix("values")
glUniform4ivARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, @Const IntBuffer values)164 	void glUniform4ivARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const IntBuffer values);
165 
166 	@StripPostfix("matrices")
glUniformMatrix2fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, boolean transpose, @Const FloatBuffer matrices)167 	void glUniformMatrix2fvARB(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
168 
169 	@StripPostfix("matrices")
glUniformMatrix3fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, boolean transpose, @Const FloatBuffer matrices)170 	void glUniformMatrix3fvARB(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
171 
172 	@StripPostfix("matrices")
glUniformMatrix4fvARB(int location, @AutoSize(value = R, expression = R) @GLsizei int count, boolean transpose, @Const FloatBuffer matrices)173 	void glUniformMatrix4fvARB(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
174 
175 	@StripPostfix("params")
glGetObjectParameterfvARB(@LhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params)176 	void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params);
177 
178 	@Alternate("glGetObjectParameterfvARB")
179 	@GLreturn("params")
180 	@StripPostfix(value = "params", hasPostfix = false)
glGetObjectParameterfvARB2(@LhandleARB int obj, @GLenum int pname, @OutParameter FloatBuffer params)181 	void glGetObjectParameterfvARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter FloatBuffer params);
182 
183 	@StripPostfix("params")
glGetObjectParameterivARB(@LhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params)184 	void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params);
185 
186 	@Alternate("glGetObjectParameterivARB")
187 	@GLreturn("params")
188 	@StripPostfix(value = "params", hasPostfix = false)
glGetObjectParameterivARB2(@LhandleARB int obj, @GLenum int pname, @OutParameter IntBuffer params)189 	void glGetObjectParameterivARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter IntBuffer params);
190 
glGetInfoLogARB(@LhandleARB int obj, @AutoSize(R) @GLsizei int maxLength, @OutParameter @GLsizei @Check(value = R, canBeNull = true) IntBuffer length, @OutParameter @GLcharARB ByteBuffer infoLog)191 	void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength,
192 	                     @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
193 	                     @OutParameter @GLcharARB ByteBuffer infoLog);
194 
195 	@Alternate("glGetInfoLogARB")
196 	@GLreturn(value = "infoLog", maxLength = "maxLength")
glGetInfoLogARB2(@LhandleARB int obj, @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter @GLcharARB ByteBuffer infoLog)197 	void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength,
198 	                      @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
199 	                      @OutParameter @GLcharARB ByteBuffer infoLog);
200 
glGetAttachedObjectsARB(@LhandleARB int containerObj, @AutoSize(R) @GLsizei int maxCount, @OutParameter @GLsizei @Check(value = R, canBeNull = true) IntBuffer count, @OutParameter @GLhandleARB IntBuffer obj)201 	void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount,
202 	                             @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count,
203 	                             @OutParameter @GLhandleARB IntBuffer obj);
204 
205 	/**
206 	 * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a <b>null-terminated</b> string.
207 	 *
208 	 * @param programObj
209 	 * @param name
210 	 */
glGetUniformLocationARB(@LhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name)211 	int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
212 
213 	@Alternate("glGetUniformLocationARB")
glGetUniformLocationARB(@LhandleARB int programObj, @NullTerminated CharSequence name)214 	int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name);
215 
glGetActiveUniformARB(@LhandleARB int programObj, @GLuint int index, @AutoSize(R) @GLsizei int maxLength, @OutParameter @GLsizei @Check(value = R, canBeNull = true) IntBuffer length, @OutParameter @Check(R) IntBuffer size, @OutParameter @GLenum @Check(R) IntBuffer type, @OutParameter @GLcharARB ByteBuffer name)216 	void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength,
217 	                           @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
218 	                           @OutParameter @Check("1") IntBuffer size,
219 	                           @OutParameter @GLenum @Check("1") IntBuffer type,
220 	                           @OutParameter @GLcharARB ByteBuffer name);
221 
222 	/** Overloads glGetActiveUniformARB. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
223 	@Alternate("glGetActiveUniformARB")
224 	@GLreturn(value = "name", maxLength = "maxLength")
glGetActiveUniformARB2(@LhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter @Check(R) IntBuffer sizeType, @OutParameter @GLenum @Constant(R) IntBuffer type, @OutParameter @GLcharARB ByteBuffer name)225 	void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
226 	                            @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
227 	                            @OutParameter @Check("2") IntBuffer sizeType,
228 	                            @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
229 	                            @OutParameter @GLcharARB ByteBuffer name);
230 
231 	/** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
232 	@Alternate(value = "glGetActiveUniformARB", javaAlt = true)
233 	@GLreturn(value = "name", maxLength = "maxLength")
glGetActiveUniformARB(@LhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter @GLcharARB ByteBuffer name)234 	void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
235 	                           @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
236 	                           @OutParameter @GLcharARB ByteBuffer name);
237 
238 	/** Overloads glGetActiveUniformARB. This version returns only the uniform size. */
239 	@Alternate(value = "glGetActiveUniformARB", javaAlt = true)
240 	@GLreturn(value = "size")
glGetActiveUniformSizeARB(@LhandleARB int programObj, @GLuint int index, @Constant(R) @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant(R) IntBuffer type, @OutParameter @GLcharARB @Constant(R) ByteBuffer name)241 	void glGetActiveUniformSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
242 	                               @OutParameter @GLsizei @Constant("0L") IntBuffer length,
243 	                               @OutParameter IntBuffer size,
244 	                               @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
245 	                               @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
246 
247 	/** Overloads glGetActiveUniformARB. This version returns only the uniform type. */
248 	@Alternate(value = "glGetActiveUniformARB", javaAlt = true)
249 	@GLreturn(value = "type")
glGetActiveUniformTypeARB(@LhandleARB int programObj, @GLuint int index, @Constant(R) @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter @Constant(R) IntBuffer size, @OutParameter @GLenum IntBuffer type, @OutParameter @GLcharARB @Constant(R) ByteBuffer name)250 	void glGetActiveUniformTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
251 	                               @OutParameter @GLsizei @Constant("0L") IntBuffer length,
252 	                               @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
253 	                               @OutParameter @GLenum IntBuffer type,
254 	                               @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
255 
256 	@StripPostfix("params")
glGetUniformfvARB(@LhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params)257 	void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params);
258 
259 	@StripPostfix("params")
glGetUniformivARB(@LhandleARB int programObj, int location, @OutParameter @Check IntBuffer params)260 	void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params);
261 
glGetShaderSourceARB(@LhandleARB int obj, @AutoSize(R) @GLsizei int maxLength, @OutParameter @GLsizei @Check(value = R, canBeNull = true) IntBuffer length, @OutParameter @GLcharARB ByteBuffer source)262 	void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength,
263 	                          @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
264 	                          @OutParameter @GLcharARB ByteBuffer source);
265 
266 	@Alternate("glGetShaderSourceARB")
267 	@GLreturn(value = "source", maxLength = "maxLength")
glGetShaderSourceARB2(@LhandleARB int obj, @GLsizei int maxLength, @OutParameter @GLsizei @Constant(R) IntBuffer length, @OutParameter @GLcharARB ByteBuffer source)268 	void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength,
269 	                           @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(source_length)") IntBuffer length,
270 	                           @OutParameter @GLcharARB ByteBuffer source);
271 
272 }
273