Gestion taille de rendu si modification de la taille de la fenêtre + unbind() à la fin du cycle de rendu du vertexArray
This commit is contained in:
parent
b02119dca7
commit
e2b43446c8
@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package engine;
|
package engine;
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
|
||||||
import org.lwjgl.glfw.GLFWVidMode;
|
import org.lwjgl.glfw.GLFWVidMode;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class Engine {
|
|||||||
this.window = glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL);
|
this.window = glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL);
|
||||||
assert this.window != NULL;
|
assert this.window != NULL;
|
||||||
|
|
||||||
// On récupère les informations du moniteur principale
|
// On récupère les informations du moniteur principal
|
||||||
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||||||
assert vidmode != null;
|
assert vidmode != null;
|
||||||
|
|
||||||
@ -57,6 +58,8 @@ public class Engine {
|
|||||||
glfwShowWindow(this.window);
|
glfwShowWindow(this.window);
|
||||||
GL.createCapabilities();
|
GL.createCapabilities();
|
||||||
|
|
||||||
|
glfwSetFramebufferSizeCallback(window, resizeWindow);
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
System.out.println("OpenGL: " + glGetString(GL_VERSION));
|
System.out.println("OpenGL: " + glGetString(GL_VERSION));
|
||||||
|
|
||||||
@ -96,6 +99,17 @@ public class Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Est appelé à chaque modification de la taille de la fenêtre, et modifie la taille de la zone de rendu
|
||||||
|
pour quelle corresponde à la taille de la fenêtre
|
||||||
|
*/
|
||||||
|
private static GLFWFramebufferSizeCallback resizeWindow = new GLFWFramebufferSizeCallback(){
|
||||||
|
@Override
|
||||||
|
public void invoke(long window, int width, int height){
|
||||||
|
glViewport(0,0,width,height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Engine engine = new Engine();
|
Engine engine = new Engine();
|
||||||
engine.run();
|
engine.run();
|
||||||
|
@ -42,6 +42,7 @@ public class VertexArray {
|
|||||||
public void render(){
|
public void render(){
|
||||||
bind();
|
bind();
|
||||||
draw();
|
draw();
|
||||||
|
unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user