📄 opengl.cc
字号:
//
// opengl.cc
//
// $Id: opengl.cc,v 1.1.1.1 2001/02/28 00:28:37 cstolte Exp $
//
#include <sgl/tuples.h>
#include <sgl/transform3.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <GL/gl.h>
void
Tuple2f::glVertex() const
{
glVertex2f(u, v);
}
void
Tuple2d::glVertex() const
{
glVertex2d(u, v);
}
void
Tuple3f::glVertex() const
{
glVertex3f(x, y, z);
}
void
Tuple3f::glNormal() const
{
glNormal3f(x, y, z);
}
void
Tuple3d::glVertex() const
{
glVertex3d(x, y, z);
}
void
Tuple3d::glNormal() const
{
glNormal3d(x, y, z);
}
void
Matrix3::glLoadMatrix() const
{
float mat[16];
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
mat[4*i + j] = T[j][i];
mat[12] = mat[13] = mat[14] = mat[3] = mat[7] = mat[11] = 0;
mat[15] = 1;
glLoadMatrixf(mat);
}
void
Matrix3::glMultMatrix() const
{
float mat[16];
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
mat[4*i + j] = T[j][i];
mat[12] = mat[13] = mat[14] = mat[3] = mat[7] = mat[11] = 0;
mat[3] = mat[7] = mat[11] = 0;
mat[15] = 1;
glMultMatrixf(mat);
}
void
Transform3::glLoadMatrix() const
{
float mat[16];
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
mat[4*i + j] = T[j][i];
mat[12] = translation.x;
mat[13] = translation.y;
mat[14] = translation.z;
mat[3] = mat[7] = mat[11] = 0;
mat[15] = 1;
glLoadMatrixf(mat);
}
void
Transform3::glMultMatrix() const
{
float mat[16];
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
mat[4*i + j] = T[j][i];
mat[12] = translation.x;
mat[13] = translation.y;
mat[14] = translation.z;
mat[3] = mat[7] = mat[11] = 0;
mat[15] = 1;
glMultMatrixf(mat);
}
void
Projection3::glLoadMatrix() const
{
float mat[16];
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
mat[4*i + j] = T[j][i];
glLoadMatrixf(mat);
}
void
Projection3::glMultMatrix() const
{
float mat[16];
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
mat[4*i + j] = T[j][i];
glMultMatrixf(mat);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -