本文整理汇总了C++中Viewport::eyedist方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::eyedist方法的具体用法?C++ Viewport::eyedist怎么用?C++ Viewport::eyedist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::eyedist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(shader);
// Enable light sources.
glEnable(GL_LIGHTING);
if (lights_enabled[0])
{
// Abuse GL_SPOT_CUTOFF as a switch to toggle the light.
glEnable(GL_LIGHT0);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 1.0f);
glLightfv(GL_LIGHT0, GL_POSITION, lights[0]);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lights_diffuse[0]);
glLightfv(GL_LIGHT0, GL_SPECULAR, lights_specular[0]);
}
else
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 0.0f);
if (lights_enabled[1])
{
glEnable(GL_LIGHT1);
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 1.0f);
glLightfv(GL_LIGHT1, GL_POSITION, lights[1]);
glLightfv(GL_LIGHT1, GL_DIFFUSE, lights_diffuse[1]);
glLightfv(GL_LIGHT1, GL_SPECULAR, lights_specular[1]);
}
else
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 0.0f);
// Copy the orientation matrix to a float array. That's needed so we
// can pass it to the shaders.
float oriMatrix[16];
Mat4 T = win.orientationMatrix();
for (int i = 0; i < 16; i++)
oriMatrix[i] = T[i];
// Same for position of the camera.
float fpos[3];
fpos[0] = win.pos().x();
fpos[1] = win.pos().y();
fpos[2] = win.pos().z();
glUniformMatrix4fv(handle_rot, 1, true, oriMatrix);
glUniform3fv(handle_pos, 1, fpos);
glUniform1f(handle_eyedist, win.eyedist());
glUniform1f(handle_stepsize, raymarching_stepsize);
glUniform1f(handle_accuracy, raymarching_accuracy);
glUniform4fv(handle_user_params0, 1, user_params[0]);
glUniform4fv(handle_user_params1, 1, user_params[1]);
// Draw one quad so that we get one fragment covering the whole
// screen.
double r = win.ratio();
glBegin(GL_QUADS);
glVertex3f(-r, -1, 0);
glVertex3f( r, -1, 0);
glVertex3f( r, 1, 0);
glVertex3f(-r, 1, 0);
glEnd();
// Draw coordinate system?
if (drawCS)
{
glUseProgram(0);
glDisable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glPushMatrix();
glLineWidth(3.0);
// In y direction, move to -0.75.
// In x direction, move to 0.75. From that point on, add the
// difference of width and height in world coordinates. This
// will keep the (drawn) coordinate system at a position with a
// fixed margin to the window borders.
glTranslated(0.75 + (win.w() - win.h()) / (double)win.h(),
-0.75, 0);
glScaled(0.2, 0.2, 0.2);
glMultMatrixf(oriMatrix);
glBegin(GL_LINES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(0, 0, 0);
glVertex3f(0, 1, 0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
glEnd();
glPopMatrix();
glDisable(GL_DEPTH_TEST);
//.........这里部分代码省略.........