Skip to content

Commit

Permalink
Improved API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tanis2000 committed Jun 29, 2023
1 parent 39c3d56 commit f434be1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ build/
build-web/
build-win/
sys_config.h
.cache/

# Project specific
32 changes: 16 additions & 16 deletions assets/api/gd.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---@class gd
local m = {}

---@meta

---@class gd
gd = {}

---@class GraphicsDevice
local GraphicsDevice = {}

Expand All @@ -11,46 +11,46 @@ local TextureFormat = {
['GL_RGBA8'] = 0x8058
}

---@return gd GraphicsDevice
function m.new() end
---@return GraphicsDevice gd_instance
function gd.new() end

---@param gd GraphicsDevice an instance of GraphicsDevice
---@param gd_instance GraphicsDevice an instance of GraphicsDevice
---@param win Window an instance of Window
function m.init(gd, win) end
function gd.init(gd_instance, win) end

---@param gd GraphicsDevice an instance of GraphicsDevice
---@param gd_instance GraphicsDevice an instance of GraphicsDevice
---@param window Window an instance of Window
---@param width number width
---@param height number height
---@param viewport kmAABB2 the viewport
---@param camera Camera the camera to apply
function m.render_screen(gd, window, width, height, viewport, camera) end
function gd.render_screen(gd_instance, window, width, height, viewport, camera) end

---@param gd GraphicsDevice an instance of GraphicsDevice
---@param gd_instance GraphicsDevice an instance of GraphicsDevice
---@param r number red 0..1
---@param g number green 0..1
---@param b number blue 0..1
---@param a number alpha 0..1
function m.set_offscreen_clear_color(gd, r, g, b, a) end
function gd.set_offscreen_clear_color(gd_instance, r, g, b, a) end

---@param vs_src string the vertex shader source code
---@param fs_src string the fragment shader source code
---@return shader the instance of the shader that contains the shader descriptor and later on the reference to the compiled shader and the reference to the pipeline
function m.create_shader_desc(vs_src, fs_src) end
function gd.create_shader_desc(vs_src, fs_src) end

---@param shader shader the shader instance
---@param stage string the shader stage, either VS or FS
---@param idx number the index of the uniform, starting at 0
---@param name string the name of the uniform (case sensitive)
---@param type string the type of the uniform (float, vec2, vec3, vec4, mat4)
function m.add_uniform_to_shader_desc(shader, stage, idx, name, type) end
function gd.add_uniform_to_shader_desc(shader, stage, idx, name, type) end

---Compiles the shader description into a shader and keeps a reference to the compiled shader as part of the shader instance itself
---@param shader shader the shader instance
function m.create_shader(shader) end
function gd.create_shader(shader) end

---Creates the pipeline for the shader based on the offscreen pipeline and using the shader defined in the shader instance
---@param shader shader the shader instance
function m.create_pipeline(shader) end
function gd.create_pipeline(shader) end

return m
return gd
5 changes: 3 additions & 2 deletions assets/api/spritebatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function sprite_batch.set_gd(batch, gd) end
---@param camera Camera the Camera instance
---@param shader Shader the Shader instance
---@param viewport kmAABB2 the viewport to use when drawing. It might be different than the one used by the ViewAdapter attached to the camera
function sprite_batch.begin(batch, camera, shader, viewport) end
---@param sort string the sorting mode to apply to this batch
function sprite_batch.begin(batch, camera, shader, viewport, sort) end

---@param batch SpriteBatch the SpriteBatch instance
---@param camera Camera the Camera instance
Expand All @@ -31,4 +32,4 @@ function sprite_batch.finish(batch, camera, viewport) end
---@param depth number the depth
function sprite_batch.draw(batch, texture, x, y, depth) end

return sprite_batch
return sprite_batch
4 changes: 2 additions & 2 deletions assets/api/viewportadapter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local ViewportAdapter = {}
---@param height number
---@param virtual_width number
---@param virtual_height number
---@return viewport_adapter ViewportAdapter
---@return ViewportAdapter viewport_adapter viewport adapter instance
function viewport_adapter.new(window, kind, scaling, width, height, virtual_width, virtual_height) end

---@param viewport_adapter ViewportAdapter an instance of ViewportAdapter
Expand All @@ -36,4 +36,4 @@ function viewport_adapter.get_multiplier(viewport_adapter) end
---@return number the inverse multiplier of the viewport
function viewport_adapter.get_inverse_multiplier(viewport_adapter) end

return viewport_adapter
return viewport_adapter

0 comments on commit f434be1

Please sign in to comment.