07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Vertex Buffer Object 229<br />

}<br />

fread(buf, length, 1, fptr); /* Read the contents of the file in to<br />

the buffer */<br />

fclose(fptr); /* Close the file */<br />

buf[length] = 0; /* Null terminator */<br />

return buf; /* Return the buffer */<br />

Vertex Shader:<br />

/*----------------- "exampleVertexShader.vert" -----------------*/<br />

#version 150 // Specify which version of GLSL we are using.<br />

// in_Position was bound to attribute index 0("shaderAtribute")<br />

in vec3 in_Position;<br />

void main(void)<br />

{<br />

1.0);<br />

}<br />

gl_Position = vec4(in_Position.x, in_Position.y, in_Position.z,<br />

/*--------------------------------------------------------------*/<br />

Fragment Shader:<br />

/*---------------- "exampleFragmentShader.frag" ----------------*/<br />

#version 150 // Specify which version of GLSL we are using.<br />

precision highp float; // Video card drivers require this next line to<br />

function properly<br />

out vec4 fragColor;<br />

void main(void)<br />

{<br />

WHITE<br />

}<br />

fragColor = vec4(1.0,1.0,1.0,1.0); //Set colour of each vertex to<br />

/*--------------------------------------------------------------*/<br />

Main OpenGL Program:<br />

/*--------------------- Main OpenGL Program ---------------------*/<br />

/* Create a variable to hold the VBO identifier */<br />

GLuint triangleVBO;<br />

/* This is a handle to the shader program */

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!