jackweb
jackweb

Reputation: 307

OpenGL - drawing GUI

I use glm::perspective(80.0f, 4.0f/3.0f, 1.0f, 120.0f); and multiply it by

glm::mat4 view = glm::lookAt(
    glm::vec3(0.0f, 0.0f, 60.5f),
    glm::vec3(0.0f, 0.0f, 0.0f),
    glm::vec3(0.0f, 1.0f, 0.0f)
);

My question touches the subject of OpenGL and Maths. It relates to drawing GUI on my viewport. I do not know how to get proper coordinates in order to draw, e.g. a square that covers ¼ of the window. If I don't use perspectives and glm::lookAt(...) (matrix indentity), I will be able to draw my GUI by setting coords from X,Y in <-1.0, 1.0>. And when I put a vertex on (-1.0, -1.0), it will be localized at the bottom left corner of the window.

How to gain the same effect using perspective and lookAt?

Upvotes: 2

Views: 897

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Don't try to fiddle things into one certain projection. Just switch your projection to something that better suits your GUI drawing needs. OpenGL is a state machine, and it's perfectly normal to switch the parameters multiple times throughout rendering a single image.

Upvotes: 3

Related Questions