How do I scale lines when using GLOrtho?

I am using GLOrtho to create a 2D view that I can map textures to. It works pretty well until I try to enlarge the image. If I go through half the width and half the height of the viewport in GLOrtho, I get all my textures rendered twice as large as usual, which is exactly what I expect.

But then I try to draw a rectangle around part of the image and it all falls apart. I call glBegin(GL_LINE_LOOP)

, place four vertices and call glEnd and I expect to see the same as I would if I draw it at a normal zoom level, doubled. Instead, I get lines that are the correct length, but they all end up one pixel, not two, and it looks really bad.

What am I missing?

+2


a source to share


2 answers


Well, you can either scale it yourself using glLineWidth, or you can emulate the line as two triangles.



+3


a source


glScale would be a better solution for scaling instead of changing glOrtho parameters. This way, whatever is drawn will scale as expected.



-1


a source







All Articles