Bishwajit Purkaystha
Bishwajit Purkaystha

Reputation: 2185

Drawing a line with open GL

I am a newbie with OpenGL. I need to draw a line with it. I browsed the web and found this code:

glBegin(GL_LINES);
glVertex2f(.25,0.25);
glVertex2f(.75,.75);
glEnd();

However, I don't see any line. The consoler appears only for some milliseconds. I need a program that will draw a line and at least visible for some moments. Thanks in advance.

Upvotes: 1

Views: 290

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Bevor you can draw something, you first need some canvas to draw upon. That's be a window with a pixel framebuffer; without doing extra effort you don't have such.

So first step is to create a window which you can draw into, that gives you the canvas.

Next you need the actual pens to draw with. That would be a OpenGL context you have to create and connect with the window.

Only after you did that you can actually ask OpenGL to draw some line. If you just call the drawing commands, there's nothing going to happen, because you neither have the canvas to draw to, nor the pen to draw with.

Upvotes: 1

Related Questions