在OpenGL中,我可以得出一个像素的准确坐标(5,5)? [英] In OpenGL, can I draw a pixel that exactly at the coordinates (5, 5)?

查看:179
本文介绍了在OpenGL中,我可以得出一个像素的准确坐标(5,5)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过(5,5)我的意思是完全相同的第五行和第五列的

By (5, 5) I mean exactly the fifth row and fifth column.

我觉得很难用屏幕坐标绘制的东西,所有的OpenGL的坐标是相对的,通常从-1.0到1.0。为什么它是使用屏幕坐标如此严重到prevent程序员/窗口坐标?

I found it very hard to draw things using screen coordinates, all the coordinates in OpenGL is relative, and usually ranging from -1.0 to 1.0. Why it is so serious to prevent programmers from using screen coordinates / window coordinates?

推荐答案

我也有点3D编程几年回来,虽然我从专家很远,我觉得你可以俯瞰经典点阵之间一个非常重要的区别 DrawPixel(X,Y)图形和Direct3D和OpenGL图形做的类型。

I did a bit of 3D programming several years back and, while I'm far from an expert, I think you are overlooking a very important difference between classical bitmapped DrawPixel(x, y) graphics and the type of graphics done with Direct3D and OpenGL.

回到3D前的日子里,计算机图形主要是关于位图,这是说彩色点的集合。这些点有一个1:您的显示器上的像素1的关系。

Back in the days before 3D, computer graphics was mostly about bitmaps, which is to say collections of colored dots. These dots had a 1:1 relationship with the pixels on your monitor.

然而,有许多缺点,包括制作3D非常困难的,需要不同大小不同的显示分辨率的位图。

However, that had numerous drawbacks, including making 3D very difficult and requiring bitmaps of different sizes for different display resolutions.

在OpenGL / D3D,你是在处理矢量图形。线被分在一个三维坐标空间中定义,形状由线等限定。表面可以具有纹理,灯光可以加入,如可以各种类型的照明效果等,这整个场景,或它的一部分,然后可通过虚拟摄像机观看。

In OpenGL/D3D, you are dealing with vector graphics. Lines are defined by points in a 3-dimensional coordinate space, shapes are defined by lines and so on. Surfaces can have textures, lights can be added, as can various types of lighting effects etc. This entire scene, or a part of it, can then be viewed through a virtual camera.

您有什么'看',虽然这个虚拟相机的场景投影到二维表面。我们仍然在处理矢量图形在这一点上。然而,因为计算机显示器由离散的象素,这个矢量图像具有被光栅化,其将所述向量与实际像素的位图。

What you 'see' though this virtual camera is a projection of the scene onto a 2D surface. We're still dealing with vector graphics at this point. However, since computer displays consist of discrete pixels, this vector image has to be rasterized, which transforms the vector into a bitmap with actual pixels.

要总结,不能使用屏幕/窗口坐标因为OpenGL是基于矢量图形。

To summarize, you can't use screen/window coordinates because OpenGL is based on vector graphics.

这篇关于在OpenGL中,我可以得出一个像素的准确坐标(5,5)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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