123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545 |
- /******************************************************************************
- Copyright (C) 2013 by Hugh Bailey <[email protected]>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- ******************************************************************************/
- #include <assert.h>
- #include "../util/base.h"
- #include "../util/bmem.h"
- #include "../util/platform.h"
- #include "graphics-internal.h"
- #include "vec2.h"
- #include "vec3.h"
- #include "quat.h"
- #include "axisang.h"
- #include "effect-parser.h"
- #include "effect.h"
- #ifdef _MSC_VER
- static __declspec(thread) graphics_t thread_graphics = NULL;
- #else /* assume GCC or that other compiler we dare not mention */
- static __thread graphics_t thread_graphics = NULL;
- #endif
- #define IMMEDIATE_COUNT 512
- bool load_graphics_imports(struct gs_exports *exports, void *module,
- const char *module_name);
- static bool graphics_init_immediate_vb(struct graphics_subsystem *graphics)
- {
- struct vb_data *vbd;
- vbd = vbdata_create();
- vbd->num = IMMEDIATE_COUNT;
- vbd->points = bmalloc(sizeof(struct vec3)*IMMEDIATE_COUNT);
- vbd->normals = bmalloc(sizeof(struct vec3)*IMMEDIATE_COUNT);
- vbd->colors = bmalloc(sizeof(uint32_t) *IMMEDIATE_COUNT);
- vbd->num_tex = 1;
- vbd->tvarray = bmalloc(sizeof(struct tvertarray));
- vbd->tvarray[0].width = 2;
- vbd->tvarray[0].array =
- bmalloc(sizeof(struct vec2) * IMMEDIATE_COUNT);
- graphics->immediate_vertbuffer = graphics->exports.
- device_create_vertexbuffer(graphics->device, vbd, GS_DYNAMIC);
- if (!graphics->immediate_vertbuffer)
- return false;
- return true;
- }
- static bool graphics_init_sprite_vb(struct graphics_subsystem *graphics)
- {
- struct vb_data *vbd;
- vbd = vbdata_create();
- vbd->num = 4;
- vbd->points = bmalloc(sizeof(struct vec3) * 4);
- vbd->num_tex = 1;
- vbd->tvarray = bmalloc(sizeof(struct tvertarray));
- vbd->tvarray[0].width = 2;
- vbd->tvarray[0].array = bmalloc(sizeof(struct vec2) * 4);
- memset(vbd->points, 0, sizeof(struct vec3) * 4);
- memset(vbd->tvarray[0].array, 0, sizeof(struct vec2) * 4);
- graphics->sprite_buffer = graphics->exports.
- device_create_vertexbuffer(graphics->device, vbd, GS_DYNAMIC);
- if (!graphics->sprite_buffer)
- return false;
- return true;
- }
- static bool graphics_init(struct graphics_subsystem *graphics)
- {
- struct matrix3 top_mat;
- matrix3_identity(&top_mat);
- da_push_back(graphics->matrix_stack, &top_mat);
- graphics->exports.device_entercontext(graphics->device);
- if (!graphics_init_immediate_vb(graphics))
- return false;
- if (!graphics_init_sprite_vb(graphics))
- return false;
- if (pthread_mutex_init(&graphics->mutex, NULL) != 0)
- return false;
- graphics->exports.device_leavecontext(graphics->device);
- return true;
- }
- int gs_create(graphics_t *pgraphics, const char *module,
- struct gs_init_data *data)
- {
- int errcode = GS_ERROR_FAIL;
- graphics_t graphics = bmalloc(sizeof(struct graphics_subsystem));
- memset(graphics, 0, sizeof(struct graphics_subsystem));
- pthread_mutex_init_value(&graphics->mutex);
- graphics->module = os_dlopen(module);
- if (!graphics->module) {
- errcode = GS_ERROR_MODULENOTFOUND;
- goto error;
- }
- if (!load_graphics_imports(&graphics->exports, graphics->module,
- module))
- goto error;
- graphics->device = graphics->exports.device_create(data);
- if (!graphics->device)
- goto error;
- if (!graphics_init(graphics))
- goto error;
- *pgraphics = graphics;
- return GS_SUCCESS;
- error:
- gs_destroy(graphics);
- return errcode;
- }
- void gs_destroy(graphics_t graphics)
- {
- if (!graphics)
- return;
- while (thread_graphics)
- gs_leavecontext();
- if (graphics->device) {
- graphics->exports.device_entercontext(graphics->device);
- graphics->exports.vertexbuffer_destroy(graphics->sprite_buffer);
- graphics->exports.vertexbuffer_destroy(
- graphics->immediate_vertbuffer);
- graphics->exports.device_destroy(graphics->device);
- }
- pthread_mutex_destroy(&graphics->mutex);
- da_free(graphics->matrix_stack);
- da_free(graphics->viewport_stack);
- os_dlclose(graphics->module);
- bfree(graphics);
- }
- void gs_entercontext(graphics_t graphics)
- {
- bool is_current = thread_graphics == graphics;
- if (thread_graphics && !is_current) {
- while (thread_graphics)
- gs_leavecontext();
- }
- if (!is_current) {
- pthread_mutex_lock(&graphics->mutex);
- graphics->exports.device_entercontext(graphics->device);
- thread_graphics = graphics;
- }
- graphics->ref++;
- }
- void gs_leavecontext(void)
- {
- if (thread_graphics) {
- if (!--thread_graphics->ref) {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_leavecontext(graphics->device);
- pthread_mutex_unlock(&graphics->mutex);
- thread_graphics = NULL;
- }
- }
- }
- graphics_t gs_getcontext(void)
- {
- return thread_graphics;
- }
- static inline struct matrix3 *top_matrix(graphics_t graphics)
- {
- return graphics->matrix_stack.array + graphics->cur_matrix;
- }
- void gs_matrix_push(void)
- {
- graphics_t graphics = thread_graphics;
- struct matrix3 mat, *top_mat = top_matrix(graphics);
- memcpy(&mat, top_mat, sizeof(struct matrix3));
- da_push_back(graphics->matrix_stack, &mat);
- graphics->cur_matrix++;
- }
- void gs_matrix_pop(void)
- {
- graphics_t graphics = thread_graphics;
- if (graphics->cur_matrix == 0) {
- blog(LOG_ERROR, "Tried to pop last matrix on stack");
- return;
- }
- da_erase(graphics->matrix_stack, graphics->cur_matrix);
- graphics->cur_matrix--;
- }
- void gs_matrix_identity(void)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_identity(top_mat);
- }
- void gs_matrix_transpose(void)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_transpose(top_mat, top_mat);
- }
- void gs_matrix_set(const struct matrix3 *matrix)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_copy(top_mat, matrix);
- }
- void gs_matrix_get(struct matrix3 *dst)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_copy(dst, top_mat);
- }
- void gs_matrix_mul(const struct matrix3 *matrix)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_mul(top_mat, top_mat, matrix);
- }
- void gs_matrix_rotquat(const struct quat *rot)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_rotate(top_mat, top_mat, rot);
- }
- void gs_matrix_rotaa(const struct axisang *rot)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_rotate_aa(top_mat, top_mat, rot);
- }
- void gs_matrix_translate(const struct vec3 *pos)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_translate(top_mat, top_mat, pos);
- }
- void gs_matrix_scale(const struct vec3 *scale)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- matrix3_scale(top_mat, top_mat, scale);
- }
- void gs_matrix_rotaa4f(float x, float y, float z, float angle)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- struct axisang aa;
-
- axisang_set(&aa, x, y, z, angle);
- matrix3_rotate_aa(top_mat, top_mat, &aa);
- }
- void gs_matrix_translate3f(float x, float y, float z)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- struct vec3 p;
- vec3_set(&p, x, y, z);
- matrix3_translate(top_mat, top_mat, &p);
- }
- void gs_matrix_scale3f(float x, float y, float z)
- {
- struct matrix3 *top_mat = top_matrix(thread_graphics);
- struct vec3 p;
- vec3_set(&p, x, y, z);
- matrix3_scale(top_mat, top_mat, &p);
- }
- static inline void reset_immediate_arrays(graphics_t graphics)
- {
- size_t i;
- da_init(graphics->verts);
- da_init(graphics->norms);
- da_init(graphics->colors);
- for (i = 0; i < 16; i++)
- da_init(graphics->texverts[i]);
- }
- void gs_renderstart(bool b_new)
- {
- graphics_t graphics = thread_graphics;
- graphics->using_immediate = !b_new;
- reset_immediate_arrays(graphics);
- if (b_new) {
- graphics->vbd = vbdata_create();
- } else {
- graphics->vbd = vertexbuffer_getdata(
- graphics->immediate_vertbuffer);
- memset(graphics->vbd->colors, 0xFF,
- sizeof(uint32_t) * IMMEDIATE_COUNT);
- graphics->verts.array = graphics->vbd->points;
- graphics->norms.array = graphics->vbd->normals;
- graphics->colors.array = graphics->vbd->colors;
- graphics->texverts[0].array = graphics->vbd->tvarray[0].array;
- graphics->verts.capacity = IMMEDIATE_COUNT;
- graphics->norms.capacity = IMMEDIATE_COUNT;
- graphics->colors.capacity = IMMEDIATE_COUNT;
- graphics->texverts[0].capacity = IMMEDIATE_COUNT;
- }
- }
- static inline size_t min_size(const size_t a, const size_t b)
- {
- return (a < b) ? a : b;
- }
- void gs_renderstop(enum gs_draw_mode mode)
- {
- graphics_t graphics = thread_graphics;
- size_t i, num = graphics->verts.num;
- if (!num) {
- if (!graphics->using_immediate) {
- da_free(graphics->verts);
- da_free(graphics->norms);
- da_free(graphics->colors);
- for (i = 0; i < 16; i++)
- da_free(graphics->texverts[i]);
- vbdata_destroy(graphics->vbd);
- }
- return;
- }
- if (graphics->norms.num &&
- (graphics->norms.num != graphics->verts.num)) {
- blog(LOG_WARNING, "gs_renderstop: normal count does "
- "not match vertex count");
- num = min_size(num, graphics->norms.num);
- }
- if (graphics->colors.num &&
- (graphics->colors.num != graphics->verts.num)) {
- blog(LOG_WARNING, "gs_renderstop: color count does "
- "not match vertex count");
- num = min_size(num, graphics->colors.num);
- }
- if (graphics->texverts[0].num &&
- (graphics->texverts[0].num != graphics->verts.num)) {
- blog(LOG_WARNING, "gs_renderstop: texture vertex count does "
- "not match vertex count");
- num = min_size(num, graphics->texverts[0].num);
- }
- if (graphics->using_immediate) {
- vertexbuffer_flush(graphics->immediate_vertbuffer, false);
- gs_load_vertexbuffer(graphics->immediate_vertbuffer);
- gs_load_indexbuffer(NULL);
- gs_draw(mode, 0, (uint32_t)num);
- reset_immediate_arrays(graphics);
- } else {
- vertbuffer_t vb = gs_rendersave();
- gs_load_vertexbuffer(vb);
- gs_load_indexbuffer(NULL);
- gs_draw(mode, 0, 0);
- vertexbuffer_destroy(vb);
- }
- graphics->vbd = NULL;
- }
- vertbuffer_t gs_rendersave(void)
- {
- graphics_t graphics = thread_graphics;
- size_t num_tex, i;
- if (graphics->using_immediate)
- return NULL;
- if (!graphics->vbd->num) {
- vbdata_destroy(graphics->vbd);
- return NULL;
- }
- for (num_tex = 0; num_tex < 16; num_tex++) {
- if (!graphics->texverts[num_tex].num)
- break;
- }
- graphics->vbd->points = graphics->verts.array;
- graphics->vbd->normals = graphics->norms.array;
- graphics->vbd->colors = graphics->colors.array;
- graphics->vbd->num = graphics->verts.num;
- graphics->vbd->num_tex = num_tex;
- graphics->vbd->tvarray = bmalloc(sizeof(struct tvertarray) * num_tex);
- for (i = 0; i < num_tex; i++) {
- graphics->vbd->tvarray[i].width = 2;
- graphics->vbd->tvarray[i].array = graphics->texverts[i].array;
- }
- reset_immediate_arrays(graphics);
- return gs_create_vertexbuffer(graphics->vbd, 0);
- }
- void gs_vertex2f(float x, float y)
- {
- struct vec3 v3;
-
- vec3_set(&v3, x, y, 0.0f);
- gs_vertex3v(&v3);
- }
- void gs_vertex3f(float x, float y, float z)
- {
- struct vec3 v3;
- vec3_set(&v3, x, y, z);
- gs_vertex3v(&v3);
- }
- void gs_normal3f(float x, float y, float z)
- {
- struct vec3 v3;
- vec3_set(&v3, x, y, z);
- gs_normal3v(&v3);
- }
- static inline bool validvertsize(graphics_t graphics, size_t num,
- const char *name)
- {
- if (graphics->using_immediate && num == IMMEDIATE_COUNT) {
- blog(LOG_WARNING, "%s: tried to use over %u "
- "for immediate rendering",
- name, IMMEDIATE_COUNT);
- return false;
- }
- return true;
- }
- void gs_color(uint32_t color)
- {
- graphics_t graphics = thread_graphics;
- if (!validvertsize(graphics, graphics->colors.num, "gs_color"))
- return;
-
- da_push_back(graphics->colors, &color);
- }
- void gs_texcoord(float x, float y, int unit)
- {
- struct vec2 v2;
- vec2_set(&v2, x, y);
- gs_texcoord2v(&v2, unit);
- }
- void gs_vertex2v(const struct vec2 *v)
- {
- struct vec3 v3;
- vec3_set(&v3, v->x, v->y, 0.0f);
- gs_vertex3v(&v3);
- }
- void gs_vertex3v(const struct vec3 *v)
- {
- graphics_t graphics = thread_graphics;
- if (!validvertsize(graphics, graphics->verts.num, "gs_vertex"))
- return;
- da_push_back(graphics->verts, v);
- }
- void gs_normal3v(const struct vec3 *v)
- {
- graphics_t graphics = thread_graphics;
- if (!validvertsize(graphics, graphics->norms.num, "gs_normal"))
- return;
-
- da_push_back(graphics->norms, v);
- }
- void gs_color4v(const struct vec4 *v)
- {
- /* TODO */
- }
- void gs_texcoord2v(const struct vec2 *v, int unit)
- {
- graphics_t graphics = thread_graphics;
- if (!validvertsize(graphics, graphics->texverts[unit].num,
- "gs_texcoord"))
- return;
- da_push_back(graphics->texverts[unit], v);
- }
- input_t gs_getinput(void)
- {
- /* TODO */
- return NULL;
- }
- effect_t gs_geteffect(void)
- {
- return thread_graphics->cur_effect;
- }
- effect_t gs_create_effect_from_file(const char *file, char **error_string)
- {
- char *file_string;
- effect_t effect = NULL;
- file_string = os_quick_read_utf8_file(file);
- if (!file_string) {
- blog(LOG_WARNING, "Could not load effect file '%s'", file);
- return NULL;
- }
- effect = gs_create_effect(file_string, file, error_string);
- bfree(file_string);
- return effect;
- }
- effect_t gs_create_effect(const char *effect_string, const char *filename,
- char **error_string)
- {
- struct gs_effect *effect = bmalloc(sizeof(struct gs_effect));
- struct effect_parser parser;
- bool success;
- memset(effect, 0, sizeof(struct gs_effect));
- effect->graphics = thread_graphics;
- ep_init(&parser);
- success = ep_parse(&parser, effect, effect_string, filename);
- if (!success) {
- *error_string = error_data_buildstring(
- &parser.cfp.error_list);
- effect_destroy(effect);
- effect = NULL;
- }
- ep_free(&parser);
- return effect;
- }
- shader_t gs_create_vertexshader_from_file(const char *file, char **error_string)
- {
- char *file_string;
- shader_t shader = NULL;
- file_string = os_quick_read_utf8_file(file);
- if (!file_string) {
- blog(LOG_WARNING, "Could not load vertex shader file '%s'",
- file);
- return NULL;
- }
- shader = gs_create_vertexshader(file_string, file, error_string);
- bfree(file_string);
- return shader;
- }
- shader_t gs_create_pixelshader_from_file(const char *file, char **error_string)
- {
- char *file_string;
- shader_t shader = NULL;
- file_string = os_quick_read_utf8_file(file);
- if (!file_string) {
- blog(LOG_WARNING, "Could not load pixel shader file '%s'",
- file);
- return NULL;
- }
- shader = gs_create_pixelshader(file_string, file, error_string);
- bfree(file_string);
- return shader;
- }
- texture_t gs_create_texture_from_file(const char *file, uint32_t flags)
- {
- /* TODO */
- return NULL;
- }
- texture_t gs_create_cubetexture_from_file(const char *file, uint32_t flags)
- {
- /* TODO */
- return NULL;
- }
- texture_t gs_create_volumetexture_from_file(const char *file, uint32_t flags)
- {
- /* TODO */
- return NULL;
- }
- static inline void assign_sprite_uv(float *start, float *end, bool flip)
- {
- if (!flip) {
- *start = 0.0f;
- *end = 1.0f;
- } else {
- *start = 1.0f;
- *end = 0.0f;
- }
- }
- static inline void build_sprite(struct vb_data *data, float fcx, float fcy,
- uint32_t flip)
- {
- struct vec2 *tvarray = data->tvarray[0].array;
- float start_u, end_u;
- float start_v, end_v;
- assign_sprite_uv(&start_u, &end_u, (flip & GS_FLIP_U) != 0);
- assign_sprite_uv(&start_v, &end_v, (flip & GS_FLIP_V) != 0);
- vec3_zero(data->points);
- vec3_set(data->points+1, fcx, 0.0f, 0.0f);
- vec3_set(data->points+2, 0.0f, fcy, 0.0f);
- vec3_set(data->points+3, fcx, fcy, 0.0f);
- vec2_set(tvarray, start_u, start_v);
- vec2_set(tvarray+1, end_u, start_v);
- vec2_set(tvarray+2, start_u, end_v);
- vec2_set(tvarray+3, end_u, end_v);
- }
- void gs_draw_sprite(texture_t tex, uint32_t flip)
- {
- graphics_t graphics = thread_graphics;
- float fcx, fcy;
- struct vb_data *data;
- assert(tex);
- if (gs_gettexturetype(tex) != GS_TEXTURE_2D) {
- blog(LOG_ERROR, "A sprite must be a 2D texture");
- return;
- }
- fcx = (float)texture_getwidth(tex);
- fcy = (float)texture_getheight(tex);
- data = vertexbuffer_getdata(graphics->sprite_buffer);
- build_sprite(data, fcx, fcy, flip);
- vertexbuffer_flush(graphics->sprite_buffer, false);
- gs_load_vertexbuffer(graphics->sprite_buffer);
- gs_load_indexbuffer(NULL);
- gs_draw(GS_TRISTRIP, 0, 0);
- }
- void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot,
- float left, float right, float top, float bottom, float znear)
- {
- /* TODO */
- }
- void gs_resetviewport(void)
- {
- uint32_t cx, cy;
- gs_getsize(&cx, &cy);
- gs_setviewport(0, 0, (int)cx, (int)cy);
- }
- void gs_set2dmode(void)
- {
- uint32_t cx, cy;
- gs_getsize(&cx, &cy);
- gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -1.0, -1024.0f);
- }
- void gs_set3dmode(double fovy, double znear, double zvar)
- {
- /* TODO */
- }
- void gs_viewport_push(void)
- {
- struct gs_rect *rect = da_push_back_new(
- thread_graphics->viewport_stack);
- gs_getviewport(rect);
- }
- void gs_viewport_pop(void)
- {
- struct gs_rect *rect;
- if (!thread_graphics->viewport_stack.num)
- return;
- rect = da_end(thread_graphics->viewport_stack);
- gs_setviewport(rect->x, rect->y, rect->cx, rect->cy);
- da_pop_back(thread_graphics->viewport_stack);
- }
- void texture_setimage(texture_t tex, const void *data, uint32_t row_bytes,
- bool flip)
- {
- void *ptr;
- uint32_t row_bytes_out;
- uint32_t row_copy;
- int32_t height = (int32_t)texture_getheight(tex);
- int32_t y;
- if (!texture_map(tex, &ptr, &row_bytes_out))
- return;
- row_copy = (row_bytes < row_bytes_out) ? row_bytes : row_bytes_out;
- if (flip) {
- for (y = height-1; y >= 0; y--)
- memcpy((uint8_t*)ptr + (uint32_t)y * row_bytes_out,
- (uint8_t*)data + (uint32_t)y * row_bytes,
- row_copy);
- } else if (row_bytes == row_bytes_out) {
- memcpy(ptr, data, row_copy * height);
- } else {
- for (y = 0; y < height; y++)
- memcpy((uint8_t*)ptr + (uint32_t)y * row_bytes_out,
- (uint8_t*)data + (uint32_t)y * row_bytes,
- row_copy);
- }
- }
- void cubetexture_setimage(texture_t cubetex, uint32_t side, const void *data,
- uint32_t row_bytes, bool invert)
- {
- /* TODO */
- }
- void gs_perspective(float angle, float aspect, float near, float far)
- {
- graphics_t graphics = thread_graphics;
- float xmin, xmax, ymin, ymax;
- ymax = near * tanf(RAD(angle)*0.5f);
- ymin = -ymax;
- xmin = ymin * aspect;
- xmax = ymax * aspect;
- graphics->exports.device_frustum(graphics->device, xmin, xmax,
- ymin, ymax, near, far);
- }
- /* ------------------------------------------------------------------------- */
- swapchain_t gs_create_swapchain(struct gs_init_data *data)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_swapchain(graphics->device,
- data);
- }
- void gs_resize(uint32_t x, uint32_t y)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_resize(graphics->device, x, y);
- }
- void gs_getsize(uint32_t *x, uint32_t *y)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_getsize(graphics->device, x, y);
- }
- uint32_t gs_getwidth(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getwidth(graphics->device);
- }
- uint32_t gs_getheight(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getheight(graphics->device);
- }
- static inline bool is_pow2(uint32_t size)
- {
- return size >= 2 && (size & (size-1)) == 0;
- }
- texture_t gs_create_texture(uint32_t width, uint32_t height,
- enum gs_color_format color_format, uint32_t levels,
- const void **data, uint32_t flags)
- {
- graphics_t graphics = thread_graphics;
- bool pow2tex = is_pow2(width) && is_pow2(height);
- bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1);
- if (uses_mipmaps && !pow2tex) {
- blog(LOG_WARNING, "Cannot use mipmaps with a "
- "non-power-of-two texture. Disabling "
- "mipmaps for this texture.");
- uses_mipmaps = false;
- flags &= ~GS_BUILDMIPMAPS;
- levels = 1;
- }
- if (uses_mipmaps && flags & GS_RENDERTARGET) {
- blog(LOG_WARNING, "Cannot use mipmaps with render targets. "
- "Disabling mipmaps for this texture.");
- flags &= ~GS_BUILDMIPMAPS;
- levels = 1;
- }
- return graphics->exports.device_create_texture(graphics->device,
- width, height, color_format, levels, data, flags);
- }
- texture_t gs_create_cubetexture(uint32_t size,
- enum gs_color_format color_format, uint32_t levels,
- const void **data, uint32_t flags)
- {
- graphics_t graphics = thread_graphics;
- bool pow2tex = is_pow2(size);
- bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1);
- if (uses_mipmaps && !pow2tex) {
- blog(LOG_WARNING, "Cannot use mipmaps with a "
- "non-power-of-two texture. Disabling "
- "mipmaps for this texture.");
- uses_mipmaps = false;
- flags &= ~GS_BUILDMIPMAPS;
- levels = 1;
- }
- if (uses_mipmaps && flags & GS_RENDERTARGET) {
- blog(LOG_WARNING, "Cannot use mipmaps with render targets. "
- "Disabling mipmaps for this texture.");
- flags &= ~GS_BUILDMIPMAPS;
- levels = 1;
- data = NULL;
- }
- return graphics->exports.device_create_cubetexture(graphics->device,
- size, color_format, levels, data, flags);
- }
- texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
- uint32_t depth, enum gs_color_format color_format,
- uint32_t levels, const void **data, uint32_t flags)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_volumetexture(graphics->device,
- width, height, depth, color_format, levels, data,
- flags);
- }
- zstencil_t gs_create_zstencil(uint32_t width, uint32_t height,
- enum gs_zstencil_format format)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_zstencil(graphics->device,
- width, height, format);
- }
- stagesurf_t gs_create_stagesurface(uint32_t width, uint32_t height,
- enum gs_color_format color_format)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_stagesurface(graphics->device,
- width, height, color_format);
- }
- samplerstate_t gs_create_samplerstate(struct gs_sampler_info *info)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_samplerstate(graphics->device,
- info);
- }
- shader_t gs_create_vertexshader(const char *shader, const char *file,
- char **error_string)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_vertexshader(graphics->device,
- shader, file, error_string);
- }
- shader_t gs_create_pixelshader(const char *shader,
- const char *file, char **error_string)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_pixelshader(graphics->device,
- shader, file, error_string);
- }
- vertbuffer_t gs_create_vertexbuffer(struct vb_data *data,
- uint32_t flags)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_vertexbuffer(graphics->device,
- data, flags);
- }
- indexbuffer_t gs_create_indexbuffer(enum gs_index_type type,
- void *indices, size_t num, uint32_t flags)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_create_indexbuffer(graphics->device,
- type, indices, num, flags);
- }
- enum gs_texture_type gs_gettexturetype(texture_t texture)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_gettexturetype(graphics->device,
- texture);
- }
- void gs_load_vertexbuffer(vertbuffer_t vertbuffer)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_vertexbuffer(graphics->device,
- vertbuffer);
- }
- void gs_load_indexbuffer(indexbuffer_t indexbuffer)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_indexbuffer(graphics->device,
- indexbuffer);
- }
- void gs_load_texture(texture_t tex, int unit)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_texture(graphics->device, tex, unit);
- }
- void gs_load_samplerstate(samplerstate_t samplerstate, int unit)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_samplerstate(graphics->device,
- samplerstate, unit);
- }
- void gs_load_vertexshader(shader_t vertshader)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_vertexshader(graphics->device,
- vertshader);
- }
- void gs_load_pixelshader(shader_t pixelshader)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_pixelshader(graphics->device,
- pixelshader);
- }
- void gs_load_defaultsamplerstate(bool b_3d, int unit)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_defaultsamplerstate(graphics->device,
- b_3d, unit);
- }
- shader_t gs_getvertexshader(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getvertexshader(graphics->device);
- }
- shader_t gs_getpixelshader(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getpixelshader(graphics->device);
- }
- texture_t gs_getrendertarget(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getrendertarget(graphics->device);
- }
- zstencil_t gs_getzstenciltarget(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getzstenciltarget(graphics->device);
- }
- void gs_setrendertarget(texture_t tex, zstencil_t zstencil)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setrendertarget(graphics->device, tex,
- zstencil);
- }
- void gs_setcuberendertarget(texture_t cubetex, int side, zstencil_t zstencil)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setcuberendertarget(graphics->device, cubetex,
- side, zstencil);
- }
- void gs_copy_texture(texture_t dst, texture_t src)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_copy_texture(graphics->device, dst, src);
- }
- void gs_stage_texture(stagesurf_t dst, texture_t src)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_stage_texture(graphics->device, dst, src);
- }
- void gs_beginscene(void)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_beginscene(graphics->device);
- }
- void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert,
- uint32_t num_verts)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_draw(graphics->device, draw_mode,
- start_vert, num_verts);
- }
- void gs_endscene(void)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_endscene(graphics->device);
- }
- void gs_load_swapchain(swapchain_t swapchain)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_load_swapchain(graphics->device, swapchain);
- }
- void gs_clear(uint32_t clear_flags, struct vec4 *color, float depth,
- uint8_t stencil)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_clear(graphics->device, clear_flags, color,
- depth, stencil);
- }
- void gs_present(void)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_present(graphics->device);
- }
- void gs_setcullmode(enum gs_cull_mode mode)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setcullmode(graphics->device, mode);
- }
- enum gs_cull_mode gs_getcullmode(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_getcullmode(graphics->device);
- }
- void gs_enable_blending(bool enable)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_blending(graphics->device, enable);
- }
- void gs_enable_depthtest(bool enable)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_depthtest(graphics->device, enable);
- }
- void gs_enable_stenciltest(bool enable)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_stenciltest(graphics->device, enable);
- }
- void gs_enable_stencilwrite(bool enable)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_stencilwrite(graphics->device, enable);
- }
- void gs_enable_color(bool red, bool green, bool blue, bool alpha)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_color(graphics->device, red, green,
- blue, alpha);
- }
- void gs_blendfunction(enum gs_blend_type src, enum gs_blend_type dest)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_blendfunction(graphics->device, src, dest);
- }
- void gs_depthfunction(enum gs_depth_test test)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_depthfunction(graphics->device, test);
- }
- void gs_stencilfunction(enum gs_stencil_side side, enum gs_depth_test test)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_stencilfunction(graphics->device, side, test);
- }
- void gs_stencilop(enum gs_stencil_side side, enum gs_stencil_op fail,
- enum gs_stencil_op zfail, enum gs_stencil_op zpass)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_stencilop(graphics->device, side, fail, zfail,
- zpass);
- }
- void gs_enable_fullscreen(bool enable)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_enable_fullscreen(graphics->device, enable);
- }
- int gs_fullscreen_enabled(void)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.device_fullscreen_enabled(graphics->device);
- }
- void gs_setdisplaymode(const struct gs_display_mode *mode)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setdisplaymode(graphics->device, mode);
- }
- void gs_getdisplaymode(struct gs_display_mode *mode)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_getdisplaymode(graphics->device, mode);
- }
- void gs_setcolorramp(float gamma, float brightness, float contrast)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setcolorramp(graphics->device, gamma,
- brightness, contrast);
- }
- void gs_setviewport(int x, int y, int width, int height)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setviewport(graphics->device, x, y, width,
- height);
- }
- void gs_getviewport(struct gs_rect *rect)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_getviewport(graphics->device, rect);
- }
- void gs_setscissorrect(struct gs_rect *rect)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_setscissorrect(graphics->device, rect);
- }
- void gs_ortho(float left, float right, float top, float bottom, float znear,
- float zfar)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_ortho(graphics->device, left, right, top,
- bottom, znear, zfar);
- }
- void gs_frustum(float left, float right, float top, float bottom, float znear,
- float zfar)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_frustum(graphics->device, left, right, top,
- bottom, znear, zfar);
- }
- void gs_projection_push(void)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_projection_push(graphics->device);
- }
- void gs_projection_pop(void)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.device_projection_pop(graphics->device);
- }
- void swapchain_destroy(swapchain_t swapchain)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.swapchain_destroy(swapchain);
- }
- void shader_destroy(shader_t shader)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_destroy(shader);
- }
- int shader_numparams(shader_t shader)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.shader_numparams(shader);
- }
- sparam_t shader_getparambyidx(shader_t shader, uint32_t param)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.shader_getparambyidx(shader, param);
- }
- sparam_t shader_getparambyname(shader_t shader, const char *name)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.shader_getparambyname(shader, name);
- }
- void shader_getparaminfo(shader_t shader, sparam_t param,
- struct shader_param_info *info)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_getparaminfo(shader, param, info);
- }
- sparam_t shader_getviewprojmatrix(shader_t shader)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.shader_getviewprojmatrix(shader);
- }
- sparam_t shader_getworldmatrix(shader_t shader)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.shader_getworldmatrix(shader);
- }
- void shader_setbool(shader_t shader, sparam_t param, bool val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setbool(shader, param, val);
- }
- void shader_setfloat(shader_t shader, sparam_t param, float val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setfloat(shader, param, val);
- }
- void shader_setint(shader_t shader, sparam_t param, int val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setint(shader, param, val);
- }
- void shader_setmatrix3(shader_t shader, sparam_t param,
- const struct matrix3 *val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setmatrix3(shader, param, val);
- }
- void shader_setmatrix4(shader_t shader, sparam_t param,
- const struct matrix4 *val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setmatrix4(shader, param, val);
- }
- void shader_setvec2(shader_t shader, sparam_t param,
- const struct vec2 *val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setvec2(shader, param, val);
- }
- void shader_setvec3(shader_t shader, sparam_t param,
- const struct vec3 *val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setvec3(shader, param, val);
- }
- void shader_setvec4(shader_t shader, sparam_t param,
- const struct vec4 *val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setvec4(shader, param, val);
- }
- void shader_settexture(shader_t shader, sparam_t param, texture_t val)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_settexture(shader, param, val);
- }
- void shader_setval(shader_t shader, sparam_t param, const void *val,
- size_t size)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setval(shader, param, val, size);
- }
- void shader_setdefault(shader_t shader, sparam_t param)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.shader_setdefault(shader, param);
- }
- void texture_destroy(texture_t tex)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.texture_destroy(tex);
- }
- uint32_t texture_getwidth(texture_t tex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.texture_getwidth(tex);
- }
- uint32_t texture_getheight(texture_t tex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.texture_getheight(tex);
- }
- enum gs_color_format texture_getcolorformat(texture_t tex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.texture_getcolorformat(tex);
- }
- bool texture_map(texture_t tex, void **ptr, uint32_t *row_bytes)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.texture_map(tex, ptr, row_bytes);
- }
- void texture_unmap(texture_t tex)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.texture_unmap(tex);
- }
- void cubetexture_destroy(texture_t cubetex)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.cubetexture_destroy(cubetex);
- }
- uint32_t cubetexture_getsize(texture_t cubetex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.cubetexture_getsize(cubetex);
- }
- enum gs_color_format cubetexture_getcolorformat(texture_t cubetex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.cubetexture_getcolorformat(cubetex);
- }
- void volumetexture_destroy(texture_t voltex)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.volumetexture_destroy(voltex);
- }
- uint32_t volumetexture_getwidth(texture_t voltex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.volumetexture_getwidth(voltex);
- }
- uint32_t volumetexture_getheight(texture_t voltex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.volumetexture_getheight(voltex);
- }
- uint32_t volumetexture_getdepth(texture_t voltex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.volumetexture_getdepth(voltex);
- }
- enum gs_color_format volumetexture_getcolorformat(texture_t voltex)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.volumetexture_getcolorformat(voltex);
- }
- void stagesurface_destroy(stagesurf_t stagesurf)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.stagesurface_destroy(stagesurf);
- }
- uint32_t stagesurface_getwidth(stagesurf_t stagesurf)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.stagesurface_getwidth(stagesurf);
- }
- uint32_t stagesurface_getheight(stagesurf_t stagesurf)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.stagesurface_getheight(stagesurf);
- }
- enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.stagesurface_getcolorformat(stagesurf);
- }
- bool stagesurface_map(stagesurf_t stagesurf, const void **data,
- uint32_t *row_bytes)
- {
- graphics_t graphics = thread_graphics;
- return graphics->exports.stagesurface_map(stagesurf, data, row_bytes);
- }
- void stagesurface_unmap(stagesurf_t stagesurf)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.stagesurface_unmap(stagesurf);
- }
- void zstencil_destroy(zstencil_t zstencil)
- {
- thread_graphics->exports.zstencil_destroy(zstencil);
- }
- void samplerstate_destroy(samplerstate_t samplerstate)
- {
- thread_graphics->exports.samplerstate_destroy(samplerstate);
- }
- void vertexbuffer_destroy(vertbuffer_t vertbuffer)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.vertexbuffer_destroy(vertbuffer);
- }
- void vertexbuffer_flush(vertbuffer_t vertbuffer, bool rebuild)
- {
- thread_graphics->exports.vertexbuffer_flush(vertbuffer, rebuild);
- }
- struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer)
- {
- return thread_graphics->exports.vertexbuffer_getdata(vertbuffer);
- }
- void indexbuffer_destroy(indexbuffer_t indexbuffer)
- {
- graphics_t graphics = thread_graphics;
- graphics->exports.indexbuffer_destroy(indexbuffer);
- }
- void indexbuffer_flush(indexbuffer_t indexbuffer)
- {
- thread_graphics->exports.indexbuffer_flush(indexbuffer);
- }
- void *indexbuffer_getdata(indexbuffer_t indexbuffer)
- {
- return thread_graphics->exports.indexbuffer_getdata(indexbuffer);
- }
- size_t indexbuffer_numindices(indexbuffer_t indexbuffer)
- {
- return thread_graphics->exports.indexbuffer_numindices(indexbuffer);
- }
- enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer)
- {
- return thread_graphics->exports.indexbuffer_gettype(indexbuffer);
- }
|