1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"glShaderSource">
6 <refentrytitle>glShaderSource
</refentrytitle>
7 <manvolnum>3G
</manvolnum>
10 <refname>glShaderSource
</refname>
11 <refpurpose>Replaces the source code in a shader object
</refpurpose>
13 <refsynopsisdiv><title>C Specification
</title>
16 <funcdef>void
<function>glShaderSource
</function></funcdef>
17 <paramdef>GLuint
<parameter>shader
</parameter></paramdef>
18 <paramdef>GLsizei
<parameter>count
</parameter></paramdef>
19 <paramdef>const GLchar **
<parameter>string
</parameter></paramdef>
20 <paramdef>const GLint *
<parameter>length
</parameter></paramdef>
24 <refsect1 id=
"parameters"><title>Parameters
</title>
27 <term><parameter>shader
</parameter></term>
29 <para>Specifies the handle of the shader object
30 whose source code is to be replaced.
</para>
34 <term><parameter>count
</parameter></term>
36 <para>Specifies the number of elements in the
37 <parameter>string
</parameter> and
38 <parameter>length
</parameter>
43 <term><parameter>string
</parameter></term>
45 <para>Specifies an array of pointers to strings
46 containing the source code to be loaded into the
51 <term><parameter>length
</parameter></term>
53 <para>Specifies an array of string lengths.
</para>
58 <refsect1 id=
"description"><title>Description
</title>
59 <para><function>glShaderSource
</function> sets the source code
60 in
<parameter>shader
</parameter> to the source code in the array
61 of strings specified by
<parameter>string
</parameter>. Any
62 source code previously stored in the shader object is completely
63 replaced. The number of strings in the array is specified by
64 <parameter>count
</parameter>. If
<parameter>length
</parameter>
65 is
<constant>NULL
</constant>, each string is assumed to be null
66 terminated. If
<parameter>length
</parameter> is a value other
67 than
<constant>NULL
</constant>, it points to an array containing
68 a string length for each of the corresponding elements of
69 <parameter>string
</parameter>. Each element in the
70 <parameter>length
</parameter> array may contain the length of
71 the corresponding string (the null character is not counted as
72 part of the string length) or a value less than
0 to indicate
73 that the string is null terminated. The source code strings are
74 not scanned or parsed at this time; they are simply copied into
75 the specified shader object.
</para>
77 <refsect1 id=
"notes"><title>Notes
</title>
78 <para><function>glShaderSource
</function> is available only if
79 the GL version is
2.0 or greater.
</para>
81 <para>OpenGL copies the shader source code strings when
82 <function>glShaderSource
</function> is called, so an application
83 may free its copy of the source code strings immediately after
84 the function returns.
</para>
86 <refsect1 id=
"errors"><title>Errors
</title>
87 <para><constant>GL_INVALID_VALUE
</constant> is generated if
88 <parameter>shader
</parameter> is not a value generated by
91 <para><constant>GL_INVALID_OPERATION
</constant> is generated if
92 <parameter>shader
</parameter> is not a shader object.
</para>
94 <para><constant>GL_INVALID_VALUE
</constant> is generated if
95 <parameter>count
</parameter> is less than
0.
</para>
97 <para><constant>GL_INVALID_OPERATION
</constant> is generated if
98 <function>glShaderSource
</function> is executed between the
100 <citerefentry><refentrytitle>glBegin
</refentrytitle></citerefentry>
101 and the corresponding execution of
102 <citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
</para>
104 <refsect1 id=
"associatedgets"><title>Associated Gets
</title>
105 <para><citerefentry><refentrytitle>glGetShader
</refentrytitle></citerefentry>
106 with arguments
<parameter>shader
</parameter> and
107 <constant>GL_SHADER_SOURCE_LENGTH
</constant></para>
109 <para><citerefentry><refentrytitle>glGetShaderSource
</refentrytitle></citerefentry>
110 with argument
<parameter>shader
</parameter></para>
112 <para><citerefentry><refentrytitle>glIsShader
</refentrytitle></citerefentry></para>
114 <refsect1 id=
"seealso"><title>See Also
</title>
115 <para><citerefentry><refentrytitle>glCompileShader
</refentrytitle></citerefentry>,
116 <citerefentry><refentrytitle>glCreateShader
</refentrytitle></citerefentry>,
117 <citerefentry><refentrytitle>glDeleteShader
</refentrytitle></citerefentry></para>
119 <refsect1 id=
"Copyright"><title>Copyright
</title>
121 Copyright
<trademark class=
"copyright"></trademark> 2003-
2005 3Dlabs Inc. Ltd.
122 This material may be distributed subject to the terms and conditions set forth in
123 the Open Publication License, v
1.0,
8 June
1999.
124 <ulink url=
"http://opencontent.org/openpub/">http://opencontent.org/openpub/
</ulink>.