Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e3a33d946c | |||
| 3cdabfeb40 | |||
| 0c6ccbbb42 |
Generated
+2
@@ -0,0 +1,2 @@
|
||||
# Default ignored files
|
||||
/workspace.xml
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="lwjgl-release-3.2" level="project" />
|
||||
<orderEntry type="library" name="commons-io-2" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+15
@@ -0,0 +1,15 @@
|
||||
<component name="libraryTable">
|
||||
<library name="commons-io-2">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6/docs" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$USER_HOME$/Downloads/commons-io-2.6" recursive="false" />
|
||||
<jarDirectory url="file://$USER_HOME$/Downloads/commons-io-2.6" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="lwjgl-release-3.2">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom" recursive="false" />
|
||||
<jarDirectory url="file://$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Helium-Engine.iml" filepath="$PROJECT_DIR$/.idea/Helium-Engine.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+124
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
import org.hl.engine.graphics.*;
|
||||
import org.hl.engine.io.Display;
|
||||
import org.hl.engine.io.Input;
|
||||
import org.hl.engine.math.lalg.*;
|
||||
import org.hl.engine.math.lalg.Vector3f;
|
||||
import org.hl.engine.math.lalg.Vector2f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class Mesh {
|
||||
|
||||
private Vertex[] vertices;
|
||||
private int[] indices;
|
||||
private int vertexArrayObject, positionBufferObject, indicesBufferObject, colorBufferObject, textureBufferObject;
|
||||
@@ -22,6 +23,7 @@ public class Mesh {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
|
||||
// Destroy the mesh
|
||||
public void destroy () {
|
||||
GL15.glDeleteBuffers(positionBufferObject);
|
||||
@@ -53,6 +55,7 @@ public class Mesh {
|
||||
return positionBufferObject;
|
||||
}
|
||||
|
||||
|
||||
public int getIndicesBufferObject() {
|
||||
return indicesBufferObject;
|
||||
}
|
||||
@@ -65,6 +68,7 @@ public class Mesh {
|
||||
return textureBufferObject;
|
||||
}
|
||||
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.hl.engine.graphics;
|
||||
|
||||
|
||||
import org.hl.engine.math.lalg.*;
|
||||
|
||||
|
||||
public class Vertex {
|
||||
|
||||
// Just a vertex
|
||||
@@ -10,6 +12,7 @@ public class Vertex {
|
||||
private Vector3f color;
|
||||
private Vector2f textureCoords;
|
||||
|
||||
|
||||
public Vertex (Vector3f position, Vector3f color, Vector2f textureCoords) {
|
||||
this.position = position;
|
||||
this.color = color;
|
||||
@@ -20,6 +23,7 @@ public class Vertex {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
public Vector3f getColor() {
|
||||
return color;
|
||||
}
|
||||
@@ -27,4 +31,5 @@ public class Vertex {
|
||||
public Vector2f getTextureCoords() {
|
||||
return textureCoords;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package org.hl.engine.io;
|
||||
|
||||
import org.hl.engine.math.lalg.Vector3f;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
@@ -9,6 +10,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
|
||||
public class Display {
|
||||
|
||||
private int width, height;
|
||||
private String windowName;
|
||||
private long window;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.hl.engine.math.lalg;
|
||||
|
||||
|
||||
public class Vector3f {
|
||||
private float x;
|
||||
private float y;
|
||||
@@ -42,3 +43,4 @@ public class Vector3f {
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package org.hl.engine.utils;
|
||||
|
||||
// Original TextureLoader by Krythic (replaces SlickUtils texture loader)
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class TextureLoader {
|
||||
private static final int BYTES_PER_PIXEL = 4;//3 for RGB, 4 for RGBA
|
||||
public static int loadTexture(BufferedImage image){
|
||||
|
||||
int[] pixels = new int[image.getWidth() * image.getHeight()];
|
||||
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
|
||||
|
||||
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_PIXEL); //4 for RGBA, 3 for RGB
|
||||
|
||||
for(int y = 0; y < image.getHeight(); y++){
|
||||
for(int x = 0; x < image.getWidth(); x++){
|
||||
int pixel = pixels[y * image.getWidth() + x];
|
||||
buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component
|
||||
buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component
|
||||
buffer.put((byte) (pixel & 0xFF)); // Blue component
|
||||
buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. Only for RGBA
|
||||
}
|
||||
}
|
||||
|
||||
buffer.flip(); //FOR THE LOVE OF GOD DO NOT FORGET THIS
|
||||
|
||||
// You now have a ByteBuffer filled with the color data of each pixel.
|
||||
// Now just create a texture ID and bind it. Then you can load it using
|
||||
// whatever OpenGL method you want, for example:
|
||||
|
||||
int textureID = glGenTextures(); //Generate texture ID
|
||||
glBindTexture(GL_TEXTURE_2D, textureID); //Bind texture ID
|
||||
|
||||
//Setup wrap mode
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
|
||||
//Setup texture scaling filtering
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
//Send texel data to OpenGL
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
//Return the texture ID so we can bind it later again
|
||||
return textureID;
|
||||
}
|
||||
|
||||
public static BufferedImage loadImage(String loc)
|
||||
{
|
||||
try {
|
||||
return ImageIO.read(TextureLoader.class.getResource(loc));
|
||||
} catch (IOException e) {
|
||||
//Error Handling Here
|
||||
System.err.println("Error with loading texture. ");
|
||||
System.exit(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#version 410 core
|
||||
|
||||
|
||||
|
||||
layout(location = 0) in vec3 passColor;
|
||||
layout(location = 1) in vec2 passTextureCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main() {
|
||||
outColor = texture(tex, passTextureCoord);
|
||||
outColor = vec4(passColor, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
#version 410 core
|
||||
|
||||
|
||||
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 1) in vec3 color;
|
||||
layout(location = 2) in vec2 textureCoord;
|
||||
|
||||
|
||||
|
||||
|
||||
layout(location = 0) out vec3 passColor;
|
||||
layout(location = 1) out vec2 passTextureCoord;
|
||||
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 1.0);
|
||||
passColor = color;
|
||||
|
||||
passTextureCoord = textureCoord;
|
||||
}
|
||||
Reference in New Issue
Block a user