Opengl中的gluProject函数认识

1. 从官方说明如下  https://www.opengl.org/sdk/docs/man2/xhtml/gluProject.xml  Name      gluProject   — map object coordinates to window coordinatesC,匹配“物体坐标系”“Win窗口坐标系(坐标原点在左下方)”  Specification ...
摘要由CSDN通过智能技术生成

 

1. 从官方说明如下

  https://www.opengl.org/sdk/docs/man2/xhtml/gluProject.xml

  Name  

    gluProject   — map object coordinates to window coordinatesC,匹配“物体坐标系”“Win窗口坐标系(坐标原点在左下方)”

  Specification

    GLint  gluProject(GLdouble objX,  GLdouble objY,  GLdouble objZ,  const GLdouble * model,  const GLdouble * proj,  const GLint * view,  GLdouble* winX,  GLdouble* winY,  GLdouble* winZ);

  Parameters  

    objX, objY, objZ
                    Specify the object coordinates.
                model
                    Specifies the current modelview matrix (as from a glGetDoublev call).
                proj
                    Specifies the current projection matrix (as from a glGetDoublev call).
                view
                    Specifies the current viewport (as from a glGetIntegerv call).
                winX, winY, winZ
                    Return the computed window coordinates.

  Description
            gluProject transforms the specified object coordinates into window coordinates using model, proj, and view. The result is stored in winX, winY, and winZ. A return value of GLU_TRUE indicates success, a return value of GLU_FALSE indicates failure.

2. 使用介绍

  把空间中的一个三维坐标转换成二维坐标,用这个gluProject函数

3. 原码分析

  原码的写法很好 nice, 先通过看代码,来一步一步分析它的数学原理吧!既学习代码,同时也要掌握数学原理, 在这里才是成长的关键所在!

static void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
{
#define M(row,col) m[col*4+row]
    out[0] = M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
    out[1] = M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值