texturing works
This commit is contained in:
parent
5fc63b6c73
commit
2294aba9e3
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB |
BIN
resources/textures/thonk.png
Normal file
BIN
resources/textures/thonk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
|
@ -24,7 +24,7 @@ public class Test {
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3
|
0, 2, 3
|
||||||
|
|
||||||
}, new Material(new Texture("resources/textures/testimg.png")));
|
}, new Material(new Texture("resources/textures/thonk.png")));
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
setup();
|
setup();
|
||||||
|
@ -49,7 +49,7 @@ public class Test {
|
||||||
display.create();
|
display.create();
|
||||||
shader = new Shader("/resources/shaders/mainVertex.glsl", "/resources/shaders/mainFragment.glsl");
|
shader = new Shader("/resources/shaders/mainVertex.glsl", "/resources/shaders/mainFragment.glsl");
|
||||||
renderer = new Renderer(shader);
|
renderer = new Renderer(shader);
|
||||||
display.setBackgroundColor(1F, 0, 0);
|
display.setBackgroundColor(1F, 1F, 1F);
|
||||||
mesh.create();
|
mesh.create();
|
||||||
shader.create();
|
shader.create();
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,10 @@ public class Vertex {
|
||||||
private Vector3f color;
|
private Vector3f color;
|
||||||
private Vector2f textureCoords;
|
private Vector2f textureCoords;
|
||||||
|
|
||||||
public Vertex (Vector3f position, Vector3f color, Vector2f texture) {
|
public Vertex (Vector3f position, Vector3f color, Vector2f textureCoords) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.textureCoords = textureCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f getPosition() {
|
public Vector3f getPosition() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hl.engine.io;
|
package org.hl.engine.io;
|
||||||
import org.hl.engine.math.lalg.Vector3f;
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||||
import org.lwjgl.glfw.GLFWVidMode;
|
import org.lwjgl.glfw.GLFWVidMode;
|
||||||
import org.lwjgl.glfw.GLFWWindowSizeCallback;
|
import org.lwjgl.glfw.GLFWWindowSizeCallback;
|
||||||
import org.lwjgl.opengl.GL;
|
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)
|
// Creates the window (should go in the init() function of your Main program)
|
||||||
public void create() throws Exception {
|
public void create() throws Exception {
|
||||||
|
|
||||||
|
GLFWErrorCallback.createPrint(System.err).set();
|
||||||
|
|
||||||
// initializing glfw
|
// initializing glfw
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
//System.err.println("Failed to initialize GLFW! ");
|
//System.err.println("Failed to initialize GLFW! ");
|
||||||
|
@ -104,7 +107,7 @@ public class Display {
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
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_FORWARD_COMPAT, GL11.GL_TRUE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
|
@ -190,6 +193,7 @@ public class Display {
|
||||||
// Completely DESTROYS the window
|
// Completely DESTROYS the window
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
resizeCallback.free();
|
resizeCallback.free();
|
||||||
|
glfwSetErrorCallback(null).free();
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#version 410 core
|
#version 410 core
|
||||||
|
|
||||||
in vec3 passColor;
|
layout(location = 0) in vec3 passColor;
|
||||||
in vec2 passTextureCoord;
|
layout(location = 1) in vec2 passTextureCoord;
|
||||||
|
|
||||||
out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#version 410 core
|
#version 410 core
|
||||||
|
|
||||||
in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
in vec3 color;
|
layout(location = 1) in vec3 color;
|
||||||
in vec2 textureCoord;
|
layout(location = 2) in vec2 textureCoord;
|
||||||
|
|
||||||
out vec3 passColor;
|
layout(location = 0) out vec3 passColor;
|
||||||
out vec2 passTextureCoord;
|
layout(location = 1) out vec2 passTextureCoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(position, 1.0);
|
gl_Position = vec4(position, 1.0);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB |
Reference in New Issue
Block a user