1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549 |
- Core Graphics API
- =================
- .. code:: cpp
- #include <graphics/graphics.h>
- Graphics Enumerations
- ---------------------
- .. type:: enum gs_draw_mode
- Draw mode. Can be one of the following values:
- - GS_POINTS - Draws points
- - GS_LINES - Draws individual lines
- - GS_LINESTRIP - Draws a line strip
- - GS_TRIS - Draws individual triangles
- - GS_TRISTRIP - Draws a triangle strip
- .. type:: enum gs_color_format
- Color format. Can be one of the following values:
- - GS_UNKNOWN - Unknown format
- - GS_A8 - 8 bit alpha channel only
- - GS_R8 - 8 bit red channel only
- - GS_RGBA - RGBA, 8 bits per channel
- - GS_BGRX - BGRX, 8 bits per channel
- - GS_BGRA - BGRA, 8 bits per channel
- - GS_R10G10B10A2 - RGBA, 10 bits per channel except alpha, which is 2
- bits
- - GS_RGBA16 - RGBA, 16 bits per channel
- - GS_R16 - 16 bit red channel only
- - GS_RGBA16F - RGBA, 16 bit floating point per channel
- - GS_RGBA32F - RGBA, 32 bit floating point per channel
- - GS_RG16F - 16 bit floating point red and green channels only
- - GS_RG32F - 32 bit floating point red and green channels only
- - GS_R16F - 16 bit floating point red channel only
- - GS_R32F - 32 bit floating point red channel only
- - GS_DXT1 - Compressed DXT1
- - GS_DXT3 - Compressed DXT3
- - GS_DXT5 - Compressed DXT5
- - GS_RGBA_UNORM - RGBA, 8 bits per channel, no SRGB aliasing
- - GS_BGRX_UNORM - BGRX, 8 bits per channel, no SRGB aliasing
- - GS_BGRA_UNORM - BGRA, 8 bits per channel, no SRGB aliasing
- - GS_RG16 - RG, 16 bits per channel
- .. type:: enum gs_zstencil_format
- Z-Stencil buffer format. Can be one of the following values:
- - GS_ZS_NONE - No Z-stencil buffer
- - GS_Z16 - 16 bit Z buffer
- - GS_Z24_S8 - 24 bit Z buffer, 8 bit stencil
- - GS_Z32F - 32 bit floating point Z buffer
- - GS_Z32F_S8X24 - 32 bit floating point Z buffer, 8 bit stencil
- .. type:: enum gs_index_type
- Index buffer type. Can be one of the following values:
- - GS_UNSIGNED_SHORT - 16 bit index
- - GS_UNSIGNED_LONG - 32 bit index
- .. type:: enum gs_cull_mode
- Cull mode. Can be one of the following values:
- - GS_BACK - Cull back faces
- - GS_FRONT - Cull front faces
- - GS_NEITHER - Cull neither
- .. type:: enum gs_blend_type
- Blend type. Can be one of the following values:
- - GS_BLEND_ZERO
- - GS_BLEND_ONE
- - GS_BLEND_SRCCOLOR
- - GS_BLEND_INVSRCCOLOR
- - GS_BLEND_SRCALPHA
- - GS_BLEND_INVSRCALPHA
- - GS_BLEND_DSTCOLOR
- - GS_BLEND_INVDSTCOLOR
- - GS_BLEND_DSTALPHA
- - GS_BLEND_INVDSTALPHA
- - GS_BLEND_SRCALPHASAT
- .. type:: enum gs_depth_test
- Depth test type. Can be one of the following values:
- - GS_NEVER
- - GS_LESS
- - GS_LEQUAL
- - GS_EQUAL
- - GS_GEQUAL
- - GS_GREATER
- - GS_NOTEQUAL
- - GS_ALWAYS
- .. type:: enum gs_stencil_side
- Stencil side. Can be one of the following values:
- - GS_STENCIL_FRONT=1
- - GS_STENCIL_BACK
- - GS_STENCIL_BOTH
- .. type:: enum gs_stencil_op_type
- Stencil operation type. Can be one of the following values:
- - GS_KEEP
- - GS_ZERO
- - GS_REPLACE
- - GS_INCR
- - GS_DECR
- - GS_INVERT
- .. type:: enum gs_cube_sides
- Cubemap side. Can be one of the following values:
- - GS_POSITIVE_X
- - GS_NEGATIVE_X
- - GS_POSITIVE_Y
- - GS_NEGATIVE_Y
- - GS_POSITIVE_Z
- - GS_NEGATIVE_Z
- .. type:: enum gs_sample_filter
- Sample filter type. Can be one of the following values:
- - GS_FILTER_POINT
- - GS_FILTER_LINEAR
- - GS_FILTER_ANISOTROPIC
- - GS_FILTER_MIN_MAG_POINT_MIP_LINEAR
- - GS_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
- - GS_FILTER_MIN_POINT_MAG_MIP_LINEAR
- - GS_FILTER_MIN_LINEAR_MAG_MIP_POINT
- - GS_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
- - GS_FILTER_MIN_MAG_LINEAR_MIP_POINT
- .. type:: enum gs_address_mode
- Address mode. Can be one of the following values:
- - GS_ADDRESS_CLAMP
- - GS_ADDRESS_WRAP
- - GS_ADDRESS_MIRROR
- - GS_ADDRESS_BORDER
- - GS_ADDRESS_MIRRORONCE
- .. type:: enum gs_texture_type
- Texture type. Can be one of the following values:
- - GS_TEXTURE_2D
- - GS_TEXTURE_3D
- - GS_TEXTURE_CUBE
- Graphics Structures
- -------------------
- .. type:: struct gs_monitor_info
- .. member:: int gs_monitor_info.rotation_degrees
- .. member:: long gs_monitor_info.x
- .. member:: long gs_monitor_info.y
- .. member:: long gs_monitor_info.cx
- .. member:: long gs_monitor_info.cy
- ---------------------
- .. type:: struct gs_tvertarray
- .. member:: size_t gs_tvertarray.width
- .. member:: void *gs_tvertarray.array
- ---------------------
- .. type:: struct gs_vb_data
- .. member:: size_t gs_vb_data.num
- .. member:: struct vec3 *gs_vb_data.points
- .. member:: struct vec3 *gs_vb_data.normals
- .. member:: struct vec3 *gs_vb_data.tangents
- .. member:: uint32_t *gs_vb_data.colors
- .. member:: size_t gs_vb_data.num_tex
- .. member:: struct gs_tvertarray *gs_vb_data.tvarray
- ---------------------
- .. type:: struct gs_sampler_info
- .. member:: enum gs_sample_filter gs_sampler_info.filter
- .. member:: enum gs_address_mode gs_sampler_info.address_u
- .. member:: enum gs_address_mode gs_sampler_info.address_v
- .. member:: enum gs_address_mode gs_sampler_info.address_w
- .. member:: int gs_sampler_info.max_anisotropy
- .. member:: uint32_t gs_sampler_info.border_color
- ---------------------
- .. type:: struct gs_display_mode
- .. member:: uint32_t gs_display_mode.width
- .. member:: uint32_t gs_display_mode.height
- .. member:: uint32_t gs_display_mode.bits
- .. member:: uint32_t gs_display_mode.freq
- ---------------------
- .. type:: struct gs_rect
- .. member:: int gs_rect.x
- .. member:: int gs_rect.y
- .. member:: int gs_rect.cx
- .. member:: int gs_rect.cy
- ---------------------
- .. type:: struct gs_window
- A window structure. This structure is used with a native widget.
- .. member:: void *gs_window.hwnd
- (Windows only) an HWND widget.
- .. member:: id gs_window.view
- (Mac only) A view ID.
- .. member:: uint32_t gs_window.id
- void* gs_window.display
- (Linux only) Window ID and display
- ---------------------
- .. type:: struct gs_init_data
- Swap chain initialization data.
- .. member:: struct gs_window gs_init_data.window
- .. member:: uint32_t gs_init_data.cx
- .. member:: uint32_t gs_init_data.cy
- .. member:: uint32_t gs_init_data.num_backbuffers
- .. member:: enum gs_color_format gs_init_data.format
- .. member:: enum gs_zstencil_format gs_init_data.zsformat
- .. member:: uint32_t gs_init_data.adapter
- ---------------------
- Initialization Functions
- ------------------------
- .. function:: void gs_enum_adapters(bool (*callback)(void *param, const char *name, uint32_t id), void *param)
- Enumerates adapters (this really only applies on windows).
- :param callback: Enumeration callback
- :param param: Private data passed to the callback
- ---------------------
- .. function:: int gs_create(graphics_t **graphics, const char *module, uint32_t adapter)
- Creates a graphics context
- :param graphics: Pointer to receive the graphics context
- :param module: Module name
- :param adapter: Adapter index
- :return: Can return one of the following values:
- - GS_SUCCESS
- - GS_ERROR_FAIL
- - GS_ERROR_MODULE_NOT_FOUND
- - GS_ERROR_NOT_SUPPORTED
- ---------------------
- .. function:: void gs_destroy(graphics_t *graphics)
- Destroys a graphics context
- :param graphics: Graphics context
- ---------------------
- .. function:: void gs_enter_context(graphics_t *graphics)
- Enters and locks the graphics context
- :param graphics: Graphics context
- ---------------------
- .. function:: void gs_leave_context(void)
- Leaves and unlocks the graphics context
- :param graphics: Graphics context
- ---------------------
- .. function:: graphics_t *gs_get_context(void)
- :return: The currently locked graphics context for this thread
- ---------------------
- Matrix Stack Functions
- ----------------------
- .. function:: void gs_matrix_push(void)
- Pushes the matrix stack and duplicates the current matrix.
- ---------------------
- .. function:: void gs_matrix_pop(void)
- Pops the current matrix from the matrix stack.
- ---------------------
- .. function:: void gs_matrix_identity(void)
- Sets the current matrix to an identity matrix.
- ---------------------
- .. function:: void gs_matrix_transpose(void)
- Transposes the current matrix.
- ---------------------
- .. function:: void gs_matrix_set(const struct matrix4 *matrix)
- Sets the current matrix.
- :param matrix: The matrix to set
- ---------------------
- .. function:: void gs_matrix_get(struct matrix4 *dst)
- Gets the current matrix
- :param dst: Destination matrix
- ---------------------
- .. function:: void gs_matrix_mul(const struct matrix4 *matrix)
- Multiplies the current matrix
- :param matrix: Matrix to multiply the current stack matrix with
- ---------------------
- .. function:: void gs_matrix_rotquat(const struct quat *rot)
- Multiplies the current matrix with a quaternion
- :param rot: Quaternion to multiple the current matrix stack with
- ---------------------
- .. function:: void gs_matrix_rotaa(const struct axisang *rot)
- void gs_matrix_rotaa4f(float x, float y, float z, float angle)
- Multiplies the current matrix with an axis angle
- :param rot: Axis angle to multiple the current matrix stack with
- ---------------------
- .. function:: void gs_matrix_translate(const struct vec3 *pos)
- void gs_matrix_translate3f(float x, float y, float z)
- Translates the current matrix
- :param pos: Vector to translate the current matrix stack with
- ---------------------
- .. function:: void gs_matrix_scale(const struct vec3 *scale)
- void gs_matrix_scale3f(float x, float y, float z)
- Scales the current matrix
- :param scale: Scale value to scale the current matrix stack with
- ---------------------
- Draw Functions
- --------------
- .. function:: gs_effect_t *gs_get_effect(void)
- :return: The currently active effect, or *NULL* if none active
- ---------------------
- .. function:: void gs_draw_sprite(gs_texture_t *tex, uint32_t flip, uint32_t width, uint32_t height)
- Draws a 2D sprite. Sets the "image" parameter of the current effect
- to the texture and renders a quad.
- If width or height is 0, the width or height of the texture will be
- used. The flip value specifies whether the texture should be flipped
- on the U or V axis with GS_FLIP_U and GS_FLIP_V.
- :param tex: Texture to draw
- :param flip: Can be 0 or a bitwise-OR combination of one of the
- following values:
- - GS_FLIP_U - Flips the texture horizontally
- - GS_FLIP_V - Flips the texture vertically
- :param width: Width
- :param height: Height
- ---------------------
- .. function:: void gs_draw_sprite_subregion(gs_texture_t *tex, uint32_t flip, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
- Draws a subregion of a 2D sprite. Sets the "image" parameter of the
- current effect to the texture and renders a quad.
- :param tex: Texture to draw
- :param flip: Can be 0 or a bitwise-OR combination of one of the
- following values:
- - GS_FLIP_U - Flips the texture horizontally
- - GS_FLIP_V - Flips the texture vertically
- :param x: X value within subregion
- :param y: Y value within subregion
- :param cx: CX value of subregion
- :param cy: CY value of subregion
- ---------------------
- .. function:: void gs_reset_viewport(void)
- Sets the viewport to current swap chain size
- ---------------------
- .. function:: void gs_set_2d_mode(void)
- Sets the projection matrix to a default screen-sized orthographic
- mode
- ---------------------
- .. function:: void gs_set_3d_mode(double fovy, double znear, double zfar)
- Sets the projection matrix to a default screen-sized perspective
- mode
- :param fovy: Field of view (in degrees)
- :param znear: Near plane
- :param zfar: Far plane
- ---------------------
- .. function:: void gs_viewport_push(void)
- Pushes/stores the current viewport
- ---------------------
- .. function:: void gs_viewport_pop(void)
- Pops/recalls the last pushed viewport
- ---------------------
- .. function:: void gs_perspective(float fovy, float aspect, float znear, float zfar)
- Sets the projection matrix to a perspective mode
- :param fovy: Field of view (in degrees)
- :param aspect: Aspect ratio
- :param znear: Near plane
- :param zfar: Far plane
- ---------------------
- .. function:: void gs_blend_state_push(void)
- Pushes/stores the current blend state
- ---------------------
- .. function:: void gs_blend_state_pop(void)
- Pops/restores the last blend state
- ---------------------
- .. function:: void gs_reset_blend_state(void)
- Sets the blend state to the default value: source alpha and invert
- source alpha.
- ---------------------
- Swap Chains
- -----------
- .. function:: gs_swapchain_t *gs_swapchain_create(const struct gs_init_data *data)
- Creates a swap chain (display view on a native widget)
- :param data: Swap chain initialization data
- :return: New swap chain object, or *NULL* if failed
- ---------------------
- .. function:: void gs_swapchain_destroy(gs_swapchain_t *swapchain)
- Destroys a swap chain
- ---------------------
- .. function:: void gs_resize(uint32_t cx, uint32_t cy)
- Resizes the currently active swap chain
- :param cx: New width
- :param cy: New height
- ---------------------
- .. function:: void gs_get_size(uint32_t *cx, uint32_t *cy)
- Gets the size of the currently active swap chain
- :param cx: Pointer to receive width
- :param cy: Pointer to receive height
- ---------------------
- .. function:: uint32_t gs_get_width(void)
- Gets the width of the currently active swap chain
- ---------------------
- .. function:: uint32_t gs_get_height(void)
- Gets the height of the currently active swap chain
- ---------------------
- Resource Loading
- ----------------
- .. function:: void gs_load_vertexbuffer(gs_vertbuffer_t *vertbuffer)
- Loads a vertex buffer
- :param vertbuffer: Vertex buffer to load, or NULL to unload
- ---------------------
- .. function:: void gs_load_indexbuffer(gs_indexbuffer_t *indexbuffer)
- Loads a index buffer
- :param indexbuffer: Index buffer to load, or NULL to unload
- ---------------------
- .. function:: void gs_load_texture(gs_texture_t *tex, int unit)
- Loads a texture (this is usually not called manually)
- :param tex: Texture to load, or NULL to unload
- :param unit: Texture unit to load texture for
- ---------------------
- .. function:: void gs_load_samplerstate(gs_samplerstate_t *samplerstate, int unit)
- Loads a sampler state (this is usually not called manually)
- :param samplerstate: Sampler state to load, or NULL to unload
- :param unit: Texture unit to load sampler state for
- ---------------------
- .. function:: void gs_load_swapchain(gs_swapchain_t *swapchain)
- Loads a swapchain
- :param swapchain: Swap chain to load, or NULL to unload
- ---------------------
- Draw Functions
- --------------
- .. function:: gs_texture_t *gs_get_render_target(void)
- :return: The currently active render target
- ---------------------
- .. function:: gs_zstencil_t *gs_get_zstencil_target(void)
- :return: The currently active Z-stencil target
- ---------------------
- .. function:: void gs_set_render_target(gs_texture_t *tex, gs_zstencil_t *zstencil)
- Sets the active render target
- :param tex: Texture to set as the active render target
- :param zstencil: Z-stencil to use as the active render target
- ---------------------
- .. function:: void gs_set_cube_render_target(gs_texture_t *cubetex, int side, gs_zstencil_t *zstencil)
- Sets a cubemap side as the active render target
- :param cubetex: Cubemap
- :param side: Cubemap side
- :param zstencil: Z-stencil buffer, or *NULL* if none
- ---------------------
- .. function:: void gs_copy_texture(gs_texture_t *dst, gs_texture_t *src)
- Copies a texture
- :param dst: Destination texture
- :param src: Source texture
- ---------------------
- .. function:: void gs_stage_texture(gs_stagesurf_t *dst, gs_texture_t *src)
- Copies a texture to a staging surface and copies it to RAM. Ideally
- best to give this a frame to process to prevent stalling.
- :param dst: Staging surface
- :param src: Texture to stage
- ---------------------
- .. function:: void gs_begin_scene(void)
- void gs_end_scene(void)
- Begins/ends a scene (this is automatically called by libobs, there's
- no need to call this manually).
- ---------------------
- .. function:: void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts)
- Draws a primitive or set of primitives.
- :param draw_mode: The primitive draw mode to use
- :param start_vert: Starting vertex index
- :param num_verts: Number of vertices
- ---------------------
- .. function:: void gs_clear(uint32_t clear_flags, const struct vec4 *color, float depth, uint8_t stencil)
- Clears color/depth/stencil buffers.
- :param clear_flags: Flags to clear with. Can be one of the following
- values:
- - GS_CLEAR_COLOR - Clears color buffer
- - GS_CLEAR_DEPTH - Clears depth buffer
- - GS_CLEAR_STENCIL - Clears stencil buffer
- :param color: Color value to clear the color buffer with
- :param depth: Depth value to clear the depth buffer with
- :param stencil: Stencil value to clear the stencil buffer with
- ---------------------
- .. function:: void gs_present(void)
- Displays what was rendered on to the current render target
- ---------------------
- .. function:: void gs_flush(void)
- Flushes GPU calls
- ---------------------
- .. function:: void gs_set_cull_mode(enum gs_cull_mode mode)
- Sets the current cull mode.
- :param mode: Cull mode
- ---------------------
- .. function:: enum gs_cull_mode gs_get_cull_mode(void)
- :return: The current cull mode
- ---------------------
- .. function:: void gs_enable_blending(bool enable)
- Enables/disables blending
- :param enable: *true* to enable, *false* to disable
- ---------------------
- .. function:: void gs_enable_depth_test(bool enable)
- Enables/disables depth testing
- :param enable: *true* to enable, *false* to disable
- ---------------------
- .. function:: void gs_enable_stencil_test(bool enable)
- Enables/disables stencil testing
- :param enable: *true* to enable, *false* to disable
- ---------------------
- .. function:: void gs_enable_stencil_write(bool enable)
- Enables/disables stencil writing
- :param enable: *true* to enable, *false* to disable
- ---------------------
- .. function:: void gs_enable_color(bool red, bool green, bool blue, bool alpha)
- Enables/disables specific color channels
- :param red: *true* to enable red channel, *false* to disable
- :param green: *true* to enable green channel, *false* to disable
- :param blue: *true* to enable blue channel, *false* to disable
- :param alpha: *true* to enable alpha channel, *false* to disable
- ---------------------
- .. function:: void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest)
- Sets the blend function's source and destination factors
- :param src: Blend type for the blending equation's source factors
- :param dest: Blend type for the blending equation's destination factors
- ---------------------
- .. function:: void gs_blend_function_separate(enum gs_blend_type src_c, enum gs_blend_type dest_c, enum gs_blend_type src_a, enum gs_blend_type dest_a)
- Sets the blend function's source and destination factors for RGB and alpha separately
- :param src_c: Blend type for the blending equation's source RGB factor
- :param dest_c: Blend type for the blending equation's destination RGB factor
- :param src_a: Blend type for the blending equation's source alpha factor
- :param dest_a: Blend type for the blending equation's destination alpha factor
- ---------------------
- .. function:: void gs_blend_op(enum gs_blend_op_type op)
- Sets the blend function's operation type
- :param op: Operation type for the blending equation
- ---------------------
- .. function:: void gs_depth_function(enum gs_depth_test test)
- Sets the depth function
- :param test: Sets the depth test type
- ---------------------
- .. function:: void gs_stencil_function(enum gs_stencil_side side, enum gs_depth_test test)
- Sets the stencil function
- :param side: Stencil side
- :param test: Depth test
- ---------------------
- .. function:: void gs_stencil_op(enum gs_stencil_side side, enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail, enum gs_stencil_op_type zpass)
- Sets the stencil operation
- :param side: Stencil side
- :param fail: Operation to perform on stencil test failure
- :param zfail: Operation to perform on depth test failure
- :param zpass: Operation to perform on depth test success
- ---------------------
- .. function:: void gs_set_viewport(int x, int y, int width, int height)
- Sets the current viewport
- :param x: X position relative to upper left
- :param y: Y position relative to upper left
- :param width: Width of the viewport
- :param height: Height of the viewport
- ---------------------
- .. function:: void gs_get_viewport(struct gs_rect *rect)
- Gets the current viewport
- :param rect: Pointer to receive viewport rectangle
- ---------------------
- .. function:: void gs_set_scissor_rect(const struct gs_rect *rect)
- Sets or clears the current scissor rectangle
- :rect: Scissor rectangle, or *NULL* to clear
- ---------------------
- .. function:: void gs_ortho(float left, float right, float top, float bottom, float znear, float zfar)
- Sets the projection matrix to an orthographic matrix
- ---------------------
- .. function:: void gs_frustum(float left, float right, float top, float bottom, float znear, float zfar)
- Sets the projection matrix to a frustum matrix
- ---------------------
- .. function:: void gs_projection_push(void)
- Pushes/stores the current projection matrix
- ---------------------
- .. function:: void gs_projection_pop(void)
- Pops/restores the last projection matrix pushed
- ---------------------
- Texture Functions
- -----------------
- .. function:: gs_texture_t *gs_texture_create(uint32_t width, uint32_t height, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags)
- Creates a texture.
- :param width: Width
- :param height: Height
- :param color_format: Color format
- :param levels: Number of total texture levels. Set to 1 if no
- mip-mapping
- :param data: Pointer to array of texture data pointers
- :param flags: Can be 0 or a bitwise-OR combination of one or
- more of the following value:
- - GS_BUILD_MIPMAPS - Automatically builds
- mipmaps (Note: not fully tested)
- - GS_DYNAMIC - Dynamic
- - GS_RENDER_TARGET - Render target
- :return: A new texture object
- ---------------------
- .. function:: gs_texture_t *gs_texture_create_from_file(const char *file)
- Creates a texture from a file. Note that this isn't recommended for
- animated gifs -- instead use the :ref:`image_file_helper`.
- :param file: Image file to open
- ---------------------
- .. function:: void gs_texture_destroy(gs_texture_t *tex)
- Destroys a texture
- :param tex: Texture object
- ---------------------
- .. function:: uint32_t gs_texture_get_width(const gs_texture_t *tex)
- Gets the texture's width
- :param tex: Texture object
- :return: The texture's width
- ---------------------
- .. function:: uint32_t gs_texture_get_height(const gs_texture_t *tex)
- Gets the texture's height
- :param tex: Texture object
- :return: The texture's height
- ---------------------
- .. function:: enum gs_color_format gs_texture_get_color_format(const gs_texture_t *tex)
- Gets the texture's color format
- :param tex: Texture object
- :return: The texture's color format
- ---------------------
- .. function:: bool gs_texture_map(gs_texture_t *tex, uint8_t **ptr, uint32_t *linesize)
- Maps a texture.
- :param tex: Texture object
- :param ptr: Pointer to receive the pointer to the texture data
- to write to
- :param linesize: Pointer to receive the line size (pitch) of the
- texture
- ---------------------
- .. function:: void gs_texture_unmap(gs_texture_t *tex)
- Unmaps a texture.
- :param tex: Texture object
- ---------------------
- .. function:: void gs_texture_set_image(gs_texture_t *tex, const uint8_t *data, uint32_t linesize, bool invert)
- Sets the image of a dynamic texture
- :param tex: Texture object
- :param data: Data to set as the image
- :param linesize: Line size (pitch) of the data
- :param invert: *true* to invert vertically, *false* otherwise
- ---------------------
- .. function:: gs_texture_t *gs_texture_create_from_dmabuf(unsigned int width, unsigned int height, uint32_t drm_format, enum gs_color_format color_format, uint32_t n_planes, const int *fds, const uint32_t *strides, const uint32_t *offsets, const uint64_t *modifiers)
- **Linux only:** Creates a texture from DMA-BUF metadata.
- Exchanging DMA-BUFs is a verbose process because of its multiplanar nature.
- For example, YUV can have each plane as a color channel, or a monitor buffer
- can have the cursor stored in a separate plane.
- This function treats the OBS Studio format and the DRM format separately.
- This allows creating textures from DMA-BUFs with unsupported formats (e.g.
- YUV) and perform the color format conversion using shaders. However, be
- careful to always try and match the formats correctly, otherwise textures
- can fail to be created or rendered.
- All modifiers passed in the modifiers array must be equal. Passing different
- modifiers for each plane is unsupported.
- :param width: Width of the texture
- :param height: Height of the texture
- :param drm_format: DRM format of the DMA-BUF buffer
- :param color_format: Color format compatible with OBS Studio
- :param n_planes: Number of planes of the DMA-BUF
- :param fds: Array of size *n_planes* with the file descriptor of each plane
- :param strides: Array of size *n_planes* with the stride of each plane
- :param offsets: Array of size *n_planes* with the offset of each plane
- :param modifiers: Array of size *n_planes* with the modifier of each plane
- :return: A texture object on success, or *NULL* on failure
- :rtype: gs_texture_t*
- ---------------------
- .. type:: enum gs_dmabuf_flags
- DMA-BUF capabilities:
- - GS_DMABUF_FLAG_NONE
- - GS_DMABUF_FLAG_SUPPORTS_IMPLICIT_MODIFIERS - Renderer supports implicit modifiers
- ---------------------
- .. function:: bool *gs_query_dmabuf_capabilities(enum gs_dmabuf_flags *dmabuf_flags, uint32_t **drm_formats, size_t *n_formats)
- **Linux only:** Queries the capabilities for DMA-BUFs.
- Graphics cards can optimize frame buffers by storing them in custom layouts,
- depending on their hardware features. These layouts can make these frame
- buffers unsuitable for linear processing. This function allows querying whether
- the graphics card in use supports implicit modifiers, and the supported texture
- formats.
- The caller must free the `drm_formats` array with `bfree()` after use.
- :param dmabuf_flags: Pointer to receive a capability bitmap
- :param drm_formats: Pointer to receive an array of DRM formats
- :param n_formats: Pointer to receive the number of formats
- :rtype: bool
- ---------------------
- .. function:: bool *gs_query_dmabuf_modifiers_for_format(uint32_t drm_format, uint64_t **modifiers, size_t *n_modifiers)
- **Linux only:** Queries the supported DMA-BUF modifiers for a given format.
- This function queries all supported explicit modifiers for a format,
- stores them as an array and returns the number of supported modifiers.
- The caller must free the `modifiers` array with `bfree()` after use.
- :param drm_format: DRM format of the DMA-BUF buffer
- :param modifiers: Pointer to receive an array of modifiers
- :param n_modifiers: Pointer to receive the number of modifiers
- :rtype: bool
- ---------------------
- .. function:: gs_texture_t *gs_texture_create_from_iosurface(void *iosurf)
- **Mac only:** Creates a texture from an IOSurface.
- :param iosurf: IOSurface object
- ---------------------
- .. function:: bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf)
- **Mac only:** Rebinds a texture to another IOSurface
- :param texture: Texture object
- :param iosuf: IOSurface object
- ---------------------
- .. function:: gs_texture_t *gs_texture_create_gdi(uint32_t width, uint32_t height)
- **Windows only:** Creates a GDI-interop texture
- :param width: Width
- :param height: Height
- ---------------------
- .. function:: void *gs_texture_get_dc(gs_texture_t *gdi_tex)
- **Windows only:** Gets the HDC of a GDI-interop texture. Call
- :c:func:`gs_texture_release_dc()` to release the HDC.
- :param gdi_tex: GDI-interop texture object
- :return: HDC object
- ---------------------
- .. function:: void gs_texture_release_dc(gs_texture_t *gdi_tex)
- **Windows only:** Releases the HDC of the GDI-interop texture.
- :param gdi_tex: GDI-interop texture object
- ---------------------
- .. function:: gs_texture_t *gs_texture_open_shared(uint32_t handle)
- **Windows only:** Creates a texture from a shared texture handle.
- :param handle: Shared texture handle
- :return: A texture object
- ---------------------
- .. function:: bool gs_gdi_texture_available(void)
- **Windows only:** Returns whether GDI-interop textures are available.
- :return: *true* if available, *false* otherwise
- ---------------------
- .. function:: bool gs_shared_texture_available(void)
- **Windows only:** Returns whether shared textures are available.
- :return: *true* if available, *false* otherwise
- ---------------------
- Cube Texture Functions
- ----------------------
- .. function:: gs_texture_t *gs_cubetexture_create(uint32_t size, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags)
- Creates a cubemap texture.
- :param size: Width/height/depth value
- :param color_format: Color format
- :param levels: Number of texture levels
- :param data: Pointer to array of texture data pointers
- :param flags: Can be 0 or a bitwise-OR combination of one or
- more of the following value:
- - GS_BUILD_MIPMAPS - Automatically builds
- mipmaps (Note: not fully tested)
- - GS_DYNAMIC - Dynamic
- - GS_RENDER_TARGET - Render target
- :return: A new cube texture object
- ---------------------
- .. function:: void gs_cubetexture_destroy(gs_texture_t *cubetex)
- Destroys a cube texture.
- :param cubetex: Cube texture object
- ---------------------
- .. function:: uint32_t gs_cubetexture_get_size(const gs_texture_t *cubetex)
- Get the width/height/depth value of a cube texture.
- :param cubetex: Cube texture object
- :return: The width/height/depth value of the cube texture
- ---------------------
- .. function:: enum gs_color_format gs_cubetexture_get_color_format(const gs_texture_t *cubetex)
- Gets the color format of a cube texture.
- :param cubetex: Cube texture object
- :return: The color format of the cube texture
- ---------------------
- .. function:: void gs_cubetexture_set_image(gs_texture_t *cubetex, uint32_t side, const void *data, uint32_t linesize, bool invert)
- Sets an image of a cube texture side.
- :param cubetex: Cube texture object
- :param side: Side
- :param data: Texture data to set
- :param linesize: Line size (pitch) of the texture data
- :param invert: *true* to invert texture data, *false* otherwise
- ---------------------
- Staging Surface Functions
- -------------------------
- Staging surfaces are used to efficiently copy textures from VRAM to RAM.
- .. function:: gs_stagesurf_t *gs_stagesurface_create(uint32_t width, uint32_t height, enum gs_color_format color_format)
- Creates a staging surface.
- :param width: Width
- :param height: Height
- :param color_format: Color format
- :return: The staging surface object
- ---------------------
- .. function:: void gs_stagesurface_destroy(gs_stagesurf_t *stagesurf)
- Destroys a staging surface.
- :param stagesurf: Staging surface object
- ---------------------
- .. function:: uint32_t gs_stagesurface_get_width(const gs_stagesurf_t *stagesurf)
- uint32_t gs_stagesurface_get_height(const gs_stagesurf_t *stagesurf)
- Gets the width/height of a staging surface object.
- :param stagesurf: Staging surface object
- :return: Width/height of the staging surface
- ---------------------
- .. function:: enum gs_color_format gs_stagesurface_get_color_format(const gs_stagesurf_t *stagesurf)
- Gets the color format of a staging surface object.
- :param stagesurf: Staging surface object
- :return: Color format of the staging surface
- ---------------------
- .. function:: bool gs_stagesurface_map(gs_stagesurf_t *stagesurf, uint8_t **data, uint32_t *linesize)
- Maps the staging surface texture (for reading). Call
- :c:func:`gs_stagesurface_unmap()` to unmap when complete.
- :param stagesurf: Staging surface object
- :param data: Pointer to receive texture data pointer
- :param linesize: Pointer to receive line size (pitch) of the texture
- data
- :return: *true* if map successful, *false* otherwise
- ---------------------
- .. function:: void gs_stagesurface_unmap(gs_stagesurf_t *stagesurf)
- Unmaps a staging surface.
- :param stagesurf: Staging surface object
- ---------------------
- Z-Stencil Functions
- -------------------
- .. function:: gs_zstencil_t *gs_zstencil_create(uint32_t width, uint32_t height, enum gs_zstencil_format format)
- Creates a Z-stencil surface object.
- :param width: Width
- :param height: Height
- :param format: Format
- :return: New Z-stencil surface object, or *NULL* if failed
- ---------------------
- .. function:: void gs_zstencil_destroy(gs_zstencil_t *zstencil)
- Destroys a Z-stencil buffer.
- :param zstencil: Z-stencil surface object
- ---------------------
- Sampler State Functions
- -----------------------
- .. function:: gs_samplerstate_t *gs_samplerstate_create(const struct gs_sampler_info *info)
- Creates a sampler state object.
- :param info: Sampler state information
- :return: New sampler state object
- ---------------------
- .. function:: void gs_samplerstate_destroy(gs_samplerstate_t *samplerstate)
- Destroys a sampler state object.
- :param samplerstate: Sampler state object
- ---------------------
- Vertex Buffer Functions
- -----------------------
- .. function:: gs_vertbuffer_t *gs_vertexbuffer_create(struct gs_vb_data *data, uint32_t flags)
- Creates a vertex buffer.
- :param data: Vertex buffer data to create vertex buffer with. The
- structure should be created with gs_vbdata_create(),
- and then buffers in this structure should be allocated
- with :c:func:`bmalloc()`, :c:func:`bzalloc()`, or
- :c:func:`brealloc()`. The ownership of the gs_vb_data
- pointer is then passed to the function, and they should
- not be destroyed by the caller once passed
- :param flags: Creation flags. Can be 0 or a bitwise-OR combination
- of any of the following values:
- - GS_DYNAMIC - Can be dynamically updated in real time.
- - GS_DUP_BUFFER - Do not pass buffer ownership of the
- structure or the buffer pointers within the
- structure.
- :return: A new vertex buffer object, or *NULL* if failed
- ---------------------
- .. function:: void gs_vertexbuffer_destroy(gs_vertbuffer_t *vertbuffer)
- Destroys a vertex buffer object.
- :param vertbuffer: Vertex buffer object
- ---------------------
- .. function:: void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
- Flushes a vertex buffer to its interval vertex data object. To
- modify its internal vertex data, call
- :c:func:`gs_vertexbuffer_get_data()`.
- Can only be used with dynamic vertex buffer objects.
- :param vertbuffer: Vertex buffer object
- ---------------------
- .. function:: void gs_vertexbuffer_flush_direct(gs_vertbuffer_t *vertbuffer, const struct gs_vb_data *data)
- Directly flushes a vertex buffer to the specified vertex buffer data.
- .
- Can only be used with dynamic vertex buffer objects.
- :param vertbuffer: Vertex buffer object
- :param data: Vertex buffer data to flush. Components that
- don't need to be flushed can be left *NULL*
- ---------------------
- .. function:: struct gs_vb_data *gs_vertexbuffer_get_data(const gs_vertbuffer_t *vertbuffer)
- Gets the vertex buffer data associated with a vertex buffer object.
- This data can be changed and vertex buffer can be updated with
- :c:func:`gs_vertexbuffer_flush()`.
- Can only be used with dynamic vertex buffer objects.
- :param vertbuffer: Vertex buffer object
- :return: Vertex buffer data structure
- ---------------------
- Index Buffer Functions
- ----------------------
- .. function:: gs_indexbuffer_t *gs_indexbuffer_create(enum gs_index_type type, void *indices, size_t num, uint32_t flags)
- Creates an index buffer.
- :param type: Index buffer type
- :param indices: Index buffer data. This buffer must be allocated
- with :c:func:`bmalloc()`, :c:func:`bzalloc()`, or
- :c:func:`bralloc()`, and ownership of this buffer is
- passed to the index buffer object.
- :param num: Number of indices in the buffer
- :param flags: Creation flags. Can be 0 or a bitwise-OR combination
- of any of the following values:
- - GS_DYNAMIC - Can be dynamically updated in real time.
- - GS_DUP_BUFFER - Do not pass buffer ownership
- :return: A new index buffer object, or *NULL* if failed
- ---------------------
- .. function:: void gs_indexbuffer_destroy(gs_indexbuffer_t *indexbuffer)
- Destroys an index buffer object.
- :param indexbuffer: Index buffer object
- ---------------------
- .. function:: void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
- Flushes a index buffer to its interval index data object. To modify
- its internal index data, call :c:func:`gs_indexbuffer_get_data()`.
- Can only be used with dynamic index buffer objects.
- :param indexbuffer: Index buffer object
- ---------------------
- .. function:: void gs_indexbuffer_flush_direct(gs_indexbuffer_t *indexbuffer, const void *data)
- Flushes a index buffer to the specified index buffer data.
- Can only be used with dynamic index buffer objects.
- :param indexbuffer: Index buffer object
- :param data: Index buffer data to flush
- ---------------------
- .. function:: void *gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer)
- Gets the index buffer data associated with a index buffer object.
- This data can be changed and index buffer can be updated with
- :c:func:`gs_indexbuffer_flush()`.
- Can only be used with dynamic index buffer objects.
- :param vertbuffer: Index buffer object
- :return: Index buffer data pointer
- ---------------------
- .. function:: size_t gs_indexbuffer_get_num_indices(const gs_indexbuffer_t *indexbuffer)
- Gets the number of indices associated with this index buffer.
- :param indexbuffer: Index buffer object
- :return: Number of indices the vertex buffer object has
- ---------------------
- .. function:: enum gs_index_type gs_indexbuffer_get_type(const gs_indexbuffer_t *indexbuffer)
- Gets the type of index buffer.
- :param indexbuffer: Index buffer object
- :return: Index buffer type
- ---------------------
- Display Duplicator (Windows Only)
- ---------------------------------
- .. function:: gs_duplicator_t *gs_duplicator_create(int monitor_idx)
- ---------------------
- .. function:: void gs_duplicator_destroy(gs_duplicator_t *duplicator)
- ---------------------
- .. function:: bool gs_duplicator_update_frame(gs_duplicator_t *duplicator)
- ---------------------
- .. function:: gs_texture_t *gs_duplicator_get_texture(gs_duplicator_t *duplicator)
- ---------------------
- .. function:: bool gs_get_duplicator_monitor_info(int monitor_idx, struct gs_monitor_info *monitor_info)
- ---------------------
- Render Helper Functions
- -----------------------
- .. function:: void gs_render_start(bool b_new)
- ---------------------
- .. function:: void gs_render_stop(enum gs_draw_mode mode)
- ---------------------
- .. function:: gs_vertbuffer_t *gs_render_save(void)
- ---------------------
- .. function:: void gs_vertex2f(float x, float y)
- ---------------------
- .. function:: void gs_vertex3f(float x, float y, float z)
- ---------------------
- .. function:: void gs_normal3f(float x, float y, float z)
- ---------------------
- .. function:: void gs_color(uint32_t color)
- ---------------------
- .. function:: void gs_texcoord(float x, float y, int unit)
- ---------------------
- .. function:: void gs_vertex2v(const struct vec2 *v)
- ---------------------
- .. function:: void gs_vertex3v(const struct vec3 *v)
- ---------------------
- .. function:: void gs_normal3v(const struct vec3 *v)
- ---------------------
- .. function:: void gs_color4v(const struct vec4 *v)
- ---------------------
- .. function:: void gs_texcoord2v(const struct vec2 *v, int unit)
- ---------------------
- Graphics Types
- --------------
- .. type:: typedef struct gs_duplicator gs_duplicator_t
- .. type:: typedef struct gs_texture gs_texture_t
- .. type:: typedef struct gs_stage_surface gs_stagesurf_t
- .. type:: typedef struct gs_zstencil_buffer gs_zstencil_t
- .. type:: typedef struct gs_vertex_buffer gs_vertbuffer_t
- .. type:: typedef struct gs_index_buffer gs_indexbuffer_t
- .. type:: typedef struct gs_sampler_state gs_samplerstate_t
- .. type:: typedef struct gs_swap_chain gs_swapchain_t
- .. type:: typedef struct gs_texture_render gs_texrender_t
- .. type:: typedef struct gs_shader gs_shader_t
- .. type:: typedef struct gs_shader_param gs_sparam_t
- .. type:: typedef struct gs_device gs_device_t
- .. type:: typedef struct graphics_subsystem graphics_t
|