texturing works

This commit is contained in:
EvilMuffinHa 2020-05-25 14:59:42 -04:00
parent 5fc63b6c73
commit 2294aba9e3
8 changed files with 17 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -24,7 +24,7 @@ public class Test {
0, 1, 2,
0, 2, 3
}, new Material(new Texture("resources/textures/testimg.png")));
}, new Material(new Texture("resources/textures/thonk.png")));
public void run() throws Exception {
setup();
@ -49,7 +49,7 @@ public class Test {
display.create();
shader = new Shader("/resources/shaders/mainVertex.glsl", "/resources/shaders/mainFragment.glsl");
renderer = new Renderer(shader);
display.setBackgroundColor(1F, 0, 0);
display.setBackgroundColor(1F, 1F, 1F);
mesh.create();
shader.create();

View File

@ -10,9 +10,10 @@ public class Vertex {
private Vector3f color;
private Vector2f textureCoords;
public Vertex (Vector3f position, Vector3f color, Vector2f texture) {
public Vertex (Vector3f position, Vector3f color, Vector2f textureCoords) {
this.position = position;
this.color = color;
this.textureCoords = textureCoords;
}
public Vector3f getPosition() {

View File

@ -1,5 +1,6 @@
package org.hl.engine.io;
import org.hl.engine.math.lalg.Vector3f;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.glfw.GLFWWindowSizeCallback;
import org.lwjgl.opengl.GL;
@ -96,6 +97,8 @@ public class Display {
// Creates the window (should go in the init() function of your Main program)
public void create() throws Exception {
GLFWErrorCallback.createPrint(System.err).set();
// initializing glfw
if (!glfwInit()) {
//System.err.println("Failed to initialize GLFW! ");
@ -104,7 +107,7 @@ public class Display {
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
@ -190,6 +193,7 @@ public class Display {
// Completely DESTROYS the window
public void destroy() {
resizeCallback.free();
glfwSetErrorCallback(null).free();
glfwDestroyWindow(window);
glfwTerminate();
}

View File

@ -1,9 +1,9 @@
#version 410 core
in vec3 passColor;
in vec2 passTextureCoord;
layout(location = 0) in vec3 passColor;
layout(location = 1) in vec2 passTextureCoord;
out vec4 outColor;
layout(location = 0) out vec4 outColor;
uniform sampler2D tex;

View File

@ -1,11 +1,11 @@
#version 410 core
in vec3 position;
in vec3 color;
in vec2 textureCoord;
layout(location = 0) in vec3 position;
layout(location = 1) in vec3 color;
layout(location = 2) in vec2 textureCoord;
out vec3 passColor;
out vec2 passTextureCoord;
layout(location = 0) out vec3 passColor;
layout(location = 1) out vec2 passTextureCoord;
void main() {
gl_Position = vec4(position, 1.0);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB