# Matrixes and coordinates

This topic is 2251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all.

I have a quad with texture. Set viewport and matrixes:
[source lang="python"]glViewport(0, 0, self._size[0], self._size[1])
glMatrixMode(GL_PROJECTION)
glOrtho(0, self._size[0], self._size[1], 0, -1, 1)

glMatrixMode(GL_MODELVIEW)

Vertex and texture coordinates:
[source lang="python"]
coordarr = [[0, self._size[1], 0, 0, 0, 0],
[self._size[0], self._size[1], 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[self._size[0], 0, 0, 1, 1, 0]]
[/source]

There is some scaling in shader, so quad doesn't change shapes when window is resizing.
[source lang="python"]gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex
* vec4(image_width/viewport_width, image_height/viewport_height, 1, 1)
[/source]

I try to draw some markup on the quad, for example crosses made from GL_LINES. Their positions compute from real image coordinates
[source lang="python"]markup_x = (real_x / self._image.shape[1]) * self._size[0]
markup_y = (real_y / self._image.shape[0]) * self._size[1]
[/source]
I set the same matrixes and coordinates to shader that draws markup, apply the same scaling. But crosses display incorrect, their shapes depend on viewport size, so they stretch and shrink.

But if I set glOrtho(-1, 1, 1, -1, -1, 1) everywhere and coordinates:
[source lang="python"] coordarr = [[-1, 1, 0, 0, 0, 0],
[ 1, 1, 0, 1, 0, 0],
[-1, -1, 0, 0, 1, 0],
[ 1, -1, 0, 1, 1, 0]][/source]
Also some changes in crosses coordinates computation
[source lang="python"] markup_x = (real_x / float(self._image.shape[1])) * 2 - 1
markup_y = (real_y / float(self._image.shape[0])) * 2 - 1[/source]

... and shaders code leave the same, markup displays correct. I guess that problem in matrixes, but cannot find it. What I'm doing wrong?

Thanks a lot.

##### Share on other sites
Please state what the problem is.

##### Share on other sites
I need to display markup (crosses) correctly. Currently their shapes depend on viewport size, so they stretch and shrink. Edited by AlexBlack

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 24
• 9
• 57
• ### Forum Statistics

• Total Topics
632639
• Total Posts
3007612
• ### Who's Online (See full list)

There are no registered users currently online

×