I Am at https://youtu.be/-6P_CkT-FlQ?list=PLILiqflMilIxta2xKk2EftiRHD4nQGW0u&t=1125
This Tutorial Is About VAOs And VBOs In LWJGL
And When I Run It, It Shows This:

I've Tried To Use STBImage in Texture.java I've Also Tried To Use A Diffrent Path in Main.java
Code:
MAIN.JAVA
import com.sun.tools.javac.Main;
import org.lwjgl.glfw.GLFWVidMode;
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;
import org.lwjgl.openvr.Texture;
import static org.lwjgl.glfw.GLFW.*;
public class main {
public static void Main(){
if(!glfwInit()){
throw new IllegalStateException("Can't Init Glfw!");
}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
long window = glfwCreateWindow(640, 480, "Game", 0, 0);
if(window == 0){
throw new IllegalStateException("Failed To Init Window!");
}
GLFWVidMode videomode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window, videomode.width() - 640 /2, videomode.height() - 480 /2);
glfwShowWindow(window);
//-----------------
glfwMakeContextCurrent(window);
GL.createCapabilities();
glEnable(3553);
float[] verticles = new float[]{
-0.5f, 0.5f, 0, //TOP LEFT
0.5f, 0.5f, 0, //top RIGHT
0.5f, -0.5f, 0, //BOTTOM RIGHT
0.5f, -0.5f, 0,
-0.5f, -0.5f, 0,
-0.5f, 0.5f, 0,
};
float[] texture = new float[]{
0,1,
1,1,
1,0,
0,0,
1,0,
0,1
};
model Model = new model(verticles, texture);
texture tex = new texture("rfde.png");
//-----------------
float x = 0;
float y = 0;
while(!glfwWindowShouldClose(window)){
glfwPollEvents();
//-----------
glClear(GL_COLOR_BUFFER_BIT);
tex.bind();
Model.render();
//-----------
glfwSwapBuffers(window);
String error = String.valueOf(glGetError());
System.out.println(error);
}
glfwTerminate();
}
public static void main(String[] args){
Main();
}
}
Texture.java:
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.stb.STBImage;
import org.lwjgl.stb.STBImage.*;
import org.lwjgl.BufferUtils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
public class texture {
private int id;
private int width;
private int height;
public texture(String filename){
IntBuffer width = BufferUtils.createIntBuffer(1);
IntBuffer height = BufferUtils.createIntBuffer(1);
IntBuffer comp = BufferUtils.createIntBuffer(1);
ByteBuffer data = STBImage.stbi_load("./res/" + filename, width, height, comp, 4);
id = glGenTextures();
this.width = width.get();
this.height = height.get();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
STBImage.stbi_image_free(data);
}
public void bind(){
glBindTexture(GL_TEXTURE_2D, id);
}
}
model.java:
import org.lwjgl.BufferUtils;
import java.nio.FloatBuffer;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
public class model {
private int draw_count;
private int v_id;
private int t_id;
public model(float[] vertices, float[] tex_coords){
draw_count = vertices.length / 3;
v_id = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, v_id);
glBufferData(GL_ARRAY_BUFFER, createBuffer(vertices), GL_STATIC_DRAW);
t_id = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, t_id);
glBufferData(GL_ARRAY_BUFFER, createBuffer(tex_coords), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
public void render(){
glEnable(GL_VERTEX_ARRAY);
glEnable(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, v_id);
glVertexPointer(3, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, draw_count);
glBindBuffer(GL_ARRAY_BUFFER, t_id);
glTexCoordPointer(2, GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisable(GL_VERTEX_ARRAY);
glDisable(GL_TEXTURE_COORD_ARRAY);
}
private FloatBuffer createBuffer(float[] data){
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
}