Open Broadcaster Software
Free, open source software for live streaming and recording
graphics.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "../util/bmem.h"
21 #include "input.h"
22 #ifdef __APPLE__
23 #include <objc/objc-runtime.h>
24 #endif
25 
26 /*
27  * This is an API-independent graphics subsystem wrapper.
28  *
29  * This allows the use of OpenGL and different Direct3D versions through
30  * one shared interface.
31  */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define GS_MAX_TEXTURES 8
38 
39 struct vec2;
40 struct vec3;
41 struct vec4;
42 struct quat;
43 struct axisang;
44 struct plane;
45 struct matrix3;
46 struct matrix4;
47 
54 };
55 
76 };
77 
84 };
85 
89 };
90 
95 };
96 
109 };
110 
120 };
121 
126 };
127 
135 };
136 
144 };
145 
156 };
157 
164 };
165 
170 };
171 
174  long x;
175  long y;
176  long cx;
177  long cy;
178 };
179 
181  size_t width;
182  void *array;
183 };
184 
185 struct gs_vb_data {
186  size_t num;
187  struct vec3 *points;
188  struct vec3 *normals;
189  struct vec3 *tangents;
191 
192  size_t num_tex;
194 };
195 
196 static inline struct gs_vb_data *gs_vbdata_create(void)
197 {
198  return (struct gs_vb_data*)bzalloc(sizeof(struct gs_vb_data));
199 }
200 
201 static inline void gs_vbdata_destroy(struct gs_vb_data *data)
202 {
203  uint32_t i;
204  if (!data)
205  return;
206 
207  bfree(data->points);
208  bfree(data->normals);
209  bfree(data->tangents);
210  bfree(data->colors);
211  for (i = 0; i < data->num_tex; i++)
212  bfree(data->tvarray[i].array);
213  bfree(data->tvarray);
214  bfree(data);
215 }
216 
224 };
225 
231 };
232 
233 struct gs_rect {
234  int x;
235  int y;
236  int cx;
237  int cy;
238 };
239 
240 /* wrapped opaque data types */
241 
242 struct gs_texture;
243 struct gs_stage_surface;
244 struct gs_zstencil_buffer;
245 struct gs_vertex_buffer;
246 struct gs_index_buffer;
247 struct gs_sampler_state;
248 struct gs_shader;
249 struct gs_swap_chain;
250 struct gs_texrender;
251 struct gs_shader_param;
252 struct gs_effect;
253 struct gs_effect_technique;
254 struct gs_effect_pass;
255 struct gs_effect_param;
256 struct gs_device;
257 struct graphics_subsystem;
258 
259 typedef struct gs_texture gs_texture_t;
260 typedef struct gs_stage_surface gs_stagesurf_t;
261 typedef struct gs_zstencil_buffer gs_zstencil_t;
262 typedef struct gs_vertex_buffer gs_vertbuffer_t;
263 typedef struct gs_index_buffer gs_indexbuffer_t;
264 typedef struct gs_sampler_state gs_samplerstate_t;
265 typedef struct gs_swap_chain gs_swapchain_t;
266 typedef struct gs_texture_render gs_texrender_t;
267 typedef struct gs_shader gs_shader_t;
268 typedef struct gs_shader_param gs_sparam_t;
269 typedef struct gs_effect gs_effect_t;
271 typedef struct gs_effect_pass gs_epass_t;
273 typedef struct gs_device gs_device_t;
275 
276 /* ---------------------------------------------------
277  * shader functions
278  * --------------------------------------------------- */
279 
294 };
295 
296 #ifndef SWIG
299  const char *name;
300 };
301 
305 };
306 
307 EXPORT void gs_shader_destroy(gs_shader_t *shader);
308 
309 EXPORT int gs_shader_get_num_params(const gs_shader_t *shader);
311  uint32_t param);
313  const char *name);
314 
317 
319  struct gs_shader_param_info *info);
320 EXPORT void gs_shader_set_bool(gs_sparam_t *param, bool val);
321 EXPORT void gs_shader_set_float(gs_sparam_t *param, float val);
322 EXPORT void gs_shader_set_int(gs_sparam_t *param, int val);
323 EXPORT void gs_shader_set_matrix3(gs_sparam_t *param, const struct matrix3 *val);
324 EXPORT void gs_shader_set_matrix4(gs_sparam_t *param, const struct matrix4 *val);
325 EXPORT void gs_shader_set_vec2(gs_sparam_t *param, const struct vec2 *val);
326 EXPORT void gs_shader_set_vec3(gs_sparam_t *param, const struct vec3 *val);
327 EXPORT void gs_shader_set_vec4(gs_sparam_t *param, const struct vec4 *val);
329 EXPORT void gs_shader_set_val(gs_sparam_t *param, const void *val, size_t size);
332  gs_samplerstate_t *sampler);
333 #endif
334 
335 /* ---------------------------------------------------
336  * effect functions
337  * --------------------------------------------------- */
338 
339 /*enum gs_effect_property_type {
340  GS_EFFECT_NONE,
341  GS_EFFECT_BOOL,
342  GS_EFFECT_FLOAT,
343  GS_EFFECT_COLOR,
344  GS_EFFECT_TEXTURE
345 };*/
346 
347 #ifndef SWIG
349  const char *name;
351 
352  /* const char *full_name;
353  enum gs_effect_property_type prop_type;
354 
355  float min, max, inc, mul; */
356 };
357 #endif
358 
359 EXPORT void gs_effect_destroy(gs_effect_t *effect);
360 
362  const char *name);
363 
365  const gs_effect_t *effect);
366 
367 EXPORT size_t gs_technique_begin(gs_technique_t *technique);
368 EXPORT void gs_technique_end(gs_technique_t *technique);
369 EXPORT bool gs_technique_begin_pass(gs_technique_t *technique, size_t pass);
371  const char *name);
374  size_t pass);
376  const gs_technique_t *technique, const char *name);
377 
378 EXPORT size_t gs_effect_get_num_params(const gs_effect_t *effect);
380  size_t param);
382  const char *name);
383 EXPORT size_t gs_param_get_num_annotations(const gs_eparam_t *param);
385  size_t annotation);
387  const char *name);
388 
392 EXPORT bool gs_effect_loop(gs_effect_t *effect, const char *name);
393 
396 
399 
400 #ifndef SWIG
402  struct gs_effect_param_info *info);
403 #endif
404 
405 EXPORT void gs_effect_set_bool(gs_eparam_t *param, bool val);
406 EXPORT void gs_effect_set_float(gs_eparam_t *param, float val);
407 EXPORT void gs_effect_set_int(gs_eparam_t *param, int val);
409  const struct matrix4 *val);
410 EXPORT void gs_effect_set_vec2(gs_eparam_t *param, const struct vec2 *val);
411 EXPORT void gs_effect_set_vec3(gs_eparam_t *param, const struct vec3 *val);
412 EXPORT void gs_effect_set_vec4(gs_eparam_t *param, const struct vec4 *val);
414 EXPORT void gs_effect_set_val(gs_eparam_t *param, const void *val, size_t size);
417 EXPORT void *gs_effect_get_val(gs_eparam_t *param);
421  gs_samplerstate_t *sampler);
422 
424 
425 /* ---------------------------------------------------
426  * texture render helper functions
427  * --------------------------------------------------- */
428 
430  enum gs_zstencil_format zsformat);
433  uint32_t cy);
434 EXPORT void gs_texrender_end(gs_texrender_t *texrender);
435 EXPORT void gs_texrender_reset(gs_texrender_t *texrender);
437 
438 /* ---------------------------------------------------
439  * graphics subsystem
440  * --------------------------------------------------- */
441 
442 #define GS_BUILD_MIPMAPS (1<<0)
443 #define GS_DYNAMIC (1<<1)
444 #define GS_RENDER_TARGET (1<<2)
445 #define GS_GL_DUMMYTEX (1<<3)
446 #define GS_DUP_BUFFER (1<<4)
448 #define GS_SHARED_TEX (1<<5)
449 #define GS_SHARED_KM_TEX (1<<6)
451 /* ---------------- */
452 /* global functions */
453 
454 #define GS_SUCCESS 0
455 #define GS_ERROR_FAIL -1
456 #define GS_ERROR_MODULE_NOT_FOUND -2
457 #define GS_ERROR_NOT_SUPPORTED -3
459 struct gs_window {
460 #if defined(_WIN32)
461  void *hwnd;
462 #elif defined(__APPLE__)
463  __unsafe_unretained id view;
464 #elif defined(__linux__) || defined(__FreeBSD__)
465  /* I'm not sure how portable defining id to uint32_t is. */
466  uint32_t id;
467  void* display;
468 #endif
469 };
470 
471 struct gs_init_data {
478 };
479 
480 #define GS_DEVICE_OPENGL 1
481 #define GS_DEVICE_DIRECT3D_11 2
483 EXPORT const char *gs_get_device_name(void);
484 EXPORT int gs_get_device_type(void);
486  bool (*callback)(void *param, const char *name, uint32_t id),
487  void *param);
488 
489 EXPORT int gs_create(graphics_t **graphics, const char *module,
490  uint32_t adapter);
491 EXPORT void gs_destroy(graphics_t *graphics);
492 
493 EXPORT void gs_enter_context(graphics_t *graphics);
494 EXPORT void gs_leave_context(void);
496 
497 EXPORT void gs_matrix_push(void);
498 EXPORT void gs_matrix_pop(void);
499 EXPORT void gs_matrix_identity(void);
500 EXPORT void gs_matrix_transpose(void);
501 EXPORT void gs_matrix_set(const struct matrix4 *matrix);
502 EXPORT void gs_matrix_get(struct matrix4 *dst);
503 EXPORT void gs_matrix_mul(const struct matrix4 *matrix);
504 EXPORT void gs_matrix_rotquat(const struct quat *rot);
505 EXPORT void gs_matrix_rotaa(const struct axisang *rot);
506 EXPORT void gs_matrix_translate(const struct vec3 *pos);
507 EXPORT void gs_matrix_scale(const struct vec3 *scale);
508 EXPORT void gs_matrix_rotaa4f(float x, float y, float z, float angle);
509 EXPORT void gs_matrix_translate3f(float x, float y, float z);
510 EXPORT void gs_matrix_scale3f(float x, float y, float z);
511 
512 EXPORT void gs_render_start(bool b_new);
513 EXPORT void gs_render_stop(enum gs_draw_mode mode);
515 EXPORT void gs_vertex2f(float x, float y);
516 EXPORT void gs_vertex3f(float x, float y, float z);
517 EXPORT void gs_normal3f(float x, float y, float z);
518 EXPORT void gs_color(uint32_t color);
519 EXPORT void gs_texcoord(float x, float y, int unit);
520 EXPORT void gs_vertex2v(const struct vec2 *v);
521 EXPORT void gs_vertex3v(const struct vec3 *v);
522 EXPORT void gs_normal3v(const struct vec3 *v);
523 EXPORT void gs_color4v(const struct vec4 *v);
524 EXPORT void gs_texcoord2v(const struct vec2 *v, int unit);
525 
528 
530  char **error_string);
531 EXPORT gs_effect_t *gs_effect_create(const char *effect_string,
532  const char *filename, char **error_string);
533 
535  char **error_string);
537  char **error_string);
538 
540 EXPORT uint8_t *gs_create_texture_file_data(const char *file,
541  enum gs_color_format *format, uint32_t *cx, uint32_t *cy);
542 
543 #define GS_FLIP_U (1<<0)
544 #define GS_FLIP_V (1<<1)
553 EXPORT void gs_draw_sprite(gs_texture_t *tex, uint32_t flip, uint32_t width,
554  uint32_t height);
555 
557  uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
558 
559 EXPORT void gs_draw_cube_backdrop(gs_texture_t *cubetex, const struct quat *rot,
560  float left, float right, float top, float bottom, float znear);
561 
563 EXPORT void gs_reset_viewport(void);
564 
566 EXPORT void gs_set_2d_mode(void);
568 EXPORT void gs_set_3d_mode(double fovy, double znear, double zvar);
569 
570 EXPORT void gs_viewport_push(void);
571 EXPORT void gs_viewport_pop(void);
572 
573 EXPORT void gs_texture_set_image(gs_texture_t *tex, const uint8_t *data,
574  uint32_t linesize, bool invert);
576  const void *data, uint32_t linesize, bool invert);
577 
578 EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar);
579 
580 EXPORT void gs_blend_state_push(void);
581 EXPORT void gs_blend_state_pop(void);
582 EXPORT void gs_reset_blend_state(void);
583 
584 /* -------------------------- */
585 /* library-specific functions */
586 
588 
589 EXPORT void gs_resize(uint32_t x, uint32_t y);
590 EXPORT void gs_get_size(uint32_t *x, uint32_t *y);
593 
595  enum gs_color_format color_format, uint32_t levels,
596  const uint8_t **data, uint32_t flags);
598  enum gs_color_format color_format, uint32_t levels,
599  const uint8_t **data, uint32_t flags);
601  uint32_t depth, enum gs_color_format color_format,
602  uint32_t levels, const uint8_t **data, uint32_t flags);
603 
605  enum gs_zstencil_format format);
606 
608  enum gs_color_format color_format);
609 
611  const struct gs_sampler_info *info);
612 
613 EXPORT gs_shader_t *gs_vertexshader_create(const char *shader,
614  const char *file, char **error_string);
615 EXPORT gs_shader_t *gs_pixelshader_create(const char *shader,
616  const char *file, char **error_string);
617 
619  uint32_t flags);
621  void *indices, size_t num, uint32_t flags);
622 
624 
626 EXPORT void gs_load_indexbuffer(gs_indexbuffer_t *indexbuffer);
627 EXPORT void gs_load_texture(gs_texture_t *tex, int unit);
628 EXPORT void gs_load_samplerstate(gs_samplerstate_t *samplerstate, int unit);
629 EXPORT void gs_load_vertexshader(gs_shader_t *vertshader);
630 EXPORT void gs_load_pixelshader(gs_shader_t *pixelshader);
631 
632 EXPORT void gs_load_default_samplerstate(bool b_3d, int unit);
633 
636 
639 
641 EXPORT void gs_set_cube_render_target(gs_texture_t *cubetex, int side,
642  gs_zstencil_t *zstencil);
643 
646  gs_texture_t *dst, uint32_t dst_x, uint32_t dst_y,
647  gs_texture_t *src, uint32_t src_x, uint32_t src_y,
648  uint32_t src_w, uint32_t src_h);
650 
651 EXPORT void gs_begin_scene(void);
652 EXPORT void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert,
653  uint32_t num_verts);
654 EXPORT void gs_end_scene(void);
655 
656 #define GS_CLEAR_COLOR (1<<0)
657 #define GS_CLEAR_DEPTH (1<<1)
658 #define GS_CLEAR_STENCIL (1<<2)
660 EXPORT void gs_load_swapchain(gs_swapchain_t *swapchain);
661 EXPORT void gs_clear(uint32_t clear_flags, const struct vec4 *color,
662  float depth, uint8_t stencil);
663 EXPORT void gs_present(void);
664 EXPORT void gs_flush(void);
665 
666 EXPORT void gs_set_cull_mode(enum gs_cull_mode mode);
668 
669 EXPORT void gs_enable_blending(bool enable);
670 EXPORT void gs_enable_depth_test(bool enable);
671 EXPORT void gs_enable_stencil_test(bool enable);
672 EXPORT void gs_enable_stencil_write(bool enable);
673 EXPORT void gs_enable_color(bool red, bool green, bool blue, bool alpha);
674 
675 EXPORT void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest);
677  enum gs_blend_type src_c, enum gs_blend_type dest_c,
678  enum gs_blend_type src_a, enum gs_blend_type dest_a);
679 EXPORT void gs_depth_function(enum gs_depth_test test);
680 
682  enum gs_depth_test test);
683 EXPORT void gs_stencil_op(enum gs_stencil_side side,
684  enum gs_stencil_op_type fail,
685  enum gs_stencil_op_type zfail,
686  enum gs_stencil_op_type zpass);
687 
688 EXPORT void gs_set_viewport(int x, int y, int width, int height);
689 EXPORT void gs_get_viewport(struct gs_rect *rect);
690 EXPORT void gs_set_scissor_rect(const struct gs_rect *rect);
691 
692 EXPORT void gs_ortho(float left, float right, float top, float bottom,
693  float znear, float zfar);
694 EXPORT void gs_frustum(float left, float right, float top, float bottom,
695  float znear, float zfar);
696 
697 EXPORT void gs_projection_push(void);
698 EXPORT void gs_projection_pop(void);
699 
701 
706  const gs_texture_t *tex);
707 EXPORT bool gs_texture_map(gs_texture_t *tex, uint8_t **ptr,
708  uint32_t *linesize);
713 EXPORT bool gs_texture_is_rect(const gs_texture_t *tex);
719 
723  const gs_texture_t *cubetex);
724 
730  const gs_texture_t *voltex);
731 
736  const gs_stagesurf_t *stagesurf);
737 EXPORT bool gs_stagesurface_map(gs_stagesurf_t *stagesurf, uint8_t **data,
738  uint32_t *linesize);
740 
742 
744 
748  const struct gs_vb_data *data);
750  const gs_vertbuffer_t *vertbuffer);
751 
753 EXPORT void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer);
755  const void *data);
756 EXPORT void *gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer);
758  const gs_indexbuffer_t *indexbuffer);
760  const gs_indexbuffer_t *indexbuffer);
761 
762 EXPORT bool gs_nv12_available(void);
763 
764 #ifdef __APPLE__
765 
768 EXPORT gs_texture_t *gs_texture_create_from_iosurface(void *iosurf);
769 EXPORT bool gs_texture_rebind_iosurface(gs_texture_t *texture,
770  void *iosurf);
771 
772 #elif _WIN32
773 
774 EXPORT bool gs_gdi_texture_available(void);
775 EXPORT bool gs_shared_texture_available(void);
776 
777 struct gs_duplicator;
778 typedef struct gs_duplicator gs_duplicator_t;
779 
784 EXPORT bool gs_get_duplicator_monitor_info(int monitor_idx,
785  struct gs_monitor_info *monitor_info);
786 
788 EXPORT gs_duplicator_t *gs_duplicator_create(int monitor_idx);
789 EXPORT void gs_duplicator_destroy(gs_duplicator_t *duplicator);
790 
791 EXPORT bool gs_duplicator_update_frame(gs_duplicator_t *duplicator);
792 EXPORT gs_texture_t *gs_duplicator_get_texture(gs_duplicator_t *duplicator);
793 
795 EXPORT gs_texture_t *gs_texture_create_gdi(uint32_t width, uint32_t height);
796 
797 EXPORT void *gs_texture_get_dc(gs_texture_t *gdi_tex);
798 EXPORT void gs_texture_release_dc(gs_texture_t *gdi_tex);
799 
801 EXPORT gs_texture_t *gs_texture_open_shared(uint32_t handle);
802 
803 #define GS_INVALID_HANDLE (uint32_t)-1
804 EXPORT uint32_t gs_texture_get_shared_handle(gs_texture_t *tex);
805 
806 #define GS_WAIT_INFINITE (uint32_t)-1
807 
812 EXPORT int gs_texture_acquire_sync(gs_texture_t *tex, uint64_t key, uint32_t ms);
813 
818 EXPORT int gs_texture_release_sync(gs_texture_t *tex, uint64_t key);
819 
820 EXPORT bool gs_texture_create_nv12(gs_texture_t **tex_y, gs_texture_t **tex_uv,
821  uint32_t width, uint32_t height, uint32_t flags);
822 
823 EXPORT gs_stagesurf_t *gs_stagesurface_create_nv12(
824  uint32_t width, uint32_t height);
825 
826 #endif
827 
828 /* inline functions used by modules */
829 
830 static inline uint32_t gs_get_format_bpp(enum gs_color_format format)
831 {
832  switch (format) {
833  case GS_A8: return 8;
834  case GS_R8: return 8;
835  case GS_RGBA: return 32;
836  case GS_BGRX: return 32;
837  case GS_BGRA: return 32;
838  case GS_R10G10B10A2: return 32;
839  case GS_RGBA16: return 64;
840  case GS_R16: return 16;
841  case GS_RGBA16F: return 64;
842  case GS_RGBA32F: return 128;
843  case GS_RG16F: return 32;
844  case GS_RG32F: return 64;
845  case GS_R16F: return 16;
846  case GS_R32F: return 32;
847  case GS_DXT1: return 4;
848  case GS_DXT3: return 8;
849  case GS_DXT5: return 8;
850  case GS_R8G8: return 16;
851  case GS_UNKNOWN: return 0;
852  }
853 
854  return 0;
855 }
856 
857 static inline bool gs_is_compressed_format(enum gs_color_format format)
858 {
859  return (format == GS_DXT1 || format == GS_DXT3 || format == GS_DXT5);
860 }
861 
862 static inline uint32_t gs_get_total_levels(uint32_t width, uint32_t height)
863 {
864  uint32_t size = width > height ? width : height;
865  uint32_t num_levels = 0;
866 
867  while (size > 1) {
868  size /= 2;
869  num_levels++;
870  }
871 
872  return num_levels;
873 }
874 
875 #ifdef __cplusplus
876 }
877 #endif
EXPORT void gs_texture_unmap(gs_texture_t *tex)
Definition: graphics.h:50
Definition: graphics.h:81
EXPORT gs_sparam_t * gs_shader_get_viewproj_matrix(const gs_shader_t *shader)
struct vec3 * points
Definition: graphics.h:187
Definition: graphics.h:60
EXPORT gs_shader_t * gs_pixelshader_create_from_file(const char *file, char **error_string)
Definition: graphics.h:112
EXPORT void gs_effect_set_vec4(gs_eparam_t *param, const struct vec4 *val)
EXPORT void gs_stagesurface_unmap(gs_stagesurf_t *stagesurf)
Definition: graphics.h:71
uint32_t cx
Definition: graphics.h:474
EXPORT void gs_frustum(float left, float right, float top, float bottom, float znear, float zfar)
EXPORT void gs_load_swapchain(gs_swapchain_t *swapchain)
gs_texture_type
Definition: graphics.h:166
EXPORT void gs_effect_set_texture(gs_eparam_t *param, gs_texture_t *val)
enum gs_address_mode address_w
Definition: graphics.h:221
Definition: graphics.h:285
Definition: graphics.h:67
struct input_subsystem input_t
Definition: input.h:146
Definition: graphics.h:168
EXPORT gs_sparam_t * gs_shader_get_param_by_idx(gs_shader_t *shader, uint32_t param)
Definition: axisang.h:28
EXPORT gs_eparam_t * gs_param_get_annotation_by_name(const gs_eparam_t *param, const char *name)
EXPORT void gs_shader_set_matrix3(gs_sparam_t *param, const struct matrix3 *val)
EXPORT gs_vertbuffer_t * gs_vertexbuffer_create(struct gs_vb_data *data, uint32_t flags)
struct gs_tvertarray * tvarray
Definition: graphics.h:193
EXPORT void gs_shader_destroy(gs_shader_t *shader)
int cx
Definition: graphics.h:236
EXPORT void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest)
EXPORT void gs_set_viewport(int x, int y, int width, int height)
EXPORT 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)
EXPORT void gs_enable_depth_test(bool enable)
Definition: graphics.h:217
EXPORT enum gs_texture_type gs_get_texture_type(const gs_texture_t *texture)
gs_sample_filter
Definition: graphics.h:146
Definition: graphics.h:293
int x
Definition: graphics.h:234
EXPORT void gs_vertexbuffer_flush(gs_vertbuffer_t *vertbuffer)
EXPORT void gs_leave_context(void)
EXPORT void gs_reset_viewport(void)
EXPORT void gs_enable_color(bool red, bool green, bool blue, bool alpha)
EXPORT void gs_shader_set_vec2(gs_sparam_t *param, const struct vec2 *val)
EXPORT 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)
enum gs_sample_filter filter
Definition: graphics.h:218
EXPORT void gs_matrix_rotaa4f(float x, float y, float z, float angle)
EXPORT enum gs_cull_mode gs_get_cull_mode(void)
EXPORT void gs_projection_pop(void)
EXPORT void gs_normal3f(float x, float y, float z)
struct gs_shader gs_shader_t
Definition: graphics.h:267
EXPORT size_t gs_effect_get_default_val_size(gs_eparam_t *param)
unsigned uint32_t
Definition: vc_stdint.h:31
int cy
Definition: graphics.h:237
EXPORT void gs_samplerstate_destroy(gs_samplerstate_t *samplerstate)
size_t width
Definition: graphics.h:181
EXPORT void gs_zstencil_destroy(gs_zstencil_t *zstencil)
Definition: graphics.h:141
EXPORT gs_eparam_t * gs_effect_get_param_by_idx(const gs_effect_t *effect, size_t param)
Definition: graphics.h:58
EXPORT void gs_end_scene(void)
Definition: vec3.h:33
EXPORT void gs_set_render_target(gs_texture_t *tex, gs_zstencil_t *zstencil)
enum gs_color_format format
Definition: graphics.h:476
EXPORT gs_zstencil_t * gs_zstencil_create(uint32_t width, uint32_t height, enum gs_zstencil_format format)
struct gs_vertex_buffer gs_vertbuffer_t
Definition: graphics.h:262
EXPORT void gs_present(void)
EXPORT gs_epass_t * gs_technique_get_pass_by_name(const gs_technique_t *technique, const char *name)
Definition: graphics.h:149
Definition: graphics.h:72
const char * name
Definition: graphics.h:299
struct gs_stage_surface gs_stagesurf_t
Definition: graphics.h:260
EXPORT uint32_t gs_get_height(void)
struct gs_window window
Definition: graphics.h:473
EXPORT void gs_technique_end_pass(gs_technique_t *technique)
struct gs_device gs_device_t
Definition: graphics.h:273
long y
Definition: graphics.h:175
uint32_t freq
Definition: graphics.h:230
uint32_t border_color
Definition: graphics.h:223
Definition: vec2.h:27
uint32_t height
Definition: graphics.h:228
int max_anisotropy
Definition: graphics.h:222
EXPORT void gs_stencil_function(enum gs_stencil_side side, enum gs_depth_test test)
Definition: graphics.h:282
EXPORT void * gs_indexbuffer_get_data(const gs_indexbuffer_t *indexbuffer)
EXPORT void gs_resize(uint32_t x, uint32_t y)
EXPORT void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts)
EXPORT void gs_matrix_rotquat(const struct quat *rot)
Definition: graphics.h:472
EXPORT void gs_shader_get_param_info(const gs_sparam_t *param, struct gs_shader_param_info *info)
EXPORT void gs_texrender_end(gs_texrender_t *texrender)
gs_stencil_side
Definition: graphics.h:122
Definition: graphics.h:289
unsigned __int64 uint64_t
Definition: vc_stdint.h:33
Definition: graphics.h:281
EXPORT const char * gs_get_device_name(void)
EXPORT bool gs_texrender_begin(gs_texrender_t *texrender, uint32_t cx, uint32_t cy)
Definition: graphics.h:142
EXPORT void gs_load_default_samplerstate(bool b_3d, int unit)
EXPORT void gs_set_3d_mode(double fovy, double znear, double zvar)
Definition: graphics.h:460
struct gs_shader_param gs_sparam_t
Definition: graphics.h:268
EXPORT void gs_viewport_push(void)
gs_color_format
Definition: graphics.h:56
EXPORT void gs_load_samplerstate(gs_samplerstate_t *samplerstate, int unit)
unsigned char uint8_t
Definition: vc_stdint.h:27
const char * name
Definition: graphics.h:349
Definition: graphics.h:65
struct vec3 * tangents
Definition: graphics.h:189
Definition: graphics.h:150
Definition: graphics.h:73
EXPORT gs_shader_t * gs_vertexshader_create_from_file(const char *file, char **error_string)
EXPORT void gs_texcoord(float x, float y, int unit)
Definition: graphics.h:70
EXPORT gs_effect_t * gs_get_effect(void)
EXPORT enum gs_color_format gs_voltexture_get_color_format(const gs_texture_t *voltex)
Definition: graphics.h:117
EXPORT void gs_projection_push(void)
EXPORT void gs_voltexture_destroy(gs_texture_t *voltex)
EXPORT void gs_draw_sprite_subregion(gs_texture_t *tex, uint32_t flip, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
Definition: graphics.h:139
Definition: matrix3.h:31
Definition: graphics.h:160
EXPORT uint32_t gs_get_width(void)
Definition: graphics.h:92
EXPORT enum gs_color_format gs_texture_get_color_format(const gs_texture_t *tex)
EXPORT void gs_color4v(const struct vec4 *v)
Definition: graphics.h:292
EXPORT void gs_render_start(bool b_new)
EXPORT bool gs_technique_begin_pass_by_name(gs_technique_t *technique, const char *name)
EXPORT void * gs_effect_get_default_val(gs_eparam_t *param)
EXPORT gs_epass_t * gs_technique_get_pass_by_idx(const gs_technique_t *technique, size_t pass)
Definition: graphics.h:63
EXPORT void gs_matrix_transpose(void)
EXPORT gs_texture_t * gs_get_render_target(void)
EXPORT void gs_indexbuffer_flush(gs_indexbuffer_t *indexbuffer)
Definition: graphics.h:80
EXPORT void gs_indexbuffer_destroy(gs_indexbuffer_t *indexbuffer)
EXPORT void gs_vertex3v(const struct vec3 *v)
EXPORT void gs_viewport_pop(void)
uint32_t bits
Definition: graphics.h:229
EXPORT void gs_stagesurface_destroy(gs_stagesurf_t *stagesurf)
EXPORT void gs_shader_set_vec4(gs_sparam_t *param, const struct vec4 *val)
Definition: vec4.h:30
EXPORT bool gs_texture_map(gs_texture_t *tex, uint8_t **ptr, uint32_t *linesize)
EXPORT struct gs_vb_data * gs_vertexbuffer_get_data(const gs_vertbuffer_t *vertbuffer)
EXPORT uint32_t gs_cubetexture_get_size(const gs_texture_t *cubetex)
EXPORT void gs_shader_set_bool(gs_sparam_t *param, bool val)
Definition: graphics.h:304
enum gs_zstencil_format zsformat
Definition: graphics.h:477
Definition: graphics.h:283
gs_stencil_op_type
Definition: graphics.h:128
EXPORT void gs_matrix_scale3f(float x, float y, float z)
gs_index_type
Definition: graphics.h:86
EXPORT enum gs_color_format gs_cubetexture_get_color_format(const gs_texture_t *cubetex)
Definition: graphics.h:130
EXPORT void gs_shader_set_vec3(gs_sparam_t *param, const struct vec3 *val)
EXPORT void gs_enable_stencil_test(bool enable)
EXPORT void gs_matrix_mul(const struct matrix4 *matrix)
#define EXPORT
Definition: c99defs.h:49
EXPORT void gs_set_cull_mode(enum gs_cull_mode mode)
Definition: graphics.h:74
Definition: graphics.h:87
EXPORT bool gs_stagesurface_map(gs_stagesurf_t *stagesurf, uint8_t **data, uint32_t *linesize)
Definition: graphics.h:290
Definition: graphics.h:131
EXPORT void gs_indexbuffer_flush_direct(gs_indexbuffer_t *indexbuffer, const void *data)
EXPORT void * gs_texture_get_obj(gs_texture_t *tex)
EXPORT void gs_matrix_translate3f(float x, float y, float z)
EXPORT uint32_t gs_texture_get_height(const gs_texture_t *tex)
Definition: graphics-internal.h:287
Definition: graphics.h:161
EXPORT size_t gs_param_get_num_annotations(const gs_eparam_t *param)
gs_cull_mode
Definition: graphics.h:91
EXPORT gs_sparam_t * gs_shader_get_param_by_name(gs_shader_t *shader, const char *name)
EXPORT gs_texture_t * gs_voltexture_create(uint32_t width, uint32_t height, uint32_t depth, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags)
EXPORT 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)
EXPORT bool gs_texture_is_rect(const gs_texture_t *tex)
Definition: graphics.h:114
enum gs_address_mode address_v
Definition: graphics.h:220
EXPORT void gs_vertexbuffer_flush_direct(gs_vertbuffer_t *vertbuffer, const struct gs_vb_data *data)
Definition: graphics.h:129
Definition: graphics.h:105
EXPORT void gs_set_cube_render_target(gs_texture_t *cubetex, int side, gs_zstencil_t *zstencil)
EXPORT void gs_shader_set_texture(gs_sparam_t *param, gs_texture_t *val)
Definition: effect.h:150
EXPORT void gs_texture_set_image(gs_texture_t *tex, const uint8_t *data, uint32_t linesize, bool invert)
Definition: graphics.h:143
EXPORT void gs_blend_state_push(void)
EXPORT void gs_get_viewport(struct gs_rect *rect)
gs_shader_param_type
Definition: graphics.h:280
EXPORT void gs_enter_context(graphics_t *graphics)
EXPORT gs_shader_t * gs_get_pixel_shader(void)
EXPORT void gs_shader_set_val(gs_sparam_t *param, const void *val, size_t size)
EXPORT gs_eparam_t * gs_param_get_annotation_by_idx(const gs_eparam_t *param, size_t annotation)
Definition: effect.h:98
Definition: graphics.h:132
Definition: graphics.h:51
EXPORT bool gs_effect_loop(gs_effect_t *effect, const char *name)
Definition: graphics.h:147
Definition: graphics.h:284
EXPORT void gs_begin_scene(void)
EXPORT uint32_t gs_stagesurface_get_height(const gs_stagesurf_t *stagesurf)
Definition: graphics.h:113
EXPORT size_t gs_indexbuffer_get_num_indices(const gs_indexbuffer_t *indexbuffer)
EXPORT void gs_matrix_pop(void)
Definition: graphics.h:104
Definition: graphics.h:124
EXPORT void gs_shader_set_next_sampler(gs_sparam_t *param, gs_samplerstate_t *sampler)
EXPORT 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)
Definition: graphics.h:226
Definition: matrix4.h:32
EXPORT size_t gs_effect_get_num_params(const gs_effect_t *effect)
struct gs_index_buffer gs_indexbuffer_t
Definition: graphics.h:263
EXPORT gs_eparam_t * gs_effect_get_param_by_name(const gs_effect_t *effect, const char *name)
EXPORT void gs_swapchain_destroy(gs_swapchain_t *swapchain)
Definition: graphics.h:115
Definition: graphics.h:140
struct gs_texture gs_texture_t
Definition: graphics.h:259
EXPORT gs_samplerstate_t * gs_samplerstate_create(const struct gs_sampler_info *info)
EXPORT void gs_copy_texture_region(gs_texture_t *dst, uint32_t dst_x, uint32_t dst_y, gs_texture_t *src, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h)
EXPORT void gs_vertex2v(const struct vec2 *v)
EXPORT void gs_effect_destroy(gs_effect_t *effect)
EXPORT void gs_shader_set_default(gs_sparam_t *param)
Definition: graphics.h:100
struct gs_zstencil_buffer gs_zstencil_t
Definition: graphics.h:261
Definition: quat.h:41
EXPORT uint32_t gs_texture_get_width(const gs_texture_t *tex)
uint32_t width
Definition: graphics.h:227
EXPORT void gs_matrix_push(void)
EXPORT gs_shader_t * gs_vertexshader_create(const char *shader, const char *file, char **error_string)
EXPORT void gs_effect_set_next_sampler(gs_eparam_t *param, gs_samplerstate_t *sampler)
EXPORT gs_shader_t * gs_pixelshader_create(const char *shader, const char *file, char **error_string)
EXPORT gs_texrender_t * gs_texrender_create(enum gs_color_format format, enum gs_zstencil_format zsformat)
Definition: graphics.h:106
size_t num_tex
Definition: graphics.h:192
EXPORT void gs_effect_set_float(gs_eparam_t *param, float val)
EXPORT bool gs_technique_begin_pass(gs_technique_t *technique, size_t pass)
int y
Definition: graphics.h:235
EXPORT int gs_shader_get_num_params(const gs_shader_t *shader)
EXPORT size_t gs_technique_begin(gs_technique_t *technique)
int rotation_degrees
Definition: graphics.h:173
EXPORT enum gs_color_format gs_stagesurface_get_color_format(const gs_stagesurf_t *stagesurf)
EXPORT gs_sparam_t * gs_shader_get_world_matrix(const gs_shader_t *shader)
Definition: graphics.h:66
EXPORT void gs_ortho(float left, float right, float top, float bottom, float znear, float zfar)
Definition: graphics.h:52
long x
Definition: graphics.h:174
Definition: graphics.h:172
Definition: graphics.h:162
EXPORT void gs_set_scissor_rect(const struct gs_rect *rect)
EXPORT void gs_shader_set_float(gs_sparam_t *param, float val)
uint32_t num_backbuffers
Definition: graphics.h:475
EXPORT gs_effect_t * gs_effect_create_from_file(const char *file, char **error_string)
EXPORT void gs_effect_set_int(gs_eparam_t *param, int val)
EXPORT input_t * gs_get_input(void)
gs_shader_type
Definition: graphics.h:302
Definition: graphics.h:153
EXPORT void gs_normal3v(const struct vec3 *v)
Definition: graphics.h:159
EXPORT uint32_t gs_stagesurface_get_width(const gs_stagesurf_t *stagesurf)
EXPORT void gs_effect_set_vec3(gs_eparam_t *param, const struct vec3 *val)
struct gs_sampler_state gs_samplerstate_t
Definition: graphics.h:264
void * array
Definition: graphics.h:182
gs_draw_mode
Definition: graphics.h:48
EXPORT int gs_get_device_type(void)
Definition: graphics.h:297
EXPORT void gs_cubetexture_destroy(gs_texture_t *cubetex)
EXPORT gs_texture_t * gs_texrender_get_texture(const gs_texrender_t *texrender)
EXPORT void gs_matrix_get(struct matrix4 *dst)
Definition: graphics.h:88
EXPORT void gs_flush(void)
EXPORT void gs_effect_set_matrix4(gs_eparam_t *param, const struct matrix4 *val)
Definition: graphics.h:286
EXPORT void gs_copy_texture(gs_texture_t *dst, gs_texture_t *src)
EXPORT enum gs_index_type gs_indexbuffer_get_type(const gs_indexbuffer_t *indexbuffer)
EXPORT uint32_t gs_voltexture_get_width(const gs_texture_t *voltex)
EXPORT void gs_effect_set_default(gs_eparam_t *param)
EXPORT uint32_t gs_voltexture_get_depth(const gs_texture_t *voltex)
EXPORT size_t gs_effect_get_val_size(gs_eparam_t *param)
EXPORT void gs_load_indexbuffer(gs_indexbuffer_t *indexbuffer)
Definition: graphics.h:99
EXPORT void gs_texture_destroy(gs_texture_t *tex)
struct vec3 * normals
Definition: graphics.h:188
Definition: graphics.h:123
Definition: graphics.h:103
Definition: graphics.h:107
Definition: graphics.h:233
enum gs_address_mode address_u
Definition: graphics.h:219
EXPORT void gs_set_2d_mode(void)
Definition: graphics.h:288
EXPORT void gs_vertex2f(float x, float y)
EXPORT gs_swapchain_t * gs_swapchain_create(const struct gs_init_data *data)
EXPORT void gs_effect_set_vec2(gs_eparam_t *param, const struct vec2 *val)
Definition: graphics.h:93
Definition: graphics.h:119
EXPORT void gs_clear(uint32_t clear_flags, const struct vec4 *color, float depth, uint8_t stencil)
uint32_t adapter
Definition: graphics.h:478
Definition: graphics.h:61
Definition: graphics.h:303
Definition: graphics.h:287
EXPORT void gs_color(uint32_t color)
uint32_t * colors
Definition: graphics.h:190
Definition: graphics.h:118
EXPORT void gs_effect_get_param_info(const gs_eparam_t *param, struct gs_effect_param_info *info)
enum gs_shader_param_type type
Definition: graphics.h:350
Definition: graphics.h:291
Definition: effect.h:50
EXPORT void gs_blend_state_pop(void)
EXPORT gs_shader_t * gs_get_vertex_shader(void)
EXPORT void gs_technique_end(gs_technique_t *technique)
EXPORT void gs_cubetexture_set_image(gs_texture_t *cubetex, uint32_t side, const void *data, uint32_t linesize, bool invert)
EXPORT gs_eparam_t * gs_effect_get_viewproj_matrix(const gs_effect_t *effect)
EXPORT void gs_depth_function(enum gs_depth_test test)
EXPORT void gs_texcoord2v(const struct vec2 *v, int unit)
EXPORT void gs_destroy(graphics_t *graphics)
EXPORT uint8_t * gs_create_texture_file_data(const char *file, enum gs_color_format *format, uint32_t *cx, uint32_t *cy)
EXPORT gs_technique_t * gs_effect_get_current_technique(const gs_effect_t *effect)
gs_cube_sides
Definition: graphics.h:137
EXPORT gs_texture_t * gs_texture_create_from_file(const char *file)
Definition: graphics.h:94
gs_zstencil_format
Definition: graphics.h:78
EXPORT void gs_shader_set_matrix4(gs_sparam_t *param, const struct matrix4 *val)
EXPORT graphics_t * gs_get_context(void)
gs_blend_type
Definition: graphics.h:97
Definition: graphics.h:53
EXPORT void gs_effect_update_params(gs_effect_t *effect)
EXPORT gs_zstencil_t * gs_get_zstencil_target(void)
gs_address_mode
Definition: graphics.h:158
EXPORT void gs_stage_texture(gs_stagesurf_t *dst, gs_texture_t *src)
EXPORT void gs_texrender_destroy(gs_texrender_t *texrender)
EXPORT gs_vertbuffer_t * gs_render_save(void)
Definition: graphics.h:62
EXPORT void gs_effect_set_color(gs_eparam_t *param, uint32_t argb)
Definition: graphics.h:180
Definition: graphics.h:98
Definition: graphics.h:102
Definition: graphics.h:185
Definition: effect.h:125
EXPORT void gs_load_pixelshader(gs_shader_t *pixelshader)
Definition: graphics.h:125
Definition: graphics.h:79
EXPORT int gs_create(graphics_t **graphics, const char *module, uint32_t adapter)
Definition: graphics.h:75
EXPORT void gs_get_size(uint32_t *x, uint32_t *y)
Definition: graphics.h:49
Definition: graphics.h:152
EXPORT void gs_draw_cube_backdrop(gs_texture_t *cubetex, const struct quat *rot, float left, float right, float top, float bottom, float znear)
EXPORT void gs_enable_stencil_write(bool enable)
Definition: graphics.h:167
Definition: graphics.h:83
Definition: plane.h:30
Definition: graphics.h:148
EXPORT void gs_load_texture(gs_texture_t *tex, int unit)
Definition: graphics.h:108
EXPORT void gs_matrix_identity(void)
EXPORT void bfree(void *ptr)
EXPORT uint32_t gs_voltexture_get_height(const gs_texture_t *voltex)
EXPORT void gs_effect_set_val(gs_eparam_t *param, const void *val, size_t size)
Definition: graphics.h:57
size_t num
Definition: graphics.h:186
Definition: graphics.h:68
enum gs_shader_param_type type
Definition: graphics.h:298
EXPORT void gs_load_vertexshader(gs_shader_t *vertshader)
EXPORT gs_indexbuffer_t * gs_indexbuffer_create(enum gs_index_type type, void *indices, size_t num, uint32_t flags)
EXPORT void gs_matrix_set(const struct matrix4 *matrix)
Definition: graphics.h:82
Definition: graphics.h:133
Definition: graphics.h:163
EXPORT gs_stagesurf_t * gs_stagesurface_create(uint32_t width, uint32_t height, enum gs_color_format color_format)
gs_depth_test
Definition: graphics.h:111
Definition: graphics.h:69
EXPORT void gs_matrix_scale(const struct vec3 *scale)
Definition: graphics.h:116
EXPORT void gs_vertex3f(float x, float y, float z)
EXPORT gs_technique_t * gs_effect_get_technique(const gs_effect_t *effect, const char *name)
Definition: graphics.h:64
EXPORT void gs_texrender_reset(gs_texrender_t *texrender)
EXPORT gs_effect_t * gs_effect_create(const char *effect_string, const char *filename, char **error_string)
struct gs_texture_render gs_texrender_t
Definition: graphics.h:266
EXPORT void gs_enum_adapters(bool(*callback)(void *param, const char *name, uint32_t id), void *param)
EXPORT void gs_shader_set_int(gs_sparam_t *param, int val)
Definition: graphics.h:59
EXPORT void gs_vertexbuffer_destroy(gs_vertbuffer_t *vertbuffer)
EXPORT void gs_load_vertexbuffer(gs_vertbuffer_t *vertbuffer)
EXPORT void gs_enable_blending(bool enable)
Definition: graphics.h:101
EXPORT void gs_reset_blend_state(void)
uint32_t cy
Definition: graphics.h:474
EXPORT void gs_matrix_rotaa(const struct axisang *rot)
EXPORT void * gs_effect_get_val(gs_eparam_t *param)
EXPORT void gs_effect_set_bool(gs_eparam_t *param, bool val)
EXPORT bool gs_nv12_available(void)
Definition: graphics.h:155
struct gs_swap_chain gs_swapchain_t
Definition: graphics.h:265
Definition: graphics.h:169
EXPORT void gs_draw_sprite(gs_texture_t *tex, uint32_t flip, uint32_t width, uint32_t height)
EXPORT void gs_render_stop(enum gs_draw_mode mode)
Definition: graphics.h:134
long cx
Definition: graphics.h:176
EXPORT gs_eparam_t * gs_effect_get_world_matrix(const gs_effect_t *effect)
EXPORT void gs_matrix_translate(const struct vec3 *pos)
long cy
Definition: graphics.h:177
Definition: graphics.h:138
Definition: graphics.h:348
EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar)