如何在OpenGl中画线? [英] How to draw line in OpenGl?

查看:77
本文介绍了如何在OpenGl中画线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在opengl中画一条线.

I want to draw a line in opengl.

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

此代码画线,但是如果我想从坐标(10,10)到坐标(20,20)画一条线,我该怎么办?

this code draw line but if i want to draw a line from coordinate(10,10) to coordinate(20,20) what will i do ?

(.25,.25)和(.75,.75)是什么意思?

what it means (.25,.25) and (.75, .75) ?

推荐答案

(.25,.25)和(.75,.75)是线的起点和终点.

(.25, .25) and (.75,.75) are line's start and end point.

要从(10,10)到(20,20)画一条线:

To draw a line from (10,10) to (20,20):

glBegin(GL_LINES);
    glVertex2f(10, 10);
    glVertex2f(20, 20);
glEnd();

这篇关于如何在OpenGl中画线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆