Commits

Jason McKesson  committed 47866cc

Adjusted tutorial 2 to remove reference to moving triangle.

  • Participants
  • Parent commits 244ede3

Comments (0)

Files changed (4)

File Documents/Outline.xml

         </itemizedlist>
     </section>
     <section>
+        <title>Playing with Colors</title>
+        <para>This tutorial puts colors on our triangle.</para>
+        <para>Concepts:</para>
+        <itemizedlist>
+            <listitem>
+                <para>gl_FragCoord and its values.</para>
+            </listitem>
+            <listitem>
+                <para>Vertex arrays/streams. A discussion of how vertex data gets passed
+                    around.</para>
+            </listitem>
+            <listitem>
+                <para>Buffer objects. The containers for vertex data.</para>
+            </listitem>
+            <listitem>
+                <para>Multiple vertex attributes. Matching vertex attributes between the vertex
+                    shader and the vertex array. Passing colors to OpenGL.</para>
+            </listitem>
+            <listitem>
+                <para>Interleaving vertex arrays. The colors should be interleaved with the
+                    positions.</para>
+            </listitem>
+            <listitem>
+                <para>Inputs and outputs between GLSL stages.</para>
+            </listitem>
+            <listitem>
+                <para>Interpolation of the stage inputs/outputs.</para>
+            </listitem>
+        </itemizedlist>
+        <para>Tutorial sub-files:</para>
+        <orderedlist>
+            <listitem>
+                <para>Use gl_FragCoord to calculate fragment colors based on the position of the
+                    fragments. Use the moving triangle as a base.</para>
+            </listitem>
+            <listitem>
+                <para>Use multiple vertex arrays to send position and color data. Use a vertex
+                    shader output/fragment shader input to pass the per-vertex colors
+                    through.</para>
+            </listitem>
+        </orderedlist>
+    </section>
+    <section>
         <title>OpenGL's Moving Triangle</title>
         <para>This tutorial has a triangle moving around on the screen.</para>
         <para>Concepts:</para>
         </orderedlist>
     </section>
     <section>
-        <title>Playing with Colors</title>
-        <para>This tutorial puts colors on our triangle.</para>
-        <para>Concepts:</para>
-        <itemizedlist>
-            <listitem>
-                <para>gl_FragCoord and its values.</para>
-            </listitem>
-            <listitem>
-                <para>Vertex arrays/streams. A discussion of how vertex data gets passed
-                    around.</para>
-            </listitem>
-            <listitem>
-                <para>Buffer objects. The containers for vertex data.</para>
-            </listitem>
-            <listitem>
-                <para>Multiple vertex attributes. Matching vertex attributes between the vertex
-                    shader and the vertex array. Passing colors to OpenGL.</para>
-            </listitem>
-            <listitem>
-                <para>Interleaving vertex arrays. The colors should be interleaved with the
-                    positions.</para>
-            </listitem>
-            <listitem>
-                <para>Inputs and outputs between GLSL stages.</para>
-            </listitem>
-            <listitem>
-                <para>Interpolation of the stage inputs/outputs.</para>
-            </listitem>
-        </itemizedlist>
-        <para>Tutorial sub-files:</para>
-        <orderedlist>
-            <listitem>
-                <para>Use gl_FragCoord to calculate fragment colors based on the position of the
-                    fragments. Use the moving triangle as a base.</para>
-            </listitem>
-            <listitem>
-                <para>Use multiple vertex arrays to send position and color data. Use a vertex
-                    shader output/fragment shader input to pass the per-vertex colors
-                    through.</para>
-            </listitem>
-        </orderedlist>
-    </section>
-    <section>
         <title>Objects at Rest</title>
         <para>This tutorial shows a scene of objects, along with a recognizable ground plane. This
             should all be rendered with a perspective projection.</para>

File Tut 02 Playing with Colors/FragPosition.cpp

 	theProgram = Framework::CreateProgram(shaderList);
 
 	positionAttrib = glGetAttribLocation(theProgram, "position");
-	elapsedTimeUniform = glGetUniformLocation(theProgram, "time");
-	wndDimensions = glGetUniformLocation(theProgram, "wndDimensions");
-
-	GLuint loopDurationUnf = glGetUniformLocation(theProgram, "loopDuration");
-
-	glUseProgram(theProgram);
-	glUniform1f(loopDurationUnf, 5.0f);
-	glUseProgram(0);
 }
 
 const float vertexData[] = {
-	0.25f, 0.25f, 0.0f, 1.0f,
-	0.25f, -0.25f, 0.0f, 1.0f,
-	-0.25f, -0.25f, 0.0f, 1.0f,
+	0.75f, 0.75f, 0.0f, 1.0f,
+	0.75f, -0.75f, 0.0f, 1.0f,
+	-0.75f, -0.75f, 0.0f, 1.0f,
 };
 
 GLuint vertexBufferObject;
 
 	glUseProgram(theProgram);
 
-	glUniform1f(elapsedTimeUniform, glutGet(GLUT_ELAPSED_TIME) / 1000.0f);
-
 	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
 	glEnableVertexAttribArray(positionAttrib);
 	glVertexAttribPointer(positionAttrib, 4, GL_FLOAT, GL_FALSE, 0, 0);
 	glUseProgram(0);
 
 	glutSwapBuffers();
-	glutPostRedisplay();
 }
 
 //Called whenever the window is resized. The new window size is given, in pixels.

File Tut 02 Playing with Colors/data/FragPosition.frag

 
 out vec4 outputColor;
 
-uniform vec2 wndDimensions;
-
-const vec4 firstColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);
-const vec4 secondColor = vec4(0.2f, 0.2f, 0.2f, 1.0f);
-
 void main()
 {
-	float lerpValue = gl_FragCoord.y / wndDimensions.y;
+	float lerpValue = gl_FragCoord.y / 500.0f;
 		
-	outputColor = mix(firstColor, secondColor, lerpValue);
+	outputColor = mix(vec4(1.0f, 1.0f, 1.0f, 1.0f), vec4(0.2f, 0.2f, 0.2f, 1.0f), lerpValue);
 }

File Tut 02 Playing with Colors/data/FragPosition.vert

 #version 150
 
 in vec4 position;
-uniform float loopDuration;
-uniform float time;
 
 void main()
 {
-	float timeScale = 3.14159f * 2.0f / loopDuration;
-	
-	float currTime = mod(time, loopDuration);
-	vec4 totalOffset = vec4(
-		cos(currTime * timeScale) * 0.5f,
-		sin(currTime * timeScale) * 0.5f,
-		0.0f,
-		0.0f);
-
-	gl_Position = position + totalOffset;
+	gl_Position = position;
 }