0% found this document useful (0 votes)
51 views

Opengl - Control Functions

1) OpenGL control functions allow interaction with windows in a multiwindow environment and setting window properties like position, size, and title. 2) Functions like glutInit(), glutInitDisplayMode(), glutWindowSize(), glutWindowPosition(), and glutCreateWindow() initialize the system and create an OpenGL window with the specified properties. 3) Aspect ratios need to match between the viewing area and window to avoid distortions. The glViewport() function adjusts the viewport size within the window.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Opengl - Control Functions

1) OpenGL control functions allow interaction with windows in a multiwindow environment and setting window properties like position, size, and title. 2) Functions like glutInit(), glutInitDisplayMode(), glutWindowSize(), glutWindowPosition(), and glutCreateWindow() initialize the system and create an OpenGL window with the specified properties. 3) Aspect ratios need to match between the viewing area and window to avoid distortions. The glViewport() function adjusts the viewport size within the window.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

OPENGL - CONTROL FUNCTIONS

2.7 Control Functions (interaction with windows)

Window – A rectangular area of our display.

Modern systems allow many windows to be displayed on the screen (multiwindow


environment).

The position of the window is with reference to the origin. The origin (0,0) is the top
left corner of the screen.
glutInit allows application to get command line arguments and initializes system

gluInitDisplayMode requests properties for the window (the rendering context)


o RGB color
o Single buffering
o Properties logically ORed together

glutWindowSize in pixels
glutWindowPosition from top-left corner of display
glutCreateWindow create window with a particular title

Aspect ratio and viewports

Aspect ratio is the ratio of width to height of a particular object.

We may obtain undesirable output if the aspect ratio of the viewing rectangle
(specified by glOrtho), is not same as the aspect ratio of the window (specified by
glutInitWindowSize)

Viewport – A rectangular area of the display window, whose height and width can be
adjusted to match that of the clipping window, to avoid distortion of the images.
void glViewport(Glint x, Glint y, GLsizei w, GLsizei h) ;
The main, display and myinit functions
In our application, once the primitive is rendered onto the display and the application
program ends, the window may disappear from the display.
Event processing loop :

void glutMainLoop();

Graphics is sent to the screen through a function called display callback.

void glutDisplayFunc(function name)


The function myinit() is used to set the OpenGL state variables dealing with viewing and
attributes.

Control Functions

glutInit(int *argc, char **argv) initializes GLUT and processes any command line
arguments (for X, this would be options like -display and -geometry). glutInit() should be
called before any other GLUT routine.

glutInitDisplayMode(unsigned int mode) specifies whether to use an RGBA or color-


index color model. You can also specify whether you want a single- or double-buffered
window. (If you’re working in color-index mode, you’ll want to load certain colors into
the color map; use glutSetColor() to do this.)
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH).

If you want a window with double buffering, the RGBA color model, and a depth buffer,
you might call
glutInitWindowPosition(int x, int y) specifies the screen location for the upper-left
corner of your window
glutInitWindowSize(int width, int size) specifies the size, in pixels, of your window.

int glutCreateWindow(char *string) creates a window with an OpenGL context. It


returns a unique identifier for the new window. Be warned: Until glutMainLoop() is
called.

Source : http://elearningatria.files.wordpress.com/2013/10/cse-vi-computer-graphics-and-
visualization-10cs65-notes.pdf

You might also like