Add various raylib modules.

This commit is contained in:
TSnake41 2020-03-31 21:32:36 +02:00
parent f03010630a
commit 7a14562f25
8 changed files with 340 additions and 4 deletions

View File

@ -4,10 +4,10 @@ LDFLAGS := -O2 -s -lm
AR ?= ar
LUA ?= luajit/src/luajit
CFLAGS += -Iluajit/src -Iraylib/src
CFLAGS += -Iluajit/src -Iraylib/src -Iraygui/src
LDFLAGS += -Lluajit/src -lluajit -Lraylib/src -lraylib
MODULES := rlgl physac
MODULES := raymath rlgl camera easings gestures physac raygui
ifeq ($(OS),Windows_NT)
LDFLAGS += -lopengl32 -lgdi32 -lwinmm -static
@ -53,7 +53,8 @@ src/autogen/builder.c: src/raylua_builder.lua
$(LUA) tools/lua2str.lua $@ raylua_builder_lua $^
clean:
rm -rf raylua_s raylua_e src/raylua_e.o src/raylua_s.o src/raylua.o src/autogen/*.c src/lib/miniz.o
rm -rf raylua_s raylua_e src/raylua_e.o src/raylua_s.o src/raylua.o \
src/raylua_builder.o src/autogen/*.c src/lib/miniz.o
$(MAKE) -C luajit clean
$(MAKE) -C raylib/src clean

View File

@ -596,6 +596,12 @@ ffi.cdef [[
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);
]]
-- raymath cdef
ffi.cdef [[
typedef struct float3 { float v[3]; } float3;
typedef struct float16 { float v[16]; } float16;
]]
-- Physac cdef
ffi.cdef [[
typedef struct PhysicsBodyData *PhysicsBody;
@ -648,6 +654,160 @@ ffi.cdef [[
} PhysicsBodyData;
]]
-- gestures cdef
ffi.cdef [[
typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
typedef struct {
int touchAction;
int pointCount;
int pointerId[4];
Vector2 position[4];
} GestureEvent;
]]
-- raygui cdef
ffi.cdef [[
typedef struct GuiStyleProp {
unsigned short controlId;
unsigned short propertyId;
int propertyValue;
} GuiStyleProp;
typedef enum {
GUI_STATE_NORMAL = 0,
GUI_STATE_FOCUSED,
GUI_STATE_PRESSED,
GUI_STATE_DISABLED,
} GuiControlState;
typedef enum {
GUI_TEXT_ALIGN_LEFT = 0,
GUI_TEXT_ALIGN_CENTER,
GUI_TEXT_ALIGN_RIGHT,
} GuiTextAlignment;
typedef enum {
DEFAULT = 0,
LABEL,
BUTTON,
TOGGLE,
SLIDER,
PROGRESSBAR,
CHECKBOX,
COMBOBOX,
DROPDOWNBOX,
TEXTBOX,
VALUEBOX,
SPINNER,
LISTVIEW,
COLORPICKER,
SCROLLBAR,
STATUSBAR
} GuiControl;
typedef enum {
BORDER_COLOR_NORMAL = 0,
BASE_COLOR_NORMAL,
TEXT_COLOR_NORMAL,
BORDER_COLOR_FOCUSED,
BASE_COLOR_FOCUSED,
TEXT_COLOR_FOCUSED,
BORDER_COLOR_PRESSED,
BASE_COLOR_PRESSED,
TEXT_COLOR_PRESSED,
BORDER_COLOR_DISABLED,
BASE_COLOR_DISABLED,
TEXT_COLOR_DISABLED,
BORDER_WIDTH,
TEXT_PADDING,
TEXT_ALIGNMENT,
RESERVED
} GuiControlProperty;
typedef enum {
TEXT_SIZE = 16,
TEXT_SPACING,
LINE_COLOR,
BACKGROUND_COLOR,
} GuiDefaultProperty;
typedef enum {
GROUP_PADDING = 16,
} GuiToggleProperty;
typedef enum {
SLIDER_WIDTH = 16,
SLIDER_PADDING
} GuiSliderProperty;
typedef enum {
PROGRESS_PADDING = 16,
} GuiProgressBarProperty;
typedef enum {
CHECK_PADDING = 16
} GuiCheckBoxProperty;
typedef enum {
COMBO_BUTTON_WIDTH = 16,
COMBO_BUTTON_PADDING
} GuiComboBoxProperty;
typedef enum {
ARROW_PADDING = 16,
DROPDOWN_ITEMS_PADDING
} GuiDropdownBoxProperty;
typedef enum {
TEXT_INNER_PADDING = 16,
TEXT_LINES_PADDING,
COLOR_SELECTED_FG,
COLOR_SELECTED_BG
} GuiTextBoxProperty;
typedef enum {
SPIN_BUTTON_WIDTH = 16,
SPIN_BUTTON_PADDING,
} GuiSpinnerProperty;
typedef enum {
ARROWS_SIZE = 16,
ARROWS_VISIBLE,
SCROLL_SLIDER_PADDING,
SCROLL_SLIDER_SIZE,
SCROLL_PADDING,
SCROLL_SPEED,
} GuiScrollBarProperty;
typedef enum {
SCROLLBAR_LEFT_SIDE = 0,
SCROLLBAR_RIGHT_SIDE
} GuiScrollBarSide;
typedef enum {
LIST_ITEMS_HEIGHT = 16,
LIST_ITEMS_PADDING,
SCROLLBAR_WIDTH,
SCROLLBAR_SIDE,
} GuiListViewProperty;
typedef enum {
COLOR_SELECTOR_SIZE = 16,
HUEBAR_WIDTH,
HUEBAR_PADDING,
HUEBAR_SELECTOR_HEIGHT,
HUEBAR_SELECTOR_OVERFLOW
} GuiColorPickerProperty;
typedef struct GuiTextBoxState {
int cursor;
int start;
int index;
int select;
} GuiTextBoxState;
]]
-- Load bind entry
ffi.cdef [[
struct raylua_bind_entry {

6
tools/camera.h Normal file
View File

@ -0,0 +1,6 @@
void SetCameraMode(Camera camera, int mode)
void UpdateCamera(Camera *camera)
void SetCameraPanControl(int panKey)
void SetCameraAltControl(int altKey)
void SetCameraSmoothZoomControl(int szoomKey);
void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey);

28
tools/easings.h Normal file
View File

@ -0,0 +1,28 @@
float EaseLinearNone(float t, float b, float c, float d)
float EaseLinearIn(float t, float b, float c, float d)
float EaseLinearOut(float t, float b, float c, float d)
float EaseLinearInOut(float t,float b, float c, float d)
float EaseSineIn(float t, float b, float c, float d)
float EaseSineOut(float t, float b, float c, float d)
float EaseSineInOut(float t, float b, float c, float d)
float EaseCircIn(float t, float b, float c, float d)
float EaseCircOut(float t, float b, float c, float d)
float EaseCircInOut(float t, float b, float c, float d)
float EaseCubicIn(float t, float b, float c, float d)
float EaseCubicOut(float t, float b, float c, float d)
float EaseCubicInOut(float t, float b, float c, float d)
float EaseQuadIn(float t, float b, float c, float d)
float EaseQuadOut(float t, float b, float c, float d)
float EaseQuadInOut(float t, float b, float c, float d)
float EaseExpoIn(float t, float b, float c, float d)
float EaseExpoOut(float t, float b, float c, float d)
float EaseExpoInOut(float t, float b, float c, float d)
float EaseBackIn(float t, float b, float c, float d)
float EaseBackOut(float t, float b, float c, float d)
float EaseBackInOut(float t, float b, float c, float d)
float EaseBounceOut(float t, float b, float c, float d)
float EaseBounceIn(float t, float b, float c, float d)
float EaseBounceInOut(float t, float b, float c, float d)
float EaseElasticIn(float t, float b, float c, float d)
float EaseElasticOut(float t, float b, float c, float d)
float EaseElasticInOut(float t, float b, float c, float d)

View File

@ -13,7 +13,8 @@ local structs = {
"Material", "Model", "Transform", "BoneInfo", "ModelAnimation",
"Ray", "RayHitInfo", "BoundingBox", "Wave", "Sound", "Music",
"AudioStream", "VrDeviceInfo", "Camera3D", "RenderTexture2D",
"TextureCubemap", "TraceLogCallback", "PhysicsBody"
"TextureCubemap", "TraceLogCallback", "PhysicsBody",
"GestureEvent", "GuiStyle", "GuiTextBoxState"
}
local functions = {}

2
tools/gestures.h Normal file
View File

@ -0,0 +1,2 @@
void ProcessGestureEvent(GestureEvent event)
void UpdateGestures(void)

59
tools/raygui.h Normal file
View File

@ -0,0 +1,59 @@
void GuiEnable(void)
void GuiDisable(void)
void GuiLock(void)
void GuiUnlock(void)
void GuiFade(float alpha)
void GuiSetState(int state)
int GuiGetState(void)
void GuiSetFont(Font font)
Font GuiGetFont(void)
void GuiSetStyle(int control, int property, int value)
int GuiGetStyle(int control, int property)
void GuiEnableTooltip(void)
void GuiDisableTooltip(void)
void GuiSetTooltip(const char *tooltip)
void GuiClearTooltip(void)
bool GuiWindowBox(Rectangle bounds, const char *title)
void GuiGroupBox(Rectangle bounds, const char *text)
void GuiLine(Rectangle bounds, const char *text)
void GuiPanel(Rectangle bounds)
Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
void GuiLabel(Rectangle bounds, const char *text)
bool GuiButton(Rectangle bounds, const char *text)
bool GuiLabelButton(Rectangle bounds, const char *text)
bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture)
bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource)
bool GuiToggle(Rectangle bounds, const char *text, bool active)
int GuiToggleGroup(Rectangle bounds, const char *text, int active)
bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
int GuiComboBox(Rectangle bounds, const char *text, int active)
bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode)
bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
void GuiStatusBar(Rectangle bounds, const char *text)
void GuiDummyRec(Rectangle bounds, const char *text)
int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs)
int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active)
int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active)
int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons)
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text)
Color GuiColorPicker(Rectangle bounds, Color color)
Color GuiColorPanel(Rectangle bounds, Color color)
float GuiColorBarAlpha(Rectangle bounds, float alpha)
float GuiColorBarHue(Rectangle bounds, float value)
void GuiLoadStyle(const char *fileName)
void GuiLoadStyleDefault(void)
const char *GuiIconText(int iconId, const char *text)
void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color);
unsigned int *GuiGetIcons(void)
unsigned int *GuiGetIconData(int iconId)
void GuiSetIconData(int iconId, unsigned int *data)
void GuiSetIconPixel(int iconId, int x, int y)
void GuiClearIconPixel(int iconId, int x, int y)
bool GuiCheckIconPixel(int iconId, int x, int y)

79
tools/raymath.h Normal file
View File

@ -0,0 +1,79 @@
float Clamp(float value, float min, float max);
float Lerp(float start, float end, float amount);
Vector2 Vector2Zero(void);
Vector2 Vector2One(void);
Vector2 Vector2Add(Vector2 v1, Vector2 v2);
Vector2 Vector2Subtract(Vector2 v1, Vector2 v2);
float Vector2Length(Vector2 v);
float Vector2DotProduct(Vector2 v1, Vector2 v2);
float Vector2Distance(Vector2 v1, Vector2 v2);
float Vector2Angle(Vector2 v1, Vector2 v2);
Vector2 Vector2Scale(Vector2 v, float scale);
Vector2 Vector2MultiplyV(Vector2 v1, Vector2 v2);
Vector2 Vector2Negate(Vector2 v);
Vector2 Vector2Divide(Vector2 v, float div);
Vector2 Vector2DivideV(Vector2 v1, Vector2 v2);
Vector2 Vector2Normalize(Vector2 v);
Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount);
Vector2 Vector2Rotate(Vector2 v, float degs);
Vector3 Vector3Zero(void);
Vector3 Vector3One(void);
Vector3 Vector3Add(Vector3 v1, Vector3 v2);
Vector3 Vector3Subtract(Vector3 v1, Vector3 v2);
Vector3 Vector3Scale(Vector3 v, float scalar);
Vector3 Vector3Multiply(Vector3 v1, Vector3 v2);
Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2);
Vector3 Vector3Perpendicular(Vector3 v);
float Vector3Length(const Vector3 v);
float Vector3DotProduct(Vector3 v1, Vector3 v2);
float Vector3Distance(Vector3 v1, Vector3 v2);
Vector3 Vector3Negate(Vector3 v);
Vector3 Vector3Divide(Vector3 v, float div);
Vector3 Vector3DivideV(Vector3 v1, Vector3 v2);
Vector3 Vector3Normalize(Vector3 v);
void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2);
Vector3 Vector3Transform(Vector3 v, Matrix mat);
Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);
Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount);
Vector3 Vector3Reflect(Vector3 v, Vector3 normal);
Vector3 Vector3Min(Vector3 v1, Vector3 v2);
Vector3 Vector3Max(Vector3 v1, Vector3 v2);
Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c);
float3 Vector3ToFloatV(Vector3 v);
float MatrixDeterminant(Matrix mat);
float MatrixTrace(Matrix mat);
Matrix MatrixTranspose(Matrix mat);
Matrix MatrixInvert(Matrix mat);
Matrix MatrixNormalize(Matrix mat);
Matrix MatrixIdentity(void);
Matrix MatrixAdd(Matrix left, Matrix right);
Matrix MatrixSubtract(Matrix left, Matrix right);
Matrix MatrixTranslate(float x, float y, float z);
Matrix MatrixRotate(Vector3 axis, float angle);
Matrix MatrixRotateXYZ(Vector3 ang);
Matrix MatrixRotateX(float angle);
Matrix MatrixRotateY(float angle);
Matrix MatrixRotateZ(float angle);
Matrix MatrixScale(float x, float y, float z);
Matrix MatrixMultiply(Matrix left, Matrix right);
Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far);
Matrix MatrixPerspective(double fovy, double aspect, double near, double far);
Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far);
Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up);
float16 MatrixToFloatV(Matrix mat);
Quaternion QuaternionIdentity(void);
float QuaternionLength(Quaternion q);
Quaternion QuaternionNormalize(Quaternion q);
Quaternion QuaternionInvert(Quaternion q);
Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2);
Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount);
Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount);
Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount);
Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to);
Quaternion QuaternionFromMatrix(Matrix mat);
Matrix QuaternionToMatrix(Quaternion q);
Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle);
void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle);
Quaternion QuaternionFromEuler(float roll, float pitch, float yaw);
Vector3 QuaternionToEuler(Quaternion q);
Quaternion QuaternionTransform(Quaternion q, Matrix mat);