Im looking for OpenGL 4.X (2D) tutorials.
Please let me know if you know some good ones
Looking for OpenGL 4.X (2D) Tutorials!
Re: Looking for OpenGL 4.X (2D) Tutorials!
Most of the tutorials i found use GLFW https://www.glfw.org which looks really good.
So i made an PureBasic include for the current version 3.3 (no pain no gain)
I first tried to use the static lib but i was not able to remove all linker errors.
What i did to get rid of most of the errors (if someone wants to look into this):
Linking 'legacy_stdio_definitions.lib' did not fix it for me (this was the only solution i found online).
Anways i can use the dll version without issues
Now can try some of the GLFW tutorials
So i made an PureBasic include for the current version 3.3 (no pain no gain)
I first tried to use the static lib but i was not able to remove all linker errors.
What i did to get rid of most of the errors (if someone wants to look into this):
Code: Select all
Import "User32.lib":EndImport
Import "ntdll.lib":EndImport
Import "BufferOverflow.lib":EndImport
Import "BufferOverflowU.lib":EndImport
Import "libcmt.lib":EndImport
;-> POLINK: error Unresolved external symbol '__imp_vsnprintf'
Anways i can use the dll version without issues
Now can try some of the GLFW tutorials
Re: Looking for OpenGL 4.X (2D) Tutorials!
Found a good site that uses GLFW: https://learnopengl.com
I completed the 1st Tutorial
How it looks in PureBasic:
I completed the 1st Tutorial
How it looks in PureBasic:
Code: Select all
EnableExplicit
;https://learnopengl.com/Getting-started/Hello-Triangle
XIncludeFile "glfw3.pbi"
Global *window.GLFWwindow
Global vertex_shader.i
Global vertex_shader_string.s
Global *vertex_shader_source
Global vertex_shader_status.i
Global fragment_shader.i
Global fragment_shader_string.s
Global *fragment_shader_source
Global fragment_shader_status.i
Global shader_program.i
Global shader_program_status.i
Global Dim vertices.f(9)
Global vbo.i
Global vao.i
Procedure.i FrameBufferCallback(*window,width.i,height.i)
glViewport_(0,0,width,height)
EndProcedure
If glfwVersionCheck()
If glfwInit() = #GLFW_TRUE
glfwWindowHint(#GLFW_SAMPLES, 4)
glfwWindowHint(#GLFW_CONTEXT_VERSION_MAJOR,4);<- window setup for opengl 4.X this alone will take ~ 200 lines of code when done manually!
glfwWindowHint(#GLFW_CONTEXT_VERSION_MINOR,0)
glfwWindowHint(#GLFW_OPENGL_PROFILE,#GLFW_OPENGL_CORE_PROFILE);
*window = glfwCreateWindow(800,600,"Test",#Null,#Null)
If *window
glfwSetWindowSizeLimits(*window,800,600,#GLFW_DONT_CARE,#GLFW_DONT_CARE)
glfwMakeContextCurrent(*window)
If glfwLoadOpenGL();<- load all opengl (4.X) functions!
glfwSetFramebufferSizeCallback(*window,@FrameBufferCallback())
glfwSwapInterval(1)
glfwSetInputMode(*window,#GLFW_STICKY_KEYS,#GLFW_TRUE)
vertex_shader_string = "#version 330 core" + #CRLF$
vertex_shader_string + "layout (location = 0) in vec3 aPos;"+ #CRLF$
vertex_shader_string + "void main()"+ #CRLF$
vertex_shader_string + "{"+ #CRLF$
vertex_shader_string + " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);"+ #CRLF$
vertex_shader_string + "}"
*vertex_shader_source = Ascii(vertex_shader_string)
vertex_shader = *glCreateShader(#GL_VERTEX_SHADER)
*glShaderSource(vertex_shader,1,@*vertex_shader_source,0)
*glCompileShader(vertex_shader)
*glGetShaderiv(vertex_shader,#GL_COMPILE_STATUS,@vertex_shader_status);<- error handling!
fragment_shader_string = "#version 330 core" + #CRLF$
fragment_shader_string + "out vec4 FragColor;" + #CRLF$
fragment_shader_string + "void main()" + #CRLF$
fragment_shader_string + "{" + #CRLF$
fragment_shader_string + " FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);" + #CRLF$
fragment_shader_string + "}" + #CRLF$
*fragment_shader_source = Ascii(fragment_shader_string)
fragment_shader = *glCreateShader(#GL_FRAGMENT_SHADER)
*glShaderSource(fragment_shader,1,@*fragment_shader_source,0)
*glCompileShader(fragment_shader)
*glGetShaderiv(fragment_shader,#GL_COMPILE_STATUS,@fragment_shader_status);<- error handling!
Debug vertex_shader_status
Debug fragment_shader_status
shader_program = *glCreateProgram()
*glAttachShader(shader_program,vertex_shader)
*glAttachShader(shader_program,fragment_shader)
*glLinkProgram(shader_program)
*glGetProgramiv(shader_program,#GL_LINK_STATUS,@shader_program_status);<- error handling!
Debug shader_program_status
*glDeleteShader(vertex_shader)
*glDeleteShader(fragment_shader)
FreeMemory(*vertex_shader_source)
FreeMemory(*fragment_shader_source)
vertices(0) = -0.5
vertices(1) = -0.5
vertices(2) = 0
vertices(3) = 0.5
vertices(4) = -0.5
vertices(5) = 0
vertices(6) = 0
vertices(7) = 0.5
vertices(8) = 0
*glGenVertexArrays(1,@vao)
*glGenBuffers(1,@vbo)
*glBindVertexArray(vao)
*glBindBuffer(#GL_ARRAY_BUFFER,vbo)
*glBufferData(#GL_ARRAY_BUFFER,9 * 4,vertices(),#GL_STATIC_DRAW)
*glVertexAttribPointer(0,3,#GL_FLOAT,#GL_FALSE,3 * 4,#Null)
*glEnableVertexAttribArray(0)
*glBindBuffer(#GL_ARRAY_BUFFER,0)
*glBindVertexArray(0)
*glClearColor(0.2,0.3,0.3,0)
Repeat
*glClear(#GL_COLOR_BUFFER_BIT)
*glUseProgram(shader_program)
*glBindVertexArray(vao)
*glDrawArrays(#GL_TRIANGLES,0,3)
glfwSwapBuffers(*window)
glfwPollEvents()
Until glfwGetKey(*window,#GLFW_KEY_ESCAPE) = #GLFW_PRESS Or glfwWindowShouldClose(*window)
EndIf
glfwDestroyWindow(*window)
EndIf
glfwTerminate()
EndIf
EndIf
Re: Looking for OpenGL 4.X (2D) Tutorials!
Thanks for the exemple but where can i find glfw3.pbi
Re: Looking for OpenGL 4.X (2D) Tutorials!
viewtopic.php?f=12&t=73073ultimzeus wrote:Thanks for the exemple but where can i find glfw3.pbi
@Mijikai: I've got an error: glfwVersionCheck() is not a function..
"Daddy, I'll run faster, then it is not so far..."
Re: Looking for OpenGL 4.X (2D) Tutorials!
I added some helper functions myself glfwLoadOpenGL() for example is also not a function in GLFW.dige wrote:viewtopic.php?f=12&t=73073ultimzeus wrote:Thanks for the exemple but where can i find glfw3.pbi
@Mijikai: I've got an error: glfwVersionCheck() is not a function..