Skip to content
scriptum edited this page Mar 22, 2013 · 6 revisions

Classes

Image

cheetah.newImage (constructor)

Image cheetah.newImage(
	string filename,
	string options = ''
)

Create new Image from file. Reads file from disk by path specified in filename. If You may pass some options to this function. Image loader supports these image formats:

  • PNG (24-bit or 32-bit only, indexed colors are not supported) - slow and pretty
  • Jpeg (only non-progressive!) - good for photos but may produce artifacts
  • BMP - slow and disk space hungry
  • DDS (DXT1 or DXT3) - fastest loading and rendering on most desktop GPUs

Parameters

  • path to file
  • string of options. This is depends on image loading module you use. Supported options:
  • nearest - use nearest interpolation instead of default linear interpolation
  • mipmap - generate mip-maps (automatically sets mip-map interpolation)
  • instant - load instantly without delayed resource loader
  • clamp - force texture clamp (default is repeat)

See also: cheetah.generate, cheetah.newBorderImage

cheetah.generate (constructor)

Image cheetah.generate(
	string type,
	number width,
	number height,
	string options = ''
)

Procedural generation of Image. Engine generates procedural texture specified in type and loads it as Image object. Fast and simple way to create simple demosntrations and effects withount using even external files.

Parameters

  • type of procedural contet. Following types are supported:
  • dummy - just white rectangle
  • noise - random pixels - often used as noise pattern for shaders
  • light - create light
  • lightexp - create smooth gaussian light
  • circle - generates ugly aliased circle
  • width of Image
  • height of generated Image
  • string of generator's options. Supported options:
  • alpha - generate 32-bit image with alpha channel instead of making 24-bit RGB image
  • nearest - use nearest interpolation instead of linear interpolation which is by default
  • clamp - enable texture clamp (default is repeat)

See also: cheetah.newImage, cheetah.newBorderImage

Image:draw

Image:draw(
	number x = 0,
	number y = 0,
	number width = Image:getWidth(),
	number height = Image:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw Image on screen with transformations.

Parameters

  • x position
  • y position
  • width of object
  • height of object
  • angle (radians)
  • origin x
  • origin y

Image:drawq

Image:drawq(
	number x = 0,
	number y = 0,
	number width = Image:getWidth(),
	number height = Image:getHeight(),
	quad_x = 0,
	quad_y = 0,
	quad_wigth = Image:getWidth(),
	quad_height = Image:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw part of Image on screen with transformations. Quads are useful for drawing or only part of image or drawing repeating patterns. Image will be clamped according to quad metrics and then it works as Image:draw() method.

Parameters

  • x position
  • y position
  • quad x position
  • quad y position
  • quad width
  • quad height
  • angle (radians)
  • origin x
  • origin y

Image:getWidth

number Image:getWidth()

Get width of Image.

Image:getHeight

number Image:getHeight()

Get height of Image.

Atlas

Atlas:draw

Atlas:draw(
	number x = 0,
	number y = 0,
	number width = Atlas:getWidth(),
	number height = Atlas:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw Atlas on screen with transformations.

Parameters

  • x position
  • y position
  • width of object
  • height of object
  • angle (radians)
  • origin x
  • origin y

Atlas:getWidth

number Atlas:getWidth()

Get width of Atlas.

Font

cheetah.newFont (constructor)

cheetah.newFont(
	string filename,
	bool scalable = true
)

Create new Font, this function reads font file generated by UBFG (Ultimate Bitmap Font Generator). Font files of UBFG have .fnt extension. One .fnt file may contains several fonts (different sizes, garnitures), all fonts objects placed into cheetah.fonts[NAME][SIZE].

Parameters

  • font file name
  • is font scalable (if true, uses linear interpolation, nearest otherwise)

Font:getHeight

Font Font:getHeight()

Get height of Font in pixels, takes into account screen scale. Usually this is full height of font.

Font:getScale

number Font:getScale()

Get scale of Font.

See also: cheetah.setScale

Font:setScale

Font:setScale(number scale)

Set scale of Font in pixels.

Parameters

See also: cheetah.getScale

Font:setInterval

Font:setInterval(number interval)

Set interval of Font in pixels (interval between lines). Default interval is 0 (standart interval between lines), you may increase or decrease it by using positive or negative values of interval.

Parameters

  • interval

See also: cheetah.getInterval

Font:getInterval

number Font:getInterval()

Get interval of Font in pixels (interval between lines).

See also: cheetah.setInterval

Font:print

Font:print(
	string text = 'undefined',
	number x = 0,
	number y = 0,
	number width = 0,
	Align align = cheetah.alignLeft
)

Print text using Font with alignment. This function akes into account scaling factor, if font scalable x and y coordinates are floating-point, otherwise x and y are decimal to fit screen pixel grid.

Parameters

  • text string, if string is bigger than width - word-wrapping will be enabled
  • x coordinate
  • y coordinate
  • width of text, 0 means infinite width
  • alignment of text, possible values are: cheeath.alignLeft cheeath.alignRight cheeath.alignCenter cheeath.alignJustify

Shader

cheetah.newShader (constructor)

Shader cheetah.newShader(
	string fragment,
	string vertex = ''
)

Create new Shader. Shader is used to produce beatiful pixel effects: lighting, bump-mapping, texture generation and so on. Cheetah 2D Engine supports GLSL shaders. Usually shaders are consist from two shader programs: vertex shader and fragment (pixel) shader. Vertex shader usually sets to default, but fragment shader must be specified any way. Default vertex shader in Cheetah 2D Engine:

varying vec2 TexCoord;
void main()
{
	gl_Position = gl_ModelViewProjectionMatrixgl_Vertex;
	TexCoord = gl_MultiTexCoord0.xy;
}

Parameters

  • fragment shader: source code or file with source
  • vertex shader: source code or file with source

Shader:check

bool Shader:check()

Check if Shader was created without errors.

Shader:bind

Shader:bind()

Bind Shader. After binding all drawings will use this Shader.

See also: cheetah.unbind

Shader:unbind

Shader:unbind()

Unbind Shader.

See also: cheetah.bind

Shader:set

Shader:set(string uniform, ...)

Set Shader uniform variable. Any Shader may conains variables passed from script. You must set all shader usiforms after calling Shader:bind(). Supported uniforms:

  • float
  • vec2
  • vec3
  • vec4
  • sampler2D

Parameters

  • uniform name
  • values

Framebuffer

cheetah.newFramebuffer (constructor)

Framebuffer cheetah.newFramebuffer(
	number width,
	number height,
	string options = ''
)

Create new Framebuffer. Framebuffer is used as off-screen render target: when you call Framebuffer:bind all drawing will be in this Framebuffer. Then you may draw this Framebuffer as Image. Default framebuffer has 8 bits per channel percision and you can change it, but be carefull: high percision framebuffers are very slow.

Parameters

  • width
  • height
  • string of options. Supported options:
  • nearest - use nearest interpolation instead of default linear interpolation
  • clamp - force texture clamp (default is repeat)
  • alpha - use alpha channel, RGBA (defaul is RGB)
  • percision16 - set percision to half float (16 bits per channel)
  • percision32 - set percision to float (32 bits per channel)

Framebuffer:draw

Framebuffer:draw(
	number x = 0,
	number y = 0,
	number width = Framebuffer:getWidth(),
	number height = Framebuffer:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw Framebuffer on screen with transformations.

Parameters

  • x position
  • y position
  • width of object
  • height of object
  • angle (radians)
  • origin x
  • origin y

Framebuffer:drawq

Framebuffer:drawq(
	number x = 0,
	number y = 0,
	number width = Framebuffer:getWidth(),
	number height = Framebuffer:getHeight(),
	quad_x = 0,
	quad_y = 0,
	quad_wigth = Framebuffer:getWidth(),
	quad_height = Framebuffer:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw part of Framebuffer on screen with transformations. Quads are useful for drawing or only part of image or drawing repeating patterns. Framebuffer will be clamped according to quad metrics and then it works as Framebuffer:draw() method.

Parameters

  • x position
  • y position
  • quad x position
  • quad y position
  • quad width
  • quad height
  • angle (radians)
  • origin x
  • origin y

Framebuffer:getWidth

number Framebuffer:getWidth()

Get width of Framebuffer.

Framebuffer:getHeight

number Framebuffer:getHeight()

Get height of Framebuffer.

Framebuffer:bind

Framebuffer:bind()

Bind Framebuffer to store all drawings into it.

Framebuffer:unbind

Framebuffer:unbind()

Unbind Framebuffer (sets screen as default render target).

Framebuffer:save

Framebuffer:save(string filename)

Save Framebuffer as image (only BMP format supported).

Parameters

  • file name where image must be saved

Framebuffer:check

bool Framebuffer:check()

Check if Framebuffer was created without errors.

Multitexture

cheetah.newMultitexture (constructor)

Multitexture cheetah.newMultitexture(Image ...)

Create new Multitexture from several Image classes. Multitexturing - a technique often used with shaders to combine up to 8 images in one shader (see Shader).

Parameters

  • set of Image. You must pass at least 2 arguments.

Multitexture:draw

Multitexture:draw(
	number x = 0,
	number y = 0,
	number width = Multitexture:getWidth(),
	number height = Multitexture:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw Multitexture on screen with transformations.

Parameters

  • x position
  • y position
  • width of object
  • height of object
  • angle (radians)
  • origin x
  • origin y

Multitexture:drawq

Multitexture:drawq(
	number x = 0,
	number y = 0,
	number width = Multitexture:getWidth(),
	number height = Multitexture:getHeight(),
	quad_x = 0,
	quad_y = 0,
	quad_wigth = Multitexture:getWidth(),
	quad_height = Multitexture:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw part of Multitexture on screen with transformations. Quads are useful for drawing or only part of image or drawing repeating patterns. Multitexture will be clamped according to quad metrics and then it works as Multitexture:draw() method.

Parameters

  • x position
  • y position
  • quad x position
  • quad y position
  • quad width
  • quad height
  • angle (radians)
  • origin x
  • origin y

Multitexture:getWidth

number Multitexture:getWidth()

Get width of Multitexture.

Multitexture:getHeight

number Multitexture:getHeight()

Get height of Multitexture.

BorderImage

cheetah.newBorderImage (constructor)

BorderImage cheetah.newBorderImage(
	string filename,
	number top,
	number right,
	number bottom,
	number left,
	string options
)

Create new BorderImage from file. This class is based on Image and used for displaying sliced images. Image will be splitted into 9 different parts. Useful used for GUI elements.

Parameters

  • path to file
  • top slice position
  • right slice position
  • bottom slice position
  • left slice position
  • string of options. Same as Image.

See also: cheetah.generate, cheetah.newImage

BorderImage:draw

BorderImage:draw(
	number x = 0,
	number y = 0,
	number width = BorderImage:getWidth(),
	number height = BorderImage:getHeight(),
	number angle = 0,
	number origin_x = 0,
	number origin_y = 0
)

Draw BorderImage on screen with transformations.

Parameters

  • x position
  • y position
  • width of object
  • height of object
  • angle (radians)
  • origin x
  • origin y

BorderImage:getWidth

number BorderImage:getWidth()

Get width of BorderImage.

BorderImage:getHeight

number BorderImage:getHeight()

Get height of BorderImage.

Functions

Timer

cheetah.getTime

number cheetah.getTime()

Gets the time in seconds past from the execution time. Returns "pure" system time (without game speed).

See also: cheetah.getGameTime, cheetah.getTicks

cheetah.getGameTime

number cheetah.getGameTime()

Gets the time in seconds past from the execution time. This function returns the time in view of game speed! You may change speed of game using cheetah.setGameSpeed. For example, you may stop this time, increase or decrease its speed and this timer will make possible such effects as slow motion, game pause.

See also: cheetah.getTime, cheetah.getTicks

cheetah.getTicks

number cheetah.getTicks()

Gets the number of milliseconds past from the execution time. Returns "pure" system time (without game speed). Also this function does not use timer's cache as previous if you want to measure time more accurately. Equivalent to SDL_GetTicks() on PC.

See also: cheetah.getGameTime, cheetah.getTime

cheetah.delay

cheetah.delay(number ms)

Do nothing some time.

Parameters

  • delay in milliseconds (1/1000 s)

See also: cheetah.sleep

cheetah.sleep

void cheetah.sleep(number sec)

Do nothing some time.

Parameters

  • delay in seconds

See also: cheetah.delay

Filesystem

cheetah.getFile

string cheetah.getFile(string filename)

Read entire file into string.

Parameters

  • path to file

See also: cheetah.putFile, cheetah.fileExists, cheetah.appendFile

cheetah.putFile

bool cheetah.putFile(
	string filename,
	string content,
	string writemode
)

Put sting into file.

Parameters

  • path to file
  • content to write
  • write mode (as in c), use one of: w - replace file if exists wa - append string to file if exists

See also: cheetah.appendFile, cheetah.getFile

cheetah.fileExists

bool cheetah.fileExists(string filename)

Check if file exists.

Parameters

  • path to file

cheetah.appendFile

bool cheetah.appendFile(
	string filename,
	string content
)

Append string to end of file.

Parameters

  • path to file
  • content to write

See also: cheetah.putFile, cheetah.getFile

File

cheetah.fileExt

string cheetah.fileExt(string filename)

Get file extension. This functions just returns text from last dot.

Parameters

  • file name or path (may be unexistent file)

cheetah.fileName

string cheetah.fileName(string filename)

Get file name (without extension). Returns just all text before last dot.

Parameters

  • file name or path (may be unexistent file)

cheetah.fileEach

cheetah.fileEach(
	string dirname,
	cheetah.callback
)

Runs function passed as second argument for each file in directory. Callback function has one orgument: file path.

Parameters

  • path to directory you want to scan
  • callback function

cheetah.getAppDataDir

string cheetah.getAppDataDir()

Get full path to directory where you may save any data.

cheetah.fileatime

number cheetah.fileatime(string filename)

Get file access time.

Parameters

  • path to file

cheetah.filemtime

number cheetah.filemtime(string filename)

Get file modification time.

Parameters

  • path to file

cheetah.filectime

number cheetah.filectime(string filename)

Get file creation time.

Parameters

  • path to file

cheetah.mkDir

bool cheetah.mkDir(string dirname)

Create new directory.

Parameters

  • path to directory

cheetah.openDir

DIR cheetah.openDir(string dirname)

Open directory for reading. Note that returned value may not be compared with nil!

Parameters

  • path to directory

See also: cheetah.readDir, cheetah.closeDir, cheetah.isDir

cheetah.readDir

dirent cheetah.readDir(DIR dirptr)

Read files from dir. Use cheetah.getDirentName to get dir name and cheetah.isPointer to check if there is more files in this dir.

Parameters

See also: cheetah.openDir, cheetah.closeDir, cheetah.isDir, cheetah.getDirentName

cheetah.closeDir

number cheetah.closeDir(DIR dirptr)

Close opened directory and free memory.

Parameters

See also: cheetah.openDir, cheetah.readDir, cheetah.isDir

cheetah.getDirentName

string cheetah.getDirentName(dirent dir)

Get a name of dir from dirent structure.

Parameters

  • Dirent from cheetah.readdir

See also: cheetah.openDir, cheetah.readDir, cheetah.isDir

cheetah.isDir

bool cheetah.isDir(string path)

Check is this path a directory.

Parameters

  • Path to file you want to check

See also: cheetah.openDir, cheetah.readDir, cheetah.isDir

Window

cheetah.init

bool cheetah.init(string appName, string options)

Create window and initialize all OpenGL's stuff. You MUST call this before any graphics function, e.g. cheetah.newImage. You may call this function again to re-size window, change application title, toggle fullscreen. Other options are ignored.

Parameters

  • application's title shown in titlebar
  • string of options. Supported options:
  • 1024x768 - set window size to 1024x768, default window size - 800x600
  • 1024 - set window size to 1024x1024
  • fullscreen - run in fullscreen mode
  • resizable - make window resizable
  • vsync - enable vertical synchronization
  • resloader - enable delayed resource loader (all images are loaded in separate thread), possible only with internal image loader, external modules (as DevIL) are not supported
  • depth - enable depth buffer
  • stencil - enable stencil buffer
  • noframe - try to make window without frame (depending on window manager, fullscreen mode, OS may not work)

cheetah.isInit

bool cheetah.isInit()

Check, if screen exists. Useful if you have windowless version of your application, e.g. server.

cheetah.mainLoop

cheetah.mainLoop()

Starts main loop. You must always place this function at the end of all scripts to start application.

cheetah.quit

cheetah.quit()

Close application.

cheetah.getWindowWidth

number cheetah.getWindowWidth()

Get window width.

cheetah.getWindowHeight

number cheetah.getWindowHeight()

Get window height.

cheetah.swapBuffers

cheetah.swapBuffers()

Get window dimensions. Swap buffers and present graphics. This function calls automatically every frame by default.

cheetah.setTitle

cheetah.setTitle(string text)

Set window's title.

Parameters

  • text to replace the caption

See also: cheetah.init

cheetah.getModes

cheetah.getModes(string text)

Get all avaiable screen modes (screen resolution list). This is useful if you want to use fullscreen mode.

Parameters

  • text to replace the caption

See also: cheetah.init

cheetah.setResizeDelay

cheetah.setResizeDelay(number delay)

Set interval to check window resizing. Too small interval means window to be blinking, too big interval - window resizing will be laggy

Parameters

  • delay in milliseconds

Events

cheetah.getMouseX

number cheetah.getMouseX()

Get mouse position. Get mouse x position.

cheetah.getMouseY

number cheetah.getMouseY()

Get mouse y position.

cheetah.isKeyPressed

bool cheetah.isKeyPressed(string key)

Checks if key is pressed. Useful for objects movement.

Parameters

  • key (e.g. "a", "space", "enter")

cheetah.gameSpeed

cheetah.gameSpeed(number speed)

Set game speed (main timer will be slower or faster).

Parameters

  • speed (e.g. 1 - normal speed, 2 - 2x faster, 0.5 - 2x slower)

cheetah.getEventType

number cheetah.getEventType()

Pick an event from events queue and return its type.

cheetah.getEventKey

number cheetah.getEventKey()

Get numberic keyboard key from current event state.

cheetah.getEventKeyUnicode

number cheetah.getEventKeyUnicode()

Get unicode keyboard key from current event state. Useful for text input and layouts support.

cheetah.getEventMouseX

number cheetah.getEventMouseX()

Get mouse position from current event state.

cheetah.getEventMouseY

number cheetah.getEventMouseY()

Get mouse position from current event state.

cheetah.getEventMouseButton

number cheetah.getEventMouseButton()

Get mouse button from current event state. Mouse button may be pressed or released depending on event type.

cheetah.getEventResizeW

number cheetah.getEventResizeW()

Get window size from current resize event state.

cheetah.getEventResizeH

number cheetah.getEventResizeH()

Get window size from current resize event state.

cheetah.getKeyState

SDLState cheetah.getKeyState()

Get current keyboard state.

Graphics

cheetah.getFps

number cheetah.getFps()

Get FPS (frames per second).

cheetah.flushBuffer

cheetah.flushBuffer()

Draw all quads accumulated in engine's quad buffer (flush vertex accumulator). Cheetah 2D engine uses its own buffer to batch drawing of huge amount of quads with one shared texture. Usually engine flushes this buffer automatically.

cheetah.enableDepthTest

cheetah.enableDepthTest()

Enables depth test. Useless if you didn't pass 'depth' option to cheetah.init. Equivalent to glEnable(GL_DEPTH_TEST);

See also: cheetah.disableDepthTest

cheetah.disableDepthTest

cheetah.disableDepthTest()

Disables depth test. Useless if you didn't pass 'depth' option to cheetah.init. Equivalent to glDisable(GL_DEPTH_TEST);

See also: cheetah.enableDepthTest

cheetah.enableStencilTest

cheetah.enableStencilTest()

Enables stencil test. Useless if you didn't pass 'stencil' option to cheetah.init. Equivalent to glEnable(GL_STENCIL_TEST);

See also: cheetah.disableStencilTest

cheetah.disableStencilTest

cheetah.disableStencilTest()

Disables stencil test. Useless if you didn't pass 'stencil' option to cheetah.init. Equivalent to glDisable(GL_STENCIL_TEST);

See also: cheetah.enableStencilTest

cheetah.enableScissorTest

cheetah.enableScissorTest()

Enables scissor test. Equivalent to glEnable(GL_SCISSOR_TEST);

See also: cheetah.disableStencilTest

cheetah.disableScissorTest

cheetah.disableScissorTest()

Disables scissor test. Equivalent to glDisable(GL_SCISSOR_TEST);

See also: cheetah.enableStencilTest

cheetah.enableAlphaTest

cheetah.enableAlphaTest()

Enables alpha test. Equivalent to glEnable(GL_ALPHA_TEST);

See also: cheetah.disableAlphaTest

cheetah.disableAlphaTest

cheetah.disableAlphaTest()

Disables alpha test. Equivalent to glDisable(GL_ALPHA_TEST);

See also: cheetah.enableAlphaTest

cheetah.setScissor

cheetah.setScissor(
	number x,
	number y,
	number w,
	number h
)

Set scissor area.

See also: cheetah.enableScissorTest

cheetah.flush

cheetah.flush()

Flush graphics. Forces OpenGL to complete all draw calls.

cheetah.blend

cheetah.blend(bool blendMode)

Enable or disable blending. Drawing without blending usually faster, but textures with alpha-channel will loose its opacity. Blending is enabled by default.

Parameters

  • blend mode

See also: cheetah.enableBlend, cheetah.disableBlend, cheetah.blendMode

cheetah.enableBlend

cheetah.enableBlend()

Enable blending. Blending is enabled by default.

See also: cheetah.disableBlend, cheetah.blend, cheetah.blendMode

cheetah.disableBlend

cheetah.disableBlend()

Disable blending.

See also: cheetah.enableBlend, cheetah.blend, cheetah.blendMode

cheetah.push

cheetah.push()

Push the transformation matrix to stack. Equivalent to glPushMatrix();

See also: cheetah.pop, cheetah.reset

cheetah.pop

cheetah.pop()

Pop the transformation matrix from stack. Equivalent to glPopMatrix();

See also: cheetah.push, cheetah.reset

cheetah.reset

cheetah.reset()

Reset the transformation matrix. Equivalent to glLoadIdentity();

See also: cheetah.push, cheetah.pop

cheetah.move

cheetah.move(
	number translateX,
	number translateY
)

Move object relatively to the current matrix position (in pixels). This function must be called between cheetah.push and cheetah.pop functions.

Parameters

  • x coordinate
  • y coordinate

See also: cheetah.scale, cheetah.rotate, cheetah.translateObject

cheetah.scale

cheetah.scale(number scaleX, number scaleY)

Scale object relatively to the current matrix size (initially, matrix has size 1:1 to fit pixel grid). This function must be called between cheetah.push and cheetah.pop functions.

Parameters

  • x scale
  • y scale

See also: cheetah.move, cheetah.rotate, cheetah.translateObject

cheetah.rotate

cheetah.rotate(number angle)

Rotate object relatively to the current matrix angle. This function must be called between cheetah.push and cheetah.pop functions.

Parameters

  • angle

See also: cheetah.move, cheetah.scale, cheetah.translateObject

cheetah.translateObject

cheetah.translateObject(
	number x,
	number y,
	number angle,
	number width,
	number height,
	number origin_x,
	number origin_y
)

Move, rotate and scale object relatively to it's center (origin). This function must be called between cheetah.push and cheetah.pop functions.

Parameters

  • x coordinate
  • y coordinate
  • angle
  • x scale
  • y scale
  • x offset (center)
  • y offset (center)

See also: cheetah.move, cheetah.scale, cheetah.rotate

cheetah.autoScale

cheetah.autoScale(bool autoScale)

Enable or disable autoscale. Autoscale allows you to draw stuff in the fixed coordinates, and engine automatically translates all coordinates if window changes his size. Is you want to control screen size yourself, disable this.

Parameters

  • enable or disable autoscale

cheetah.color

cheetah.color(
	number red,
	number green,
	number blue,
	number alpha
)

Set the color. All graphics below will be painted with this color.

Parameters

  • red component (0-255)
  • green component (0-255)
  • blue component (0-255)
  • alpha component, opacity (0-255)

See also: cheetah.colorf, cheetah.clearColor

cheetah.colorf

cheetah.colorf(
	number red,
	number green,
	number blue,
	number alpha
)

Set the color in floating-point mode. All graphics below will be painted with this color.

Parameters

  • red component (0-1)
  • green component (0-1)
  • blue component (0-1)
  • alpha component, opacity (0-1)

See also: cheetah.color, cheetah.clearColor

cheetah.clearColor

cheetah.clearColor(
	number red,
	number green,
	number blue,
	number alpha
)

Set the color used to clear screen (default background color).

Parameters

  • red component (0-1)
  • green component (0-1)
  • blue component (0-1)
  • alpha component, opacity (0-1)

See also: cheetah.color, cheetah.colorf

cheetah.blendMode

cheetah.blendMode(enumerate mode)

Sets the blending mode. Blending modes allow you to create some cool effects.

Parameters

  • One of possible blending modes. Use pre-defined blending modes:
  • cheetah.blendAlpha - default
  • cheetah.blendMultiplicative
  • cheetah.blendAdditive
  • cheetah.blendSubstractive
  • cheetah.blendMask - render inverse alpha channel
  • cheetah.blendScreen - as PhotoShop's Screen mode
  • cheetah.blendDetail - interesting effect, allows to use gray detail textures. Gray color does not change lighness, white color increases lightness, black color makes dark places. This mode may be used to produce lighting effects without shaders.

See also: cheetah.blend, cheetah.enableBlend, cheetah.disableBlend

cheetah.blendFunc

cheetah.blendFunc(
	enumerate sourcefactor,
	enumerate destinationfactor
)

Specify pixel arithmetic. Equivalent to glBlendFunc(sourcefactor, destinationfactor);

Parameters

  • Specifies how the red, green, blue, and alpha source blending factors are computed. The following symbolic constants are accepted:
  • cheetah.GL_ZERO
  • cheetah.GL_ONE
  • cheetah.GL_DST_COLOR
  • cheetah.GL_ONE_MINUS_DST_COLOR
  • cheetah.GL_SRC_ALPHA
  • cheetah.GL_ONE_MINUS_SRC_ALPHA
  • cheetah.GL_DST_ALPHA
  • cheetah.GL_ONE_MINUS_DST_ALPHA
  • cheetah.GL_SRC_ALPHA_SATURATE
  • Specifies how the red, green, blue, and alpha destination blending factors are computed. Eight symbolic constants are accepted:
  • cheetah.GL_ZERO
  • cheetah.GL_ONE
  • cheetah.GL_SRC_COLOR
  • cheetah.GL_ONE_MINUS_SRC_COLOR
  • cheetah.GL_SRC_ALPHA
  • cheetah.GL_ONE_MINUS_SRC_ALPHA
  • cheetah.GL_DST_ALPHA
  • cheetah.GL_ONE_MINUS_DST_ALPHA

cheetah.clear

cheetah.clear()

Clear screen. Do not use it if you have background image. Cheetah 2D engine clears screen automatically, but you may use this to clear framebuffer.

See also: cheetah.clearColor, cheetah.clearColorDepth, cheetah.clearColorStencil, cheetah.clearDepth, cheetah.clearStencil

cheetah.clearColorDepth

cheetah.clearColorDepth()

Clear screen and depth buffer. Usually used in lQuery.addhook(cheetah.clearColorDepth). Slow.

See also: cheetah.clearColor, cheetah.clear, cheetah.clearColorStencil, cheetah.clearDepth, cheetah.clearStencil

cheetah.clearColorStencil

cheetah.clearColorStencil()

Clear screen and stencil buffer. Usually used in lQuery.addhook(cheetah.clearColorStencil). Slow.

See also: cheetah.clearColor, cheetah.clear, cheetah.clearColorDepth, cheetah.clearDepth, cheetah.clearStencil

cheetah.clearDepth

cheetah.clearDepth()

Clear depth buffer. Usually used in lQuery.addhook(cheetah.clearDepth). Slow.

See also: cheetah.clearColor, cheetah.clear, cheetah.clearColorDepth, cheetah.clearColorStencil, cheetah.clearStencil

cheetah.clearStencil

cheetah.clearStencil()

Clear stencil buffer. Usually used in lQuery.addhook(cheetah.clearStencil). Slow.

See also: cheetah.clearColor, cheetah.clear, cheetah.clearColorDepth, cheetah.clearColorStencil, cheetah.clearDepth

Graphics/drawing

cheetah.blendEquation

cheetah.blendEquation(enumerate mode)

Specify the equation used for both the RGB blend equation and the Alpha blend equation. Equivalent to glBlendEquation(mode);

Parameters

  • Specifies how source and destination colors are combined. It must be:
  • cheetah.GL_FUNC_ADD
  • cheetah.GL_FUNC_SUBTRACT
  • cheetah.GL_FUNC_REVERSE_SUBTRACT
  • cheetah.GL_MIN
  • cheetah.GL_MAX

Other

cheetah.isPointer

bool cheetah.isPointer(void *pointer)

Check is current lua's ffi object a non-NULL pointer. Needed to check ffi C structures.

Parameters

  • Pointer to check
Clone this wiki locally