Difference between revisions of "GLAPI/glShaderSource"

From OpenGL.org
Jump to: navigation, search
(4.0 API.)
 
m (Bot: Adding better formatting.)
(6 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
== Function Definition ==
 
== Function Definition ==
  
   void '''glShaderSource'''(GLuint ''shader'', GLsizei ''count'', const GLchar **''string'', const GLint *''length'');
+
   void '''glShaderSource'''(GLuint {{param|shader}}, GLsizei {{param|count}}, const GLchar **{{param|string}}, const GLint *{{param|length}});
  
 
; shader
 
; shader
 
: Specifies the handle of the shader object whose source code is to be replaced.
 
: Specifies the handle of the shader object whose source code is to be replaced.
 
; count
 
; count
: Specifies the number of elements in the ''string'' and ''length'' arrays.
+
: Specifies the number of elements in the {{param|string}} and {{param|length}} arrays.
 
; string
 
; string
 
: Specifies an array of pointers to strings containing the source code to be loaded into the shader.
 
: Specifies an array of pointers to strings containing the source code to be loaded into the shader.
Line 21: Line 21:
 
== Description ==
 
== Description ==
  
'''glShaderSource''' sets the source code in ''shader'' to the source code in the array of strings specified by ''string''. Any source code previously stored in the shader object is completely replaced. The number of strings in the array is specified by ''count''. If ''length'' is {{code|NULL}}, each string is assumed to be null terminated. If ''length'' is a value other than {{code|NULL}}, it points to an array containing a string length for each of the corresponding elements of ''string''. Each element in the ''length'' array may contain the length of the corresponding string (the null character is not counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or parsed at this time; they are simply copied into the specified shader object.
+
'''glShaderSource''' sets the source code in {{param|shader}} to the source code in the array of strings specified by {{param|string}}. Any source code previously stored in the shader object is completely replaced. The number of strings in the array is specified by {{param|count}}. If {{param|length}} is {{enum|NULL}}, each string is assumed to be null terminated. If {{param|length}} is a value other than {{enum|NULL}}, it points to an array containing a string length for each of the corresponding elements of {{param|string}}. Each element in the {{param|length}} array may contain the length of the corresponding string (the null character is not counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or parsed at this time; they are simply copied into the specified shader object.
  
 
== Notes ==
 
== Notes ==
Line 29: Line 29:
 
== Errors ==
 
== Errors ==
  
{{code|GL_INVALID_VALUE}} is generated if ''shader'' is not a value generated by OpenGL.
+
{{enum|GL_INVALID_VALUE}} is generated if {{param|shader}} is not a value generated by OpenGL.
  
{{code|GL_INVALID_OPERATION}} is generated if ''shader'' is not a shader object.
+
{{enum|GL_INVALID_OPERATION}} is generated if {{param|shader}} is not a shader object.
  
{{code|GL_INVALID_VALUE}} is generated if ''count'' is less than 0.
+
{{enum|GL_INVALID_VALUE}} is generated if {{param|count}} is less than 0.
  
 
== Associated Gets ==
 
== Associated Gets ==
  
[[GLAPI/glGetShader|glGetShader]] with arguments ''shader'' and {{code|GL_SHADER_SOURCE_LENGTH}}
+
{{apifunc|glGetShader}} with arguments {{param|shader}} and {{enum|GL_SHADER_SOURCE_LENGTH}}
  
[[GLAPI/glGetShaderSource|glGetShaderSource]] with argument ''shader''
+
{{apifunc|glGetShaderSource}} with argument {{param|shader}}
  
[[GLAPI/glIsShader|glIsShader]]
+
{{apifunc|glIsShader}}
  
 
== See Also ==
 
== See Also ==
  
[[GLAPI/glCompileShader|glCompileShader]], [[GLAPI/glCreateShader|glCreateShader]], [[GLAPI/glDeleteShader|glDeleteShader]]
+
{{apifunc|glCompileShader}}, {{apifunc|glCreateShader}}, {{apifunc|glDeleteShader}}, {{apifunc|glShaderBinary}}
  
 
== Copyright ==
 
== Copyright ==
Line 51: Line 51:
 
Copyright © 2003-2005 3Dlabs Inc. Ltd. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. [http://opencontent.org/openpub/ http://opencontent.org/openpub/].
 
Copyright © 2003-2005 3Dlabs Inc. Ltd. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. [http://opencontent.org/openpub/ http://opencontent.org/openpub/].
  
[[Category:API Reference 4|ShaderSource]]
+
[[Category:Core API Reference|ShaderSource]]
 +
[[Category:Core API Ref Shader Program Creation|ShaderSource]]

Revision as of 15:44, 27 September 2012

glShaderSource
Core in version 4.5
Core since version 2.0

glShaderSource: Replaces the source code in a shader object

Function Definition

 void glShaderSource(GLuint shader​, GLsizei count​, const GLchar **string​, const GLint *length​);
shader
Specifies the handle of the shader object whose source code is to be replaced.
count
Specifies the number of elements in the string​ and length​ arrays.
string
Specifies an array of pointers to strings containing the source code to be loaded into the shader.
length
Specifies an array of string lengths.

Description

glShaderSource sets the source code in shader​ to the source code in the array of strings specified by string​. Any source code previously stored in the shader object is completely replaced. The number of strings in the array is specified by count​. If length​ is NULL, each string is assumed to be null terminated. If length​ is a value other than NULL, it points to an array containing a string length for each of the corresponding elements of string​. Each element in the length​ array may contain the length of the corresponding string (the null character is not counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or parsed at this time; they are simply copied into the specified shader object.

Notes

OpenGL copies the shader source code strings when glShaderSource is called, so an application may free its copy of the source code strings immediately after the function returns.

Errors

GL_INVALID_VALUE is generated if shader​ is not a value generated by OpenGL.

GL_INVALID_OPERATION is generated if shader​ is not a shader object.

GL_INVALID_VALUE is generated if count​ is less than 0.

Associated Gets

glGetShader with arguments shader​ and GL_SHADER_SOURCE_LENGTH

glGetShaderSource with argument shader​

glIsShader

See Also

glCompileShader, glCreateShader, glDeleteShader, glShaderBinary

Copyright

Copyright © 2003-2005 3Dlabs Inc. Ltd. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.