Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
162 lines (122 sloc) 4.09 KB
OpenLase - a realtime laser graphics toolkit
Copyright (C) 2009-2011 Hector Martin "marcan" <>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 or version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef LIBOL_H
#define LIBOL_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
enum {
#define C_RED 0xff0000
#define C_GREEN 0x00ff00
#define C_BLUE 0x0000ff
#define C_WHITE 0xffffff
#define C_BLACK 0x000000
#define CLAMP(a,b,c) (((a)<(b))?(b):((a)>(c)?(c):(a)))
#define C_GREY(x) (0x010101 * CLAMP((int)(x), 0, 255))
#define C_RED_I(x) (0x010000 * CLAMP((int)(x), 0, 255))
#define C_GREEN_I(x) (0x000100 * CLAMP((int)(x), 0, 255))
#define C_BLUE_I(x) (0x000001 * CLAMP((int)(x), 0, 255))
enum {
typedef struct {
int rate;
float on_speed;
float off_speed;
int start_wait;
int start_dwell;
int curve_dwell;
int corner_dwell;
int end_dwell;
int end_wait;
float curve_angle;
float flatness;
float snap;
int render_flags;
int min_length;
int max_framelen;
float z_near;
} OLRenderParams;
typedef struct {
int objects;
int points;
int resampled_points;
int resampled_blacks;
int padding_points;
} OLFrameInfo;
int olInit(int buffer_count, int max_points);
void olSetRenderParams(OLRenderParams *params);
void olGetRenderParams(OLRenderParams *params);
typedef void (*AudioCallbackFunc)(float *leftbuf, float *rightbuf, int samples);
void olSetAudioCallback(AudioCallbackFunc f);
void olLoadIdentity(void);
void olPushMatrix(void);
void olPopMatrix(void);
void olMultMatrix(float m[9]);
void olRotate(float theta);
void olTranslate(float x, float y);
void olScale(float sx, float sy);
void olLoadIdentity3(void);
void olPushMatrix3(void);
void olPopMatrix3(void);
void olMultMatrix3(float m[16]);
void olRotate3X(float theta);
void olRotate3Y(float theta);
void olRotate3Z(float theta);
void olTranslate3(float x, float y, float z);
void olScale3(float sx, float sy, float sz);
void olFrustum (float left, float right, float bot, float ttop, float near, float far);
void olPerspective(float fovy, float aspect, float zNear, float zFar);
void olResetColor(void);
void olMultColor(uint32_t color);
void olPushColor(void);
void olPopColor(void);
void olBegin(int prim);
void olVertex(float x, float y, uint32_t color);
void olVertex3(float x, float y, float z, uint32_t color);
void olVertex2Z(float x, float y, float z, uint32_t color);
void olEnd(void);
void olTransformVertex(float *x, float *y);
void olTransformVertex3(float *x, float *y, float *z);
void olTransformVertex4(float *x, float *y, float *z, float *w);
typedef void (*ShaderFunc)(float *x, float *y, uint32_t *color);
typedef void (*Shader3Func)(float *x, float *y, float *z, uint32_t *color);
void olSetVertexPreShader(ShaderFunc f);
void olSetVertexShader(ShaderFunc f);
void olSetVertex3Shader(Shader3Func f);
void olSetPixelShader(ShaderFunc f);
void olSetPixel3Shader(Shader3Func f);
void olRect(float x1, float y1, float x2, float y2, uint32_t color);
void olLine(float x1, float y1, float x2, float y2, uint32_t color);
void olDot(float x, float y, int points, uint32_t color);
float olRenderFrame(int max_fps);
void olGetFrameInfo(OLFrameInfo *info);
void olShutdown(void);
void olSetScissor (float x0, float y0, float x1, float y1);
void olLog(const char *fmt, ...);
typedef void (*LogCallbackFunc)(const char *msg);
void olSetLogCallback(LogCallbackFunc f);
#ifdef __cplusplus
} // extern "C"