3.2 Accessing OpenGL from Hollywood

GL Galore directly wraps all OpenGL commands to Hollywood with little to no changes to their original syntax. After calling @REQUIRE on GL Galore, all GL functions will be made available inside a "gl" table and the GLU functions will be made available inside a "glu" table.

Calling OpenGL functions from Hollywood is much simpler than using OpenGL directly because the argument specification (e.g., '2d', '3f', '4sv') at the end of most OpenGL functions names has been removed. For example, GL Galore's gl.Light() function binds the OpenGL functions: glLightf, glLightfv, glLighti, glLightiv. The number of parameters passed to gl.Light() defines the correct function to use.

GL Galore usually uses the floating point versions of all the OpenGL functions with the highest possible precision. Some functions that have a type parameter simply use the most precise possible (usually #GL_DOUBLE or #GL_FLOAT) and the format parameter is not used. When stride is not used, then it is assumed to be 0.

The color and the vector data can be passed as a Hollywood table or as multiple parameters. A vector can have 2, 3 or 4 values (x, y, z, w), and colors can have 3 or 4 values (red, green, blue, alpha).

For example:

v1 = {0, 0}
v2 = {1, 1}
yellow = {1, 1, 0}

Or you can also do:

gl.Color(1, 1, 0)
gl.Vertex(0, 0)
gl.Vertex(1, 1)

There are some OpenGL commands that expect a pointer. In this case, GL Galore usually offers a variant of the command so that it works with Hollywood tables. However, the original pointer variant is also available in GL Galore and can be used for time-critical scripts. For example, gl.ReadPixels() reads pixel data from the frame buffer into a Hollywood table whereas gl.ReadPixelsRaw() reads pixel data into a memory buffer directly which is much faster of course, but requires you to work with pointers. See Working with pointers for details.

Show TOC