Roi Atalla avatar Roi Atalla committed dc35606

Code is now in Maven layout.

Comments (0)

Files changed (169)

 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="src/main/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LWJGL"/>
 	<classpathentry kind="output" path="bin"/>

src/com/ra4king/opengl/GLProgram.java

-package com.ra4king.opengl;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.util.glu.GLU.*;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.ContextAttribs;
-import org.lwjgl.opengl.Display;
-import org.lwjgl.opengl.DisplayMode;
-import org.lwjgl.opengl.PixelFormat;
-
-public abstract class GLProgram {
-	private int fps;
-	
-	public GLProgram(boolean vsync) {
-		try {
-			Display.setFullscreen(true);
-			Display.setVSyncEnabled(vsync);
-		}
-		catch(Exception exc) {
-			exc.printStackTrace();
-		}
-	}
-	
-	public GLProgram(String name, int width, int height, boolean resizable) {
-		Display.setTitle(name);
-		
-		try {
-			Display.setDisplayMode(new DisplayMode(width,height));
-		}
-		catch(Exception exc) {
-			exc.printStackTrace();
-		}
-		
-		Display.setResizable(resizable);
-		
-		fps = 60;
-	}
-	
-	public void setFPS(int fps) {
-		this.fps = fps;
-	}
-	
-	public int getFPS() {
-		return fps;
-	}
-	
-	public final void run() {
-		run(false);
-	}
-	
-	public final void run(boolean core) {
-		try {
-			Display.create(new PixelFormat(),core ? new ContextAttribs(3,3) : new ContextAttribs());
-		}
-		catch(Exception exc) {
-			exc.printStackTrace();
-			System.exit(1);
-		}
-		
-		init();
-		
-		resized();
-		
-		long lastTime, lastFPS;
-		lastTime = lastFPS = System.nanoTime();
-		int frames = 0;
-		
-		while(!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
-			long deltaTime = System.nanoTime() - lastTime;
-			lastTime += deltaTime;
-			
-			if(Display.wasResized())
-				resized();
-			
-			update(deltaTime);
-			render();
-			
-			Display.update();
-			
-			int error;
-			while((error = glGetError()) != GL_NO_ERROR)
-				System.out.println(gluErrorString(error));
-			
-			frames++;
-			if(System.nanoTime() - lastFPS >= 1e9) {
-				System.out.println("FPS: ".concat(String.valueOf(frames)));
-				lastFPS += 1e9;
-				frames = 0;
-			}
-			
-			Display.sync(fps);
-		}
-		
-		destroy();
-	}
-	
-	public int getWidth() {
-		return Display.getWidth();
-	}
-	
-	public int getHeight() {
-		return Display.getHeight();
-	}
-	
-	public abstract void init();
-	
-	public void resized() {
-		glViewport(0,0,getWidth(),getHeight());
-	}
-	
-	public void update(long deltaTime) {}
-	
-	public abstract void render();
-	
-	public void destroy() {
-		Display.destroy();
-		System.exit(0);
-	}
-	
-	protected String readFromFile(String file) {
-		try(BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(file),"UTF-8"))) {
-			StringBuilder s = new StringBuilder();
-			String l;
-			
-			while((l = reader.readLine()) != null)
-				s.append(l).append("\n");
-			
-			return s.toString();
-		}
-		catch(Exception exc) {
-			throw new RuntimeException("Failure reading file: " + file,exc);
-		}
-	}
-}

src/com/ra4king/opengl/ShaderProgram.java

-package com.ra4king.opengl;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL20.*;
-
-public class ShaderProgram {
-	private int program;
-	
-	public ShaderProgram(String vertexShader, String fragmentShader) {
-		int vs = glCreateShader(GL_VERTEX_SHADER);
-		glShaderSource(vs, vertexShader);
-		
-		glCompileShader(vs);
-		
-		if(glGetShader(vs, GL_COMPILE_STATUS) == GL_FALSE)
-			throw new RuntimeException("Failure in compiling vertex shader. Error log:\n" + glGetShaderInfoLog(vs, glGetShader(vs, GL_INFO_LOG_LENGTH)));
-		
-		int fs = glCreateShader(GL_FRAGMENT_SHADER);
-		glShaderSource(fs, fragmentShader);
-		
-		glCompileShader(fs);
-		
-		if(glGetShader(fs, GL_COMPILE_STATUS) == GL_FALSE)
-			throw new RuntimeException("Failure in compiling fragment shader. Error log:\n" + glGetShaderInfoLog(fs, glGetShader(fs, GL_INFO_LOG_LENGTH)));
-		
-		program = glCreateProgram();
-		glAttachShader(program, vs);
-		glAttachShader(program, fs);
-		
-		glLinkProgram(program);
-		
-		if(glGetProgram(program, GL_LINK_STATUS) == GL_FALSE)
-			throw new RuntimeException("Failure in linking program. Error log:\n" + glGetProgramInfoLog(program, glGetProgram(program, GL_INFO_LOG_LENGTH)));
-		
-		glDetachShader(program, vs);
-		glDetachShader(program, fs);
-		
-		glDeleteShader(vs);
-		glDeleteShader(fs);
-	}
-	
-	public int getProgram() {
-		return program;
-	}
-	
-	public void begin() {
-		glUseProgram(program);
-	}
-	
-	public void end() {
-		glUseProgram(0);
-	}
-	
-	public void destroy() {
-		glDeleteProgram(program);
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter1/Example1_1.java

-package com.ra4king.opengl.arcsynthesis.chapter1;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-
-public class Example1_1 extends GLProgram {
-	public static void main(String[] args) {
-		new Example1_1().run(true);
-	}
-	
-	private int program, vbo;
-	
-	public Example1_1() {
-		super("Example 1.1", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		int vs = glCreateShader(GL_VERTEX_SHADER);
-		glShaderSource(vs, readFromFile("example1.1.vert"));
-		
-		glCompileShader(vs);
-		
-		if(glGetShader(vs, GL_COMPILE_STATUS) == GL_FALSE) {
-			System.err.println("Failure in compiling vertex shader. Error log:\n" + glGetShaderInfoLog(vs, glGetShader(vs, GL_INFO_LOG_LENGTH)));
-			System.exit(0);
-		}
-		
-		int fs = glCreateShader(GL_FRAGMENT_SHADER);
-		glShaderSource(fs, readFromFile("example1.1.frag"));
-		
-		glCompileShader(fs);
-		
-		if(glGetShader(fs, GL_COMPILE_STATUS) == GL_FALSE) {
-			System.err.println("Failure in compiling fragment shader. Error log:\n" + glGetShaderInfoLog(fs, glGetShader(fs, GL_INFO_LOG_LENGTH)));
-			destroy();
-		}
-		
-		program = glCreateProgram();
-		glAttachShader(program, vs);
-		glAttachShader(program, fs);
-		
-		glLinkProgram(program);
-		
-		if(glGetProgram(program, GL_LINK_STATUS) == GL_FALSE) {
-			System.err.println("Failure in linking program. Error log:\n" + glGetProgramInfoLog(program, glGetProgram(program, GL_INFO_LOG_LENGTH)));
-			destroy();
-		}
-		
-		glDetachShader(program, vs);
-		glDetachShader(program, fs);
-		
-		glDeleteShader(vs);
-		glDeleteShader(fs);
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(24).put(new float[] { 0.75f,  0.75f, 0.0f, 1.0f,
-																									   0.75f, -0.75f, 0.0f, 1.0f,
-																									  -0.75f, -0.75f, 0.0f, 1.0f}).flip(),GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		glUseProgram(program);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		glUseProgram(0);
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter1/example1.1.frag

-#version 330
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = vec4(1,1,1,1);
-}

src/com/ra4king/opengl/arcsynthesis/chapter1/example1.1.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-
-void main()
-{
-	gl_Position = position;
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example1/Example2_1.java

-package com.ra4king.opengl.arcsynthesis.chapter2.example1;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example2_1 extends GLProgram {
-	public static void main(String[] args) {
-		new Example2_1().run(true);
-	}
-	
-	private ShaderProgram program;
-	private int vbo;
-	
-	public Example2_1() {
-		super("Example 2.1", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example2.1.vert"),readFromFile("example2.1.frag"));
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.75f,  0.75f, 0.0f, 1.0f,
-																									   0.75f, -0.75f, 0.0f, 1.0f,
-																									  -0.75f, -0.75f, 0.0f, 1.0f}).flip(),GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example1/example2.1.frag

-#version 330
-
-out vec4 outputColor;
-
-void main()
-{
-    float lerpValue = gl_FragCoord.y / 600.0f;
-        
-    outputColor = mix(vec4(1.0f, 1.0f, 1.0f, 1.0f), vec4(0.2f, 0.2f, 0.2f, 1.0f), lerpValue);
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example1/example2.1.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-
-void main()
-{
-	gl_Position = position;
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example2/Example2_2.java

-package com.ra4king.opengl.arcsynthesis.chapter2.example2;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example2_2 extends GLProgram {
-	public static void main(String[] args) {
-		new Example2_2().run(true);
-	}
-	
-	private ShaderProgram program;
-	private int vbo;
-	
-	public Example2_2() {
-		super("Example 2.2", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example2.2.vert"),readFromFile("example2.2.frag"));
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(24).put(new float[] { 0.0f,    0.5f, 0.0f, 1.0f,
-																									   0.5f, -0.366f, 0.0f, 1.0f,
-																									  -0.5f, -0.366f, 0.0f, 1.0f,
-																									   1.0f,    0.0f, 0.0f, 1.0f,
-																									   0.0f,    1.0f, 0.0f, 1.0f,
-																									   0.0f,    0.0f, 1.0f, 1.0f}).flip(),GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glEnableVertexAttribArray(1);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		glVertexAttribPointer(1, 4, GL_FLOAT, false, 0, 48);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glDisableVertexAttribArray(1);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example2/example2.2.frag

-#version 330
-
-smooth in vec4 theColor;
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = theColor;
-}

src/com/ra4king/opengl/arcsynthesis/chapter2/example2/example2.2.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-layout(location = 1) in vec4 color;
-
-smooth out vec4 theColor;
-
-void main()
-{
-	gl_Position = position;
-	theColor = color;
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example1/Example3_1.java

-package com.ra4king.opengl.arcsynthesis.chapter3.example1;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example3_1 extends GLProgram {
-	public static void main(String[] args) {
-		new Example3_1().run(true);
-	}
-	
-	private ShaderProgram program;
-	
-	private FloatBuffer vertexData, newData;
-	private int vbo;
-	
-	private long elapsedTime;
-	
-	public Example3_1() {
-		super("Example 3.1", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example3.1.vert"),readFromFile("example3.1.frag"));
-		
-		vbo = glGenBuffers();
-		
-		vertexData = (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f,  0.25f, 0.0f, 1.0f,
-																					  0.25f, -0.25f, 0.0f, 1.0f,
-																					 -0.25f, -0.25f, 0.0f, 1.0f}).flip();
-		newData = BufferUtils.createFloatBuffer(12);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STREAM_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void update(long deltaTime) {
-		elapsedTime += deltaTime;
-		
-		float loopDuration = 5;
-		float scale = (float)Math.PI * 2 / loopDuration;
-		float currentTimeThroughLoop = (elapsedTime/(float)1e9) % loopDuration;
-		
-		float xOffset = (float)Math.cos(currentTimeThroughLoop * scale) * 0.5f;
-		float yOffset = (float)Math.sin(currentTimeThroughLoop * scale) * 0.5f;
-		
-		newData.clear();
-		
-		for(int a = 0; a < 12; a += 4) {
-			newData.put(vertexData.get(a) + xOffset);
-			newData.put(vertexData.get(a+1) + yOffset);
-			newData.put(0);
-			newData.put(1);
-		}
-		
-		newData.flip();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferSubData(GL_ARRAY_BUFFER, 0, newData);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example1/example3.1.frag

-#version 330
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = vec4(1, 1, 1, 1);
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example1/example3.1.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-
-void main()
-{
-	gl_Position = position;
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example2/Example3_2.java

-package com.ra4king.opengl.arcsynthesis.chapter3.example2;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example3_2 extends GLProgram {
-	public static void main(String[] args) {
-		new Example3_2().run(true);
-	}
-	
-	private ShaderProgram program;
-	private int offsetLocation;
-	private int vbo;
-	
-	private long elapsedTime;
-	
-	public Example3_2() {
-		super("Example 3.2", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example3.2.vert"),readFromFile("example3.2.frag"));
-		offsetLocation = glGetUniformLocation(program.getProgram(), "offset");
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f,  0.25f, 0.0f, 1.0f,
-																									   0.25f, -0.25f, 0.0f, 1.0f,
-																									  -0.25f, -0.25f, 0.0f, 1.0f}).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void update(long deltaTime) {
-		elapsedTime += deltaTime;
-	}
-	
-	@Override
-	public void render() {
-		float loopDuration = 5;
-		float scale = (float)Math.PI * 2 / loopDuration;
-		float currentTimeThroughLoop = (elapsedTime/(float)1e9) % loopDuration;
-		
-		float xOffset = (float)Math.cos(currentTimeThroughLoop * scale) * 0.5f;
-		float yOffset = (float)Math.sin(currentTimeThroughLoop * scale) * 0.5f;
-		
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform2f(offsetLocation, xOffset, yOffset);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example2/example3.2.frag

-#version 330
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = vec4(1, 1, 1, 1);
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example2/example3.2.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-uniform vec2 offset;
-
-void main()
-{
-	gl_Position = position + vec4(offset, 0, 0);
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example3/Example3_3.java

-package com.ra4king.opengl.arcsynthesis.chapter3.example3;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example3_3 extends GLProgram {
-	public static void main(String[] args) {
-		new Example3_3().run(true);
-	}
-	
-	private ShaderProgram program;
-	private int timeLocation;
-	private int vbo;
-	
-	private long elapsedTime;
-	
-	public Example3_3() {
-		super("Example 3.3", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example3.3.vert"),readFromFile("example3.3.frag"));
-		timeLocation = glGetUniformLocation(program.getProgram(), "time");
-		
-		int loopDurationLocation = glGetUniformLocation(program.getProgram(), "loopDuration");
-		program.begin();
-		glUniform1f(loopDurationLocation, 5);
-		program.end();
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f,  0.25f, 0.0f, 1.0f,
-																									   0.25f, -0.25f, 0.0f, 1.0f,
-																									  -0.25f, -0.25f, 0.0f, 1.0f}).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void update(long deltaTime) {
-		elapsedTime += deltaTime;
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform1f(timeLocation, elapsedTime/(float)1e9);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example3/example3.3.frag

-#version 330
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = vec4(1, 1, 1, 1);
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example3/example3.3.vert

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

src/com/ra4king/opengl/arcsynthesis/chapter3/example4/Example3_4.java

-package com.ra4king.opengl.arcsynthesis.chapter3.example4;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example3_4 extends GLProgram {
-	public static void main(String[] args) {
-		new Example3_4().run(true);
-	}
-	
-	private ShaderProgram program;
-	private int timeLocation;
-	private int vbo;
-	
-	private long elapsedTime;
-	
-	public Example3_4() {
-		super("Example 3.4", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example3.4.vert"),readFromFile("example3.4.frag"));
-		timeLocation = glGetUniformLocation(program.getProgram(), "time");
-		
-		int loopDurationLocation = glGetUniformLocation(program.getProgram(), "loopDuration");
-		int fragLoopDuration = glGetUniformLocation(program.getProgram(), "fragLoopDuration");
-		program.begin();
-		glUniform1f(loopDurationLocation, 5);
-		glUniform1f(fragLoopDuration, 10);
-		program.end();
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f,  0.25f, 0.0f, 1.0f,
-																									   0.25f, -0.25f, 0.0f, 1.0f,
-																									  -0.25f, -0.25f, 0.0f, 1.0f}).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-	}
-	
-	@Override
-	public void update(long deltaTime) {
-		elapsedTime += deltaTime;
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform1f(timeLocation, elapsedTime/(float)1e9);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 3);
-		
-		glDisableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example4/example3.4.frag

-#version 330
-
-out vec4 outputColor;
-
-uniform float fragLoopDuration;
-uniform float time;
-
-const vec4 firstColor = vec4(1, 1, 1, 1);
-const vec4 secondColor = vec4(0, 1, 0, 1);
-
-void main()
-{
-	float currTime = mod(time, fragLoopDuration);
-	float currLerp = currTime/ fragLoopDuration;
-	
-	outputColor = mix(firstColor, secondColor, currLerp);
-}

src/com/ra4king/opengl/arcsynthesis/chapter3/example4/example3.4.vert

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

src/com/ra4king/opengl/arcsynthesis/chapter4/example1/Example4_1.java

-package com.ra4king.opengl.arcsynthesis.chapter4.example1;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-public class Example4_1 extends GLProgram {
-	public static void main(String[] args) {
-		new Example4_1().run(true);
-	}
-	
-	private final float[] data = {
-			 0.25f,  0.25f, 0.75f, 1.0f,
-			 0.25f, -0.25f, 0.75f, 1.0f,
-			-0.25f,  0.25f, 0.75f, 1.0f,
-			
-			 0.25f, -0.25f, 0.75f, 1.0f,
-			-0.25f, -0.25f, 0.75f, 1.0f,
-			-0.25f,  0.25f, 0.75f, 1.0f,
-			
-			 0.25f,  0.25f, -0.75f, 1.0f,
-			-0.25f,  0.25f, -0.75f, 1.0f,
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			-0.25f,  0.25f, -0.75f, 1.0f,
-			-0.25f, -0.25f, -0.75f, 1.0f,
-			
-			-0.25f,  0.25f,  0.75f, 1.0f,
-			-0.25f, -0.25f,  0.75f, 1.0f,
-			-0.25f, -0.25f, -0.75f, 1.0f,
-			
-			-0.25f,  0.25f,  0.75f, 1.0f,
-			-0.25f, -0.25f, -0.75f, 1.0f,
-			-0.25f,  0.25f, -0.75f, 1.0f,
-			
-			 0.25f,  0.25f,  0.75f, 1.0f,
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			 0.25f, -0.25f,  0.75f, 1.0f,
-			 
-			 0.25f,  0.25f,  0.75f, 1.0f,
-			 0.25f,  0.25f, -0.75f, 1.0f,
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			 
-			 0.25f,  0.25f, -0.75f, 1.0f,
-			 0.25f,  0.25f,  0.75f, 1.0f,
-			-0.25f,  0.25f,  0.75f, 1.0f,
-			
-			 0.25f,  0.25f, -0.75f, 1.0f,
-			-0.25f,  0.25f,  0.75f, 1.0f,
-			-0.25f,  0.25f, -0.75f, 1.0f,
-			
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			-0.25f, -0.25f,  0.75f, 1.0f,
-			 0.25f, -0.25f,  0.75f, 1.0f,
-			 
-			 0.25f, -0.25f, -0.75f, 1.0f,
-			-0.25f, -0.25f, -0.75f, 1.0f,
-			-0.25f, -0.25f,  0.75f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f
-	};
-	
-	private ShaderProgram program;
-	private int offsetUniform;
-	
-	private int vbo;
-	
-	public Example4_1() {
-		super("Example 4.1", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example4.1.vert"),readFromFile("example4.1.frag"));
-		
-		offsetUniform = glGetUniformLocation(program.getProgram(), "offset");
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(data.length).put(data).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		glEnable(GL_CULL_FACE);
-		glCullFace(GL_BACK);
-		glFrontFace(GL_CW);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform2f(offsetUniform, 0.5f, 0.25f);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glEnableVertexAttribArray(1);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		glVertexAttribPointer(1, 4, GL_FLOAT, false, 0, data.length * 2);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 36);
-		
-		glDisableVertexAttribArray(0);
-		glDisableVertexAttribArray(1);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example1/example4.1.frag

-#version 330
-
-smooth in vec4 theColor;
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = theColor;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example1/example4.1.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-layout(location = 1) in vec4 color;
-
-smooth out vec4 theColor;
-
-uniform vec2 offset;
-
-void main()
-{
-	gl_Position = position + vec4(offset, 0, 0);
-	theColor = color;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example2/Example4_2.java

-package com.ra4king.opengl.arcsynthesis.chapter4.example2;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example4_2 extends GLProgram {
-	public static void main(String[] args) {
-		new Example4_2().run(true);
-	}
-	
-	private final float[] data = {
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f
-	};
-	
-	private ShaderProgram program;
-	private int offsetUniform;
-	
-	private int vbo;
-	
-	public Example4_2() {
-		super("Example 4.2", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example4.2.vert"),readFromFile("example4.2.frag"));
-		
-		offsetUniform = glGetUniformLocation(program.getProgram(), "offset");
-		
-		int frustumScaleUniform = glGetUniformLocation(program.getProgram(), "frustumScale");
-		int zNearUniform = glGetUniformLocation(program.getProgram(), "zNear");
-		int zFarUniform = glGetUniformLocation(program.getProgram(), "zFar");
-		
-		program.begin();
-		glUniform1f(frustumScaleUniform, 1);
-		glUniform1f(zNearUniform, 1);
-		glUniform1f(zFarUniform, 3);
-		program.end();
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(data.length).put(data).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		glEnable(GL_CULL_FACE);
-		glCullFace(GL_BACK);
-		glFrontFace(GL_CW);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform2f(offsetUniform, 0.5f, 0.5f);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glEnableVertexAttribArray(1);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		glVertexAttribPointer(1, 4, GL_FLOAT, false, 0, data.length * 2);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 36);
-		
-		glDisableVertexAttribArray(0);
-		glDisableVertexAttribArray(1);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example2/example4.2.frag

-#version 330
-
-smooth in vec4 theColor;
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = theColor;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example2/example4.2.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-layout(location = 1) in vec4 color;
-
-smooth out vec4 theColor;
-
-uniform vec2 offset;
-uniform float zNear;
-uniform float zFar;
-uniform float frustumScale;
-
-void main()
-{
-	vec4 cameraPos = position + vec4(offset, 0, 0);
-	vec4 clipPos;
-	
-	clipPos.xy = cameraPos.xy * frustumScale;
-	clipPos.z = cameraPos.z * (zNear + zFar) / (zNear - zFar) + (2 * zNear * zFar) / (zNear - zFar);
-	clipPos.w = -cameraPos.z;
-	
-	gl_Position = clipPos;
-	theColor = color;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example3/Example4_3.java

-package com.ra4king.opengl.arcsynthesis.chapter4.example3;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example4_3 extends GLProgram {
-	public static void main(String[] args) {
-		new Example4_3().run(true);
-	}
-	
-	private final float[] data = {
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			0.0f, 1.0f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			0.5f, 0.5f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			1.0f, 0.0f, 0.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f,
-			0.0f, 1.0f, 1.0f, 1.0f
-	};
-	
-	private ShaderProgram program;
-	private int offsetUniform;
-	
-	private int vbo;
-	
-	public Example4_3() {
-		super("Example 4.3", 500, 500, false);
-	}
-	
-	@Override
-	public void init() {
-		glClearColor(0, 0, 0, 0);
-		
-		program = new ShaderProgram(readFromFile("example4.3.vert"),readFromFile("example4.3.frag"));
-		
-		offsetUniform = glGetUniformLocation(program.getProgram(), "offset");
-		
-		int perspectiveMatrixUniform = glGetUniformLocation(program.getProgram(), "perspectiveMatrix");
-		
-		float frustumScale = 1, zNear = 0.5f, zFar = 3;
-		FloatBuffer perspectiveMatrix = BufferUtils.createFloatBuffer(16);
-		perspectiveMatrix.put(0,frustumScale);
-		perspectiveMatrix.put(5,frustumScale);
-		perspectiveMatrix.put(10,(zFar + zNear) / (zNear - zFar));
-		perspectiveMatrix.put(14,(2 * zFar * zNear) / (zNear - zFar));
-		perspectiveMatrix.put(11,-1);
-		
-		program.begin();
-		glUniformMatrix4(perspectiveMatrixUniform, false, perspectiveMatrix);
-		program.end();
-		
-		vbo = glGenBuffers();
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(data.length).put(data).flip(), GL_STATIC_DRAW);
-		
-		glBindVertexArray(glGenVertexArrays());
-		
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		glEnable(GL_CULL_FACE);
-		glCullFace(GL_BACK);
-		glFrontFace(GL_CW);
-	}
-	
-	@Override
-	public void render() {
-		glClear(GL_COLOR_BUFFER_BIT);
-		
-		program.begin();
-		
-		glUniform2f(offsetUniform, 0.5f, 0.5f);
-		
-		glBindBuffer(GL_ARRAY_BUFFER, vbo);
-		glEnableVertexAttribArray(0);
-		glEnableVertexAttribArray(1);
-		glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
-		glVertexAttribPointer(1, 4, GL_FLOAT, false, 0, data.length * 2);
-		
-		glDrawArrays(GL_TRIANGLES, 0, 36);
-		
-		glDisableVertexAttribArray(0);
-		glDisableVertexAttribArray(1);
-		glBindBuffer(GL_ARRAY_BUFFER, 0);
-		
-		program.end();
-	}
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example3/example4.3.frag

-#version 330
-
-smooth in vec4 theColor;
-
-out vec4 outputColor;
-
-void main()
-{
-	outputColor = theColor;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example3/example4.3.vert

-#version 330
-
-layout(location = 0) in vec4 position;
-layout(location = 1) in vec4 color;
-
-smooth out vec4 theColor;
-
-uniform vec2 offset;
-uniform mat4 perspectiveMatrix;
-
-void main()
-{
-	gl_Position = perspectiveMatrix * (position + vec4(offset, 0, 0));
-	theColor = color;
-}

src/com/ra4king/opengl/arcsynthesis/chapter4/example4/Example4_4.java

-package com.ra4king.opengl.arcsynthesis.chapter4.example4;
-
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.opengl.GL15.*;
-import static org.lwjgl.opengl.GL20.*;
-import static org.lwjgl.opengl.GL30.*;
-
-import java.nio.FloatBuffer;
-
-import org.lwjgl.BufferUtils;
-
-import com.ra4king.opengl.GLProgram;
-import com.ra4king.opengl.ShaderProgram;
-
-public class Example4_4 extends GLProgram {
-	public static void main(String[] args) {
-		new Example4_4().run(true);
-	}
-	
-	private final float[] data = {
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			 0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			
-			 0.25f,  0.25f, -2.75f, 1.0f,
-			-0.25f,  0.25f, -1.25f, 1.0f,
-			-0.25f,  0.25f, -2.75f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			 0.25f, -0.25f, -1.25f, 1.0f,
-			
-			 0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -2.75f, 1.0f,
-			-0.25f, -0.25f, -1.25f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			0.0f, 0.0f, 1.0f, 1.0f,
-			
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,
-			0.8f, 0.8f, 0.8f, 1.0f,