Why is the sprite not rendering in OpenGL?

喜夏-厌秋 提交于 2019-11-27 16:18:54

You have to initialize the model matrix variable glm::mat4 model.

The glm API documentation refers to The OpenGL Shading Language specification 4.20.

5.4.2 Vector and Matrix Constructors

If there is a single scalar parameter to a vector constructor, it is used to initialize all components of the constructed vector to that scalar’s value. If there is a single scalar parameter to a matrix constructor, it is used to initialize all the components on the matrix’s diagonal, with the remaining components initialized to 0.0.

This means, that an identity matrix can be initialized by the single parameter 1.0:

glm::mat4 model(1.0f);

Further your sprite is very small and it is out of the viewport (clip space) at the left side:

Change your code like this:

glm::vec2 position = glm::vec2(10.0f, 10.0f); // 10.0f instead of -10.0f
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!