Having originally began learning GLSL shaders using this tutorial
https://www.opengl.org/sdk/docs/tutorials/TyphoonLabs/A lot of what I learnt was out of date.
I am currently reading a more up-to-date book, but noticed it was using a couple of deprecated methods.
I recalled the section named
Deprecation, Core, and Compatibility in the following OpenGL summary I read a few weeks ago.
http://openglbook.com/chapter-0-preface-what-is-opengl.htmlIt talks about how OpenGL historically introduced a deprecation model and several profiles.
After having looked at the origins of OpenGL, and learning GLSL I wanted to learn about the most up to date style.
I want what I'm learning to be future proof and so I can use it for a long time.
My aim is to set the OpenGL profile to "Forward Compatible", so that I will be notified when using deprecated methods from the following book.
https://www.packtpub.com/game-development/opengl-4-shading-language-cookbook-second-editionI decided to use glStart(GL_QUADS) to test what I was attempting was working.
However, even though the JavaDoc mentions this method as deprecated, the program unfortunately still compiles and runs fine.
I followed this video to set the context. Right at the beginning he talks about the context.
https://youtu.be/WvVog06bLEY?t=105Am I missing something?
if ( !glfwInit() )
throw new IllegalStateException("Unable to initialize GLFW");
// Configure GLFW
glfwDefaultWindowHints(); // optional, the current window hints are already the default
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
// Create the window
window = glfwCreateWindow(300, 300, "Hello World!", NULL, NULL);
if ( window == NULL )
throw new RuntimeException("Failed to create the GLFW window");
glfwMakeContextCurrent(window);
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
});
// Get the thread stack and push a new frame
try ( MemoryStack stack = stackPush() ) {
IntBuffer pWidth = stack.mallocInt(1); // int*
IntBuffer pHeight = stack.mallocInt(1); // int*
// Get the window size passed to glfwCreateWindow
glfwGetWindowSize(window, pWidth, pHeight);
// Get the resolution of the primary monitor
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Center the window
glfwSetWindowPos(
window,
(vidmode.width() - pWidth.get(0)) / 2,
(vidmode.height() - pHeight.get(0)) / 2
);
} // the stack frame is popped automatically
// Make the OpenGL context current
glfwMakeContextCurrent(window);
// Enable v-sync
glfwSwapInterval(1);
// Make the window visible
glfwShowWindow(window);
// This line is critical for LWJGL's interoperation with GLFW's
// OpenGL context, or any context that is managed externally.
// LWJGL detects the context that is current in the current thread,
// creates the GLCapabilities instance and makes the OpenGL
// bindings available for use.
GL.createCapabilities();
Thanks for the help
P.s. If anyone knows a newer/better GLSL book than the one I'm currently reading OR
a GLSL book tailored for LWJGL, I'd be extremely greatful.