Page 1 of 1

my first opengl 3 tutorial

PostPosted: 26 May 2014, 14:23
by rogerdv
A couple of weeks ago I decided to start learning OpenGL 3 basics, and during the process, create a few tutorials to help others going through the same process. So far I have finished the first, and here is it: https://www.dropbox.com/s/g11tl72ehmwnol7/gl301.zip
The archive contains the code (commented in english and spanish) and a Codeblocks project. My intention was to provide other build files too, but I discarded it because of 2 reasons: first, when I was googling about, source code was more relevant for me than IDE projects. Second, lack of time. I dont have a PC at home, so I have been coding in my office time, which I have to split among writing, learning, design, relax, and of course, work.
I have a couple of ideas for more basic tutorials and I will post here as soon as they are completed.

Re: my first opengl 3 tutorial

PostPosted: 27 May 2014, 16:49
by mdtrooper
I have been trying to compile...but there are some errors:

{l Code}: {l Select All Code}
miguel@miguel-HP-Pavilion-dm4-Notebook-PC /tmp $ g++ main.c
main.c: In function ‘int main(int, char**)’:
main.c:69:5: error: ‘SDL_Window’ was not declared in this scope
main.c:69:17: error: ‘mainwindow’ was not declared in this scope
main.c:70:5: error: ‘SDL_GLContext’ was not declared in this scope
main.c:70:19: error: expected ‘;’ before ‘maincontext’
main.c:87:25: error: ‘SDL_GL_CONTEXT_MAJOR_VERSION’ was not declared in this scope
main.c:88:25: error: ‘SDL_GL_CONTEXT_MINOR_VERSION’ was not declared in this scope
main.c:96:49: error: ‘SDL_WINDOWPOS_CENTERED’ was not declared in this scope
main.c:97:19: error: ‘SDL_WINDOW_OPENGL’ was not declared in this scope
main.c:97:39: error: ‘SDL_WINDOW_SHOWN’ was not declared in this scope
main.c:97:55: error: ‘SDL_CreateWindow’ was not declared in this scope
main.c:104:5: error: ‘maincontext’ was not declared in this scope
main.c:104:50: error: ‘SDL_GL_CreateContext’ was not declared in this scope
main.c:109:29: error: ‘SDL_GL_SetSwapInterval’ was not declared in this scope
main.c:150:32: error: ‘SDL_GL_SwapWindow’ was not declared in this scope
main.c:165:37: error: ‘SDL_GL_DeleteContext’ was not declared in this scope
main.c:166:33: error: ‘SDL_DestroyWindow’ was not declared in this scope

Re: my first opengl 3 tutorial

PostPosted: 27 May 2014, 17:05
by rogerdv
SDL2 is required to create an opengl 3 context. Also, make sure that paths in build options point to the right SDL2 directories.

Re: my first opengl 3 tutorial

PostPosted: 28 May 2014, 00:47
by c_xong
I suggest you use a build system such as CMake, and include that instead of project files for a specific IDE. Users can then generate project files for their own platform/IDE, and the build system can also manage dependencies.

Modern build systems like CMake are very easy to use, no more difficult than writing a Makefile. For example, for your package you might just start with the following CMakeLists.txt:

{l Code}: {l Select All Code}
project(my_first_ogl3_tut)

find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)

add_executable(tut01_thebox main.c)
target_link_libraries(tut01_thebox ${SDL_LIBRARY} ${OPENGL_LIBRARIES})

Re: my first opengl 3 tutorial

PostPosted: 29 May 2014, 09:16
by blue.bear
Thanks for sharing this tutorial. I'm plannig to learn OpenGL 3 basics so thank you for your time.

Re: my first opengl 3 tutorial

PostPosted: 29 May 2014, 12:27
by rogerdv
A tutorial about a cube and indexes is on the work (a bit slowly).