It was quite exhausting to toil since the past two months trying to install Code::Blocks and getting GLFW,
GLEW and
GLM
to run in it.
I followed this
link to get them installed.
For the shader code I referred to this site:
Open.gl
Also referred to this amazing
Site also. I have coded this project so shabbily that I have not kept track of how many external libraries I have included. There is
Linmath, there is
GLAD and
SFML and a few others were included without any real necessity.
I hope they will become useful as I go along.
Drawing a Triangle
The drawing part has been explained very well in the sites I mentioned. We need to make use of VertexArrayObjects(VAOs) and VertexBufferObjects(VBOs).
In modern OpenGL we need to include short programs called shader programs and get them
created, compiled, linked and then
attach them to a program, then
link the program with our main project.
Finally call glDrawArrays which does the
drawing of the VBOs.
The Book of Shaders
This site which you can google is what I am following and will keep posting the solutions of the amazing pictures I generate.
For the present I am simply sharing the code
here.
Snapshot:
When you move your mouse around the screen the color of the triangle changes. This change is brought about by the following fragment shader code.
static const char* fragment_shader_text =
"varying vec3 color;\n"
"uniform float u_time;\n"
"uniform vec2 u_resolution;\n"
"uniform vec2 u_mouse;\n"
"void main() {\n"
"
gl_FragColor = vec4(
u_mouse.x/u_resolution.x,u_mouse.y/u_resolution.y,0.0,1.0);\n"
"}\n";
Thanks for following till this point.
Will try and keep you all abreast of any further project.