Opengl Intro - glViewport

来源:互联网 发布:西门大妈知乎 编辑:程序博客网 时间:2024/05/18 08:40




glViewport function

The glViewport function sets the viewport.

Syntax

C++
Copy
void WINAPI glViewport(   GLint   x,   GLint   y,   GLsizei width,   GLsizei height);

Parameters

x

The lower-left corner of the viewport rectangle, in pixels. The default is (0,0).

y

The lower-left corner of the viewport rectangle, in pixels. The default is (0,0).

width

The width of the viewport. When an OpenGL context is first attached to a window,width and height are set to the dimensions of that window.

height

The height of the viewport. When an OpenGL context is first attached to a window,width and height are set to the dimensions of that window.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_VALUE

Either width or height was negative.

GL_INVALID_OPERATION

The function was called between a call to glBegin and the corresponding call to glEnd.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_VALUE

Either width or height was negative.

GL_INVALID_OPERATION

The function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

The glViewport function specifies the affine transformation ofx and y from normalized device coordinates to window coordinates. Let (xnd , ynd ) be normalized device coordinates. The window coordinates (xw , yw ) are then computed as follows:


(Xw - x) / width = (Xnd - (-1)) / 2 =>

(Yw - y) / height / (Ynd - (-1)) / 2 =>


Dd374202.view01(en-us,VS.85).png



Viewport width and height are silently clamped to a range that depends on the implementation. This range is queried by callingglGet with argument GL_MAX_VIEWPORT_DIMS.

The following functions retrieve information related to glViewport:

glGet with argument GL_VIEWPORT

glGet with argument GL_MAX_VIEWPORT_DIMS

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Gl.h

Library

Opengl32.lib

DLL

Opengl32.dll

0 0
原创粉丝点击