Reputation: 1032
I read the OpenGL Readbook 8th Editor. But I can't create example from Chapter 3 "Drawing Commands Example". Authors used in the example the own library vmath.h
. But It don't work. They forgot add to library function "vmath::translation(GLfloat, GLfloat, GLfloat);
", although used it. And authors used the own library "vapp.h
", which confuses me. There a lot of macros, by means which defined class. I'm really confused.
I used instead of their library, the "Eigen" library for linear algebra.
Here is my code on GitHub
I compiled and run this program. It work. But I see a black window, but I should to see a four triangles. What Did I do wrong?
P.S. I redid Authors's program, by means of used for matrices and vertices the "Eigen Library". I saw only the black screen. Why?! Here is code on GitHub
I have two shaders:
vertex shader:
#version 400 core
uniform mat4 model_matrix;
uniform mat4 projection_matrix;
layout (location = 0) in vec4 position;
layout (location = 1) in vec4 color;
out vec4 vs_fs_color;
void main(void)
{
vs_fs_color = color;
gl_Position = projection_matrix * (model_matrix * position);
}
And fragment shader:
#version 400 core
in vec4 vs_fs_color;
layout (location = 0) out vec4 color;
void main(void)
{
color = vs_fs_color;
}
I exactly use a these shaders.
Here is what I should see.
This is original project(MSVC++)
This is a include files(including vapp.h
and vapp.h
)
Upvotes: 0
Views: 578
Reputation: 1719
When you're setting up your model_matrix
, the second argument to glUniformMatrix4fv
should be 1, not 4. Also, you are using wrong indices in frustum
. Change result(2, 0)
to result(0, 2)
and do the same for all the other pairs.
Upvotes: 1