New rlgl functions and texture can be given as table.
This commit is contained in:
116
API.md
116
API.md
@@ -1005,13 +1005,13 @@ int id. Image type (multiple pixel formats supported). NOTE: Data stored in CPU
|
||||
|
||||
---
|
||||
|
||||
> Texture = TextureId
|
||||
> Texture = TextureId or { id, width, height, mipmaps, format }
|
||||
|
||||
int id. Texture type (multiple internal formats supported). NOTE: Data stored in GPU memory (VRAM)
|
||||
|
||||
---
|
||||
|
||||
> RenderTexture = RenderTextureId
|
||||
> RenderTexture = RenderTextureId or { id, texture, depth }
|
||||
|
||||
int id. RenderTexture type, for texture rendering
|
||||
|
||||
@@ -3571,7 +3571,7 @@ Load texture for rendering ( framebuffer )
|
||||
|
||||
> success = RL.UnloadTexture( Texture2D texture )
|
||||
|
||||
Unload texture from GPU memory ( VRAM )
|
||||
Unload texture from GPU memory ( VRAM ). NOTE! Must be texture id.
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
@@ -3702,11 +3702,20 @@ Set texture wrapping mode ( TEXTURE_WRAP_REPEAT, TEXTURE_WRAP_CLAMP... )
|
||||
|
||||
---
|
||||
|
||||
> id = RL.GetTextureId( Texture2D texture )
|
||||
|
||||
Get texture OpenGL id
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> size = RL.GetTextureSize( Texture2D texture )
|
||||
|
||||
Get texture size
|
||||
|
||||
- Failure return nil
|
||||
- Failure return false
|
||||
- Success return Vector2
|
||||
|
||||
---
|
||||
@@ -6610,6 +6619,34 @@ Get light enabled
|
||||
|
||||
---
|
||||
|
||||
## RLGL - Framebuffer state
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlEnableFramebuffer( int id )
|
||||
|
||||
Enable render texture (fbo)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> RL.rlDisableFramebuffer()
|
||||
|
||||
Disable render texture (fbo), return to default framebuffer
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlActiveDrawBuffers( int count )
|
||||
|
||||
Activate multiple draw color buffers
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
## RLGL - General render state
|
||||
|
||||
---
|
||||
@@ -6712,6 +6749,77 @@ Get current OpenGL version
|
||||
|
||||
---
|
||||
|
||||
## RLGL - Textures management
|
||||
|
||||
---
|
||||
|
||||
> id = RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )
|
||||
|
||||
Load texture in GPU
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> id = RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer )
|
||||
|
||||
Load depth texture/renderbuffer ( to be attached to fbo )
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlUnloadTexture( int id )
|
||||
|
||||
Unload texture from GPU memory
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
## RLGL - Framebuffer management (fbo)
|
||||
|
||||
---
|
||||
|
||||
> fboId = RL.rlLoadFramebuffer( Vector2 size )
|
||||
|
||||
Load an empty framebuffer
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel )
|
||||
|
||||
Attach texture/renderbuffer to a framebuffer
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> isComplete = RL.rlFramebufferComplete( int id )
|
||||
|
||||
Verify framebuffer is complete
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlUnloadFramebuffer( int id )
|
||||
|
||||
Delete framebuffer from GPU
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
|
||||
## OpenGL - Framebuffer management
|
||||
|
||||
---
|
||||
|
||||
@@ -2645,7 +2645,7 @@ function RL.LoadTextureCubemap( image, layout ) end
|
||||
---@return any renderTexture
|
||||
function RL.LoadRenderTexture( size ) end
|
||||
|
||||
---Unload texture from GPU memory ( VRAM )
|
||||
---Unload texture from GPU memory ( VRAM ). NOTE! Must be texture id.
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param texture any
|
||||
@@ -2766,8 +2766,15 @@ function RL.SetTextureFilter( texture, filter ) end
|
||||
---@return any success
|
||||
function RL.SetTextureWrap( texture, wrap ) end
|
||||
|
||||
---Get texture OpenGL id
|
||||
---- Failure return false
|
||||
---- Success return int
|
||||
---@param texture any
|
||||
---@return any id
|
||||
function RL.GetTextureId( texture ) end
|
||||
|
||||
---Get texture size
|
||||
---- Failure return nil
|
||||
---- Failure return false
|
||||
---- Success return Vector2
|
||||
---@param texture any
|
||||
---@return any size
|
||||
@@ -5410,6 +5417,26 @@ function RL.GetLightColor( light ) end
|
||||
---@return any enabled
|
||||
function RL.IsLightEnabled( light ) end
|
||||
|
||||
-- RLGL - Framebuffer state
|
||||
|
||||
---Enable render texture (fbo)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param id integer
|
||||
---@return any success
|
||||
function RL.rlEnableFramebuffer( id ) end
|
||||
|
||||
---Disable render texture (fbo), return to default framebuffer
|
||||
---@return any RL.rlDisableFramebuffer
|
||||
function RL.rlDisableFramebuffer() end
|
||||
|
||||
---Activate multiple draw color buffers
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param count integer
|
||||
---@return any success
|
||||
function RL.rlActiveDrawBuffers( count ) end
|
||||
|
||||
-- RLGL - General render state
|
||||
|
||||
---Enable color blending
|
||||
@@ -5478,6 +5505,66 @@ function RL.rlDisableSmoothLines() end
|
||||
---@return any version
|
||||
function RL.rlGetVersion() end
|
||||
|
||||
-- RLGL - Textures management
|
||||
|
||||
---Load texture in GPU
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---@param size table
|
||||
---@param format integer
|
||||
---@param mipmapCount integer
|
||||
---@return any id
|
||||
function RL.rlLoadTexture( size, format, mipmapCount ) end
|
||||
|
||||
---Load depth texture/renderbuffer ( to be attached to fbo )
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---@param size table
|
||||
---@param useRenderBuffer boolean
|
||||
---@return any id
|
||||
function RL.rlLoadTextureDepth( size, useRenderBuffer ) end
|
||||
|
||||
---Unload texture from GPU memory
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param id integer
|
||||
---@return any success
|
||||
function RL.rlUnloadTexture( id ) end
|
||||
|
||||
-- RLGL - Framebuffer management (fbo)
|
||||
|
||||
---Load an empty framebuffer
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---@param size table
|
||||
---@return any fboId
|
||||
function RL.rlLoadFramebuffer( size ) end
|
||||
|
||||
---Attach texture/renderbuffer to a framebuffer
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param fboId integer
|
||||
---@param texId integer
|
||||
---@param attachType integer
|
||||
---@param texType integer
|
||||
---@param mipLevel integer
|
||||
---@return any success
|
||||
function RL.rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel ) end
|
||||
|
||||
---Verify framebuffer is complete
|
||||
---- Failure return nil
|
||||
---- Success return bool
|
||||
---@param id integer
|
||||
---@return any isComplete
|
||||
function RL.rlFramebufferComplete( id ) end
|
||||
|
||||
---Delete framebuffer from GPU
|
||||
---- Failure return nil
|
||||
---- Success return bool
|
||||
---@param id integer
|
||||
---@return any success
|
||||
function RL.rlUnloadFramebuffer( id ) end
|
||||
|
||||
-- OpenGL - Framebuffer management
|
||||
|
||||
---Copy a block of pixels from one framebuffer object to another.
|
||||
|
||||
118
changelog
118
changelog
@@ -2,35 +2,39 @@
|
||||
Release: ReiLua version 0.5.0 Using Raylib 4.5
|
||||
------------------------------------------------------------------------
|
||||
KEY CHANGES:
|
||||
- CHANGED: All ReiLua global variables and functions are now stored in global RL table.
|
||||
- CHANGED: All examples are now changed to use new RL table method.
|
||||
- ADDED: doc_parser creates also ReiLua_API.lua that can be used in projects with Lua Language Server.
|
||||
- CHANGED: Switched to Raylib vertion 4.5. Removed some functions and added others. Main changes to camera3D.
|
||||
- REVISED: How Lua argumets are handled. Now uluaGet*Index functions can take stack index(positive only).
|
||||
Also using positive stack indexing.
|
||||
- ADDED: Camera3D Lua lib.
|
||||
- ADDED: Raygui wrapper lib.
|
||||
- CHANGED: Can now have multiple Music objects like other Raylib objects instead of just one.
|
||||
- CHANGED: Texture now can be either Texture or RenderTexture. No need to change texture source anymore.
|
||||
- ADDED: Material getter functions.
|
||||
- ADDED: Light property functions.
|
||||
- CHANGED: All ReiLua global variables and functions are now stored in global RL table
|
||||
- CHANGED: All examples are now changed to use new RL table method
|
||||
- ADDED: doc_parser creates also ReiLua_API.lua that can be used in projects with Lua Language Server
|
||||
- CHANGED: Switched to Raylib vertion 4.5. Removed some functions and added others. Main changes to camera3D
|
||||
- REVISED: How Lua argumets are handled. Now uluaGet*Index functions can take stack index(positive only)
|
||||
Also using positive stack indexing
|
||||
- ADDED: Camera3D Lua lib
|
||||
- ADDED: Raygui wrapper lib
|
||||
- CHANGED: Can now have multiple Music objects like other Raylib objects instead of just one
|
||||
- CHANGED: Texture now can be either Texture or RenderTexture. No need to change texture source anymore
|
||||
- ADDED: Material getter functions
|
||||
- ADDED: Light property functions
|
||||
- ADDED: rlgl Framebuffer management (fbo) functions
|
||||
- ADDED: rlgl Framebuffer state functions
|
||||
- ADDED: rlgl Textures management functions
|
||||
- ADDED: Texture and RenderTexture can be given as tables
|
||||
|
||||
Detailed changes:
|
||||
- FIXED: uluaGetRay was looking for integers instead of tables.
|
||||
- REMOVED: SetCameraMode.
|
||||
- REMOVED: SetCameraPanControl.
|
||||
- REMOVED: SetCameraAltControl.
|
||||
- REMOVED: SetCameraSmoothZoomControl.
|
||||
- REMOVED: SetCameraMoveControls.
|
||||
- REMOVED: DrawTextureTiled.
|
||||
- REMOVED: DrawTexturePoly.
|
||||
- REMOVED: DrawCubeTexture.
|
||||
- REMOVED: PlaySoundMulti.
|
||||
- REMOVED: StopSoundMulti.
|
||||
- REMOVED: GetSoundsPlaying.
|
||||
- CHANGED: UpdateCamera3D now takes int mode parameter. Same as UpdateCamera in raylib.
|
||||
- ADDED: UpdateCamera3DPro. Same as UpdateCameraPro in raylib.
|
||||
- ADDED: BLEND_CUSTOM_SEPARATE.
|
||||
- FIXED: uluaGetRay was looking for integers instead of tables
|
||||
- REMOVED: SetCameraMode
|
||||
- REMOVED: SetCameraPanControl
|
||||
- REMOVED: SetCameraAltControl
|
||||
- REMOVED: SetCameraSmoothZoomControl
|
||||
- REMOVED: SetCameraMoveControls
|
||||
- REMOVED: DrawTextureTiled
|
||||
- REMOVED: DrawTexturePoly
|
||||
- REMOVED: DrawCubeTexture
|
||||
- REMOVED: PlaySoundMulti
|
||||
- REMOVED: StopSoundMulti
|
||||
- REMOVED: GetSoundsPlaying
|
||||
- CHANGED: UpdateCamera3D now takes int mode parameter. Same as UpdateCamera in raylib
|
||||
- ADDED: UpdateCamera3DPro. Same as UpdateCameraPro in raylib
|
||||
- ADDED: BLEND_CUSTOM_SEPARATE
|
||||
- ADDED: Vector2LineAngle
|
||||
- ADDED: CheckCollisionPointPoly
|
||||
- ADDED: ColorTint
|
||||
@@ -66,8 +70,8 @@ Detailed changes:
|
||||
- REMOVED: GetTextureSource
|
||||
- REMOVED: UnloadRenderTexture
|
||||
- ADDED: GetTextureType
|
||||
- FIXED: Vector3RotateByAxisAngle was not connected.
|
||||
- FIXED: uluaGetBoundingBoxIndex was looking for numbers instead of tables.
|
||||
- FIXED: Vector3RotateByAxisAngle was not registered.
|
||||
- FIXED: uluaGetBoundingBoxIndex was looking for numbers instead of tables
|
||||
- ADDED: IsTextureReady
|
||||
- FIXED: UnloadTexture did not set texture id to NULL.
|
||||
- ADDED: DrawBillboardPro
|
||||
@@ -75,37 +79,39 @@ Detailed changes:
|
||||
- ADDED: More rlgl General render state functions.
|
||||
- ADDED: GetMaterialTexture, GetMaterialColor, GetMaterialValue and GetMaterialShader
|
||||
- ADDED: SetMaterialParams and GetMaterialParams
|
||||
- ADDED: TextureReference functions for RenderTexture texture or depth texture
|
||||
- ADDED: GetTextureId
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||
------------------------------------------------------------------------
|
||||
KEY CHANGES:
|
||||
- ADDED: This changelog.
|
||||
- ADDED: Lua interpreter mode.
|
||||
- ADDED: Easings extra module.
|
||||
- ADDED: exit function.
|
||||
- FIXED: uluaGetNPatchInfo fix for RL_DrawTextureNPatch. Guess this was never tested and did not work at all >:E.
|
||||
- ADDED: Flag option (-s) for doc_parser.lua for exporting module APIs to separate files.
|
||||
- ADDED: ReiLuaGui.
|
||||
- ADDED: ReiLuaGui Examples.
|
||||
- ADDED: Draw Mesh Instanced Example.
|
||||
- CHANGED: RL_DrawQuad3DTexture now takes vertex colors instead of just single color.
|
||||
- ADDED: This changelog
|
||||
- ADDED: Lua interpreter mode
|
||||
- ADDED: Easings extra module
|
||||
- ADDED: exit function
|
||||
- FIXED: uluaGetNPatchInfo fix for RL_DrawTextureNPatch. Guess this was never tested and did not work at all >:E
|
||||
- ADDED: Flag option (-s) for doc_parser.lua for exporting module APIs to separate files
|
||||
- ADDED: ReiLuaGui
|
||||
- ADDED: ReiLuaGui Examples
|
||||
- ADDED: Draw Mesh Instanced Example
|
||||
- CHANGED: RL_DrawQuad3DTexture now takes vertex colors instead of just single color
|
||||
|
||||
Detailed changes:
|
||||
- ADDED: Help argument.
|
||||
- CHANGED: RL_rlSetLineWidth renamed to RL_rlglSetLineWidth.
|
||||
- CHANGED: RL_rlGetLineWidth renamed to RL_rlglGetLineWidth.
|
||||
- FIXED: DrawRectangleGradient V and H expecting wrong arguments.
|
||||
- ADDED: RL_LoadDirectoryFilesEx.
|
||||
- FIXED: RL_DrawLineBezierQuad was called RL_DrawLineBezier in API.
|
||||
- ADDED: Color lib.
|
||||
- FIXED: RL_DrawEllipse and RL_DrawEllipseLines expecting wrong arguments.
|
||||
- ADDED: RL_IsPathFile.
|
||||
- ADDED: RL_SetMaterialShader.
|
||||
- ADDED: RL_GetFileLength.
|
||||
- ADDED: RL_LoadFontEx.
|
||||
- FIXED: RL_ImageAlphaClear expecting wrong arguments.
|
||||
- ADDED: BLEND_ALPHA_PREMULTIPLY.
|
||||
- CHANGED: RL_GetWindowSize renamed to RL_GetScreenSize.
|
||||
- ADDED: RL_GetKeyName and RL_GetKeyScancode. GLFW Functions.
|
||||
- ADDED: KEY_UNKNOWN.
|
||||
- ADDED: Help argument
|
||||
- CHANGED: RL_rlSetLineWidth renamed to RL_rlglSetLineWidth
|
||||
- CHANGED: RL_rlGetLineWidth renamed to RL_rlglGetLineWidth
|
||||
- FIXED: DrawRectangleGradient V and H expecting wrong arguments
|
||||
- ADDED: RL_LoadDirectoryFilesEx
|
||||
- FIXED: RL_DrawLineBezierQuad was called RL_DrawLineBezier in API
|
||||
- ADDED: Color lib
|
||||
- FIXED: RL_DrawEllipse and RL_DrawEllipseLines expecting wrong arguments
|
||||
- ADDED: RL_IsPathFile
|
||||
- ADDED: RL_SetMaterialShader
|
||||
- ADDED: RL_GetFileLength
|
||||
- ADDED: RL_LoadFontEx
|
||||
- FIXED: RL_ImageAlphaClear expecting wrong arguments
|
||||
- ADDED: BLEND_ALPHA_PREMULTIPLY
|
||||
- CHANGED: RL_GetWindowSize renamed to RL_GetScreenSize
|
||||
- ADDED: RL_GetKeyName and RL_GetKeyScancode. GLFW Functions
|
||||
- ADDED: KEY_UNKNOWN
|
||||
|
||||
4
devnotes
4
devnotes
@@ -20,8 +20,8 @@ Backlog {
|
||||
* ImageDrawCircleLines
|
||||
* ImageBlurGaussian
|
||||
* Models
|
||||
* LoadMaterials
|
||||
|
||||
* LoadMaterials (Load materials from model file)
|
||||
* LoadMaterialsFromModel (Could then for example edit and set back to model)
|
||||
* Needs Testing
|
||||
* UpdateTexture
|
||||
* UpdateTextureRec
|
||||
|
||||
@@ -188,9 +188,9 @@ apiFile:write( "\n> Rectangle = { 0.0, 0.0, 1.0, 1.0 } or { x = 0.0, y = 0.0, wi
|
||||
{ x, y, width ,height }. Rectangle type\n\n---\n" )
|
||||
apiFile:write( "\n> Image = ImageId\n\
|
||||
int id. Image type (multiple pixel formats supported). NOTE: Data stored in CPU memory (RAM)\n\n---\n" )
|
||||
apiFile:write( "\n> Texture = TextureId\n\
|
||||
apiFile:write( "\n> Texture = TextureId or { id, width, height, mipmaps, format }\n\
|
||||
int id. Texture type (multiple internal formats supported). NOTE: Data stored in GPU memory (VRAM)\n\n---\n" )
|
||||
apiFile:write( "\n> RenderTexture = RenderTextureId\n\
|
||||
apiFile:write( "\n> RenderTexture = RenderTextureId or { id, texture, depth }\n\
|
||||
int id. RenderTexture type, for texture rendering\n\n---\n" )
|
||||
apiFile:write( "\n> Font = FontId\n\
|
||||
int id. Font type, includes texture and chars data\n\n---\n" )
|
||||
|
||||
@@ -295,5 +295,5 @@ function RL.draw()
|
||||
|
||||
RL.DrawTexturePro( framebuffer, { 0, 0, res.x, -res.y }, { 0, 0, winSize.x, winSize.y }, { 0, 0 }, 0.0, RL.WHITE )
|
||||
|
||||
RL.glBlitFramebuffer( framebuffer, -1, res, winSize, RL.GL_COLOR_BUFFER_BIT, RL.GL_NEAREST )
|
||||
-- RL.glBlitFramebuffer( framebuffer, -1, res, winSize, RL.GL_COLOR_BUFFER_BIT, RL.GL_NEAREST )
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
/* Framebuffer state. */
|
||||
int lrlglEnableFramebuffer( lua_State *L );
|
||||
int lrlglDisableFramebuffer( lua_State *L );
|
||||
int lrlglActiveDrawBuffers( lua_State *L );
|
||||
/* General render state. */
|
||||
int lrlglEnableColorBlend( lua_State *L );
|
||||
int lrlglDisableColorBlend( lua_State *L );
|
||||
@@ -16,3 +20,12 @@ int lrlglEnableSmoothLines( lua_State *L );
|
||||
int lrlglDisableSmoothLines( lua_State *L );
|
||||
/* Initialization functions */
|
||||
int lrlglGetVersion( lua_State *L );
|
||||
/* Textures management */
|
||||
int lrlglLoadTexture( lua_State *L );
|
||||
int lrlglLoadTextureDepth( lua_State *L );
|
||||
int lrlglUnloadTexture( lua_State *L );
|
||||
/* Framebuffer management (fbo) */
|
||||
int lrlglLoadFramebuffer( lua_State *L );
|
||||
int lrlglFramebufferAttach( lua_State *L );
|
||||
int lrlglFramebufferComplete( lua_State *L );
|
||||
int lrlglUnloadFramebuffer( lua_State *L );
|
||||
@@ -7,38 +7,33 @@ void luaCallProcess();
|
||||
void luaCallDraw();
|
||||
void luaCallExit();
|
||||
void luaRegister();
|
||||
/* Lua Util functions */
|
||||
/* Type validators. */
|
||||
bool isValidTexture( lua_State *L, int index );
|
||||
bool isValidRenderTexture( lua_State *L, int index );
|
||||
/* Lua Util functions. */
|
||||
Color uluaGetColor( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Color uluaGetColorIndex( lua_State *L, int index );
|
||||
Vector2 uluaGetVector2( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector2 uluaGetVector2Index( lua_State *L, int index );
|
||||
Vector3 uluaGetVector3( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector3 uluaGetVector3Index( lua_State *L, int index );
|
||||
Vector4 uluaGetVector4( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Vector4 uluaGetVector4Index( lua_State *L, int index );
|
||||
Rectangle uluaGetRectangle( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Rectangle uluaGetRectangleIndex( lua_State *L, int index );
|
||||
Quaternion uluaGetQuaternion( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Quaternion uluaGetQuaternionIndex( lua_State *L, int index );
|
||||
Matrix uluaGetMatrix( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Matrix uluaGetMatrixIndex( lua_State *L, int index );
|
||||
BoundingBox uluaGetBoundingBox( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index );
|
||||
Ray uluaGetRay( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
Ray uluaGetRayIndex( lua_State *L, int index );
|
||||
NPatchInfo uluaGetNPatchInfo( lua_State *L );
|
||||
/* Only works with positive index. */
|
||||
NPatchInfo uluaGetNPatchInfoIndex( lua_State *L, int index );
|
||||
|
||||
Texture uluaGetTexture( lua_State *L, int index );
|
||||
RenderTexture uluaGetRenderTexture( lua_State *L, int index );
|
||||
/* Push types. */
|
||||
void uluaPushColor( lua_State *L, Color color );
|
||||
void uluaPushVector2( lua_State *L, Vector2 vector );
|
||||
void uluaPushVector3( lua_State *L, Vector3 vector );
|
||||
|
||||
@@ -9,6 +9,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
int texRef; /* TextureReference. */
|
||||
Texture texture;
|
||||
RenderTexture renderTexture;
|
||||
} ReiTexture;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
/* TEXTURE_TYPE_ALL is internal and used for accepting every type. */
|
||||
enum TEXTURE_TYPE { TEXTURE_TYPE_TEXTURE, TEXTURE_TYPE_RENDER_TEXTURE, TEXTURE_TYPE_ALL };
|
||||
enum TextureType { TEXTURE_TYPE_TEXTURE, TEXTURE_TYPE_RENDER_TEXTURE, TEXTURE_TYPE_ALL };
|
||||
|
||||
/* Validators. */
|
||||
bool validImage( size_t id );
|
||||
bool validTexture( size_t id, int type );
|
||||
bool validRenderTexture( size_t id );
|
||||
bool validSourceTexture( size_t id );
|
||||
// bool validTexture( size_t id, int type );
|
||||
// bool validTexture( lua_State *L, int index );
|
||||
Texture2D* texturesGetSourceTexture( size_t id );
|
||||
void texturesFreeTexture( size_t id );
|
||||
/* Image Loading. */
|
||||
@@ -91,6 +90,7 @@ int ltexturesGetTextureType( lua_State *L );
|
||||
int ltexturesGenTextureMipmaps( lua_State *L );
|
||||
int ltexturesSetTextureFilter( lua_State *L );
|
||||
int ltexturesSetTextureWrap( lua_State *L );
|
||||
int ltexturesGetTextureId( lua_State *L );
|
||||
int ltexturesGetTextureSize( lua_State *L );
|
||||
int ltexturesGetTextureMipmaps( lua_State *L );
|
||||
int ltexturesGetTextureFormat( lua_State *L );
|
||||
|
||||
@@ -1238,20 +1238,20 @@ Set shader uniform value for texture ( sampler2d )
|
||||
- Success return true
|
||||
*/
|
||||
int lcoreSetShaderValueTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !isValidTexture( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetShaderValueTexture( Shader shader, int locIndex, Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t shaderId = lua_tointeger( L, 1 );
|
||||
int locIndex = lua_tointeger( L, 2 );
|
||||
size_t textureId = lua_tointeger( L, 3 );
|
||||
Texture texture = uluaGetTexture( L, 3 );
|
||||
|
||||
if ( !validShader( shaderId ) || !validTexture( textureId, TEXTURE_TYPE_ALL ) ) {
|
||||
if ( !validShader( shaderId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
SetShaderValueTexture( *state->shaders[ shaderId ], locIndex, *texturesGetSourceTexture( textureId ) );
|
||||
SetShaderValueTexture( *state->shaders[ shaderId ], locIndex, texture );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
|
||||
21
src/gl.c
21
src/gl.c
@@ -18,38 +18,31 @@ Use -1 RenderTexture for window framebuffer.
|
||||
- Success return true
|
||||
*/
|
||||
int lglBlitFramebuffer( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !isValidRenderTexture( L, 1) || !isValidRenderTexture( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.glBlitFramebuffer( RenderTexture srcTex, RenderTexture dstTex, Rectangle srcRect, Rectangle dstRect, int mask, int filter )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
int srcTexId = lua_tointeger( L, 1 );
|
||||
int dstTexId = lua_tointeger( L, 2 );
|
||||
RenderTexture2D srcTex = uluaGetRenderTexture( L, 1 );
|
||||
RenderTexture2D dstTex = uluaGetRenderTexture( L, 2 );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 3 );
|
||||
Rectangle dstRect = uluaGetRectangleIndex( L, 4 );
|
||||
int mask = lua_tointeger( L, 5 );
|
||||
int filter = lua_tointeger( L, 6 );
|
||||
|
||||
// if ( ( !validRenderTexture( srcTexId ) && srcTexId != -1 ) && ( !validRenderTexture( dstTexId ) && dstTexId != -1 ) ) {
|
||||
if ( ( !validTexture( srcTexId, TEXTURE_TYPE_RENDER_TEXTURE ) && srcTexId != -1 )
|
||||
&& ( !validTexture( dstTexId, TEXTURE_TYPE_RENDER_TEXTURE ) && dstTexId != -1 ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( srcTexId == -1 ) {
|
||||
if ( lua_tointeger( L, 1 ) == -1 ) {
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
|
||||
}
|
||||
else {
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, state->textures[ srcTexId ]->renderTexture.id );
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, srcTex.id );
|
||||
}
|
||||
|
||||
if ( dstTexId == -1 ) {
|
||||
if ( lua_tointeger( L, 2 ) == -1 ) {
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
|
||||
}
|
||||
else {
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, state->textures[ dstTexId ]->renderTexture.id );
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, dstTex.id );
|
||||
}
|
||||
|
||||
glBlitFramebuffer(
|
||||
|
||||
144
src/lua_core.c
144
src/lua_core.c
@@ -1018,6 +1018,7 @@ void luaRegister() {
|
||||
assingGlobalFunction( "GenTextureMipmaps", ltexturesGenTextureMipmaps );
|
||||
assingGlobalFunction( "SetTextureFilter", ltexturesSetTextureFilter );
|
||||
assingGlobalFunction( "SetTextureWrap", ltexturesSetTextureWrap );
|
||||
assingGlobalFunction( "GetTextureId", ltexturesGetTextureId );
|
||||
assingGlobalFunction( "GetTextureSize", ltexturesGetTextureSize );
|
||||
assingGlobalFunction( "GetTextureMipmaps", ltexturesGetTextureMipmaps );
|
||||
assingGlobalFunction( "GetTextureFormat", ltexturesGetTextureFormat );
|
||||
@@ -1370,6 +1371,10 @@ void luaRegister() {
|
||||
assingGlobalFunction( "IsLightEnabled", llightsIsLightEnabled );
|
||||
|
||||
/* RLGL */
|
||||
/* Framebuffer state. */
|
||||
assingGlobalFunction( "rlEnableFramebuffer", lrlglEnableFramebuffer );
|
||||
assingGlobalFunction( "rlDisableFramebuffer", lrlglDisableFramebuffer );
|
||||
assingGlobalFunction( "rlActiveDrawBuffers", lrlglActiveDrawBuffers );
|
||||
/* General render state. */
|
||||
assingGlobalFunction( "rlEnableColorBlend", lrlglEnableColorBlend );
|
||||
assingGlobalFunction( "rlDisableColorBlend", lrlglDisableColorBlend );
|
||||
@@ -1386,6 +1391,15 @@ void luaRegister() {
|
||||
assingGlobalFunction( "rlDisableSmoothLines", lrlglDisableSmoothLines );
|
||||
/* Initialization functions. */
|
||||
assingGlobalFunction( "rlGetVersion", lrlglGetVersion );
|
||||
/* Textures management */
|
||||
assingGlobalFunction( "rlLoadTexture", lrlglLoadTexture );
|
||||
assingGlobalFunction( "rlLoadTextureDepth", lrlglLoadTextureDepth );
|
||||
assingGlobalFunction( "rlUnloadTexture", lrlglUnloadTexture );
|
||||
/* Framebuffer management (fbo). */
|
||||
assingGlobalFunction( "rlLoadFramebuffer", lrlglLoadFramebuffer );
|
||||
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
|
||||
assingGlobalFunction( "rlFramebufferComplete", lrlglFramebufferComplete );
|
||||
assingGlobalFunction( "rlUnloadFramebuffer", lrlglUnloadFramebuffer );
|
||||
|
||||
/* OpenGL */
|
||||
/* Framebuffer management. */
|
||||
@@ -1430,6 +1444,28 @@ void luaRegister() {
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
/* Type validators. */
|
||||
|
||||
bool isValidTexture( lua_State *L, int index ) {
|
||||
if ( lua_isnumber( L, index ) || lua_istable( L, index ) ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Invalid texture." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isValidRenderTexture( lua_State *L, int index ) {
|
||||
if ( lua_isnumber( L, index ) || lua_istable( L, index ) ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
TraceLog( LOG_WARNING, "%s", "Error. Invalid renderTexture." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lua util functions. */
|
||||
|
||||
Color uluaGetColor( lua_State *L ) {
|
||||
@@ -1939,6 +1975,114 @@ NPatchInfo uluaGetNPatchInfoIndex( lua_State *L, int index ) {
|
||||
return npatch;
|
||||
}
|
||||
|
||||
Texture uluaGetTexture( lua_State *L, int index ) {
|
||||
Texture texture = { 0 };
|
||||
|
||||
if ( lua_isnumber( L, index ) ) {
|
||||
if ( 0 <= lua_tointeger( L, index ) ) {
|
||||
texture = *texturesGetSourceTexture( lua_tointeger( L, index ) );
|
||||
}
|
||||
}
|
||||
else if ( lua_istable( L, index ) ) {
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
texture.id = lua_tointeger( L, -1 );
|
||||
break;
|
||||
case 1:
|
||||
texture.width = lua_tointeger( L, -1 );
|
||||
break;
|
||||
case 2:
|
||||
texture.height = lua_tointeger( L, -1 );
|
||||
break;
|
||||
case 3:
|
||||
texture.mipmaps = lua_tointeger( L, -1 );
|
||||
break;
|
||||
case 4:
|
||||
texture.format = lua_tointeger( L, -1 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "id", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
texture.id = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "width", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
texture.width = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "height", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
texture.height = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "mipmaps", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
texture.mipmaps = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "format", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
texture.format = lua_tointeger( L, -1 );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
RenderTexture uluaGetRenderTexture( lua_State *L, int index ) {
|
||||
RenderTexture renderTexture = { 0 };
|
||||
|
||||
if ( lua_isnumber( L, index ) ) {
|
||||
if ( 0 <= lua_tointeger( L, index ) ) {
|
||||
renderTexture = state->textures[ lua_tointeger( L, index ) ]->renderTexture;
|
||||
}
|
||||
}
|
||||
else if ( lua_istable( L, index ) ) {
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
renderTexture.id = lua_tointeger( L, -1 );
|
||||
break;
|
||||
case 1:
|
||||
renderTexture.texture = uluaGetTexture( L, lua_gettop( L ) );
|
||||
break;
|
||||
case 2:
|
||||
renderTexture.depth = uluaGetTexture( L, lua_gettop( L ) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "id", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
renderTexture.id = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "texture", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
renderTexture.texture = uluaGetTexture( L, lua_gettop( L ) );
|
||||
}
|
||||
else if ( strcmp( "depth", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
renderTexture.depth = uluaGetTexture( L, lua_gettop( L ) );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return renderTexture;
|
||||
}
|
||||
|
||||
/* Push types. */
|
||||
|
||||
void uluaPushColor( lua_State *L, Color color ) {
|
||||
lua_createtable( L, 3, 0 );
|
||||
lua_pushnumber( L, color.r );
|
||||
|
||||
62
src/models.c
62
src/models.c
@@ -708,14 +708,13 @@ Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ).
|
||||
- Success return true
|
||||
*/
|
||||
int lmodelDrawQuad3DTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawQuad3DTexture( Texture2D texture, Vector3{} vertices, Vector2{} texCoords, Color{} colors )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Texture. */
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
/* Vertices. */
|
||||
Vector3 vertices[4] = { 0 };
|
||||
@@ -761,14 +760,9 @@ int lmodelDrawQuad3DTexture( lua_State *L ) {
|
||||
|
||||
//TODO Normals. maybe something like Vector3Normalize(Vector3CrossProduct(Vector3Subtract(vB, vA), Vector3Subtract(vC, vA)));
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Draw. */
|
||||
rlCheckRenderBatchLimit( 4 );
|
||||
rlSetTexture( texturesGetSourceTexture( texId )->id );
|
||||
rlSetTexture( texture.id );
|
||||
|
||||
rlBegin( RL_QUADS );
|
||||
for ( i = 0; i < 4; ++i ) {
|
||||
@@ -1668,13 +1662,7 @@ int lmodelsCreateMaterial( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t4 ) != 0 ) {
|
||||
if ( strcmp( "texture", (char*)lua_tostring( L, -2 ) ) == 0 && lua_isnumber( L, -1 ) ) {
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->materials[i]->maps[map].texture = *texturesGetSourceTexture( texId );
|
||||
state->materials[i]->maps[map].texture = uluaGetTexture( L, lua_gettop( L ) );
|
||||
}
|
||||
else if ( strcmp( "color", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
|
||||
state->materials[i]->maps[map].color = uluaGetColor( L );
|
||||
@@ -1755,20 +1743,16 @@ Set texture for a material map type ( MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNES
|
||||
- Success return true
|
||||
*/
|
||||
int lmodelsSetMaterialTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !isValidTexture( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMaterialTexture( Material material, int mapType, Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t materialId = lua_tointeger( L, 1 );
|
||||
int mapType = lua_tointeger( L, 2 );
|
||||
size_t texId = lua_tointeger( L, 3 );
|
||||
Texture texture = uluaGetTexture( L, 3 );
|
||||
|
||||
if ( !validMaterial( materialId ) || !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
SetMaterialTexture( state->materials[ materialId ], mapType, *texturesGetSourceTexture( texId ) );
|
||||
SetMaterialTexture( state->materials[ materialId ], mapType, texture );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2197,7 +2181,6 @@ int lmodelsDrawModelEx( lua_State *L ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
DrawModelEx( *state->models[ modelId ], position, rotationAxis, rotationAngle, scale, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
@@ -2266,14 +2249,13 @@ int lmodelsSetModelMeshMaterial( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
size_t modelId = lua_tointeger( L, 1 );
|
||||
int meshId = lua_tointeger( L, 2 );
|
||||
int materialId = lua_tointeger( L, 3 );
|
||||
size_t meshId = lua_tointeger( L, 2 );
|
||||
size_t materialId = lua_tointeger( L, 3 );
|
||||
|
||||
if ( !validModel( modelId ) ) {
|
||||
if ( !validModel( modelId ) || !validMesh( meshId ) || !validMaterial( materialId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetModelMeshMaterial( state->models[ modelId ], meshId, materialId );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
@@ -2289,23 +2271,23 @@ Draw a billboard texture
|
||||
- Success return true
|
||||
*/
|
||||
int lmodelsDrawBillboard( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !lua_isnumber( L, 1 ) || !isValidTexture( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawBillboard( Camera camera, Texture2D texture, Vector3 position, float size, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t cameraId = lua_tointeger( L, 1 );
|
||||
size_t texId = lua_tointeger( L, 2 );
|
||||
Texture texture = uluaGetTexture( L, 2 );
|
||||
Vector3 position = uluaGetVector3Index( L, 3 );
|
||||
float size = lua_tonumber( L, 4 );
|
||||
Color tint = uluaGetColorIndex( L, 5 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) || !validCamera3D( cameraId ) ) {
|
||||
if ( !validCamera3D( cameraId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
DrawBillboard( *state->camera3Ds[ cameraId ], *texturesGetSourceTexture( texId ), position, size, tint );
|
||||
DrawBillboard( *state->camera3Ds[ cameraId ], texture, position, size, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2320,25 +2302,25 @@ Draw a billboard texture defined by source
|
||||
- Success return true
|
||||
*/
|
||||
int lmodelsDrawBillboardRec( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !lua_isnumber( L, 1 ) || !isValidTexture( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_istable( L, 5 ) || !lua_istable( L, 6 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawBillboardRec( Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t cameraId = lua_tointeger( L, 1 );
|
||||
size_t texId = lua_tointeger( L, 2 );
|
||||
Texture texture = uluaGetTexture( L, 2 );
|
||||
Rectangle source = uluaGetRectangleIndex( L, 3 );
|
||||
Vector3 position = uluaGetVector3Index( L, 4 );
|
||||
Vector2 size = uluaGetVector2Index( L, 5 );
|
||||
Color tint = uluaGetColorIndex( L, 6 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) || !validCamera3D( cameraId ) ) {
|
||||
if ( !validCamera3D( cameraId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
// DrawBillboardRec( *state->camera3Ds[ cameraId ], *texturesGetSourceTexture( texId ), source, position, size, tint );
|
||||
DrawBillboardRecNoRatio( *state->camera3Ds[ cameraId ], *texturesGetSourceTexture( texId ), source, position, size, tint );
|
||||
DrawBillboardRecNoRatio( *state->camera3Ds[ cameraId ], texture, source, position, size, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2353,7 +2335,7 @@ Draw a billboard texture defined by source and rotation
|
||||
- Success return true
|
||||
*/
|
||||
int lmodelsDrawBillboardPro( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !lua_isnumber( L, 1 ) || !isValidTexture( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_istable( L, 5 ) || !lua_istable( L, 6 )
|
||||
|| !lua_istable( L, 7 ) || !lua_isnumber( L, 8 ) || !lua_istable( L, 9 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawBillboardPro( Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint )" );
|
||||
@@ -2361,7 +2343,7 @@ int lmodelsDrawBillboardPro( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
size_t cameraId = lua_tointeger( L, 1 );
|
||||
size_t texId = lua_tointeger( L, 2 );
|
||||
Texture texture = uluaGetTexture( L, 2 );
|
||||
Rectangle source = uluaGetRectangleIndex( L, 3 );
|
||||
Vector3 position = uluaGetVector3Index( L, 4 );
|
||||
Vector3 up = uluaGetVector3Index( L, 5 );
|
||||
@@ -2370,12 +2352,12 @@ int lmodelsDrawBillboardPro( lua_State *L ) {
|
||||
float rotation = lua_tonumber( L, 8 );
|
||||
Color tint = uluaGetColorIndex( L, 9 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) || !validCamera3D( cameraId ) ) {
|
||||
if ( !validCamera3D( cameraId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
// DrawBillboardPro( *state->camera3Ds[ cameraId ], *texturesGetSourceTexture( texId ), source, position, up, size, origin, rotation, tint );
|
||||
DrawBillboardProNoRatio( *state->camera3Ds[ cameraId ], *texturesGetSourceTexture( texId ), source, position, up, size, origin, rotation, tint );
|
||||
DrawBillboardProNoRatio( *state->camera3Ds[ cameraId ], texture, source, position, up, size, origin, rotation, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
|
||||
219
src/rlgl.c
219
src/rlgl.c
@@ -3,6 +3,61 @@
|
||||
#include "lua_core.h"
|
||||
#include "lrlgl.h"
|
||||
|
||||
/*
|
||||
## RLGL - Framebuffer state
|
||||
*/
|
||||
|
||||
/*
|
||||
> success = RL.rlEnableFramebuffer( int id )
|
||||
|
||||
Enable render texture (fbo)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lrlglEnableFramebuffer( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlEnableFramebuffer( int id )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
rlEnableFramebuffer( lua_tointeger( L, 1 ) );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.rlDisableFramebuffer()
|
||||
|
||||
Disable render texture (fbo), return to default framebuffer
|
||||
*/
|
||||
int lrlglDisableFramebuffer( lua_State *L ) {
|
||||
rlDisableFramebuffer();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.rlActiveDrawBuffers( int count )
|
||||
|
||||
Activate multiple draw color buffers
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lrlglActiveDrawBuffers( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlActiveDrawBuffers( int count )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
rlActiveDrawBuffers( lua_tointeger( L, 1 ) );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## RLGL - General render state
|
||||
*/
|
||||
@@ -186,3 +241,167 @@ int lrlglGetVersion( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## RLGL - Textures management
|
||||
*/
|
||||
|
||||
/*
|
||||
> id = RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )
|
||||
|
||||
Load texture in GPU
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
*/
|
||||
int lrlglLoadTexture( lua_State *L ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
int format = lua_tointeger( L, 2 );
|
||||
int mipmapCount = lua_tointeger( L, 3 );
|
||||
|
||||
lua_pushinteger( L, rlLoadTexture( NULL, size.x, size.y, format, mipmapCount ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> id = RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer )
|
||||
|
||||
Load depth texture/renderbuffer ( to be attached to fbo )
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
*/
|
||||
int lrlglLoadTextureDepth( lua_State *L ) {
|
||||
if ( !lua_istable( L, 1 ) || !lua_isboolean( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
bool useRenderBuffer = lua_toboolean( L, 2 );
|
||||
|
||||
lua_pushinteger( L, rlLoadTextureDepth( size.x, size.y, useRenderBuffer ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.rlUnloadTexture( int id )
|
||||
|
||||
Unload texture from GPU memory
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lrlglUnloadTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlUnloadTexture( int id )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
rlUnloadTexture( lua_tointeger( L, 1 ) );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## RLGL - Framebuffer management (fbo)
|
||||
*/
|
||||
|
||||
/*
|
||||
> fboId = RL.rlLoadFramebuffer( Vector2 size )
|
||||
|
||||
Load an empty framebuffer
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
*/
|
||||
int lrlglLoadFramebuffer( lua_State *L ) {
|
||||
if ( !lua_istable( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlLoadFramebuffer( Vector2 size )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
Vector2 size = uluaGetVector2Index( L, 1 );
|
||||
|
||||
lua_pushinteger( L, rlLoadFramebuffer( size.x, size.y ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel )
|
||||
|
||||
Attach texture/renderbuffer to a framebuffer
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lrlglFramebufferAttach( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
|
||||
|| !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
unsigned int fboId = lua_tointeger( L, 1 );
|
||||
unsigned int texId = lua_tointeger( L, 2 );
|
||||
int attachType = lua_tointeger( L, 3 );
|
||||
int texType = lua_tointeger( L, 4 );
|
||||
int mipLevel = lua_tointeger( L, 5 );
|
||||
|
||||
rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> isComplete = RL.rlFramebufferComplete( int id )
|
||||
|
||||
Verify framebuffer is complete
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
*/
|
||||
int lrlglFramebufferComplete( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlFramebufferComplete( int id )" );
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
unsigned int id = lua_tointeger( L, 1 );
|
||||
|
||||
lua_pushboolean( L, rlFramebufferComplete( id ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.rlUnloadFramebuffer( int id )
|
||||
|
||||
Delete framebuffer from GPU
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
*/
|
||||
int lrlglUnloadFramebuffer( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlUnloadFramebuffer( int id )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
unsigned int id = lua_tointeger( L, 1 );
|
||||
|
||||
rlUnloadFramebuffer( id );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
10
src/shapes.c
10
src/shapes.c
@@ -18,19 +18,15 @@ defining a font char white rectangle would allow drawing everything in a single
|
||||
- Success return true
|
||||
*/
|
||||
int lshapesSetShapesTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetShapesTexture( Texture2D texture, Rectangle source )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
Rectangle source = uluaGetRectangleIndex( L, 2 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
SetShapesTexture( *texturesGetSourceTexture( texId ), source );
|
||||
SetShapesTexture( texture, source );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
|
||||
225
src/textures.c
225
src/textures.c
@@ -44,19 +44,19 @@ bool validImage( size_t id ) {
|
||||
}
|
||||
}
|
||||
|
||||
bool validTexture( size_t id, int type ) {
|
||||
if ( id < 0 || state->textureCount < id || state->textures[ id ] == NULL ) {
|
||||
TraceLog( LOG_WARNING, "%s %d", "Invalid texture", id );
|
||||
return false;
|
||||
}
|
||||
else if ( type != TEXTURE_TYPE_ALL && type != state->textures[ id ]->type ) {
|
||||
TraceLog( LOG_WARNING, "%s %d", "Wrong texture type", type );
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// bool validTexture( size_t id, int type ) {
|
||||
// if ( id < 0 || state->textureCount < id || state->textures[ id ] == NULL ) {
|
||||
// TraceLog( LOG_WARNING, "%s %d", "Invalid texture", id );
|
||||
// return false;
|
||||
// }
|
||||
// else if ( type != TEXTURE_TYPE_ALL && type != state->textures[ id ]->type ) {
|
||||
// TraceLog( LOG_WARNING, "%s %d", "Wrong texture type", type );
|
||||
// return false;
|
||||
// }
|
||||
// else {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
static int newImage() {
|
||||
int i = 0;
|
||||
@@ -154,19 +154,15 @@ Load image from GPU texture data
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesLoadImageFromTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadImageFromTexture( Texture2D texture )" );
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
int i = newImage();
|
||||
*state->images[i] = LoadImageFromTexture( *texturesGetSourceTexture( texId ) );
|
||||
*state->images[i] = LoadImageFromTexture( texture );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
return 1;
|
||||
@@ -1730,7 +1726,7 @@ int ltexturesLoadRenderTexture( lua_State *L ) {
|
||||
/*
|
||||
> success = RL.UnloadTexture( Texture2D texture )
|
||||
|
||||
Unload texture from GPU memory ( VRAM )
|
||||
Unload texture from GPU memory ( VRAM ). NOTE! Must be texture id.
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
@@ -1743,10 +1739,6 @@ int ltexturesUnloadTexture( lua_State *L ) {
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
texturesFreeTexture( texId );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
@@ -1762,18 +1754,14 @@ Check if a texture is ready
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesIsTextureReady( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsTextureReady( Texture2D texture )" );
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_TEXTURE ) ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
lua_pushboolean( L, IsTextureReady( state->textures[ texId ]->texture) );
|
||||
lua_pushboolean( L, IsTextureReady( texture ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1788,17 +1776,13 @@ NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 25
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesUpdateTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UpdateTexture( Texture2D texture, int{} pixels )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_TEXTURE ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t len = uluaGetTableLenIndex( L, 2 );
|
||||
unsigned char *pixels = malloc( len * 4 * sizeof( unsigned char ) );
|
||||
|
||||
@@ -1822,8 +1806,7 @@ int ltexturesUpdateTexture( lua_State *L ) {
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
// UpdateTexture( *state->textures[ texId ], pixels );
|
||||
UpdateTexture( state->textures[ texId ]->texture, pixels );
|
||||
UpdateTexture( texture, pixels );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
free( pixels );
|
||||
@@ -1841,17 +1824,13 @@ NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 25
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesUpdateTextureRec( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UpdateTextureRec( Texture2D texture, Rectangle rec, int{} pixels )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_TEXTURE ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t len = uluaGetTableLenIndex( L, 3 );
|
||||
unsigned char *pixels = malloc( len * 4 * sizeof( unsigned char ) );
|
||||
|
||||
@@ -1879,7 +1858,7 @@ int ltexturesUpdateTextureRec( lua_State *L ) {
|
||||
|
||||
Rectangle rec = uluaGetRectangleIndex( L, 2 );
|
||||
|
||||
UpdateTextureRec( state->textures[ texId ]->texture, rec, pixels );
|
||||
UpdateTextureRec( texture, rec, pixels );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
free( pixels );
|
||||
@@ -1900,21 +1879,16 @@ Draw a Texture2D
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTexture( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTexture( Texture2D texture, Vector2 position, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
Vector2 pos = uluaGetVector2Index( L, 2 );
|
||||
Color color = uluaGetColorIndex( L, 3 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
DrawTexture( *texturesGetSourceTexture( texId ), pos.x, pos.y, color );
|
||||
DrawTexture( texture, pos.x, pos.y, color );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -1929,22 +1903,17 @@ Draw a part of a texture defined by a rectangle
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTextureRec( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTextureRec( Texture2D texture, Rectangle source, Vector2 position, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 2 );
|
||||
Vector2 pos = uluaGetVector2Index( L, 3 );
|
||||
Color tint = uluaGetColorIndex( L, 4 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
DrawTextureRec( *texturesGetSourceTexture( texId ), srcRect, pos, tint );
|
||||
DrawTextureRec( texture, srcRect, pos, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -1959,25 +1928,20 @@ Draw a part of a texture defined by a rectangle with "pro" parameters
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTexturePro( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTexturePro( Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 2 );
|
||||
Rectangle dstRect = uluaGetRectangleIndex( L, 3 );
|
||||
Vector2 origin = uluaGetVector2Index( L, 4 );
|
||||
float rot = lua_tonumber( L, 5 );
|
||||
Color color = uluaGetColorIndex( L, 6 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
DrawTexturePro( *texturesGetSourceTexture( texId ), srcRect, dstRect, origin, rot, color );
|
||||
DrawTexturePro( texture, srcRect, dstRect, origin, rot, color );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -1992,24 +1956,20 @@ Draws a texture ( or part of it ) that stretches or shrinks nicely
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesDrawTextureNPatch( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
|
||||
|| !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTextureNPatch( Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
NPatchInfo nPatchInfo = uluaGetNPatchInfoIndex( L, 2 );
|
||||
Rectangle dest = uluaGetRectangleIndex( L, 3 );
|
||||
Vector2 origin = uluaGetVector2Index( L, 4 );
|
||||
float rotation = lua_tonumber( L, 5 );
|
||||
Color tint = uluaGetColorIndex( L, 6 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
DrawTextureNPatch( *texturesGetSourceTexture( texId ), nPatchInfo, dest, origin, rotation, tint );
|
||||
DrawTextureNPatch( texture, nPatchInfo, dest, origin, rotation, tint );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2024,19 +1984,14 @@ Begin drawing to render texture
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesBeginTextureMode( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidRenderTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.BeginTextureMode( RenderTexture2D target )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
RenderTexture renderTexture = uluaGetRenderTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_RENDER_TEXTURE ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
BeginTextureMode( state->textures[ texId ]->renderTexture );
|
||||
BeginTextureMode( renderTexture );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2069,10 +2024,6 @@ int ltexturesGetTextureType( lua_State *L ) {
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, state->textures[ texId ]->type );
|
||||
|
||||
return 1;
|
||||
@@ -2091,18 +2042,14 @@ Generate GPU mipmaps for a texture
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesGenTextureMipmaps( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GenTextureMipmaps( Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
GenTextureMipmaps( texturesGetSourceTexture( texId ) );
|
||||
GenTextureMipmaps( &texture );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2117,20 +2064,15 @@ Set texture scaling filter mode ( TEXTURE_FILTER_POINT, TEXTURE_FILTER_BILINEAR.
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesSetTextureFilter( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetTextureFilter( Texture2D texture, int filter )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
int filter = lua_tointeger( L, 2 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetTextureFilter( *texturesGetSourceTexture( texId ), filter );
|
||||
SetTextureFilter( texture, filter );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2145,21 +2087,36 @@ Set texture wrapping mode ( TEXTURE_WRAP_REPEAT, TEXTURE_WRAP_CLAMP... )
|
||||
- Success return true
|
||||
*/
|
||||
int ltexturesSetTextureWrap( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetTextureWrap( Texture2D texture, int wrap )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
int wrap = lua_tointeger( L, 2 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
SetTextureWrap( texture, wrap );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> id = RL.GetTextureId( Texture2D texture )
|
||||
|
||||
Get texture OpenGL id
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGetTextureId( lua_State *L ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetTextureId( Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetTextureWrap( *texturesGetSourceTexture( texId ), wrap );
|
||||
lua_pushboolean( L, true );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
lua_pushinteger( L, texture.id );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -2169,22 +2126,16 @@ int ltexturesSetTextureWrap( lua_State *L ) {
|
||||
|
||||
Get texture size
|
||||
|
||||
- Failure return nil
|
||||
- Failure return false
|
||||
- Success return Vector2
|
||||
*/
|
||||
int ltexturesGetTextureSize( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetTextureSize( Texture2D texture )" );
|
||||
lua_pushnil( L );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
Texture2D texture = *texturesGetSourceTexture( texId );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
uluaPushVector2( L, (Vector2){ texture.width, texture.height } );
|
||||
|
||||
return 1;
|
||||
@@ -2199,18 +2150,12 @@ Get texture mipmaps. Mipmap levels, 1 by default
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGetTextureMipmaps( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetTextureMipmaps( Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Texture2D texture = *texturesGetSourceTexture( texId );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
lua_pushinteger( L, texture.mipmaps );
|
||||
|
||||
return 1;
|
||||
@@ -2225,18 +2170,12 @@ Get texture mipmaps. Mipmap levels, 1 by default
|
||||
- Success return int
|
||||
*/
|
||||
int ltexturesGetTextureFormat( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetTextureFormat( Texture2D texture )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
|
||||
if ( !validImage( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Texture2D texture = *texturesGetSourceTexture( texId );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
lua_pushinteger( L, texture.format );
|
||||
|
||||
return 1;
|
||||
@@ -2516,20 +2455,14 @@ Get pixel color from source texture
|
||||
- Success return Color
|
||||
*/
|
||||
int ltexturesGetPixelColor( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
if ( !isValidTexture( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetPixelColor( Texture2D texture, Vector2 position )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t texId = lua_tointeger( L, 1 );
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
Vector2 pos = uluaGetVector2Index( L, 2 );
|
||||
|
||||
if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
Texture2D *texture = texturesGetSourceTexture( texId );
|
||||
Image srcImage = LoadImageFromTexture( *texture );
|
||||
Image srcImage = LoadImageFromTexture( texture );
|
||||
|
||||
uluaPushColor( L, GetImageColor( srcImage, pos.x, pos.y ) );
|
||||
UnloadImage( srcImage );
|
||||
|
||||
Reference in New Issue
Block a user