Update Commit
This commit is contained in:
parent
fa79114e3e
commit
ce933acda6
6 changed files with 101 additions and 1 deletions
BIN
First Game Engine Project/res/font/Thumbs.db
Normal file
BIN
First Game Engine Project/res/font/Thumbs.db
Normal file
Binary file not shown.
|
@ -6,6 +6,7 @@ import static org.lwjgl.opengl.GL11.*;
|
||||||
public class DisplayManager {
|
public class DisplayManager {
|
||||||
|
|
||||||
public static void clear(){
|
public static void clear(){
|
||||||
|
glClearColor(1,1,1,1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
89
First Game Engine Project/src/mrdev023/opengl/VAO.java
Normal file
89
First Game Engine Project/src/mrdev023/opengl/VAO.java
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
package mrdev023.opengl;
|
||||||
|
|
||||||
|
import static org.lwjgl.opengl.GL15.*;
|
||||||
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
import static org.lwjgl.opengl.GL30.*;
|
||||||
|
|
||||||
|
import java.nio.*;
|
||||||
|
|
||||||
|
import org.lwjgl.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class VAO {
|
||||||
|
|
||||||
|
public int vao,vertexBuffer,colorBuffer,texBuffer;
|
||||||
|
|
||||||
|
public VAO(){
|
||||||
|
vao = glGenVertexArrays();
|
||||||
|
vertexBuffer = glGenBuffers();
|
||||||
|
colorBuffer = glGenBuffers();
|
||||||
|
texBuffer = glGenBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setVertexBuffer(float... a){
|
||||||
|
FloatBuffer buffer = BufferUtils.createFloatBuffer(8);
|
||||||
|
for(float c : a)buffer.put(c);
|
||||||
|
buffer.flip();
|
||||||
|
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,vertexBuffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,buffer,GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColorBuffer(float... a){
|
||||||
|
FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
|
||||||
|
for(float c : a)buffer.put(c);
|
||||||
|
buffer.flip();
|
||||||
|
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,colorBuffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,buffer,GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTexBuffer(float... a){
|
||||||
|
FloatBuffer buffer = BufferUtils.createFloatBuffer(8);
|
||||||
|
for(float c : a)buffer.put(c);
|
||||||
|
buffer.flip();
|
||||||
|
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,texBuffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,buffer,GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(){
|
||||||
|
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,vertexBuffer);
|
||||||
|
glVertexPointer(2, GL_FLOAT, 8, 0);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,colorBuffer);
|
||||||
|
glColorPointer(4,GL_FLOAT,16,0);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,texBuffer);
|
||||||
|
glTexCoordPointer(2,GL_FLOAT,8,0);
|
||||||
|
|
||||||
|
glDrawArrays(GL_QUADS,0,4);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void destroy(){
|
||||||
|
glDeleteBuffers(vertexBuffer);
|
||||||
|
glDeleteBuffers(colorBuffer);
|
||||||
|
glDeleteBuffers(texBuffer);
|
||||||
|
glDeleteVertexArrays(vao);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package mrdev023.opengl.gui;
|
||||||
|
|
||||||
|
public class Button extends GUIComponent{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package mrdev023.opengl.gui;
|
||||||
|
|
||||||
|
public abstract class GUIComponent {
|
||||||
|
|
||||||
|
}
|
Reference in a new issue