diff --git a/libobs-d3d11/d3d11-indexbuffer.cpp b/libobs-d3d11/d3d11-indexbuffer.cpp index 82dcfb0b4..997fc39e7 100644 --- a/libobs-d3d11/d3d11-indexbuffer.cpp +++ b/libobs-d3d11/d3d11-indexbuffer.cpp @@ -37,7 +37,7 @@ void gs_index_buffer::InitBuffer() throw HRError("Failed to create buffer", hr); } -gs_index_buffer::gs_index_buffer(device_t device, enum gs_index_type type, +gs_index_buffer::gs_index_buffer(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags) : device (device), type (type), diff --git a/libobs-d3d11/d3d11-samplerstate.cpp b/libobs-d3d11/d3d11-samplerstate.cpp index 2557c126c..63fe26f36 100644 --- a/libobs-d3d11/d3d11-samplerstate.cpp +++ b/libobs-d3d11/d3d11-samplerstate.cpp @@ -59,7 +59,7 @@ static inline D3D11_FILTER ConvertGSFilter( gs_sample_filter filter) return D3D11_FILTER_MIN_MAG_MIP_POINT; } -gs_sampler_state::gs_sampler_state(device_t device, gs_sampler_info *info) +gs_sampler_state::gs_sampler_state(gs_device_t device, gs_sampler_info *info) : device (device), info (*info) { diff --git a/libobs-d3d11/d3d11-shader.cpp b/libobs-d3d11/d3d11-shader.cpp index a97f9266c..af6548c65 100644 --- a/libobs-d3d11/d3d11-shader.cpp +++ b/libobs-d3d11/d3d11-shader.cpp @@ -38,9 +38,9 @@ void gs_vertex_shader::GetBuffersExpected( } } -gs_vertex_shader::gs_vertex_shader(device_t device, const char *file, +gs_vertex_shader::gs_vertex_shader(gs_device_t device, const char *file, const char *shaderString) - : gs_shader (device, SHADER_VERTEX), + : gs_shader (device, GS_SHADER_VERTEX), hasNormals (false), hasColors (false), hasTangents (false), @@ -72,13 +72,13 @@ gs_vertex_shader::gs_vertex_shader(device_t device, const char *file, if (FAILED(hr)) throw HRError("Failed to create input layout", hr); - viewProj = shader_getparambyname(this, "ViewProj"); - world = shader_getparambyname(this, "World"); + viewProj = gs_shader_get_param_by_name(this, "ViewProj"); + world = gs_shader_get_param_by_name(this, "World"); } -gs_pixel_shader::gs_pixel_shader(device_t device, const char *file, +gs_pixel_shader::gs_pixel_shader(gs_device_t device, const char *file, const char *shaderString) - : gs_shader(device, SHADER_PIXEL) + : gs_shader(device, GS_SHADER_PIXEL) { ShaderProcessor processor(device); ComPtr shaderBlob; @@ -125,17 +125,17 @@ gs_pixel_shader::gs_pixel_shader(device_t device, const char *file, void gs_shader::BuildConstantBuffer() { for (size_t i = 0; i < params.size(); i++) { - shader_param ¶m = params[i]; + gs_shader_param ¶m = params[i]; size_t size = 0; switch (param.type) { - case SHADER_PARAM_BOOL: - case SHADER_PARAM_INT: - case SHADER_PARAM_FLOAT: size = sizeof(float); break; - case SHADER_PARAM_VEC2: size = sizeof(vec2); break; - case SHADER_PARAM_VEC3: size = sizeof(float)*3; break; - case SHADER_PARAM_VEC4: size = sizeof(vec4); break; - case SHADER_PARAM_MATRIX4X4: size = sizeof(float)*4*4; + case GS_SHADER_PARAM_BOOL: + case GS_SHADER_PARAM_INT: + case GS_SHADER_PARAM_FLOAT: size = sizeof(float); break; + case GS_SHADER_PARAM_VEC2: size = sizeof(vec2); break; + case GS_SHADER_PARAM_VEC3: size = sizeof(float)*3; break; + case GS_SHADER_PARAM_VEC4: size = sizeof(vec4); break; + case GS_SHADER_PARAM_MATRIX4X4: size = sizeof(float)*4*4; } /* checks to see if this constant needs to start at a new @@ -168,7 +168,7 @@ void gs_shader::BuildConstantBuffer() } for (size_t i = 0; i < params.size(); i++) - shader_setdefault(¶ms[i]); + gs_shader_set_default(¶ms[i]); } void gs_shader::Compile(const char *shaderString, const char *file, @@ -193,9 +193,9 @@ void gs_shader::Compile(const char *shaderString, const char *file, } inline void gs_shader::UpdateParam(vector &constData, - shader_param ¶m, bool &upload) + gs_shader_param ¶m, bool &upload) { - if (param.type != SHADER_PARAM_TEXTURE) { + if (param.type != GS_SHADER_PARAM_TEXTURE) { if (!param.curValue.size()) throw "Not all shader parameters were set"; @@ -216,9 +216,9 @@ inline void gs_shader::UpdateParam(vector &constData, upload = true; param.changed = false; } - } else if (param.curValue.size() == sizeof(texture_t)) { - texture_t tex; - memcpy(&tex, param.curValue.data(), sizeof(texture_t)); + } else if (param.curValue.size() == sizeof(gs_texture_t)) { + gs_texture_t tex; + memcpy(&tex, param.curValue.data(), sizeof(gs_texture_t)); device_load_texture(device, tex, param.textureID); } } @@ -250,25 +250,25 @@ void gs_shader::UploadParams() } } -void shader_destroy(shader_t shader) +void gs_shader_destroy(gs_shader_t shader) { delete shader; } -int shader_numparams(shader_t shader) +int gs_shader_get_num_params(gs_shader_t shader) { return (int)shader->params.size(); } -sparam_t shader_getparambyidx(shader_t shader, uint32_t param) +gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, uint32_t param) { return &shader->params[param]; } -sparam_t shader_getparambyname(shader_t shader, const char *name) +gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, const char *name) { for (size_t i = 0; i < shader->params.size(); i++) { - shader_param ¶m = shader->params[i]; + gs_shader_param ¶m = shader->params[i]; if (strcmp(param.name.c_str(), name) == 0) return ¶m; } @@ -276,23 +276,24 @@ sparam_t shader_getparambyname(shader_t shader, const char *name) return NULL; } -sparam_t shader_getviewprojmatrix(shader_t shader) +gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader) { - if (shader->type != SHADER_VERTEX) + if (shader->type != GS_SHADER_VERTEX) return NULL; return static_cast(shader)->viewProj; } -sparam_t shader_getworldmatrix(shader_t shader) +gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader) { - if (shader->type != SHADER_VERTEX) + if (shader->type != GS_SHADER_VERTEX) return NULL; return static_cast(shader)->world; } -void shader_getparaminfo(sparam_t param, struct shader_param_info *info) +void gs_shader_get_param_info(gs_sparam_t param, + struct gs_shader_param_info *info) { if (!param) return; @@ -301,8 +302,8 @@ void shader_getparaminfo(sparam_t param, struct shader_param_info *info) info->type = param->type; } -static inline void shader_setval_inline(shader_param *param, const void *data, - size_t size) +static inline void shader_setval_inline(gs_shader_param *param, + const void *data, size_t size) { assert(param); if (!param) @@ -318,59 +319,59 @@ static inline void shader_setval_inline(shader_param *param, const void *data, } } -void shader_setbool(sparam_t param, bool val) +void gs_shader_set_bool(gs_sparam_t param, bool val) { shader_setval_inline(param, &val, sizeof(bool)); } -void shader_setfloat(sparam_t param, float val) +void gs_shader_set_float(gs_sparam_t param, float val) { shader_setval_inline(param, &val, sizeof(float)); } -void shader_setint(sparam_t param, int val) +void gs_shader_set_int(gs_sparam_t param, int val) { shader_setval_inline(param, &val, sizeof(int)); } -void shader_setmatrix3(sparam_t param, const struct matrix3 *val) +void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val) { struct matrix4 mat; matrix4_from_matrix3(&mat, val); shader_setval_inline(param, &mat, sizeof(matrix4)); } -void shader_setmatrix4(sparam_t param, const struct matrix4 *val) +void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val) { shader_setval_inline(param, val, sizeof(matrix4)); } -void shader_setvec2(sparam_t param, const struct vec2 *val) +void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val) { shader_setval_inline(param, val, sizeof(vec2)); } -void shader_setvec3(sparam_t param, const struct vec3 *val) +void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val) { shader_setval_inline(param, val, sizeof(float) * 3); } -void shader_setvec4(sparam_t param, const struct vec4 *val) +void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val) { shader_setval_inline(param, val, sizeof(vec4)); } -void shader_settexture(sparam_t param, texture_t val) +void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val) { - shader_setval_inline(param, &val, sizeof(texture_t)); + shader_setval_inline(param, &val, sizeof(gs_texture_t)); } -void shader_setval(sparam_t param, const void *val, size_t size) +void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size) { shader_setval_inline(param, val, size); } -void shader_setdefault(sparam_t param) +void gs_shader_set_default(gs_sparam_t param) { if (param->defaultValue.size()) shader_setval_inline(param, param->defaultValue.data(), diff --git a/libobs-d3d11/d3d11-shaderprocessor.cpp b/libobs-d3d11/d3d11-shaderprocessor.cpp index 300a774fa..3ac9b0d1e 100644 --- a/libobs-d3d11/d3d11-shaderprocessor.cpp +++ b/libobs-d3d11/d3d11-shaderprocessor.cpp @@ -146,7 +146,7 @@ void ShaderProcessor::BuildInputLayout( BuildInputLayoutFromVars(&parser, &func->params.da, layout); } -shader_param::shader_param(shader_var &var, uint32_t &texCounter) +gs_shader_param::gs_shader_param(shader_var &var, uint32_t &texCounter) : type (get_shader_param_type(var.type)), name (var.name), textureID (texCounter), @@ -156,23 +156,23 @@ shader_param::shader_param(shader_var &var, uint32_t &texCounter) defaultValue.resize(var.default_val.num); memcpy(defaultValue.data(), var.default_val.array, var.default_val.num); - if (type == SHADER_PARAM_TEXTURE) + if (type == GS_SHADER_PARAM_TEXTURE) texCounter++; else textureID = 0; } -static inline void AddParam(shader_var &var, vector ¶ms, +static inline void AddParam(shader_var &var, vector ¶ms, uint32_t &texCounter) { if (var.var_type != SHADER_VAR_UNIFORM || strcmp(var.type, "sampler") == 0) return; - params.push_back(shader_param(var, texCounter)); + params.push_back(gs_shader_param(var, texCounter)); } -void ShaderProcessor::BuildParams(vector ¶ms) +void ShaderProcessor::BuildParams(vector ¶ms) { uint32_t texCounter = 0; @@ -180,7 +180,7 @@ void ShaderProcessor::BuildParams(vector ¶ms) AddParam(parser.params.array[i], params, texCounter); } -static inline void AddSampler(device_t device, shader_sampler &sampler, +static inline void AddSampler(gs_device_t device, shader_sampler &sampler, vector &samplers) { gs_sampler_info si; diff --git a/libobs-d3d11/d3d11-shaderprocessor.hpp b/libobs-d3d11/d3d11-shaderprocessor.hpp index 9178a4c5f..e1252f76b 100644 --- a/libobs-d3d11/d3d11-shaderprocessor.hpp +++ b/libobs-d3d11/d3d11-shaderprocessor.hpp @@ -25,16 +25,16 @@ struct ShaderParser : shader_parser { }; struct ShaderProcessor { - device_t device; + gs_device_t device; ShaderParser parser; void BuildInputLayout(vector &inputs); - void BuildParams(vector ¶ms); + void BuildParams(vector ¶ms); void BuildSamplers(vector &samplers); void BuildString(string &outputString); void Process(const char *shader_string, const char *file); - inline ShaderProcessor(device_t device) : device(device) + inline ShaderProcessor(gs_device_t device) : device(device) { } }; diff --git a/libobs-d3d11/d3d11-stagesurf.cpp b/libobs-d3d11/d3d11-stagesurf.cpp index 7af6d4573..6b9881b03 100644 --- a/libobs-d3d11/d3d11-stagesurf.cpp +++ b/libobs-d3d11/d3d11-stagesurf.cpp @@ -17,7 +17,7 @@ #include "d3d11-subsystem.hpp" -gs_stage_surface::gs_stage_surface(device_t device, uint32_t width, +gs_stage_surface::gs_stage_surface(gs_device_t device, uint32_t width, uint32_t height, gs_color_format colorFormat) : device (device), width (width), diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index ddb2d25bc..9c475eaa3 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -387,7 +387,7 @@ void gs_device::UpdateViewProjMatrix() matrix4_transpose(&curViewProjMatrix, &curViewProjMatrix); if (curVertexShader->viewProj) - shader_setmatrix4(curVertexShader->viewProj, + gs_shader_set_matrix4(curVertexShader->viewProj, &curViewProjMatrix); } @@ -423,15 +423,15 @@ gs_device::gs_device(gs_init_data *data) InitFactory(data->adapter, adapter.Assign()); InitDevice(data, adapter); - device_setrendertarget(this, NULL, NULL); + device_set_render_target(this, NULL, NULL); } -const char *device_name(void) +const char *device_get_name(void) { return "Direct3D 11"; } -int device_type(void) +int device_get_type(void) { return GS_DEVICE_DIRECT3D_11; } @@ -441,7 +441,7 @@ const char *device_preprocessor_name(void) return "_D3D11"; } -int device_create(device_t *p_device, gs_init_data *data) +int device_create(gs_device_t *p_device, gs_init_data *data) { gs_device *device = NULL; int errorcode = GS_SUCCESS; @@ -464,38 +464,39 @@ int device_create(device_t *p_device, gs_init_data *data) return errorcode; } -void device_destroy(device_t device) +void device_destroy(gs_device_t device) { delete device; } -void device_entercontext(device_t device) +void device_enter_context(gs_device_t device) { /* does nothing */ UNUSED_PARAMETER(device); } -void device_leavecontext(device_t device) +void device_leave_context(gs_device_t device) { /* does nothing */ UNUSED_PARAMETER(device); } -swapchain_t device_create_swapchain(device_t device, struct gs_init_data *data) +gs_swapchain_t device_swapchain_create(gs_device_t device, + struct gs_init_data *data) { gs_swap_chain *swap = NULL; try { swap = new gs_swap_chain(device, data); } catch (HRError error) { - blog(LOG_ERROR, "device_create_swapchain (D3D11): %s (%08lX)", + blog(LOG_ERROR, "device_swapchain_create (D3D11): %s (%08lX)", error.str, error.hr); } return swap; } -void device_resize(device_t device, uint32_t cx, uint32_t cy) +void device_resize(gs_device_t device, uint32_t cx, uint32_t cy) { try { ID3D11RenderTargetView *renderView = NULL; @@ -517,23 +518,23 @@ void device_resize(device_t device, uint32_t cx, uint32_t cy) } } -void device_getsize(device_t device, uint32_t *cx, uint32_t *cy) +void device_get_size(gs_device_t device, uint32_t *cx, uint32_t *cy) { *cx = device->curSwapChain->target.width; *cy = device->curSwapChain->target.height; } -uint32_t device_getwidth(device_t device) +uint32_t device_get_width(gs_device_t device) { return device->curSwapChain->target.width; } -uint32_t device_getheight(device_t device) +uint32_t device_get_height(gs_device_t device) { return device->curSwapChain->target.height; } -texture_t device_create_texture(device_t device, uint32_t width, +gs_texture_t device_texture_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags) { @@ -543,16 +544,16 @@ texture_t device_create_texture(device_t device, uint32_t width, levels, data, flags, GS_TEXTURE_2D, false, false); } catch (HRError error) { - blog(LOG_ERROR, "device_create_texture (D3D11): %s (%08lX)", + blog(LOG_ERROR, "device_texture_create (D3D11): %s (%08lX)", error.str, error.hr); } catch (const char *error) { - blog(LOG_ERROR, "device_create_texture (D3D11): %s", error); + blog(LOG_ERROR, "device_texture_create (D3D11): %s", error); } return texture; } -texture_t device_create_cubetexture(device_t device, uint32_t size, +gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags) { @@ -562,18 +563,18 @@ texture_t device_create_cubetexture(device_t device, uint32_t size, levels, data, flags, GS_TEXTURE_CUBE, false, false); } catch (HRError error) { - blog(LOG_ERROR, "device_create_cubetexture (D3D11): %s " + blog(LOG_ERROR, "device_cubetexture_create (D3D11): %s " "(%08lX)", error.str, error.hr); } catch (const char *error) { - blog(LOG_ERROR, "device_create_cubetexture (D3D11): %s", + blog(LOG_ERROR, "device_cubetexture_create (D3D11): %s", error); } return texture; } -texture_t device_create_volumetexture(device_t device, uint32_t width, +gs_texture_t device_voltexture_create(gs_device_t device, 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) @@ -590,7 +591,7 @@ texture_t device_create_volumetexture(device_t device, uint32_t width, return NULL; } -zstencil_t device_create_zstencil(device_t device, uint32_t width, +gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_zstencil_format format) { gs_zstencil_buffer *zstencil = NULL; @@ -598,14 +599,14 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width, zstencil = new gs_zstencil_buffer(device, width, height, format); } catch (HRError error) { - blog(LOG_ERROR, "device_create_zstencil (D3D11): %s (%08lX)", + blog(LOG_ERROR, "device_zstencil_create (D3D11): %s (%08lX)", error.str, error.hr); } return zstencil; } -stagesurf_t device_create_stagesurface(device_t device, uint32_t width, +gs_stagesurf_t device_stagesurface_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format) { gs_stage_surface *surf = NULL; @@ -613,7 +614,7 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width, surf = new gs_stage_surface(device, width, height, color_format); } catch (HRError error) { - blog(LOG_ERROR, "device_create_stagesurface (D3D11): %s " + blog(LOG_ERROR, "device_stagesurface_create (D3D11): %s " "(%08lX)", error.str, error.hr); } @@ -621,14 +622,14 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width, return surf; } -samplerstate_t device_create_samplerstate(device_t device, +gs_samplerstate_t device_samplerstate_create(gs_device_t device, struct gs_sampler_info *info) { gs_sampler_state *ss = NULL; try { ss = new gs_sampler_state(device, info); } catch (HRError error) { - blog(LOG_ERROR, "device_create_samplerstate (D3D11): %s " + blog(LOG_ERROR, "device_samplerstate_create (D3D11): %s " "(%08lX)", error.str, error.hr); } @@ -636,7 +637,7 @@ samplerstate_t device_create_samplerstate(device_t device, return ss; } -shader_t device_create_vertexshader(device_t device, +gs_shader_t device_vertexshader_create(gs_device_t device, const char *shader_string, const char *file, char **error_string) { @@ -645,7 +646,7 @@ shader_t device_create_vertexshader(device_t device, shader = new gs_vertex_shader(device, file, shader_string); } catch (HRError error) { - blog(LOG_ERROR, "device_create_vertexshader (D3D11): %s " + blog(LOG_ERROR, "device_vertexshader_create (D3D11): %s " "(%08lX)", error.str, error.hr); @@ -653,19 +654,19 @@ shader_t device_create_vertexshader(device_t device, const char *buf = (const char*)error.errors->GetBufferPointer(); if (error_string) *error_string = bstrdup(buf); - blog(LOG_ERROR, "device_create_vertexshader (D3D11): " + blog(LOG_ERROR, "device_vertexshader_create (D3D11): " "Compile warnings/errors for %s:\n%s", file, buf); } catch (const char *error) { - blog(LOG_ERROR, "device_create_vertexshader (D3D11): %s", + blog(LOG_ERROR, "device_vertexshader_create (D3D11): %s", error); } return shader; } -shader_t device_create_pixelshader(device_t device, +gs_shader_t device_pixelshader_create(gs_device_t device, const char *shader_string, const char *file, char **error_string) { @@ -674,7 +675,7 @@ shader_t device_create_pixelshader(device_t device, shader = new gs_pixel_shader(device, file, shader_string); } catch (HRError error) { - blog(LOG_ERROR, "device_create_pixelshader (D3D11): %s " + blog(LOG_ERROR, "device_pixelshader_create (D3D11): %s " "(%08lX)", error.str, error.hr); @@ -682,37 +683,37 @@ shader_t device_create_pixelshader(device_t device, const char *buf = (const char*)error.errors->GetBufferPointer(); if (error_string) *error_string = bstrdup(buf); - blog(LOG_ERROR, "device_create_pixelshader (D3D11): " + blog(LOG_ERROR, "device_pixelshader_create (D3D11): " "Compiler warnings/errors for %s:\n%s", file, buf); } catch (const char *error) { - blog(LOG_ERROR, "device_create_pixelshader (D3D11): %s", + blog(LOG_ERROR, "device_pixelshader_create (D3D11): %s", error); } return shader; } -vertbuffer_t device_create_vertexbuffer(device_t device, - struct vb_data *data, uint32_t flags) +gs_vertbuffer_t device_vertexbuffer_create(gs_device_t device, + struct gs_vb_data *data, uint32_t flags) { gs_vertex_buffer *buffer = NULL; try { buffer = new gs_vertex_buffer(device, data, flags); } catch (HRError error) { - blog(LOG_ERROR, "device_create_vertexbuffer (D3D11): %s " + blog(LOG_ERROR, "device_vertexbuffer_create (D3D11): %s " "(%08lX)", error.str, error.hr); } catch (const char *error) { - blog(LOG_ERROR, "device_create_vertexbuffer (D3D11): %s", + blog(LOG_ERROR, "device_vertexbuffer_create (D3D11): %s", error); } return buffer; } -indexbuffer_t device_create_indexbuffer(device_t device, +gs_indexbuffer_t device_indexbuffer_create(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags) { @@ -720,19 +721,19 @@ indexbuffer_t device_create_indexbuffer(device_t device, try { buffer = new gs_index_buffer(device, type, indices, num, flags); } catch (HRError error) { - blog(LOG_ERROR, "device_create_indexbuffer (D3D11): %s (%08lX)", + blog(LOG_ERROR, "device_indexbuffer_create (D3D11): %s (%08lX)", error.str, error.hr); } return buffer; } -enum gs_texture_type device_gettexturetype(texture_t texture) +enum gs_texture_type device_get_texture_type(gs_texture_t texture) { return texture->type; } -void device_load_vertexbuffer(device_t device, vertbuffer_t vertbuffer) +void device_load_vertexbuffer(gs_device_t device, gs_vertbuffer_t vertbuffer) { if (device->curVertexBuffer == vertbuffer) return; @@ -761,7 +762,7 @@ void device_load_vertexbuffer(device_t device, vertbuffer_t vertbuffer) buffers.data(), strides.data(), offsets.data()); } -void device_load_indexbuffer(device_t device, indexbuffer_t indexbuffer) +void device_load_indexbuffer(gs_device_t device, gs_indexbuffer_t indexbuffer) { DXGI_FORMAT format; ID3D11Buffer *buffer; @@ -786,7 +787,7 @@ void device_load_indexbuffer(device_t device, indexbuffer_t indexbuffer) device->context->IASetIndexBuffer(buffer, format, 0); } -void device_load_texture(device_t device, texture_t tex, int unit) +void device_load_texture(gs_device_t device, gs_texture_t tex, int unit) { ID3D11ShaderResourceView *view = NULL; @@ -800,8 +801,8 @@ void device_load_texture(device_t device, texture_t tex, int unit) device->context->PSSetShaderResources(unit, 1, &view); } -void device_load_samplerstate(device_t device, - samplerstate_t samplerstate, int unit) +void device_load_samplerstate(gs_device_t device, + gs_samplerstate_t samplerstate, int unit) { ID3D11SamplerState *state = NULL; @@ -815,7 +816,7 @@ void device_load_samplerstate(device_t device, device->context->PSSetSamplers(unit, 1, &state); } -void device_load_vertexshader(device_t device, shader_t vertshader) +void device_load_vertexshader(gs_device_t device, gs_shader_t vertshader) { ID3D11VertexShader *shader = NULL; ID3D11InputLayout *layout = NULL; @@ -828,7 +829,7 @@ void device_load_vertexshader(device_t device, shader_t vertshader) gs_vertex_buffer *curVB = device->curVertexBuffer; if (vertshader) { - if (vertshader->type != SHADER_VERTEX) { + if (vertshader->type != GS_SHADER_VERTEX) { blog(LOG_ERROR, "device_load_vertexshader (D3D11): " "Specified shader is not a vertex " "shader"); @@ -852,7 +853,7 @@ void device_load_vertexshader(device_t device, shader_t vertshader) device_load_vertexbuffer(device, curVB); } -static inline void clear_textures(device_t device) +static inline void clear_textures(gs_device_t device) { ID3D11ShaderResourceView *views[GS_MAX_TEXTURES]; memset(views, 0, sizeof(views)); @@ -860,7 +861,7 @@ static inline void clear_textures(device_t device) device->context->PSSetShaderResources(0, GS_MAX_TEXTURES, views); } -void device_load_pixelshader(device_t device, shader_t pixelshader) +void device_load_pixelshader(gs_device_t device, gs_shader_t pixelshader) { ID3D11PixelShader *shader = NULL; ID3D11Buffer *constants = NULL; @@ -872,7 +873,7 @@ void device_load_pixelshader(device_t device, shader_t pixelshader) gs_pixel_shader *ps = static_cast(pixelshader); if (pixelshader) { - if (pixelshader->type != SHADER_PIXEL) { + if (pixelshader->type != GS_SHADER_PIXEL) { blog(LOG_ERROR, "device_load_pixelshader (D3D11): " "Specified shader is not a pixel " "shader"); @@ -899,7 +900,7 @@ void device_load_pixelshader(device_t device, shader_t pixelshader) device->curSamplers[i] = nullptr; } -void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit) +void device_load_default_samplerstate(gs_device_t device, bool b_3d, int unit) { /* TODO */ UNUSED_PARAMETER(device); @@ -907,17 +908,17 @@ void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit) UNUSED_PARAMETER(unit); } -shader_t device_getvertexshader(device_t device) +gs_shader_t device_get_vertex_shader(gs_device_t device) { return device->curVertexShader; } -shader_t device_getpixelshader(device_t device) +gs_shader_t device_get_pixel_shader(gs_device_t device) { return device->curPixelShader; } -texture_t device_getrendertarget(device_t device) +gs_texture_t device_get_render_target(gs_device_t device) { if (device->curRenderTarget == &device->curSwapChain->target) return NULL; @@ -925,7 +926,7 @@ texture_t device_getrendertarget(device_t device) return device->curRenderTarget; } -zstencil_t device_getzstenciltarget(device_t device) +gs_zstencil_t device_get_zstencil_target(gs_device_t device) { if (device->curZStencilBuffer == &device->curSwapChain->zs) return NULL; @@ -933,7 +934,8 @@ zstencil_t device_getzstenciltarget(device_t device) return device->curZStencilBuffer; } -void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil) +void device_set_render_target(gs_device_t device, gs_texture_t tex, + gs_zstencil_t zstencil) { if (!tex) tex = &device->curSwapChain->target; @@ -945,14 +947,14 @@ void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil) return; if (tex->type != GS_TEXTURE_2D) { - blog(LOG_ERROR, "device_setrendertarget (D3D11): " + blog(LOG_ERROR, "device_set_render_target (D3D11): " "texture is not a 2D texture"); return; } gs_texture_2d *tex2d = static_cast(tex); if (!tex2d->renderTarget[0]) { - blog(LOG_ERROR, "device_setrendertarget (D3D11): " + blog(LOG_ERROR, "device_set_render_target (D3D11): " "texture is not a render target"); return; } @@ -965,8 +967,8 @@ void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil) device->context->OMSetRenderTargets(1, &rt, zstencil->view); } -void device_setcuberendertarget(device_t device, texture_t tex, int side, - zstencil_t zstencil) +void device_set_cube_render_target(gs_device_t device, gs_texture_t tex, + int side, gs_zstencil_t zstencil) { if (!tex) { tex = &device->curSwapChain->target; @@ -982,14 +984,14 @@ void device_setcuberendertarget(device_t device, texture_t tex, int side, return; if (tex->type != GS_TEXTURE_CUBE) { - blog(LOG_ERROR, "device_setcuberendertarget (D3D11): " + blog(LOG_ERROR, "device_set_cube_render_target (D3D11): " "texture is not a cube texture"); return; } gs_texture_2d *tex2d = static_cast(tex); if (!tex2d->renderTarget[side]) { - blog(LOG_ERROR, "device_setcuberendertarget (D3D11): " + blog(LOG_ERROR, "device_set_cube_render_target (D3D11): " "texture is not a render target"); return; } @@ -1004,7 +1006,7 @@ void device_setcuberendertarget(device_t device, texture_t tex, int side, inline void gs_device::CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, + gs_texture_t src, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h) { if (src->type != GS_TEXTURE_2D) @@ -1039,9 +1041,9 @@ inline void gs_device::CopyTex(ID3D11Texture2D *dst, } } -void device_copy_texture_region(device_t device, - texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, +void device_copy_texture_region(gs_device_t device, + 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) { try { @@ -1088,12 +1090,13 @@ void device_copy_texture_region(device_t device, } } -void device_copy_texture(device_t device, texture_t dst, texture_t src) +void device_copy_texture(gs_device_t device, gs_texture_t dst, gs_texture_t src) { device_copy_texture_region(device, dst, 0, 0, src, 0, 0, 0, 0); } -void device_stage_texture(device_t device, stagesurf_t dst, texture_t src) +void device_stage_texture(gs_device_t device, gs_stagesurf_t dst, + gs_texture_t src) { try { gs_texture_2d *src2d = static_cast(src); @@ -1118,12 +1121,12 @@ void device_stage_texture(device_t device, stagesurf_t dst, texture_t src) } } -void device_beginscene(device_t device) +void device_begin_scene(gs_device_t device) { clear_textures(device); } -void device_draw(device_t device, enum gs_draw_mode draw_mode, +void device_draw(gs_device_t device, enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts) { try { @@ -1136,9 +1139,9 @@ void device_draw(device_t device, enum gs_draw_mode draw_mode, if (!device->curVertexBuffer) throw "No vertex buffer specified"; - effect_t effect = gs_geteffect(); + gs_effect_t effect = gs_get_effect(); if (effect) - effect_updateparams(effect); + gs_effect_update_params(effect); device->UpdateBlendState(); device->UpdateRasterState(); @@ -1174,16 +1177,16 @@ void device_draw(device_t device, enum gs_draw_mode draw_mode, } } -void device_endscene(device_t device) +void device_end_scene(gs_device_t device) { /* does nothing in D3D11 */ UNUSED_PARAMETER(device); } -void device_load_swapchain(device_t device, swapchain_t swapchain) +void device_load_swapchain(gs_device_t device, gs_swapchain_t swapchain) { - texture_t target = device->curRenderTarget; - zstencil_t zs = device->curZStencilBuffer; + gs_texture_t target = device->curRenderTarget; + gs_zstencil_t zs = device->curZStencilBuffer; bool is_cube = device->curRenderTarget->type == GS_TEXTURE_CUBE; if (target == &device->curSwapChain->target) @@ -1197,13 +1200,13 @@ void device_load_swapchain(device_t device, swapchain_t swapchain) device->curSwapChain = swapchain; if (is_cube) - device_setcuberendertarget(device, target, + device_set_cube_render_target(device, target, device->curRenderSide, zs); else - device_setrendertarget(device, target, zs); + device_set_render_target(device, target, zs); } -void device_clear(device_t device, uint32_t clear_flags, struct vec4 *color, +void device_clear(gs_device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil) { int side = device->curRenderSide; @@ -1226,17 +1229,17 @@ void device_clear(device_t device, uint32_t clear_flags, struct vec4 *color, } } -void device_present(device_t device) +void device_present(gs_device_t device) { device->curSwapChain->swap->Present(0, 0); } -void device_flush(device_t device) +void device_flush(gs_device_t device) { device->context->Flush(); } -void device_setcullmode(device_t device, enum gs_cull_mode mode) +void device_set_cull_mode(gs_device_t device, enum gs_cull_mode mode) { if (mode == device->rasterState.cullMode) return; @@ -1245,12 +1248,12 @@ void device_setcullmode(device_t device, enum gs_cull_mode mode) device->rasterStateChanged = true; } -enum gs_cull_mode device_getcullmode(device_t device) +enum gs_cull_mode device_get_cull_mode(gs_device_t device) { return device->rasterState.cullMode; } -void device_enable_blending(device_t device, bool enable) +void device_enable_blending(gs_device_t device, bool enable) { if (enable == device->blendState.blendEnabled) return; @@ -1259,7 +1262,7 @@ void device_enable_blending(device_t device, bool enable) device->blendStateChanged = true; } -void device_enable_depthtest(device_t device, bool enable) +void device_enable_depth_test(gs_device_t device, bool enable) { if (enable == device->zstencilState.depthEnabled) return; @@ -1268,7 +1271,7 @@ void device_enable_depthtest(device_t device, bool enable) device->zstencilStateChanged = true; } -void device_enable_stenciltest(device_t device, bool enable) +void device_enable_stencil_test(gs_device_t device, bool enable) { if (enable == device->zstencilState.stencilEnabled) return; @@ -1277,7 +1280,7 @@ void device_enable_stenciltest(device_t device, bool enable) device->zstencilStateChanged = true; } -void device_enable_stencilwrite(device_t device, bool enable) +void device_enable_stencil_write(gs_device_t device, bool enable) { if (enable == device->zstencilState.stencilWriteEnabled) return; @@ -1286,7 +1289,7 @@ void device_enable_stencilwrite(device_t device, bool enable) device->zstencilStateChanged = true; } -void device_enable_color(device_t device, bool red, bool green, +void device_enable_color(gs_device_t device, bool red, bool green, bool blue, bool alpha) { if (device->blendState.redEnabled == red && @@ -1302,7 +1305,7 @@ void device_enable_color(device_t device, bool red, bool green, device->blendStateChanged = true; } -void device_blendfunction(device_t device, enum gs_blend_type src, +void device_blend_function(gs_device_t device, enum gs_blend_type src, enum gs_blend_type dest) { if (device->blendState.srcFactor == src && @@ -1314,7 +1317,7 @@ void device_blendfunction(device_t device, enum gs_blend_type src, device->blendStateChanged = true; } -void device_depthfunction(device_t device, enum gs_depth_test test) +void device_depth_function(gs_device_t device, enum gs_depth_test test) { if (device->zstencilState.depthFunc == test) return; @@ -1323,7 +1326,7 @@ void device_depthfunction(device_t device, enum gs_depth_test test) device->zstencilStateChanged = true; } -static inline void update_stencilside_test(device_t device, StencilSide &side, +static inline void update_stencilside_test(gs_device_t device, StencilSide &side, gs_depth_test test) { if (side.test == test) @@ -1333,7 +1336,7 @@ static inline void update_stencilside_test(device_t device, StencilSide &side, device->zstencilStateChanged = true; } -void device_stencilfunction(device_t device, enum gs_stencil_side side, +void device_stencil_function(gs_device_t device, enum gs_stencil_side side, enum gs_depth_test test) { int sideVal = (int)side; @@ -1346,9 +1349,9 @@ void device_stencilfunction(device_t device, enum gs_stencil_side side, device->zstencilState.stencilBack, test); } -static inline void update_stencilside_op(device_t device, StencilSide &side, - enum gs_stencil_op fail, enum gs_stencil_op zfail, - enum gs_stencil_op zpass) +static inline void update_stencilside_op(gs_device_t device, StencilSide &side, + enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail, + enum gs_stencil_op_type zpass) { if (side.fail == fail && side.zfail == zfail && side.zpass == zpass) return; @@ -1359,9 +1362,9 @@ static inline void update_stencilside_op(device_t device, StencilSide &side, device->zstencilStateChanged = true; } -void device_stencilop(device_t device, enum gs_stencil_side side, - enum gs_stencil_op fail, enum gs_stencil_op zfail, - enum gs_stencil_op zpass) +void device_stencil_op(gs_device_t device, enum gs_stencil_side side, + enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail, + enum gs_stencil_op_type zpass) { int sideVal = (int)side; @@ -1375,7 +1378,7 @@ void device_stencilop(device_t device, enum gs_stencil_side side, fail, zfail, zpass); } -void device_setviewport(device_t device, int x, int y, int width, +void device_set_viewport(gs_device_t device, int x, int y, int width, int height) { D3D11_VIEWPORT vp; @@ -1393,12 +1396,12 @@ void device_setviewport(device_t device, int x, int y, int width, device->viewport.cy = height; } -void device_getviewport(device_t device, struct gs_rect *rect) +void device_get_viewport(gs_device_t device, struct gs_rect *rect) { memcpy(rect, &device->viewport, sizeof(gs_rect)); } -void device_setscissorrect(device_t device, struct gs_rect *rect) +void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect) { D3D11_RECT d3drect; @@ -1415,7 +1418,7 @@ void device_setscissorrect(device_t device, struct gs_rect *rect) device->rasterStateChanged = true; } -void device_ortho(device_t device, float left, float right, float top, +void device_ortho(gs_device_t device, float left, float right, float top, float bottom, float zNear, float zFar) { matrix4 *dst = &device->curProjMatrix; @@ -1441,7 +1444,7 @@ void device_ortho(device_t device, float left, float right, float top, dst->t.w = 1.0f; } -void device_frustum(device_t device, float left, float right, float top, +void device_frustum(gs_device_t device, float left, float right, float top, float bottom, float zNear, float zFar) { matrix4 *dst = &device->curProjMatrix; @@ -1468,14 +1471,14 @@ void device_frustum(device_t device, float left, float right, float top, dst->z.w = 1.0f; } -void device_projection_push(device_t device) +void device_projection_push(gs_device_t device) { mat4float mat; memcpy(&mat, &device->curProjMatrix, sizeof(matrix4)); device->projStack.push_back(mat); } -void device_projection_pop(device_t device) +void device_projection_pop(gs_device_t device) { if (!device->projStack.size()) return; @@ -1488,7 +1491,7 @@ void device_projection_pop(device_t device) device->projStack.pop_back(); } -void swapchain_destroy(swapchain_t swapchain) +void gs_swapchain_destroy(gs_swapchain_t swapchain) { if (!swapchain) return; @@ -1500,12 +1503,12 @@ void swapchain_destroy(swapchain_t swapchain) delete swapchain; } -void texture_destroy(texture_t tex) +void gs_texture_destroy(gs_texture_t tex) { delete tex; } -uint32_t texture_getwidth(texture_t tex) +uint32_t gs_texture_get_width(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return 0; @@ -1513,7 +1516,7 @@ uint32_t texture_getwidth(texture_t tex) return static_cast(tex)->width; } -uint32_t texture_getheight(texture_t tex) +uint32_t gs_texture_get_height(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return 0; @@ -1521,7 +1524,7 @@ uint32_t texture_getheight(texture_t tex) return static_cast(tex)->height; } -enum gs_color_format texture_getcolorformat(texture_t tex) +enum gs_color_format gs_texture_get_color_format(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return GS_UNKNOWN; @@ -1529,7 +1532,7 @@ enum gs_color_format texture_getcolorformat(texture_t tex) return static_cast(tex)->format; } -bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize) +bool gs_texture_map(gs_texture_t tex, uint8_t **ptr, uint32_t *linesize) { HRESULT hr; @@ -1549,7 +1552,7 @@ bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize) return true; } -void texture_unmap(texture_t tex) +void gs_texture_unmap(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return; @@ -1558,7 +1561,7 @@ void texture_unmap(texture_t tex) tex2d->device->context->Unmap(tex2d->texture, 0); } -void *texture_getobj(texture_t tex) +void *gs_texture_get_obj(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return nullptr; @@ -1568,12 +1571,12 @@ void *texture_getobj(texture_t tex) } -void cubetexture_destroy(texture_t cubetex) +void gs_cubetexture_destroy(gs_texture_t cubetex) { delete cubetex; } -uint32_t cubetexture_getsize(texture_t cubetex) +uint32_t gs_cubetexture_get_size(gs_texture_t cubetex) { if (cubetex->type != GS_TEXTURE_CUBE) return 0; @@ -1582,7 +1585,7 @@ uint32_t cubetexture_getsize(texture_t cubetex) return tex->width; } -enum gs_color_format cubetexture_getcolorformat(texture_t cubetex) +enum gs_color_format gs_cubetexture_get_color_format(gs_texture_t cubetex) { if (cubetex->type != GS_TEXTURE_CUBE) return GS_UNKNOWN; @@ -1592,33 +1595,33 @@ enum gs_color_format cubetexture_getcolorformat(texture_t cubetex) } -void volumetexture_destroy(texture_t voltex) +void gs_voltexture_destroy(gs_texture_t voltex) { delete voltex; } -uint32_t volumetexture_getwidth(texture_t voltex) +uint32_t gs_voltexture_get_width(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -uint32_t volumetexture_getheight(texture_t voltex) +uint32_t gs_voltexture_get_height(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -uint32_t volumetexture_getdepth(texture_t voltex) +uint32_t gs_voltexture_getdepth(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -enum gs_color_format volumetexture_getcolorformat(texture_t voltex) +enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); @@ -1626,27 +1629,28 @@ enum gs_color_format volumetexture_getcolorformat(texture_t voltex) } -void stagesurface_destroy(stagesurf_t stagesurf) +void gs_stagesurface_destroy(gs_stagesurf_t stagesurf) { delete stagesurf; } -uint32_t stagesurface_getwidth(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf) { return stagesurf->width; } -uint32_t stagesurface_getheight(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf) { return stagesurf->height; } -enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf) +enum gs_color_format gs_stagesurface_get_color_format(gs_stagesurf_t stagesurf) { return stagesurf->format; } -bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize) +bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data, + uint32_t *linesize) { D3D11_MAPPED_SUBRESOURCE map; if (FAILED(stagesurf->device->context->Map(stagesurf->texture, 0, @@ -1658,19 +1662,19 @@ bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize) return true; } -void stagesurface_unmap(stagesurf_t stagesurf) +void gs_stagesurface_unmap(gs_stagesurf_t stagesurf) { stagesurf->device->context->Unmap(stagesurf->texture, 0); } -void zstencil_destroy(zstencil_t zstencil) +void gs_zstencil_destroy(gs_zstencil_t zstencil) { delete zstencil; } -void samplerstate_destroy(samplerstate_t samplerstate) +void gs_samplerstate_destroy(gs_samplerstate_t samplerstate) { if (!samplerstate) return; @@ -1685,15 +1689,15 @@ void samplerstate_destroy(samplerstate_t samplerstate) } -void vertexbuffer_destroy(vertbuffer_t vertbuffer) +void gs_vertexbuffer_destroy(gs_vertbuffer_t vertbuffer) { delete vertbuffer; } -void vertexbuffer_flush(vertbuffer_t vertbuffer) +void gs_vertexbuffer_flush(gs_vertbuffer_t vertbuffer) { if (!vertbuffer->dynamic) { - blog(LOG_ERROR, "vertexbuffer_flush: vertex buffer is " + blog(LOG_ERROR, "gs_vertexbuffer_flush: vertex buffer is " "not dynamic"); return; } @@ -1714,24 +1718,24 @@ void vertexbuffer_flush(vertbuffer_t vertbuffer) vertbuffer->vbd.data->colors, sizeof(uint32_t)); for (size_t i = 0; i < vertbuffer->uvBuffers.size(); i++) { - tvertarray &tv = vertbuffer->vbd.data->tvarray[i]; + gs_tvertarray &tv = vertbuffer->vbd.data->tvarray[i]; vertbuffer->FlushBuffer(vertbuffer->uvBuffers[i], tv.array, tv.width*sizeof(float)); } } -struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer) +struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vertbuffer) { return vertbuffer->vbd.data; } -void indexbuffer_destroy(indexbuffer_t indexbuffer) +void gs_indexbuffer_destroy(gs_indexbuffer_t indexbuffer) { delete indexbuffer; } -void indexbuffer_flush(indexbuffer_t indexbuffer) +void gs_indexbuffer_flush(gs_indexbuffer_t indexbuffer) { HRESULT hr; @@ -1750,39 +1754,39 @@ void indexbuffer_flush(indexbuffer_t indexbuffer) indexbuffer->device->context->Unmap(indexbuffer->indexBuffer, 0); } -void *indexbuffer_getdata(indexbuffer_t indexbuffer) +void *gs_indexbuffer_get_data(gs_indexbuffer_t indexbuffer) { return indexbuffer->indices.data; } -size_t indexbuffer_numindices(indexbuffer_t indexbuffer) +size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t indexbuffer) { return indexbuffer->num; } -enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer) +enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t indexbuffer) { return indexbuffer->type; } -extern "C" EXPORT bool gdi_texture_available(void) +extern "C" EXPORT bool device_gdi_texture_available(void) { return true; } -extern "C" EXPORT texture_t device_create_gdi_texture(device_t device, +extern "C" EXPORT gs_texture_t device_texture_create_gdi(gs_device_t device, uint32_t width, uint32_t height) { gs_texture *texture = nullptr; try { texture = new gs_texture_2d(device, width, height, GS_BGRA, - 1, nullptr, GS_RENDERTARGET, GS_TEXTURE_2D, + 1, nullptr, GS_RENDER_TARGET, GS_TEXTURE_2D, true, false); } catch (HRError error) { - blog(LOG_ERROR, "device_create_gdi_texture (D3D11): %s (%08lX)", + blog(LOG_ERROR, "device_texture_create_gdi (D3D11): %s (%08lX)", error.str, error.hr); } catch (const char *error) { - blog(LOG_ERROR, "device_create_gdi_texture (D3D11): %s", error); + blog(LOG_ERROR, "device_texture_create_gdi (D3D11): %s", error); } return texture; @@ -1799,7 +1803,7 @@ static inline bool TextureGDICompatible(gs_texture_2d *tex2d, const char *func) return true; } -extern "C" EXPORT void *texture_get_dc(texture_t tex) +extern "C" EXPORT void *gs_texture_get_dc(gs_texture_t tex) { HDC hDC = nullptr; @@ -1807,20 +1811,20 @@ extern "C" EXPORT void *texture_get_dc(texture_t tex) return nullptr; gs_texture_2d *tex2d = static_cast(tex); - if (!TextureGDICompatible(tex2d, "texture_get_dc")) + if (!TextureGDICompatible(tex2d, "gs_texture_get_dc")) return nullptr; tex2d->gdiSurface->GetDC(true, &hDC); return hDC; } -extern "C" EXPORT void texture_release_dc(texture_t tex) +extern "C" EXPORT void gs_texture_release_dc(gs_texture_t tex) { if (tex->type != GS_TEXTURE_2D) return; gs_texture_2d *tex2d = static_cast(tex); - if (!TextureGDICompatible(tex2d, "texture_release_dc")) + if (!TextureGDICompatible(tex2d, "gs_texture_release_dc")) return; tex2d->gdiSurface->ReleaseDC(nullptr); diff --git a/libobs-d3d11/d3d11-subsystem.hpp b/libobs-d3d11/d3d11-subsystem.hpp index 4070e7195..75bafddfb 100644 --- a/libobs-d3d11/d3d11-subsystem.hpp +++ b/libobs-d3d11/d3d11-subsystem.hpp @@ -108,7 +108,7 @@ static inline D3D11_COMPARISON_FUNC ConvertGSDepthTest(gs_depth_test test) return D3D11_COMPARISON_NEVER; } -static inline D3D11_STENCIL_OP ConvertGSStencilOp(gs_stencil_op op) +static inline D3D11_STENCIL_OP ConvertGSStencilOp(gs_stencil_op_type op) { switch (op) { case GS_KEEP: return D3D11_STENCIL_OP_KEEP; @@ -167,12 +167,12 @@ static inline D3D11_PRIMITIVE_TOPOLOGY ConvertGSTopology(gs_draw_mode mode) /* exception-safe RAII wrapper for vertex buffer data (NOTE: not copy-safe) */ struct VBDataPtr { - vb_data *data; + gs_vb_data *data; - inline void Clear() {vbdata_destroy(data); data = nullptr;} + inline void Clear() {gs_vbdata_destroy(data); data = nullptr;} - inline VBDataPtr(vb_data *data) : data(data) {} - inline ~VBDataPtr() {vbdata_destroy(data);} + inline VBDataPtr(gs_vb_data *data) : data(data) {} + inline ~VBDataPtr() {gs_vbdata_destroy(data);} }; struct gs_vertex_buffer { @@ -182,7 +182,7 @@ struct gs_vertex_buffer { ComPtr tangentBuffer; vector> uvBuffers; - device_t device; + gs_device_t device; bool dynamic; VBDataPtr vbd; size_t numVerts; @@ -199,7 +199,8 @@ struct gs_vertex_buffer { const size_t numVerts, void *array, ID3D11Buffer **buffer); - gs_vertex_buffer(device_t device, struct vb_data *data, uint32_t flags); + gs_vertex_buffer(gs_device_t device, struct gs_vb_data *data, + uint32_t flags); }; /* exception-safe RAII wrapper for index buffer data (NOTE: not copy-safe) */ @@ -212,7 +213,7 @@ struct DataPtr { struct gs_index_buffer { ComPtr indexBuffer; - device_t device; + gs_device_t device; bool dynamic; gs_index_type type; size_t indexSize; @@ -221,7 +222,7 @@ struct gs_index_buffer { void InitBuffer(); - gs_index_buffer(device_t device, enum gs_index_type type, + gs_index_buffer(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags); }; @@ -278,7 +279,7 @@ struct gs_texture_2d : gs_texture { { } - gs_texture_2d(device_t device, uint32_t width, uint32_t height, + gs_texture_2d(gs_device_t device, uint32_t width, uint32_t height, gs_color_format colorFormat, uint32_t levels, const uint8_t **data, uint32_t flags, gs_texture_type type, bool gdiCompatible, bool shared); @@ -303,7 +304,7 @@ struct gs_zstencil_buffer { { } - gs_zstencil_buffer(device_t device, uint32_t width, uint32_t height, + gs_zstencil_buffer(gs_device_t device, uint32_t width, uint32_t height, gs_zstencil_format format); }; @@ -315,21 +316,21 @@ struct gs_stage_surface { gs_color_format format; DXGI_FORMAT dxgiFormat; - gs_stage_surface(device_t device, uint32_t width, uint32_t height, + gs_stage_surface(gs_device_t device, uint32_t width, uint32_t height, gs_color_format colorFormat); }; struct gs_sampler_state { ComPtr state; - device_t device; + gs_device_t device; gs_sampler_info info; - gs_sampler_state(device_t device, gs_sampler_info *info); + gs_sampler_state(gs_device_t device, gs_sampler_info *info); }; -struct shader_param { +struct gs_shader_param { string name; - shader_param_type type; + gs_shader_param_type type; uint32_t textureID; @@ -341,7 +342,7 @@ struct shader_param { vector defaultValue; bool changed; - shader_param(shader_var &var, uint32_t &texCounter); + gs_shader_param(shader_var &var, uint32_t &texCounter); }; struct ShaderError { @@ -356,21 +357,21 @@ struct ShaderError { }; struct gs_shader { - device_t device; - shader_type type; - vector params; + gs_device_t device; + gs_shader_type type; + vector params; ComPtr constants; size_t constantSize; - inline void UpdateParam(vector &constData, shader_param ¶m, - bool &upload); + inline void UpdateParam(vector &constData, + gs_shader_param ¶m, bool &upload); void UploadParams(); void BuildConstantBuffer(); void Compile(const char *shaderStr, const char *file, const char *target, ID3D10Blob **shader); - inline gs_shader(device_t device, shader_type type) + inline gs_shader(gs_device_t device, gs_shader_type type) : device (device), type (type), constantSize (0) @@ -384,7 +385,7 @@ struct ShaderSampler { string name; gs_sampler_state sampler; - inline ShaderSampler(const char *name, device_t device, + inline ShaderSampler(const char *name, gs_device_t device, gs_sampler_info *info) : name (name), sampler (device, info) @@ -396,7 +397,7 @@ struct gs_vertex_shader : gs_shader { ComPtr shader; ComPtr layout; - shader_param *world, *viewProj; + gs_shader_param *world, *viewProj; bool hasNormals; bool hasColors; @@ -415,7 +416,7 @@ struct gs_vertex_shader : gs_shader { void GetBuffersExpected(const vector &inputs); - gs_vertex_shader(device_t device, const char *file, + gs_vertex_shader(gs_device_t device, const char *file, const char *shaderString); }; @@ -432,7 +433,7 @@ struct gs_pixel_shader : gs_shader { states[i] = NULL; } - gs_pixel_shader(device_t device, const char *file, + gs_pixel_shader(gs_device_t device, const char *file, const char *shaderString); }; @@ -497,9 +498,9 @@ struct SavedBlendState : BlendState { struct StencilSide { gs_depth_test test; - gs_stencil_op fail; - gs_stencil_op zfail; - gs_stencil_op zpass; + gs_stencil_op_type fail; + gs_stencil_op_type zfail; + gs_stencil_op_type zpass; inline StencilSide() : test (GS_ALWAYS), @@ -623,7 +624,7 @@ struct gs_device { void UpdateBlendState(); inline void CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, + gs_texture_t src, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h); void UpdateViewProjMatrix(); diff --git a/libobs-d3d11/d3d11-texture2d.cpp b/libobs-d3d11/d3d11-texture2d.cpp index a33c473e0..679d36562 100644 --- a/libobs-d3d11/d3d11-texture2d.cpp +++ b/libobs-d3d11/d3d11-texture2d.cpp @@ -27,7 +27,7 @@ void gs_texture_2d::InitSRD(vector &srd, uint32_t actual_levels = levels; if (!actual_levels) - actual_levels = gs_num_total_levels(width, height); + actual_levels = gs_get_total_levels(width, height); rowSizeBytes /= 8; @@ -141,7 +141,7 @@ void gs_texture_2d::InitRenderTargets() } } -gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height, +gs_texture_2d::gs_texture_2d(gs_device_t device, uint32_t width, uint32_t height, gs_color_format colorFormat, uint32_t levels, const uint8_t **data, uint32_t flags, gs_texture_type type, bool gdiCompatible, bool shared) @@ -152,8 +152,8 @@ gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height, isGDICompatible (gdiCompatible), isShared (shared), isDynamic ((flags & GS_DYNAMIC) != 0), - isRenderTarget ((flags & GS_RENDERTARGET) != 0), - genMipmaps ((flags & GS_BUILDMIPMAPS) != 0) + isRenderTarget ((flags & GS_RENDER_TARGET) != 0), + genMipmaps ((flags & GS_BUILD_MIPMAPS) != 0) { InitTexture(data); InitResourceView(); diff --git a/libobs-d3d11/d3d11-vertexbuffer.cpp b/libobs-d3d11/d3d11-vertexbuffer.cpp index 61be9e8e2..1e57564a1 100644 --- a/libobs-d3d11/d3d11-vertexbuffer.cpp +++ b/libobs-d3d11/d3d11-vertexbuffer.cpp @@ -93,7 +93,7 @@ inline void gs_vertex_buffer::InitBuffer(const size_t elementSize, throw HRError("Failed to create buffer", hr); } -gs_vertex_buffer::gs_vertex_buffer(device_t device, struct vb_data *data, +gs_vertex_buffer::gs_vertex_buffer(gs_device_t device, struct gs_vb_data *data, uint32_t flags) : device (device), vbd (data), @@ -121,7 +121,7 @@ gs_vertex_buffer::gs_vertex_buffer(device_t device, struct vb_data *data, colorBuffer.Assign()); for (size_t i = 0; i < data->num_tex; i++) { - struct tvertarray *tverts = data->tvarray+i; + struct gs_tvertarray *tverts = data->tvarray+i; if (tverts->width != 2 && tverts->width != 4) throw "Invalid texture vertex size specified"; diff --git a/libobs-d3d11/d3d11-zstencilbuffer.cpp b/libobs-d3d11/d3d11-zstencilbuffer.cpp index 862740dbe..1e3e40647 100644 --- a/libobs-d3d11/d3d11-zstencilbuffer.cpp +++ b/libobs-d3d11/d3d11-zstencilbuffer.cpp @@ -47,7 +47,7 @@ void gs_zstencil_buffer::InitBuffer() throw HRError("Failed to create depth stencil view", hr); } -gs_zstencil_buffer::gs_zstencil_buffer(device_t device, +gs_zstencil_buffer::gs_zstencil_buffer(gs_device_t device, uint32_t width, uint32_t height, gs_zstencil_format format) : device (device), diff --git a/libobs-opengl/gl-cocoa.m b/libobs-opengl/gl-cocoa.m index fac34f6ab..c31856b1f 100644 --- a/libobs-opengl/gl-cocoa.m +++ b/libobs-opengl/gl-cocoa.m @@ -96,7 +96,7 @@ static NSOpenGLContext *gl_context_create(struct gs_init_data *info) return context; } -static bool gl_init_default_swap(struct gl_platform *plat, device_t dev, +static bool gl_init_default_swap(struct gl_platform *plat, gs_device_t dev, struct gs_init_data *info) { if(!(plat->context = gl_context_create(info))) @@ -109,7 +109,7 @@ static bool gl_init_default_swap(struct gl_platform *plat, device_t dev, return plat->swap.wi != NULL; } -struct gl_platform *gl_platform_create(device_t device, +struct gl_platform *gl_platform_create(gs_device_t device, struct gs_init_data *info) { struct gl_platform *plat = bzalloc(sizeof(struct gl_platform)); @@ -186,24 +186,24 @@ void gl_windowinfo_destroy(struct gl_windowinfo *wi) bfree(wi); } -void gl_update(device_t device) +void gl_update(gs_device_t device) { [device->plat->context update]; } -void device_entercontext(device_t device) +void device_enter_context(gs_device_t device) { [device->plat->context makeCurrentContext]; } -void device_leavecontext(device_t device) +void device_leave_context(gs_device_t device) { UNUSED_PARAMETER(device); [NSOpenGLContext clearCurrentContext]; } -void device_load_swapchain(device_t device, swapchain_t swap) +void device_load_swapchain(gs_device_t device, gs_swapchain_t swap) { if(!swap) swap = &device->plat->swap; @@ -215,7 +215,7 @@ void device_load_swapchain(device_t device, swapchain_t swap) [device->plat->context setView:swap->wi->view]; } -void device_present(device_t device) +void device_present(gs_device_t device) { [device->plat->context flushBuffer]; } @@ -227,7 +227,8 @@ void gl_getclientsize(struct gs_swap_chain *swap, uint32_t *width, if(height) *height = swap->info.cy; } -texture_t texture_create_from_iosurface(device_t device, void *iosurf) +gs_texture_t device_texture_create_from_iosurface(gs_device_t device, + void *iosurf) { IOSurfaceRef ref = (IOSurfaceRef)iosurf; struct gs_texture_2d *tex = bzalloc(sizeof(struct gs_texture_2d)); @@ -270,7 +271,7 @@ texture_t texture_create_from_iosurface(device_t device, void *iosurf) if(err != kCGLNoError) { blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s" - " (texture_create_from_iosurface)", + " (device_texture_create_from_iosurface)", err, CGLErrorString(err)); gl_success("CGLTexImageIOSurface2D"); @@ -284,15 +285,15 @@ texture_t texture_create_from_iosurface(device_t device, void *iosurf) if (!gl_bind_texture(tex->base.gl_target, 0)) goto fail; - return (texture_t)tex; + return (gs_texture_t)tex; fail: - texture_destroy((texture_t)tex); - blog(LOG_ERROR, "texture_create_from_iosurface (GL) failed"); + gs_texture_destroy((gs_texture_t)tex); + blog(LOG_ERROR, "device_texture_create_from_iosurface (GL) failed"); return NULL; } -bool texture_rebind_iosurface(texture_t texture, void *iosurf) +bool gs_texture_rebind_iosurface(gs_texture_t texture, void *iosurf) { if (!texture) return false; @@ -326,7 +327,7 @@ bool texture_rebind_iosurface(texture_t texture, void *iosurf) if(err != kCGLNoError) { blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s" - " (texture_rebind_iosurface)", + " (gs_texture_rebind_iosurface)", err, CGLErrorString(err)); gl_success("CGLTexImageIOSurface2D"); diff --git a/libobs-opengl/gl-indexbuffer.c b/libobs-opengl/gl-indexbuffer.c index 7bb2a7105..2a4e8568d 100644 --- a/libobs-opengl/gl-indexbuffer.c +++ b/libobs-opengl/gl-indexbuffer.c @@ -33,7 +33,7 @@ static inline bool init_ib(struct gs_index_buffer *ib) return success; } -indexbuffer_t device_create_indexbuffer(device_t device, +gs_indexbuffer_t device_indexbuffer_create(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags) { @@ -51,15 +51,15 @@ indexbuffer_t device_create_indexbuffer(device_t device, GL_UNSIGNED_SHORT; if (!init_ib(ib)) { - blog(LOG_ERROR, "device_create_indexbuffer (GL) failed"); - indexbuffer_destroy(ib); + blog(LOG_ERROR, "device_indexbuffer_create (GL) failed"); + gs_indexbuffer_destroy(ib); return NULL; } return ib; } -void indexbuffer_destroy(indexbuffer_t ib) +void gs_indexbuffer_destroy(gs_indexbuffer_t ib) { if (ib) { if (ib->buffer) @@ -70,7 +70,7 @@ void indexbuffer_destroy(indexbuffer_t ib) } } -void indexbuffer_flush(indexbuffer_t ib) +void gs_indexbuffer_flush(gs_indexbuffer_t ib) { if (!ib->dynamic) { blog(LOG_ERROR, "Index buffer is not dynamic"); @@ -83,25 +83,25 @@ void indexbuffer_flush(indexbuffer_t ib) return; fail: - blog(LOG_ERROR, "indexbuffer_flush (GL) failed"); + blog(LOG_ERROR, "gs_indexbuffer_flush (GL) failed"); } -void *indexbuffer_getdata(indexbuffer_t ib) +void *gs_indexbuffer_get_data(gs_indexbuffer_t ib) { return ib->data; } -size_t indexbuffer_numindices(indexbuffer_t ib) +size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t ib) { return ib->num; } -enum gs_index_type indexbuffer_gettype(indexbuffer_t ib) +enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t ib) { return ib->type; } -void device_load_indexbuffer(device_t device, indexbuffer_t ib) +void device_load_indexbuffer(gs_device_t device, gs_indexbuffer_t ib) { if (ib == device->cur_index_buffer) return; diff --git a/libobs-opengl/gl-shader.c b/libobs-opengl/gl-shader.c index 3ba96d960..d52318677 100644 --- a/libobs-opengl/gl-shader.c +++ b/libobs-opengl/gl-shader.c @@ -25,12 +25,12 @@ #include "gl-subsystem.h" #include "gl-shaderparser.h" -static inline void shader_param_init(struct shader_param *param) +static inline void shader_param_init(struct gs_shader_param *param) { - memset(param, 0, sizeof(struct shader_param)); + memset(param, 0, sizeof(struct gs_shader_param)); } -static inline void shader_param_free(struct shader_param *param) +static inline void shader_param_free(struct gs_shader_param *param) { bfree(param->name); da_free(param->cur_value); @@ -63,14 +63,14 @@ static void gl_get_program_info(GLuint program, const char *file, static bool gl_add_param(struct gs_shader *shader, struct shader_var *var, GLint *texture_id) { - struct shader_param param = {0}; + struct gs_shader_param param = {0}; param.array_count = var->array_count; param.name = bstrdup(var->name); param.shader = shader; param.type = get_shader_param_type(var->type); - if (param.type == SHADER_PARAM_TEXTURE) { + if (param.type == GS_SHADER_PARAM_TEXTURE) { param.sampler_id = var->gl_sampler_id; param.texture_id = (*texture_id)++; } else { @@ -84,7 +84,7 @@ static bool gl_add_param(struct gs_shader *shader, struct shader_var *var, if (!gl_success("glGetUniformLocation")) goto fail; - if (param.type == SHADER_PARAM_TEXTURE) { + if (param.type == GS_SHADER_PARAM_TEXTURE) { glProgramUniform1i(shader->program, param.param, param.texture_id); if (!gl_success("glProgramUniform1i")) @@ -109,8 +109,8 @@ static inline bool gl_add_params(struct gs_shader *shader, if (!gl_add_param(shader, glsp->parser.params.array+i, &tex_id)) return false; - shader->viewproj = shader_getparambyname(shader, "ViewProj"); - shader->world = shader_getparambyname(shader, "World"); + shader->viewproj = gs_shader_get_param_by_name(shader, "ViewProj"); + shader->world = gs_shader_get_param_by_name(shader, "World"); return true; } @@ -118,11 +118,11 @@ static inline bool gl_add_params(struct gs_shader *shader, static inline void gl_add_sampler(struct gs_shader *shader, struct shader_sampler *sampler) { - samplerstate_t new_sampler; + gs_samplerstate_t new_sampler; struct gs_sampler_info info; shader_sampler_convert(sampler, &info); - new_sampler = device_create_samplerstate(shader->device, &info); + new_sampler = device_samplerstate_create(shader->device, &info); da_push_back(shader->samplers, &new_sampler); } @@ -235,7 +235,7 @@ static bool gl_shader_init(struct gs_shader *shader, if (success) success = gl_add_params(shader, glsp); /* Only vertex shaders actually require input attributes */ - if (success && shader->type == SHADER_VERTEX) + if (success && shader->type == GS_SHADER_VERTEX) success = gl_process_attribs(shader, glsp); if (success) gl_add_samplers(shader, glsp); @@ -243,8 +243,9 @@ static bool gl_shader_init(struct gs_shader *shader, return success; } -static struct gs_shader *shader_create(device_t device, enum shader_type type, - const char *shader_str, const char *file, char **error_string) +static struct gs_shader *shader_create(gs_device_t device, + enum gs_shader_type type, const char *shader_str, + const char *file, char **error_string) { struct gs_shader *shader = bzalloc(sizeof(struct gs_shader)); struct gl_shader_parser glsp; @@ -260,7 +261,7 @@ static struct gs_shader *shader_create(device_t device, enum shader_type type, success = gl_shader_init(shader, &glsp, file, error_string); if (!success) { - shader_destroy(shader); + gs_shader_destroy(shader); shader = NULL; } @@ -268,29 +269,31 @@ static struct gs_shader *shader_create(device_t device, enum shader_type type, return shader; } -shader_t device_create_vertexshader(device_t device, +gs_shader_t device_vertexshader_create(gs_device_t device, const char *shader, const char *file, char **error_string) { struct gs_shader *ptr; - ptr = shader_create(device, SHADER_VERTEX, shader, file, error_string); + ptr = shader_create(device, GS_SHADER_VERTEX, shader, file, + error_string); if (!ptr) - blog(LOG_ERROR, "device_create_vertexshader (GL) failed"); + blog(LOG_ERROR, "device_vertexshader_create (GL) failed"); return ptr; } -shader_t device_create_pixelshader(device_t device, +gs_shader_t device_pixelshader_create(gs_device_t device, const char *shader, const char *file, char **error_string) { struct gs_shader *ptr; - ptr = shader_create(device, SHADER_PIXEL, shader, file, error_string); + ptr = shader_create(device, GS_SHADER_PIXEL, shader, file, + error_string); if (!ptr) - blog(LOG_ERROR, "device_create_pixelshader (GL) failed"); + blog(LOG_ERROR, "device_pixelshader_create (GL) failed"); return ptr; } -void shader_destroy(shader_t shader) +void gs_shader_destroy(gs_shader_t shader) { size_t i; @@ -298,7 +301,7 @@ void shader_destroy(shader_t shader) return; for (i = 0; i < shader->samplers.num; i++) - samplerstate_destroy(shader->samplers.array[i]); + gs_samplerstate_destroy(shader->samplers.array[i]); for (i = 0; i < shader->params.num; i++) shader_param_free(shader->params.array+i); @@ -314,22 +317,22 @@ void shader_destroy(shader_t shader) bfree(shader); } -int shader_numparams(shader_t shader) +int gs_shader_get_num_params(gs_shader_t shader) { return (int)shader->params.num; } -sparam_t shader_getparambyidx(shader_t shader, uint32_t param) +gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, uint32_t param) { assert(param < shader->params.num); return shader->params.array+param; } -sparam_t shader_getparambyname(shader_t shader, const char *name) +gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, const char *name) { size_t i; for (i = 0; i < shader->params.num; i++) { - struct shader_param *param = shader->params.array+i; + struct gs_shader_param *param = shader->params.array+i; if (strcmp(param->name, name) == 0) return param; @@ -338,44 +341,45 @@ sparam_t shader_getparambyname(shader_t shader, const char *name) return NULL; } -sparam_t shader_getviewprojmatrix(shader_t shader) +gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader) { return shader->viewproj; } -sparam_t shader_getworldmatrix(shader_t shader) +gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader) { return shader->world; } -void shader_getparaminfo(sparam_t param, struct shader_param_info *info) +void gs_shader_get_param_info(gs_sparam_t param, + struct gs_shader_param_info *info) { info->type = param->type; info->name = param->name; } -void shader_setbool(sparam_t param, bool val) +void gs_shader_set_bool(gs_sparam_t param, bool val) { struct gs_shader *shader = param->shader; glProgramUniform1i(shader->program, param->param, (GLint)val); gl_success("glProgramUniform1i"); } -void shader_setfloat(sparam_t param, float val) +void gs_shader_set_float(gs_sparam_t param, float val) { struct gs_shader *shader = param->shader; glProgramUniform1f(shader->program, param->param, val); gl_success("glProgramUniform1f"); } -void shader_setint(sparam_t param, int val) +void gs_shader_set_int(gs_sparam_t param, int val) { struct gs_shader *shader = param->shader; glProgramUniform1i(shader->program, param->param, val); gl_success("glProgramUniform1i"); } -void shader_setmatrix3(sparam_t param, const struct matrix3 *val) +void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val) { struct gs_shader *shader = param->shader; struct matrix4 mat; @@ -386,7 +390,7 @@ void shader_setmatrix3(sparam_t param, const struct matrix3 *val) gl_success("glProgramUniformMatrix4fv"); } -void shader_setmatrix4(sparam_t param, const struct matrix4 *val) +void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val) { struct gs_shader *shader = param->shader; glProgramUniformMatrix4fv(shader->program, param->param, 1, @@ -394,58 +398,58 @@ void shader_setmatrix4(sparam_t param, const struct matrix4 *val) gl_success("glProgramUniformMatrix4fv"); } -void shader_setvec2(sparam_t param, const struct vec2 *val) +void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val) { struct gs_shader *shader = param->shader; glProgramUniform2fv(shader->program, param->param, 1, val->ptr); gl_success("glProgramUniform2fv"); } -void shader_setvec3(sparam_t param, const struct vec3 *val) +void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val) { struct gs_shader *shader = param->shader; glProgramUniform3fv(shader->program, param->param, 1, val->ptr); gl_success("glProgramUniform3fv"); } -void shader_setvec4(sparam_t param, const struct vec4 *val) +void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val) { struct gs_shader *shader = param->shader; glProgramUniform4fv(shader->program, param->param, 1, val->ptr); gl_success("glProgramUniform4fv"); } -void shader_settexture(sparam_t param, texture_t val) +void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val) { param->texture = val; } -static void shader_setval_data(sparam_t param, const void *val, int count) +static void shader_setval_data(gs_sparam_t param, const void *val, int count) { struct gs_shader *shader = param->shader; - if (param->type == SHADER_PARAM_BOOL || - param->type == SHADER_PARAM_INT) { + if (param->type == GS_SHADER_PARAM_BOOL || + param->type == GS_SHADER_PARAM_INT) { glProgramUniform1iv(shader->program, param->param, count, val); gl_success("glProgramUniform1iv"); - } else if (param->type == SHADER_PARAM_FLOAT) { + } else if (param->type == GS_SHADER_PARAM_FLOAT) { glProgramUniform1fv(shader->program, param->param, count, val); gl_success("glProgramUniform1fv"); - } else if (param->type == SHADER_PARAM_VEC2) { + } else if (param->type == GS_SHADER_PARAM_VEC2) { glProgramUniform2fv(shader->program, param->param, count, val); gl_success("glProgramUniform2fv"); - } else if (param->type == SHADER_PARAM_VEC3) { + } else if (param->type == GS_SHADER_PARAM_VEC3) { glProgramUniform3fv(shader->program, param->param, count, val); gl_success("glProgramUniform3fv"); - } else if (param->type == SHADER_PARAM_VEC4) { + } else if (param->type == GS_SHADER_PARAM_VEC4) { glProgramUniform4fv(shader->program, param->param, count, val); gl_success("glProgramUniform4fv"); - } else if (param->type == SHADER_PARAM_MATRIX4X4) { + } else if (param->type == GS_SHADER_PARAM_MATRIX4X4) { glProgramUniformMatrix4fv(shader->program, param->param, count, false, val); gl_success("glProgramUniformMatrix4fv"); @@ -456,15 +460,15 @@ void shader_update_textures(struct gs_shader *shader) { size_t i; for (i = 0; i < shader->params.num; i++) { - struct shader_param *param = shader->params.array+i; + struct gs_shader_param *param = shader->params.array+i; - if (param->type == SHADER_PARAM_TEXTURE) + if (param->type == GS_SHADER_PARAM_TEXTURE) device_load_texture(shader->device, param->texture, param->texture_id); } } -void shader_setval(sparam_t param, const void *val, size_t size) +void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size) { int count = param->array_count; size_t expected_size = 0; @@ -472,14 +476,14 @@ void shader_setval(sparam_t param, const void *val, size_t size) count = 1; switch ((uint32_t)param->type) { - case SHADER_PARAM_FLOAT: expected_size = sizeof(float); break; - case SHADER_PARAM_BOOL: - case SHADER_PARAM_INT: expected_size = sizeof(int); break; - case SHADER_PARAM_VEC2: expected_size = sizeof(float)*2; break; - case SHADER_PARAM_VEC3: expected_size = sizeof(float)*3; break; - case SHADER_PARAM_VEC4: expected_size = sizeof(float)*4; break; - case SHADER_PARAM_MATRIX4X4: expected_size = sizeof(float)*4*4; break; - case SHADER_PARAM_TEXTURE: expected_size = sizeof(void*); break; + case GS_SHADER_PARAM_FLOAT: expected_size = sizeof(float); break; + case GS_SHADER_PARAM_BOOL: + case GS_SHADER_PARAM_INT: expected_size = sizeof(int); break; + case GS_SHADER_PARAM_VEC2: expected_size = sizeof(float)*2; break; + case GS_SHADER_PARAM_VEC3: expected_size = sizeof(float)*3; break; + case GS_SHADER_PARAM_VEC4: expected_size = sizeof(float)*4; break; + case GS_SHADER_PARAM_MATRIX4X4: expected_size = sizeof(float)*4*4;break; + case GS_SHADER_PARAM_TEXTURE: expected_size = sizeof(void*); break; default: expected_size = 0; } @@ -488,18 +492,18 @@ void shader_setval(sparam_t param, const void *val, size_t size) return; if (expected_size != size) { - blog(LOG_ERROR, "shader_setval (GL): Size of shader param does " - "not match the size of the input"); + blog(LOG_ERROR, "gs_shader_set_val (GL): Size of shader " + "param does not match the size of the input"); return; } - if (param->type == SHADER_PARAM_TEXTURE) - shader_settexture(param, *(texture_t*)val); + if (param->type == GS_SHADER_PARAM_TEXTURE) + gs_shader_set_texture(param, *(gs_texture_t*)val); else shader_setval_data(param, val, count); } -void shader_setdefault(sparam_t param) +void gs_shader_set_default(gs_sparam_t param) { - shader_setval(param, param->def_value.array, param->def_value.num); + gs_shader_set_val(param, param->def_value.array, param->def_value.num); } diff --git a/libobs-opengl/gl-shaderparser.c b/libobs-opengl/gl-shaderparser.c index e7487dac0..c1fe66639 100644 --- a/libobs-opengl/gl-shaderparser.c +++ b/libobs-opengl/gl-shaderparser.c @@ -218,7 +218,7 @@ static void gl_write_struct(struct gl_shader_parser *glsp, static void gl_write_interface_block(struct gl_shader_parser *glsp) { - if (glsp->type == SHADER_VERTEX) { + if (glsp->type == GS_SHADER_VERTEX) { dstr_cat(&glsp->gl_string, "out gl_PerVertex {\n" "\tvec4 gl_Position;\n};\n\n"); } @@ -470,7 +470,7 @@ static inline void gl_write_main_interface_assign( const char *src) { /* vertex shaders: write gl_Position */ - if (glsp->type == SHADER_VERTEX && + if (glsp->type == GS_SHADER_VERTEX && strcmp(var->mapping, "POSITION") == 0) { dstr_cat(&glsp->gl_string, "\tgl_Position = "); dstr_cat(&glsp->gl_string, src); diff --git a/libobs-opengl/gl-shaderparser.h b/libobs-opengl/gl-shaderparser.h index 099a8b8f7..59ceafb11 100644 --- a/libobs-opengl/gl-shaderparser.h +++ b/libobs-opengl/gl-shaderparser.h @@ -43,7 +43,7 @@ static inline void gl_parser_attrib_free(struct gl_parser_attrib *attr) } struct gl_shader_parser { - enum shader_type type; + enum gs_shader_type type; const char *input_prefix; const char *output_prefix; struct shader_parser parser; @@ -54,14 +54,14 @@ struct gl_shader_parser { }; static inline void gl_shader_parser_init(struct gl_shader_parser *glsp, - enum shader_type type) + enum gs_shader_type type) { glsp->type = type; - if (type == SHADER_VERTEX) { + if (type == GS_SHADER_VERTEX) { glsp->input_prefix = "_input_attrib"; glsp->output_prefix = "_vertex_shader_attrib"; - } else if (type == SHADER_PIXEL) { + } else if (type == GS_SHADER_PIXEL) { glsp->input_prefix = "_vertex_shader_attrib"; glsp->output_prefix = "_pixel_shader_attrib"; } diff --git a/libobs-opengl/gl-stagesurf.c b/libobs-opengl/gl-stagesurf.c index 73d9cacc7..c48632380 100644 --- a/libobs-opengl/gl-stagesurf.c +++ b/libobs-opengl/gl-stagesurf.c @@ -42,7 +42,7 @@ static bool create_pixel_pack_buffer(struct gs_stage_surface *surf) return success; } -stagesurf_t device_create_stagesurface(device_t device, uint32_t width, +gs_stagesurf_t device_stagesurface_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format) { struct gs_stage_surface *surf; @@ -57,15 +57,15 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width, surf->bytes_per_pixel = gs_get_format_bpp(color_format)/8; if (!create_pixel_pack_buffer(surf)) { - blog(LOG_ERROR, "device_create_stagesurface (GL) failed"); - stagesurface_destroy(surf); + blog(LOG_ERROR, "device_stagesurface_create (GL) failed"); + gs_stagesurface_destroy(surf); return NULL; } return surf; } -void stagesurface_destroy(stagesurf_t stagesurf) +void gs_stagesurface_destroy(gs_stagesurf_t stagesurf) { if (stagesurf) { if (stagesurf->pack_buffer) @@ -110,7 +110,8 @@ static bool can_stage(struct gs_stage_surface *dst, struct gs_texture_2d *src) /* Apparently for mac, PBOs won't do an asynchronous transfer unless you use * FBOs aong with glReadPixels, which is really dumb. */ -void device_stage_texture(device_t device, stagesurf_t dst, texture_t src) +void device_stage_texture(gs_device_t device, gs_stagesurf_t dst, + gs_texture_t src) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)src; struct fbo_info *fbo; @@ -155,7 +156,8 @@ failed: #else -void device_stage_texture(device_t device, stagesurf_t dst, texture_t src) +void device_stage_texture(gs_device_t device, gs_stagesurf_t dst, + gs_texture_t src) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)src; if (!can_stage(dst, tex2d)) @@ -184,22 +186,23 @@ failed: #endif -uint32_t stagesurface_getwidth(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf) { return stagesurf->width; } -uint32_t stagesurface_getheight(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf) { return stagesurf->height; } -enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf) +enum gs_color_format gs_stagesurface_get_color_format(gs_stagesurf_t stagesurf) { return stagesurf->format; } -bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize) +bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data, + uint32_t *linesize) { if (!gl_bind_buffer(GL_PIXEL_PACK_BUFFER, stagesurf->pack_buffer)) goto fail; @@ -218,7 +221,7 @@ fail: return false; } -void stagesurface_unmap(stagesurf_t stagesurf) +void gs_stagesurface_unmap(gs_stagesurf_t stagesurf) { if (!gl_bind_buffer(GL_PIXEL_PACK_BUFFER, stagesurf->pack_buffer)) return; diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 44b319e60..807d9e915 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -182,12 +182,12 @@ void convert_sampler_info(struct gs_sampler_state *sampler, info->max_anisotropy, sampler->max_anisotropy); } -const char *device_name(void) +const char *device_get_name(void) { return "OpenGL"; } -int device_type(void) +int device_get_type(void) { return GS_DEVICE_OPENGL; } @@ -197,7 +197,7 @@ const char *device_preprocessor_name(void) return "_OPENGL"; } -int device_create(device_t *p_device, struct gs_init_data *info) +int device_create(gs_device_t *p_device, struct gs_init_data *info) { struct gs_device *device = bzalloc(sizeof(struct gs_device)); int errorcode = GS_ERROR_FAIL; @@ -221,7 +221,7 @@ int device_create(device_t *p_device, struct gs_init_data *info) if (!gl_success("glBindProgramPipeline")) goto fail; - device_leavecontext(device); + device_leave_context(device); device->cur_swap = gl_platform_getswap(device->plat); *p_device = device; @@ -235,7 +235,7 @@ fail: return errorcode; } -void device_destroy(device_t device) +void device_destroy(gs_device_t device) { if (device) { size_t i; @@ -252,7 +252,8 @@ void device_destroy(device_t device) } } -swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info) +gs_swapchain_t device_swapchain_create(gs_device_t device, + struct gs_init_data *info) { struct gs_swap_chain *swap = bzalloc(sizeof(struct gs_swap_chain)); @@ -260,21 +261,21 @@ swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info) swap->info = *info; swap->wi = gl_windowinfo_create(info); if (!swap->wi) { - blog(LOG_ERROR, "device_create_swapchain (GL) failed"); - swapchain_destroy(swap); + blog(LOG_ERROR, "device_swapchain_create (GL) failed"); + gs_swapchain_destroy(swap); return NULL; } if (!gl_platform_init_swapchain(swap)) { blog(LOG_ERROR, "gl_platform_init_swapchain failed"); - swapchain_destroy(swap); + gs_swapchain_destroy(swap); return NULL; } return swap; } -void device_resize(device_t device, uint32_t cx, uint32_t cy) +void device_resize(gs_device_t device, uint32_t cx, uint32_t cy) { /* GL automatically resizes the device, so it doesn't do much */ device->cur_swap->info.cx = cx; @@ -283,23 +284,23 @@ void device_resize(device_t device, uint32_t cx, uint32_t cy) gl_update(device); } -void device_getsize(device_t device, uint32_t *cx, uint32_t *cy) +void device_get_size(gs_device_t device, uint32_t *cx, uint32_t *cy) { *cx = device->cur_swap->info.cx; *cy = device->cur_swap->info.cy; } -uint32_t device_getwidth(device_t device) +uint32_t device_get_width(gs_device_t device) { return device->cur_swap->info.cx; } -uint32_t device_getheight(device_t device) +uint32_t device_get_height(gs_device_t device) { return device->cur_swap->info.cy; } -texture_t device_create_volumetexture(device_t device, uint32_t width, +gs_texture_t device_voltexture_create(gs_device_t device, 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) @@ -316,7 +317,7 @@ texture_t device_create_volumetexture(device_t device, uint32_t width, return NULL; } -samplerstate_t device_create_samplerstate(device_t device, +gs_samplerstate_t device_samplerstate_create(gs_device_t device, struct gs_sampler_info *info) { struct gs_sampler_state *sampler; @@ -329,7 +330,7 @@ samplerstate_t device_create_samplerstate(device_t device, return sampler; } -enum gs_texture_type device_gettexturetype(texture_t texture) +enum gs_texture_type device_get_texture_type(gs_texture_t texture) { return texture->type; } @@ -362,7 +363,7 @@ static inline void apply_swizzle(struct gs_texture *tex) } } -static bool load_texture_sampler(texture_t tex, samplerstate_t ss) +static bool load_texture_sampler(gs_texture_t tex, gs_samplerstate_t ss) { bool success = true; GLint min_filter; @@ -379,7 +380,7 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss) samplerstate_addref(ss); min_filter = ss->min_filter; - if (texture_isrect(tex)) + if (gs_texture_is_rect(tex)) strip_mipmap_filter(&min_filter); if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MIN_FILTER, @@ -403,14 +404,15 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss) return success; } -static inline struct shader_param *get_texture_param(device_t device, int unit) +static inline struct gs_shader_param *get_texture_param(gs_device_t device, + int unit) { struct gs_shader *shader = device->cur_pixel_shader; size_t i; for (i = 0; i < shader->params.num; i++) { - struct shader_param *param = shader->params.array+i; - if (param->type == SHADER_PARAM_TEXTURE) { + struct gs_shader_param *param = shader->params.array+i; + if (param->type == GS_SHADER_PARAM_TEXTURE) { if (param->texture_id == unit) return param; } @@ -419,9 +421,9 @@ static inline struct shader_param *get_texture_param(device_t device, int unit) return NULL; } -void device_load_texture(device_t device, texture_t tex, int unit) +void device_load_texture(gs_device_t device, gs_texture_t tex, int unit) { - struct shader_param *param; + struct gs_shader_param *param; struct gs_sampler_state *sampler; struct gs_texture *cur_tex = device->cur_textures[unit]; @@ -463,16 +465,16 @@ fail: blog(LOG_ERROR, "device_load_texture (GL) failed"); } -static bool load_sampler_on_textures(device_t device, samplerstate_t ss, +static bool load_sampler_on_textures(gs_device_t device, gs_samplerstate_t ss, int sampler_unit) { struct gs_shader *shader = device->cur_pixel_shader; size_t i; for (i = 0; i < shader->params.num; i++) { - struct shader_param *param = shader->params.array+i; + struct gs_shader_param *param = shader->params.array+i; - if (param->type == SHADER_PARAM_TEXTURE && + if (param->type == GS_SHADER_PARAM_TEXTURE && param->sampler_id == (uint32_t)sampler_unit && param->texture) { if (!gl_active_texture(GL_TEXTURE0 + param->texture_id)) @@ -485,7 +487,8 @@ static bool load_sampler_on_textures(device_t device, samplerstate_t ss, return true; } -void device_load_samplerstate(device_t device, samplerstate_t ss, int unit) +void device_load_samplerstate(gs_device_t device, gs_samplerstate_t ss, + int unit) { /* need a pixel shader to properly bind samplers */ if (!device->cur_pixel_shader) @@ -505,15 +508,15 @@ void device_load_samplerstate(device_t device, samplerstate_t ss, int unit) return; } -void device_load_vertexshader(device_t device, shader_t vertshader) +void device_load_vertexshader(gs_device_t device, gs_shader_t vertshader) { GLuint program = 0; - vertbuffer_t cur_vb = device->cur_vertex_buffer; + gs_vertbuffer_t cur_vb = device->cur_vertex_buffer; if (device->cur_vertex_shader == vertshader) return; - if (vertshader && vertshader->type != SHADER_VERTEX) { + if (vertshader && vertshader->type != GS_SHADER_VERTEX) { blog(LOG_ERROR, "Specified shader is not a vertex shader"); goto fail; } @@ -557,13 +560,13 @@ static void load_default_pixelshader_samplers(struct gs_device *device, device->cur_samplers[i] = NULL; } -void device_load_pixelshader(device_t device, shader_t pixelshader) +void device_load_pixelshader(gs_device_t device, gs_shader_t pixelshader) { GLuint program = 0; if (device->cur_pixel_shader == pixelshader) return; - if (pixelshader && pixelshader->type != SHADER_PIXEL) { + if (pixelshader && pixelshader->type != GS_SHADER_PIXEL) { blog(LOG_ERROR, "Specified shader is not a pixel shader"); goto fail; } @@ -587,7 +590,7 @@ fail: blog(LOG_ERROR, "device_load_pixelshader (GL) failed"); } -void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit) +void device_load_default_samplerstate(gs_device_t device, bool b_3d, int unit) { /* TODO */ UNUSED_PARAMETER(device); @@ -595,27 +598,28 @@ void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit) UNUSED_PARAMETER(unit); } -shader_t device_getvertexshader(device_t device) +gs_shader_t device_get_vertex_shader(gs_device_t device) { return device->cur_vertex_shader; } -shader_t device_getpixelshader(device_t device) +gs_shader_t device_get_pixel_shader(gs_device_t device) { return device->cur_pixel_shader; } -texture_t device_getrendertarget(device_t device) +gs_texture_t device_get_render_target(gs_device_t device) { return device->cur_render_target; } -zstencil_t device_getzstenciltarget(device_t device) +gs_zstencil_t device_get_zstencil_target(gs_device_t device) { return device->cur_zstencil_buffer; } -static bool get_tex_dimensions(texture_t tex, uint32_t *width, uint32_t *height) +static bool get_tex_dimensions(gs_texture_t tex, uint32_t *width, + uint32_t *height) { if (tex->type == GS_TEXTURE_2D) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; @@ -671,7 +675,7 @@ struct fbo_info *get_fbo(struct gs_device *device, } static inline struct fbo_info *get_fbo_by_tex(struct gs_device *device, - texture_t tex) + gs_texture_t tex) { uint32_t width, height; if (!get_tex_dimensions(tex, &width, &height)) @@ -680,7 +684,7 @@ static inline struct fbo_info *get_fbo_by_tex(struct gs_device *device, return get_fbo(device, width, height, tex->format); } -static bool set_current_fbo(device_t device, struct fbo_info *fbo) +static bool set_current_fbo(gs_device_t device, struct fbo_info *fbo) { if (device->cur_fbo != fbo) { GLuint fbo_obj = fbo ? fbo->fbo : 0; @@ -692,7 +696,8 @@ static bool set_current_fbo(device_t device, struct fbo_info *fbo) return true; } -static bool attach_rendertarget(struct fbo_info *fbo, texture_t tex, int side) +static bool attach_rendertarget(struct fbo_info *fbo, gs_texture_t tex, + int side) { if (fbo->cur_render_target == tex) return true; @@ -717,7 +722,7 @@ static bool attach_rendertarget(struct fbo_info *fbo, texture_t tex, int side) return gl_success("glFramebufferTexture2D"); } -static bool attach_zstencil(struct fbo_info *fbo, zstencil_t zs) +static bool attach_zstencil(struct fbo_info *fbo, gs_zstencil_t zs) { GLuint zsbuffer = 0; GLenum zs_attachment = GL_DEPTH_STENCIL_ATTACHMENT; @@ -740,7 +745,8 @@ static bool attach_zstencil(struct fbo_info *fbo, zstencil_t zs) return true; } -static bool set_target(device_t device, texture_t tex, int side, zstencil_t zs) +static bool set_target(gs_device_t device, gs_texture_t tex, int side, + gs_zstencil_t zs) { struct fbo_info *fbo; @@ -770,7 +776,8 @@ static bool set_target(device_t device, texture_t tex, int side, zstencil_t zs) return true; } -void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil) +void device_set_render_target(gs_device_t device, gs_texture_t tex, + gs_zstencil_t zstencil) { if (tex) { if (tex->type != GS_TEXTURE_2D) { @@ -790,11 +797,11 @@ void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil) return; fail: - blog(LOG_ERROR, "device_setrendertarget (GL) failed"); + blog(LOG_ERROR, "device_set_render_target (GL) failed"); } -void device_setcuberendertarget(device_t device, texture_t cubetex, - int side, zstencil_t zstencil) +void device_set_cube_render_target(gs_device_t device, gs_texture_t cubetex, + int side, gs_zstencil_t zstencil) { if (cubetex) { if (cubetex->type != GS_TEXTURE_CUBE) { @@ -814,12 +821,12 @@ void device_setcuberendertarget(device_t device, texture_t cubetex, return; fail: - blog(LOG_ERROR, "device_setcuberendertarget (GL) failed"); + blog(LOG_ERROR, "device_set_cube_render_target (GL) failed"); } -void device_copy_texture_region(device_t device, - texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, +void device_copy_texture_region(gs_device_t device, + 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) { struct gs_texture_2d *src2d = (struct gs_texture_2d*)src; @@ -851,7 +858,7 @@ void device_copy_texture_region(device_t device, if (dst2d->width - dst_x < nw || dst2d->height - dst_y < nh) { blog(LOG_ERROR, "Destination texture region is not big " - "enough to hold the source region"); + "enough to hold the source region"); goto fail; } @@ -866,17 +873,17 @@ fail: blog(LOG_ERROR, "device_copy_texture (GL) failed"); } -void device_copy_texture(device_t device, texture_t dst, texture_t src) +void device_copy_texture(gs_device_t device, gs_texture_t dst, gs_texture_t src) { device_copy_texture_region(device, dst, 0, 0, src, 0, 0, 0, 0); } -void device_beginscene(device_t device) +void device_begin_scene(gs_device_t device) { clear_textures(device); } -static inline bool can_render(device_t device) +static inline bool can_render(gs_device_t device) { if (!device->cur_vertex_shader) { blog(LOG_ERROR, "No vertex shader specified"); @@ -906,10 +913,10 @@ static void update_viewproj_matrix(struct gs_device *device) matrix4_transpose(&device->cur_viewproj, &device->cur_viewproj); if (vs->viewproj) - shader_setmatrix4(vs->viewproj, &device->cur_viewproj); + gs_shader_set_matrix4(vs->viewproj, &device->cur_viewproj); } -static inline bool check_shader_pipeline_validity(device_t device) +static inline bool check_shader_pipeline_validity(gs_device_t device) { int valid = false; @@ -927,18 +934,18 @@ static inline bool check_shader_pipeline_validity(device_t device) return valid != 0; } -void device_draw(device_t device, enum gs_draw_mode draw_mode, +void device_draw(gs_device_t device, enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts) { struct gs_index_buffer *ib = device->cur_index_buffer; GLenum topology = convert_gs_topology(draw_mode); - effect_t effect = gs_geteffect(); + gs_effect_t effect = gs_get_effect(); if (!can_render(device)) goto fail; if (effect) - effect_updateparams(effect); + gs_effect_update_params(effect); shader_update_textures(device->cur_pixel_shader); @@ -972,13 +979,13 @@ fail: blog(LOG_ERROR, "device_draw (GL) failed"); } -void device_endscene(device_t device) +void device_end_scene(gs_device_t device) { /* does nothing */ UNUSED_PARAMETER(device); } -void device_clear(device_t device, uint32_t clear_flags, +void device_clear(gs_device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil) { GLbitfield gl_flags = 0; @@ -1005,14 +1012,14 @@ void device_clear(device_t device, uint32_t clear_flags, UNUSED_PARAMETER(device); } -void device_flush(device_t device) +void device_flush(gs_device_t device) { glFlush(); UNUSED_PARAMETER(device); } -void device_setcullmode(device_t device, enum gs_cull_mode mode) +void device_set_cull_mode(gs_device_t device, enum gs_cull_mode mode) { if (device->cur_cull_mode == mode) return; @@ -1030,12 +1037,12 @@ void device_setcullmode(device_t device, enum gs_cull_mode mode) gl_disable(GL_CULL_FACE); } -enum gs_cull_mode device_getcullmode(device_t device) +enum gs_cull_mode device_get_cull_mode(gs_device_t device) { return device->cur_cull_mode; } -void device_enable_blending(device_t device, bool enable) +void device_enable_blending(gs_device_t device, bool enable) { if (enable) gl_enable(GL_BLEND); @@ -1045,7 +1052,7 @@ void device_enable_blending(device_t device, bool enable) UNUSED_PARAMETER(device); } -void device_enable_depthtest(device_t device, bool enable) +void device_enable_depth_test(gs_device_t device, bool enable) { if (enable) gl_enable(GL_DEPTH_TEST); @@ -1055,7 +1062,7 @@ void device_enable_depthtest(device_t device, bool enable) UNUSED_PARAMETER(device); } -void device_enable_stenciltest(device_t device, bool enable) +void device_enable_stencil_test(gs_device_t device, bool enable) { if (enable) gl_enable(GL_STENCIL_TEST); @@ -1065,7 +1072,7 @@ void device_enable_stenciltest(device_t device, bool enable) UNUSED_PARAMETER(device); } -void device_enable_stencilwrite(device_t device, bool enable) +void device_enable_stencil_write(gs_device_t device, bool enable) { if (enable) glStencilMask(0xFFFFFFFF); @@ -1075,7 +1082,7 @@ void device_enable_stencilwrite(device_t device, bool enable) UNUSED_PARAMETER(device); } -void device_enable_color(device_t device, bool red, bool green, +void device_enable_color(gs_device_t device, bool red, bool green, bool blue, bool alpha) { glColorMask(red, green, blue, alpha); @@ -1083,7 +1090,7 @@ void device_enable_color(device_t device, bool red, bool green, UNUSED_PARAMETER(device); } -void device_blendfunction(device_t device, enum gs_blend_type src, +void device_blend_function(gs_device_t device, enum gs_blend_type src, enum gs_blend_type dest) { GLenum gl_src = convert_gs_blend_type(src); @@ -1091,23 +1098,23 @@ void device_blendfunction(device_t device, enum gs_blend_type src, glBlendFunc(gl_src, gl_dst); if (!gl_success("glBlendFunc")) - blog(LOG_ERROR, "device_blendfunction (GL) failed"); + blog(LOG_ERROR, "device_blend_function (GL) failed"); UNUSED_PARAMETER(device); } -void device_depthfunction(device_t device, enum gs_depth_test test) +void device_depth_function(gs_device_t device, enum gs_depth_test test) { GLenum gl_test = convert_gs_depth_test(test); glDepthFunc(gl_test); if (!gl_success("glDepthFunc")) - blog(LOG_ERROR, "device_depthfunction (GL) failed"); + blog(LOG_ERROR, "device_depth_function (GL) failed"); UNUSED_PARAMETER(device); } -void device_stencilfunction(device_t device, enum gs_stencil_side side, +void device_stencil_function(gs_device_t device, enum gs_stencil_side side, enum gs_depth_test test) { GLenum gl_side = convert_gs_stencil_side(side); @@ -1115,14 +1122,14 @@ void device_stencilfunction(device_t device, enum gs_stencil_side side, glStencilFuncSeparate(gl_side, gl_test, 0, 0xFFFFFFFF); if (!gl_success("glStencilFuncSeparate")) - blog(LOG_ERROR, "device_stencilfunction (GL) failed"); + blog(LOG_ERROR, "device_stencil_function (GL) failed"); UNUSED_PARAMETER(device); } -void device_stencilop(device_t device, enum gs_stencil_side side, - enum gs_stencil_op fail, enum gs_stencil_op zfail, - enum gs_stencil_op zpass) +void device_stencil_op(gs_device_t device, enum gs_stencil_side side, + enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail, + enum gs_stencil_op_type zpass) { GLenum gl_side = convert_gs_stencil_side(side); GLenum gl_fail = convert_gs_stencil_op(fail); @@ -1131,7 +1138,7 @@ void device_stencilop(device_t device, enum gs_stencil_side side, glStencilOpSeparate(gl_side, gl_fail, gl_zfail, gl_zpass); if (!gl_success("glStencilOpSeparate")) - blog(LOG_ERROR, "device_stencilop (GL) failed"); + blog(LOG_ERROR, "device_stencil_op (GL) failed"); UNUSED_PARAMETER(device); } @@ -1139,15 +1146,15 @@ void device_stencilop(device_t device, enum gs_stencil_side side, static inline uint32_t get_target_height(struct gs_device *device) { if (!device->cur_render_target) - return device_getheight(device); + return device_get_height(device); if (device->cur_render_target->type == GS_TEXTURE_2D) - return texture_getheight(device->cur_render_target); + return gs_texture_get_height(device->cur_render_target); else /* cube map */ - return cubetexture_getsize(device->cur_render_target); + return gs_cubetexture_get_size(device->cur_render_target); } -void device_setviewport(device_t device, int x, int y, int width, +void device_set_viewport(gs_device_t device, int x, int y, int width, int height) { uint32_t base_height; @@ -1162,7 +1169,7 @@ void device_setviewport(device_t device, int x, int y, int width, glViewport(x, base_height - y - height, width, height); if (!gl_success("glViewport")) - blog(LOG_ERROR, "device_setviewport (GL) failed"); + blog(LOG_ERROR, "device_set_viewport (GL) failed"); device->cur_viewport.x = x; device->cur_viewport.y = y; @@ -1170,12 +1177,12 @@ void device_setviewport(device_t device, int x, int y, int width, device->cur_viewport.cy = height; } -void device_getviewport(device_t device, struct gs_rect *rect) +void device_get_viewport(gs_device_t device, struct gs_rect *rect) { *rect = device->cur_viewport; } -void device_setscissorrect(device_t device, struct gs_rect *rect) +void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect) { UNUSED_PARAMETER(device); @@ -1188,10 +1195,10 @@ void device_setscissorrect(device_t device, struct gs_rect *rect) return; } - blog(LOG_ERROR, "device_setscissorrect (GL) failed"); + blog(LOG_ERROR, "device_set_scissor_rect (GL) failed"); } -void device_ortho(device_t device, float left, float right, +void device_ortho(gs_device_t device, float left, float right, float top, float bottom, float near, float far) { struct matrix4 *dst = &device->cur_proj; @@ -1217,7 +1224,7 @@ void device_ortho(device_t device, float left, float right, dst->t.w = 1.0f; } -void device_frustum(device_t device, float left, float right, +void device_frustum(gs_device_t device, float left, float right, float top, float bottom, float near, float far) { struct matrix4 *dst = &device->cur_proj; @@ -1244,12 +1251,12 @@ void device_frustum(device_t device, float left, float right, dst->z.w = -1.0f; } -void device_projection_push(device_t device) +void device_projection_push(gs_device_t device) { da_push_back(device->proj_stack, &device->cur_proj); } -void device_projection_pop(device_t device) +void device_projection_pop(gs_device_t device) { struct matrix4 *end; if (!device->proj_stack.num) @@ -1260,7 +1267,7 @@ void device_projection_pop(device_t device) da_pop_back(device->proj_stack); } -void swapchain_destroy(swapchain_t swapchain) +void gs_swapchain_destroy(gs_swapchain_t swapchain) { if (!swapchain) return; @@ -1274,41 +1281,41 @@ void swapchain_destroy(swapchain_t swapchain) bfree(swapchain); } -void volumetexture_destroy(texture_t voltex) +void gs_voltexture_destroy(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); } -uint32_t volumetexture_getwidth(texture_t voltex) +uint32_t gs_voltexture_get_width(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -uint32_t volumetexture_getheight(texture_t voltex) +uint32_t gs_voltexture_get_height(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -uint32_t volumetexture_getdepth(texture_t voltex) +uint32_t gs_voltexture_getdepth(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return 0; } -enum gs_color_format volumetexture_getcolorformat(texture_t voltex) +enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex) { /* TODO */ UNUSED_PARAMETER(voltex); return GS_UNKNOWN; } -void samplerstate_destroy(samplerstate_t samplerstate) +void gs_samplerstate_destroy(gs_samplerstate_t samplerstate) { if (!samplerstate) return; diff --git a/libobs-opengl/gl-subsystem.h b/libobs-opengl/gl-subsystem.h index 25e1d1e83..c82e773e9 100644 --- a/libobs-opengl/gl-subsystem.h +++ b/libobs-opengl/gl-subsystem.h @@ -143,7 +143,7 @@ static inline GLenum convert_gs_depth_test(enum gs_depth_test test) return GL_NEVER; } -static inline GLenum convert_gs_stencil_op(enum gs_stencil_op op) +static inline GLenum convert_gs_stencil_op(enum gs_stencil_op_type op) { switch (op) { case GS_KEEP: return GL_KEEP; @@ -187,11 +187,11 @@ static inline GLenum convert_gs_blend_type(enum gs_blend_type type) return GL_ONE; } -static inline GLenum convert_shader_type(enum shader_type type) +static inline GLenum convert_shader_type(enum gs_shader_type type) { switch (type) { - case SHADER_VERTEX: return GL_VERTEX_SHADER; - case SHADER_PIXEL: return GL_FRAGMENT_SHADER; + case GS_SHADER_VERTEX: return GL_VERTEX_SHADER; + case GS_SHADER_PIXEL: return GL_FRAGMENT_SHADER; } return GL_VERTEX_SHADER; @@ -273,7 +273,7 @@ extern void convert_sampler_info(struct gs_sampler_state *sampler, struct gs_sampler_info *info); struct gs_sampler_state { - device_t device; + gs_device_t device; volatile long ref; GLint min_filter; @@ -284,22 +284,22 @@ struct gs_sampler_state { GLint max_anisotropy; }; -static inline void samplerstate_addref(samplerstate_t ss) +static inline void samplerstate_addref(gs_samplerstate_t ss) { os_atomic_inc_long(&ss->ref); } -static inline void samplerstate_release(samplerstate_t ss) +static inline void samplerstate_release(gs_samplerstate_t ss) { if (os_atomic_dec_long(&ss->ref) == 0) bfree(ss); } -struct shader_param { - enum shader_param_type type; +struct gs_shader_param { + enum gs_shader_param_type type; char *name; - shader_t shader; + gs_shader_t shader; GLint param; GLint texture_id; size_t sampler_id; @@ -328,16 +328,16 @@ struct shader_attrib { }; struct gs_shader { - device_t device; - enum shader_type type; + gs_device_t device; + enum gs_shader_type type; GLuint program; - struct shader_param *viewproj; - struct shader_param *world; + struct gs_shader_param *viewproj; + struct gs_shader_param *world; - DARRAY(struct shader_attrib) attribs; - DARRAY(struct shader_param) params; - DARRAY(samplerstate_t) samplers; + DARRAY(struct shader_attrib) attribs; + DARRAY(struct gs_shader_param) params; + DARRAY(gs_samplerstate_t) samplers; }; extern void shader_update_textures(struct gs_shader *shader); @@ -351,20 +351,20 @@ struct gs_vertex_buffer { DARRAY(GLuint) uv_buffers; DARRAY(size_t) uv_sizes; - device_t device; + gs_device_t device; size_t num; bool dynamic; - struct vb_data *data; + struct gs_vb_data *data; }; -extern bool vertexbuffer_load(device_t device, vertbuffer_t vb); +extern bool vertexbuffer_load(gs_device_t device, gs_vertbuffer_t vb); struct gs_index_buffer { GLuint buffer; enum gs_index_type type; GLuint gl_type; - device_t device; + gs_device_t device; void *data; size_t num; size_t width; @@ -373,7 +373,7 @@ struct gs_index_buffer { }; struct gs_texture { - device_t device; + gs_device_t device; enum gs_texture_type type; enum gs_color_format format; GLenum gl_format; @@ -387,7 +387,7 @@ struct gs_texture { bool is_dummy; bool gen_mipmaps; - samplerstate_t cur_sampler; + gs_samplerstate_t cur_sampler; }; struct gs_texture_2d { @@ -406,7 +406,7 @@ struct gs_texture_cube { }; struct gs_stage_surface { - device_t device; + gs_device_t device; enum gs_color_format format; uint32_t width; @@ -420,14 +420,14 @@ struct gs_stage_surface { }; struct gs_zstencil_buffer { - device_t device; + gs_device_t device; GLuint buffer; GLuint attachment; GLenum format; }; struct gs_swap_chain { - device_t device; + gs_device_t device; struct gl_windowinfo *wi; struct gs_init_data info; }; @@ -438,9 +438,9 @@ struct fbo_info { uint32_t height; enum gs_color_format format; - texture_t cur_render_target; + gs_texture_t cur_render_target; int cur_render_side; - zstencil_t cur_zstencil_buffer; + gs_zstencil_t cur_zstencil_buffer; }; static inline void fbo_info_destroy(struct fbo_info *fbo) @@ -458,16 +458,16 @@ struct gs_device { GLuint pipeline; enum copy_type copy_type; - texture_t cur_render_target; - zstencil_t cur_zstencil_buffer; + gs_texture_t cur_render_target; + gs_zstencil_t cur_zstencil_buffer; int cur_render_side; - texture_t cur_textures[GS_MAX_TEXTURES]; - samplerstate_t cur_samplers[GS_MAX_TEXTURES]; - vertbuffer_t cur_vertex_buffer; - indexbuffer_t cur_index_buffer; - shader_t cur_vertex_shader; - shader_t cur_pixel_shader; - swapchain_t cur_swap; + gs_texture_t cur_textures[GS_MAX_TEXTURES]; + gs_samplerstate_t cur_samplers[GS_MAX_TEXTURES]; + gs_vertbuffer_t cur_vertex_buffer; + gs_indexbuffer_t cur_index_buffer; + gs_shader_t cur_vertex_shader; + gs_shader_t cur_pixel_shader; + gs_swapchain_t cur_swap; enum gs_cull_mode cur_cull_mode; struct gs_rect cur_viewport; @@ -485,9 +485,9 @@ struct gs_device { extern struct fbo_info *get_fbo(struct gs_device *device, uint32_t width, uint32_t height, enum gs_color_format format); -extern void gl_update(device_t device); +extern void gl_update(gs_device_t device); -extern struct gl_platform *gl_platform_create(device_t device, +extern struct gl_platform *gl_platform_create(gs_device_t device, struct gs_init_data *info); extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform); extern void gl_platform_destroy(struct gl_platform *platform); diff --git a/libobs-opengl/gl-texture2d.c b/libobs-opengl/gl-texture2d.c index b3b7986a5..067888c33 100644 --- a/libobs-opengl/gl-texture2d.c +++ b/libobs-opengl/gl-texture2d.c @@ -26,7 +26,7 @@ static bool upload_texture_2d(struct gs_texture_2d *tex, const uint8_t **data) bool success; if (!num_levels) - num_levels = gs_num_total_levels(tex->width, tex->height); + num_levels = gs_get_total_levels(tex->width, tex->height); if (!gl_bind_texture(GL_TEXTURE_2D, tex->base.texture)) return false; @@ -74,7 +74,7 @@ static bool create_pixel_unpack_buffer(struct gs_texture_2d *tex) return success; } -texture_t device_create_texture(device_t device, uint32_t width, +gs_texture_t device_texture_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags) { @@ -87,10 +87,10 @@ texture_t device_create_texture(device_t device, uint32_t width, tex->base.gl_internal_format = convert_gs_internal_format(color_format); tex->base.gl_type = get_gl_format_type(color_format); tex->base.gl_target = GL_TEXTURE_2D; - tex->base.is_dynamic = (flags & GS_DYNAMIC) != 0; - tex->base.is_render_target = (flags & GS_RENDERTARGET) != 0; - tex->base.is_dummy = (flags & GS_GL_DUMMYTEX) != 0; - tex->base.gen_mipmaps = (flags & GS_BUILDMIPMAPS) != 0; + tex->base.is_dynamic = (flags & GS_DYNAMIC) != 0; + tex->base.is_render_target = (flags & GS_RENDER_TARGET) != 0; + tex->base.is_dummy = (flags & GS_GL_DUMMYTEX) != 0; + tex->base.gen_mipmaps = (flags & GS_BUILD_MIPMAPS) != 0; tex->width = width; tex->height = height; @@ -104,15 +104,15 @@ texture_t device_create_texture(device_t device, uint32_t width, goto fail; } - return (texture_t)tex; + return (gs_texture_t)tex; fail: - texture_destroy((texture_t)tex); - blog(LOG_ERROR, "device_create_texture (GL) failed"); + gs_texture_destroy((gs_texture_t)tex); + blog(LOG_ERROR, "device_texture_create (GL) failed"); return NULL; } -static inline bool is_texture_2d(texture_t tex, const char *func) +static inline bool is_texture_2d(gs_texture_t tex, const char *func) { bool is_tex2d = tex->type == GS_TEXTURE_2D; if (!is_tex2d) @@ -120,17 +120,17 @@ static inline bool is_texture_2d(texture_t tex, const char *func) return is_tex2d; } -void texture_destroy(texture_t tex) +void gs_texture_destroy(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; if (!tex) return; - if (!is_texture_2d(tex, "texture_destroy")) + if (!is_texture_2d(tex, "gs_texture_destroy")) return; if (tex->cur_sampler) - samplerstate_destroy(tex->cur_sampler); + gs_samplerstate_destroy(tex->cur_sampler); if (!tex->is_dummy && tex->is_dynamic && tex2d->unpack_buffer) gl_delete_buffers(1, &tex2d->unpack_buffer); @@ -141,34 +141,34 @@ void texture_destroy(texture_t tex) bfree(tex); } -uint32_t texture_getwidth(texture_t tex) +uint32_t gs_texture_get_width(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_getwidth")) + if (!is_texture_2d(tex, "gs_texture_get_width")) return 0; return tex2d->width; } -uint32_t texture_getheight(texture_t tex) +uint32_t gs_texture_get_height(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_getheight")) + if (!is_texture_2d(tex, "gs_texture_get_height")) return 0; return tex2d->height; } -enum gs_color_format texture_getcolorformat(texture_t tex) +enum gs_color_format gs_texture_get_color_format(gs_texture_t tex) { return tex->format; } -bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize) +bool gs_texture_map(gs_texture_t tex, uint8_t **ptr, uint32_t *linesize) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_map")) + if (!is_texture_2d(tex, "gs_texture_map")) goto fail; if (!tex2d->base.is_dynamic) { @@ -190,14 +190,14 @@ bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize) return true; fail: - blog(LOG_ERROR, "texture_map (GL) failed"); + blog(LOG_ERROR, "gs_texture_map (GL) failed"); return false; } -void texture_unmap(texture_t tex) +void gs_texture_unmap(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_unmap")) + if (!is_texture_2d(tex, "gs_texture_unmap")) goto failed; if (!gl_bind_buffer(GL_PIXEL_UNPACK_BUFFER, tex2d->unpack_buffer)) @@ -223,25 +223,25 @@ void texture_unmap(texture_t tex) failed: gl_bind_buffer(GL_PIXEL_UNPACK_BUFFER, 0); gl_bind_texture(GL_TEXTURE_2D, 0); - blog(LOG_ERROR, "texture_unmap (GL) failed"); + blog(LOG_ERROR, "gs_texture_unmap (GL) failed"); } -bool texture_isrect(texture_t tex) +bool gs_texture_is_rect(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_unmap")) { - blog(LOG_ERROR, "texture_isrect (GL) failed"); + if (!is_texture_2d(tex, "gs_texture_unmap")) { + blog(LOG_ERROR, "gs_texture_is_rect (GL) failed"); return false; } return tex2d->base.gl_target == GL_TEXTURE_RECTANGLE; } -void *texture_getobj(texture_t tex) +void *gs_texture_get_obj(gs_texture_t tex) { struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex; - if (!is_texture_2d(tex, "texture_unmap")) { - blog(LOG_ERROR, "texture_getobj (GL) failed"); + if (!is_texture_2d(tex, "gs_texture_unmap")) { + blog(LOG_ERROR, "gs_texture_get_obj (GL) failed"); return NULL; } diff --git a/libobs-opengl/gl-texturecube.c b/libobs-opengl/gl-texturecube.c index 0d7a36c7a..5d55405db 100644 --- a/libobs-opengl/gl-texturecube.c +++ b/libobs-opengl/gl-texturecube.c @@ -29,7 +29,7 @@ static inline bool upload_texture_cube(struct gs_texture_cube *tex, uint32_t i; if (!num_levels) - num_levels = gs_num_total_levels(tex->size, tex->size); + num_levels = gs_get_total_levels(tex->size, tex->size); for (i = 0; i < 6; i++) { GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i; @@ -58,7 +58,7 @@ static inline bool upload_texture_cube(struct gs_texture_cube *tex, return success; } -texture_t device_create_cubetexture(device_t device, uint32_t size, +gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags) { @@ -70,8 +70,8 @@ texture_t device_create_cubetexture(device_t device, uint32_t size, tex->base.gl_format = convert_gs_format(color_format); tex->base.gl_internal_format = convert_gs_internal_format(color_format); tex->base.gl_target = GL_TEXTURE_CUBE_MAP; - tex->base.is_render_target = (flags & GS_RENDERTARGET) != 0; - tex->base.gen_mipmaps = (flags & GS_BUILDMIPMAPS) != 0; + tex->base.is_render_target = (flags & GS_RENDER_TARGET) != 0; + tex->base.gen_mipmaps = (flags & GS_BUILD_MIPMAPS) != 0; tex->size = size; if (!gl_gen_textures(1, &tex->base.texture)) @@ -79,15 +79,15 @@ texture_t device_create_cubetexture(device_t device, uint32_t size, if (!upload_texture_cube(tex, data)) goto fail; - return (texture_t)tex; + return (gs_texture_t)tex; fail: - cubetexture_destroy((texture_t)tex); - blog(LOG_ERROR, "device_create_cubetexture (GL) failed"); + gs_cubetexture_destroy((gs_texture_t)tex); + blog(LOG_ERROR, "device_cubetexture_create (GL) failed"); return NULL; } -void cubetexture_destroy(texture_t tex) +void gs_cubetexture_destroy(gs_texture_t tex) { if (!tex) return; @@ -100,7 +100,7 @@ void cubetexture_destroy(texture_t tex) bfree(tex); } -static inline bool is_texture_cube(texture_t tex, const char *func) +static inline bool is_texture_cube(gs_texture_t tex, const char *func) { bool is_texcube = tex->type == GS_TEXTURE_CUBE; if (!is_texcube) @@ -108,16 +108,16 @@ static inline bool is_texture_cube(texture_t tex, const char *func) return is_texcube; } -uint32_t cubetexture_getsize(texture_t cubetex) +uint32_t gs_cubetexture_get_size(gs_texture_t cubetex) { struct gs_texture_cube *cube = (struct gs_texture_cube*)cubetex; - if (!is_texture_cube(cubetex, "cubetexture_getsize")) + if (!is_texture_cube(cubetex, "gs_cubetexture_get_size")) return 0; return cube->size; } -enum gs_color_format cubetexture_getcolorformat(texture_t cubetex) +enum gs_color_format gs_cubetexture_get_color_format(gs_texture_t cubetex) { return cubetex->format; } diff --git a/libobs-opengl/gl-vertexbuffer.c b/libobs-opengl/gl-vertexbuffer.c index becb74d01..ccc586685 100644 --- a/libobs-opengl/gl-vertexbuffer.c +++ b/libobs-opengl/gl-vertexbuffer.c @@ -54,7 +54,7 @@ static bool create_buffers(struct gs_vertex_buffer *vb) for (i = 0; i < vb->data->num_tex; i++) { GLuint tex_buffer; - struct tvertarray *tv = vb->data->tvarray+i; + struct gs_tvertarray *tv = vb->data->tvarray+i; size_t size = vb->data->num * sizeof(float) * tv->width; if (!gl_create_buffer(GL_ARRAY_BUFFER, &tex_buffer, size, @@ -66,7 +66,7 @@ static bool create_buffers(struct gs_vertex_buffer *vb) } if (!vb->dynamic) { - vbdata_destroy(vb->data); + gs_vbdata_destroy(vb->data); vb->data = NULL; } @@ -76,8 +76,8 @@ static bool create_buffers(struct gs_vertex_buffer *vb) return true; } -vertbuffer_t device_create_vertexbuffer(device_t device, - struct vb_data *data, uint32_t flags) +gs_vertbuffer_t device_vertexbuffer_create(gs_device_t device, + struct gs_vb_data *data, uint32_t flags) { struct gs_vertex_buffer *vb = bzalloc(sizeof(struct gs_vertex_buffer)); vb->device = device; @@ -86,15 +86,15 @@ vertbuffer_t device_create_vertexbuffer(device_t device, vb->dynamic = flags & GS_DYNAMIC; if (!create_buffers(vb)) { - blog(LOG_ERROR, "device_create_vertexbuffer (GL) failed"); - vertexbuffer_destroy(vb); + blog(LOG_ERROR, "device_vertexbuffer_create (GL) failed"); + gs_vertexbuffer_destroy(vb); return NULL; } return vb; } -void vertexbuffer_destroy(vertbuffer_t vb) +void gs_vertexbuffer_destroy(gs_vertbuffer_t vb) { if (vb) { if (vb->vertex_buffer) @@ -114,13 +114,13 @@ void vertexbuffer_destroy(vertbuffer_t vb) da_free(vb->uv_sizes); da_free(vb->uv_buffers); - vbdata_destroy(vb->data); + gs_vbdata_destroy(vb->data); bfree(vb); } } -void vertexbuffer_flush(vertbuffer_t vb) +void gs_vertexbuffer_flush(gs_vertbuffer_t vb) { size_t i; @@ -157,7 +157,7 @@ void vertexbuffer_flush(vertbuffer_t vb) for (i = 0; i < vb->data->num_tex; i++) { GLuint buffer = vb->uv_buffers.array[i]; - struct tvertarray *tv = vb->data->tvarray+i; + struct gs_tvertarray *tv = vb->data->tvarray+i; size_t size = vb->data->num * tv->width * sizeof(float); if (!update_buffer(GL_ARRAY_BUFFER, buffer, tv->array, size)) @@ -167,10 +167,10 @@ void vertexbuffer_flush(vertbuffer_t vb) return; failed: - blog(LOG_ERROR, "vertexbuffer_flush (GL) failed"); + blog(LOG_ERROR, "gs_vertexbuffer_flush (GL) failed"); } -struct vb_data *vertexbuffer_getdata(vertbuffer_t vb) +struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vb) { return vb->data; } @@ -251,7 +251,7 @@ static inline bool load_vb_buffers(struct gs_shader *shader, return true; } -bool vertexbuffer_load(device_t device, vertbuffer_t vb) +bool vertexbuffer_load(gs_device_t device, gs_vertbuffer_t vb) { if (device->cur_vertex_buffer == vb) return true; @@ -268,7 +268,7 @@ bool vertexbuffer_load(device_t device, vertbuffer_t vb) return true; } -void device_load_vertexbuffer(device_t device, vertbuffer_t vb) +void device_load_vertexbuffer(gs_device_t device, gs_vertbuffer_t vb) { if (!vertexbuffer_load(device, vb)) blog(LOG_ERROR, "device_load_vertexbuffer (GL) failed"); diff --git a/libobs-opengl/gl-windows.c b/libobs-opengl/gl-windows.c index 1d2272a07..0305455b6 100644 --- a/libobs-opengl/gl-windows.c +++ b/libobs-opengl/gl-windows.c @@ -350,7 +350,7 @@ static struct gl_windowinfo *gl_windowinfo_bare(struct gs_init_data *info) return wi; } -static bool init_default_swap(struct gl_platform *plat, device_t device, +static bool init_default_swap(struct gl_platform *plat, gs_device_t device, int pixel_format, PIXELFORMATDESCRIPTOR *pfd, struct gs_init_data *info) { @@ -366,13 +366,13 @@ static bool init_default_swap(struct gl_platform *plat, device_t device, return true; } -void gl_update(device_t device) +void gl_update(gs_device_t device) { /* does nothing on windows */ UNUSED_PARAMETER(device); } -struct gl_platform *gl_platform_create(device_t device, +struct gl_platform *gl_platform_create(gs_device_t device, struct gs_init_data *info) { struct gl_platform *plat = bzalloc(sizeof(struct gl_platform)); @@ -475,7 +475,7 @@ void gl_windowinfo_destroy(struct gl_windowinfo *wi) } } -void device_entercontext(device_t device) +void device_enter_context(gs_device_t device) { HDC hdc = device->plat->swap.wi->hdc; if (device->cur_swap) @@ -485,13 +485,13 @@ void device_entercontext(device_t device) blog(LOG_ERROR, "device_load_swapchain (GL) failed"); } -void device_leavecontext(device_t device) +void device_leave_context(gs_device_t device) { wglMakeCurrent(NULL, NULL); UNUSED_PARAMETER(device); } -void device_load_swapchain(device_t device, swapchain_t swap) +void device_load_swapchain(gs_device_t device, gs_swapchain_t swap) { HDC hdc; if (!swap) @@ -510,7 +510,7 @@ void device_load_swapchain(device_t device, swapchain_t swap) } } -void device_present(device_t device) +void device_present(gs_device_t device) { if (!SwapBuffers(device->cur_swap->wi->hdc)) { blog(LOG_ERROR, "SwapBuffers failed, GetLastError " @@ -528,7 +528,7 @@ extern void gl_getclientsize(struct gs_swap_chain *swap, *height = rc.bottom; } -EXPORT bool gdi_texture_available(void) +EXPORT bool device_gdi_texture_available(void) { return false; } diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index 11a8591f4..2c7671b60 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -135,7 +135,7 @@ static bool handle_x_error(Display *disp, const char *error_string) return false; } -struct gl_platform *gl_platform_create(device_t device, +struct gl_platform *gl_platform_create(gs_device_t device, struct gs_init_data *info) { int num_configs = 0; @@ -366,7 +366,7 @@ void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap) info->int_id = 0; } -void device_entercontext(device_t device) +void device_enter_context(gs_device_t device) { GLXContext context = device->plat->context; XID window = device->cur_swap->wi->glxid; @@ -377,7 +377,7 @@ void device_entercontext(device_t device) } } -void device_leavecontext(device_t device) +void device_leave_context(gs_device_t device) { Display *display = device->cur_swap->wi->display; @@ -386,7 +386,7 @@ void device_leavecontext(device_t device) } } -void gl_update(device_t device) +void gl_update(gs_device_t device) { Display *display = device->cur_swap->wi->display; XID window = device->cur_swap->wi->int_id; @@ -395,7 +395,7 @@ void gl_update(device_t device) device->cur_swap->info.cx, device->cur_swap->info.cy); } -void device_load_swapchain(device_t device, swapchain_t swap) +void device_load_swapchain(gs_device_t device, gs_swapchain_t swap) { if (!swap) swap = &device->plat->swap; @@ -414,7 +414,7 @@ void device_load_swapchain(device_t device, swapchain_t swap) } } -void device_present(device_t device) +void device_present(gs_device_t device) { Display *display = device->cur_swap->wi->display; XID window = device->cur_swap->wi->glxid; diff --git a/libobs-opengl/gl-zstencil.c b/libobs-opengl/gl-zstencil.c index 14c8bd826..dfbefe843 100644 --- a/libobs-opengl/gl-zstencil.c +++ b/libobs-opengl/gl-zstencil.c @@ -48,7 +48,7 @@ static inline GLenum get_attachment(enum gs_zstencil_format format) return 0; } -zstencil_t device_create_zstencil(device_t device, uint32_t width, +gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_zstencil_format format) { struct gs_zstencil_buffer *zs; @@ -59,15 +59,15 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width, zs->device = device; if (!gl_init_zsbuffer(zs, width, height)) { - blog(LOG_ERROR, "device_create_zstencil (GL) failed"); - zstencil_destroy(zs); + blog(LOG_ERROR, "device_zstencil_create (GL) failed"); + gs_zstencil_destroy(zs); return NULL; } return zs; } -void zstencil_destroy(zstencil_t zs) +void gs_zstencil_destroy(gs_zstencil_t zs) { if (zs) { if (zs->buffer) { diff --git a/libobs/graphics/device-exports.h b/libobs/graphics/device-exports.h index 4852d9f8e..48d115bf6 100644 --- a/libobs/graphics/device-exports.h +++ b/libobs/graphics/device-exports.h @@ -23,114 +23,121 @@ extern "C" { #endif -EXPORT const char *device_name(void); -EXPORT int device_type(void); +EXPORT const char *device_get_name(void); +EXPORT int device_get_type(void); EXPORT const char *device_preprocessor_name(void); -EXPORT int device_create(device_t *device, struct gs_init_data *data); -EXPORT void device_destroy(device_t device); -EXPORT void device_entercontext(device_t device); -EXPORT void device_leavecontext(device_t device); -EXPORT swapchain_t device_create_swapchain(device_t device, +EXPORT int device_create(gs_device_t *device, struct gs_init_data *data); +EXPORT void device_destroy(gs_device_t device); +EXPORT void device_enter_context(gs_device_t device); +EXPORT void device_leave_context(gs_device_t device); +EXPORT gs_swapchain_t device_swapchain_create(gs_device_t device, struct gs_init_data *data); -EXPORT void device_resize(device_t device, uint32_t x, uint32_t y); -EXPORT void device_getsize(device_t device, uint32_t *x, uint32_t *y); -EXPORT uint32_t device_getwidth(device_t device); -EXPORT uint32_t device_getheight(device_t device); -EXPORT texture_t device_create_texture(device_t device, uint32_t width, +EXPORT void device_resize(gs_device_t device, uint32_t x, uint32_t y); +EXPORT void device_get_size(gs_device_t device, uint32_t *x, uint32_t *y); +EXPORT uint32_t device_get_width(gs_device_t device); +EXPORT uint32_t device_get_height(gs_device_t device); +EXPORT gs_texture_t device_texture_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags); -EXPORT texture_t device_create_cubetexture(device_t device, uint32_t size, +EXPORT gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags); -EXPORT texture_t device_create_volumetexture(device_t device, uint32_t width, +EXPORT gs_texture_t device_voltexture_create(gs_device_t device, 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 zstencil_t device_create_zstencil(device_t device, uint32_t width, +EXPORT gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width, uint32_t height, enum gs_zstencil_format format); -EXPORT stagesurf_t device_create_stagesurface(device_t device, uint32_t width, - uint32_t height, enum gs_color_format color_format); -EXPORT samplerstate_t device_create_samplerstate(device_t device, +EXPORT gs_stagesurf_t device_stagesurface_create(gs_device_t device, + uint32_t width, uint32_t height, + enum gs_color_format color_format); +EXPORT gs_samplerstate_t device_samplerstate_create(gs_device_t device, struct gs_sampler_info *info); -EXPORT shader_t device_create_vertexshader(device_t device, +EXPORT gs_shader_t device_vertexshader_create(gs_device_t device, const char *shader, const char *file, char **error_string); -EXPORT shader_t device_create_pixelshader(device_t device, +EXPORT gs_shader_t device_pixelshader_create(gs_device_t device, const char *shader, const char *file, char **error_string); -EXPORT vertbuffer_t device_create_vertexbuffer(device_t device, - struct vb_data *data, uint32_t flags); -EXPORT indexbuffer_t device_create_indexbuffer(device_t device, +EXPORT gs_vertbuffer_t device_vertexbuffer_create(gs_device_t device, + struct gs_vb_data *data, uint32_t flags); +EXPORT gs_indexbuffer_t device_indexbuffer_create(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags); -EXPORT enum gs_texture_type device_gettexturetype(texture_t texture); -EXPORT void device_load_vertexbuffer(device_t device, vertbuffer_t vertbuffer); -EXPORT void device_load_indexbuffer(device_t device, indexbuffer_t indexbuffer); -EXPORT void device_load_texture(device_t device, texture_t tex, int unit); -EXPORT void device_load_samplerstate(device_t device, - samplerstate_t samplerstate, int unit); -EXPORT void device_load_vertexshader(device_t device, shader_t vertshader); -EXPORT void device_load_pixelshader(device_t device, shader_t pixelshader); -EXPORT void device_load_defaultsamplerstate(device_t device, bool b_3d, +EXPORT enum gs_texture_type device_get_texture_type(gs_texture_t texture); +EXPORT void device_load_vertexbuffer(gs_device_t device, + gs_vertbuffer_t vertbuffer); +EXPORT void device_load_indexbuffer(gs_device_t device, + gs_indexbuffer_t indexbuffer); +EXPORT void device_load_texture(gs_device_t device, gs_texture_t tex, int unit); +EXPORT void device_load_samplerstate(gs_device_t device, + gs_samplerstate_t samplerstate, int unit); +EXPORT void device_load_vertexshader(gs_device_t device, + gs_shader_t vertshader); +EXPORT void device_load_pixelshader(gs_device_t device, + gs_shader_t pixelshader); +EXPORT void device_load_default_samplerstate(gs_device_t device, bool b_3d, int unit); -EXPORT shader_t device_getvertexshader(device_t device); -EXPORT shader_t device_getpixelshader(device_t device); -EXPORT texture_t device_getrendertarget(device_t device); -EXPORT zstencil_t device_getzstenciltarget(device_t device); -EXPORT void device_setrendertarget(device_t device, texture_t tex, - zstencil_t zstencil); -EXPORT void device_setcuberendertarget(device_t device, texture_t cubetex, - int side, zstencil_t zstencil); -EXPORT void device_copy_texture(device_t device, texture_t dst, texture_t src); -EXPORT void device_copy_texture_region(device_t device, - texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, +EXPORT gs_shader_t device_get_vertex_shader(gs_device_t device); +EXPORT gs_shader_t device_get_pixel_shader(gs_device_t device); +EXPORT gs_texture_t device_get_render_target(gs_device_t device); +EXPORT gs_zstencil_t device_get_zstencil_target(gs_device_t device); +EXPORT void device_set_render_target(gs_device_t device, gs_texture_t tex, + gs_zstencil_t zstencil); +EXPORT void device_set_cube_render_target(gs_device_t device, + gs_texture_t cubetex, + int side, gs_zstencil_t zstencil); +EXPORT void device_copy_texture(gs_device_t device, gs_texture_t dst, + gs_texture_t src); +EXPORT void device_copy_texture_region(gs_device_t device, + 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 device_stage_texture(device_t device, stagesurf_t dst, - texture_t src); -EXPORT void device_beginscene(device_t device); -EXPORT void device_draw(device_t device, enum gs_draw_mode draw_mode, +EXPORT void device_stage_texture(gs_device_t device, gs_stagesurf_t dst, + gs_texture_t src); +EXPORT void device_begin_scene(gs_device_t device); +EXPORT void device_draw(gs_device_t device, enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts); -EXPORT void device_endscene(device_t device); -EXPORT void device_load_swapchain(device_t device, swapchain_t swapchain); -EXPORT void device_clear(device_t device, uint32_t clear_flags, +EXPORT void device_end_scene(gs_device_t device); +EXPORT void device_load_swapchain(gs_device_t device, gs_swapchain_t swapchain); +EXPORT void device_clear(gs_device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); -EXPORT void device_present(device_t device); -EXPORT void device_flush(device_t device); -EXPORT void device_setcullmode(device_t device, enum gs_cull_mode mode); -EXPORT enum gs_cull_mode device_getcullmode(device_t device); -EXPORT void device_enable_blending(device_t device, bool enable); -EXPORT void device_enable_depthtest(device_t device, bool enable); -EXPORT void device_enable_stenciltest(device_t device, bool enable); -EXPORT void device_enable_stencilwrite(device_t device, bool enable); -EXPORT void device_enable_color(device_t device, bool red, bool green, +EXPORT void device_present(gs_device_t device); +EXPORT void device_flush(gs_device_t device); +EXPORT void device_set_cull_mode(gs_device_t device, enum gs_cull_mode mode); +EXPORT enum gs_cull_mode device_get_cull_mode(gs_device_t device); +EXPORT void device_enable_blending(gs_device_t device, bool enable); +EXPORT void device_enable_depth_test(gs_device_t device, bool enable); +EXPORT void device_enable_stencil_test(gs_device_t device, bool enable); +EXPORT void device_enable_stencil_write(gs_device_t device, bool enable); +EXPORT void device_enable_color(gs_device_t device, bool red, bool green, bool blue, bool alpha); -EXPORT void device_blendfunction(device_t device, enum gs_blend_type src, +EXPORT void device_blend_function(gs_device_t device, enum gs_blend_type src, enum gs_blend_type dest); -EXPORT void device_depthfunction(device_t device, enum gs_depth_test test); -EXPORT void device_stencilfunction(device_t device, enum gs_stencil_side side, - enum gs_depth_test test); -EXPORT void device_stencilop(device_t device, enum gs_stencil_side side, - enum gs_stencil_op fail, enum gs_stencil_op zfail, - enum gs_stencil_op zpass); -EXPORT void device_enable_fullscreen(device_t device, bool enable); -EXPORT int device_fullscreen_enabled(device_t device); -EXPORT void device_setdisplaymode(device_t device, +EXPORT void device_depth_function(gs_device_t device, enum gs_depth_test test); +EXPORT void device_stencil_function(gs_device_t device, + enum gs_stencil_side side, enum gs_depth_test test); +EXPORT void device_stencil_op(gs_device_t device, enum gs_stencil_side side, + enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail, + enum gs_stencil_op_type zpass); +EXPORT void device_enable_fullscreen(gs_device_t device, bool enable); +EXPORT int device_fullscreen_enabled(gs_device_t device); +EXPORT void device_setdisplaymode(gs_device_t device, const struct gs_display_mode *mode); -EXPORT void device_getdisplaymode(device_t device, +EXPORT void device_getdisplaymode(gs_device_t device, struct gs_display_mode *mode); -EXPORT void device_setcolorramp(device_t device, float gamma, float brightness, - float contrast); -EXPORT void device_setviewport(device_t device, int x, int y, int width, +EXPORT void device_setcolorramp(gs_device_t device, float gamma, + float brightness, float contrast); +EXPORT void device_set_viewport(gs_device_t device, int x, int y, int width, int height); -EXPORT void device_getviewport(device_t device, struct gs_rect *rect); -EXPORT void device_setscissorrect(device_t device, struct gs_rect *rect); -EXPORT void device_ortho(device_t device, float left, float right, +EXPORT void device_get_viewport(gs_device_t device, struct gs_rect *rect); +EXPORT void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect); +EXPORT void device_ortho(gs_device_t device, float left, float right, float top, float bottom, float znear, float zfar); -EXPORT void device_frustum(device_t device, float left, float right, +EXPORT void device_frustum(gs_device_t device, float left, float right, float top, float bottom, float znear, float zfar); -EXPORT void device_projection_push(device_t device); -EXPORT void device_projection_pop(device_t device); +EXPORT void device_projection_push(gs_device_t device); +EXPORT void device_projection_pop(gs_device_t device); #ifdef __cplusplus } diff --git a/libobs/graphics/effect-parser.c b/libobs/graphics/effect-parser.c index 7e1d6d4dc..c9579a12a 100644 --- a/libobs/graphics/effect-parser.c +++ b/libobs/graphics/effect-parser.c @@ -919,7 +919,7 @@ static bool ep_compile(struct effect_parser *ep); extern const char *gs_preprocessor_name(void); -bool ep_parse(struct effect_parser *ep, effect_t effect, +bool ep_parse(struct effect_parser *ep, gs_effect_t effect, const char *effect_string, const char *file) { bool success; @@ -1283,7 +1283,7 @@ static void ep_makeshaderstring(struct effect_parser *ep, static void ep_compile_param(struct effect_parser *ep, size_t idx) { - struct effect_param *param; + struct gs_effect_param *param; struct ep_param *param_in; param = ep->effect->params.array+idx; @@ -1296,21 +1296,21 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx) da_move(param->default_val, param_in->default_val); if (strcmp(param_in->type, "bool") == 0) - param->type = SHADER_PARAM_BOOL; + param->type = GS_SHADER_PARAM_BOOL; else if (strcmp(param_in->type, "float") == 0) - param->type = SHADER_PARAM_FLOAT; + param->type = GS_SHADER_PARAM_FLOAT; else if (strcmp(param_in->type, "int") == 0) - param->type = SHADER_PARAM_INT; + param->type = GS_SHADER_PARAM_INT; else if (strcmp(param_in->type, "float2") == 0) - param->type = SHADER_PARAM_VEC2; + param->type = GS_SHADER_PARAM_VEC2; else if (strcmp(param_in->type, "float3") == 0) - param->type = SHADER_PARAM_VEC3; + param->type = GS_SHADER_PARAM_VEC3; else if (strcmp(param_in->type, "float4") == 0) - param->type = SHADER_PARAM_VEC4; + param->type = GS_SHADER_PARAM_VEC4; else if (strcmp(param_in->type, "float4x4") == 0) - param->type = SHADER_PARAM_MATRIX4X4; + param->type = GS_SHADER_PARAM_MATRIX4X4; else if (param_in->is_texture) - param->type = SHADER_PARAM_TEXTURE; + param->type = GS_SHADER_PARAM_TEXTURE; if (strcmp(param_in->name, "ViewProj") == 0) ep->effect->view_proj = param; @@ -1320,7 +1320,7 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx) static bool ep_compile_pass_shaderparams(struct effect_parser *ep, struct darray *pass_params, struct darray *used_params, - shader_t shader) + gs_shader_t shader) { size_t i; darray_resize(sizeof(struct pass_shaderparam), pass_params, @@ -1334,9 +1334,9 @@ static bool ep_compile_pass_shaderparams(struct effect_parser *ep, param = darray_item(sizeof(struct pass_shaderparam), pass_params, i); - param->eparam = effect_getparambyname(ep->effect, + param->eparam = gs_effect_get_param_by_name(ep->effect, param_name->array); - param->sparam = shader_getparambyname(shader, + param->sparam = gs_shader_get_param_by_name(shader, param_name->array); if (!param->sparam) { @@ -1349,15 +1349,15 @@ static bool ep_compile_pass_shaderparams(struct effect_parser *ep, } static inline bool ep_compile_pass_shader(struct effect_parser *ep, - struct effect_technique *tech, - struct effect_pass *pass, struct ep_pass *pass_in, - size_t pass_idx, enum shader_type type) + struct gs_effect_technique *tech, + struct gs_effect_pass *pass, struct ep_pass *pass_in, + size_t pass_idx, enum gs_shader_type type) { struct dstr shader_str; struct dstr location; struct darray used_params; /* struct dstr */ struct darray *pass_params = NULL; /* struct pass_shaderparam */ - shader_t shader = NULL; + gs_shader_t shader = NULL; bool success = true; dstr_init(&shader_str); @@ -1365,9 +1365,9 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep, dstr_init(&location); dstr_copy(&location, ep->cfp.lex.file); - if (type == SHADER_VERTEX) + if (type == GS_SHADER_VERTEX) dstr_cat(&location, " (Vertex "); - else if (type == SHADER_PIXEL) + else if (type == GS_SHADER_PIXEL) dstr_cat(&location, " (Pixel "); /*else if (type == SHADER_GEOMETRY) dstr_cat(&location, " (Geometry ");*/ @@ -1375,20 +1375,20 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep, dstr_catf(&location, "shader, technique %s, pass %u)", tech->name, pass_idx); - if (type == SHADER_VERTEX) { + if (type == GS_SHADER_VERTEX) { ep_makeshaderstring(ep, &shader_str, &pass_in->vertex_program.da, &used_params); - pass->vertshader = gs_create_vertexshader(shader_str.array, + pass->vertshader = gs_vertexshader_create(shader_str.array, location.array, NULL); shader = pass->vertshader; pass_params = &pass->vertshader_params.da; - } else if (type == SHADER_PIXEL) { + } else if (type == GS_SHADER_PIXEL) { ep_makeshaderstring(ep, &shader_str, &pass_in->fragment_program.da, &used_params); - pass->pixelshader = gs_create_pixelshader(shader_str.array, + pass->pixelshader = gs_pixelshader_create(shader_str.array, location.array, NULL); shader = pass->pixelshader; @@ -1418,11 +1418,11 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep, } static bool ep_compile_pass(struct effect_parser *ep, - struct effect_technique *tech, + struct gs_effect_technique *tech, struct ep_technique *tech_in, size_t idx) { - struct effect_pass *pass; + struct gs_effect_pass *pass; struct ep_pass *pass_in; bool success = true; @@ -1433,11 +1433,11 @@ static bool ep_compile_pass(struct effect_parser *ep, pass->section = EFFECT_PASS; if (!ep_compile_pass_shader(ep, tech, pass, pass_in, idx, - SHADER_VERTEX)) + GS_SHADER_VERTEX)) success = false; if (!ep_compile_pass_shader(ep, tech, pass, pass_in, idx, - SHADER_PIXEL)) + GS_SHADER_PIXEL)) success = false; return success; @@ -1445,7 +1445,7 @@ static bool ep_compile_pass(struct effect_parser *ep, static inline bool ep_compile_technique(struct effect_parser *ep, size_t idx) { - struct effect_technique *tech; + struct gs_effect_technique *tech; struct ep_technique *tech_in; bool success = true; size_t i; diff --git a/libobs/graphics/effect-parser.h b/libobs/graphics/effect-parser.h index 58e2ff1b1..a3553372c 100644 --- a/libobs/graphics/effect-parser.h +++ b/libobs/graphics/effect-parser.h @@ -61,7 +61,7 @@ struct ep_param { char *type, *name; DARRAY(uint8_t) default_val; DARRAY(char*) properties; - struct effect_param *param; + struct gs_effect_param *param; bool is_const, is_property, is_uniform, is_texture, written; int writeorder, array_count; }; @@ -162,7 +162,7 @@ struct ep_pass { char *name; DARRAY(struct cf_token) vertex_program; DARRAY(struct cf_token) fragment_program; - struct effect_pass *pass; + struct gs_effect_pass *pass; }; static inline void ep_pass_init(struct ep_pass *epp) @@ -243,7 +243,7 @@ static inline void ep_func_free(struct ep_func *epf) /* ------------------------------------------------------------------------- */ struct effect_parser { - effect_t effect; + gs_effect_t effect; DARRAY(struct ep_param) params; DARRAY(struct ep_struct) structs; @@ -254,7 +254,7 @@ struct effect_parser { /* internal vars */ DARRAY(struct cf_lexer) files; DARRAY(struct cf_token) tokens; - struct effect_pass *cur_pass; + struct gs_effect_pass *cur_pass; struct cf_parser cfp; }; @@ -275,7 +275,7 @@ static inline void ep_init(struct effect_parser *ep) extern void ep_free(struct effect_parser *ep); -extern bool ep_parse(struct effect_parser *ep, effect_t effect, +extern bool ep_parse(struct effect_parser *ep, gs_effect_t effect, const char *effect_string, const char *file); #ifdef __cplusplus diff --git a/libobs/graphics/effect.c b/libobs/graphics/effect.c index 90e450022..7670033c4 100644 --- a/libobs/graphics/effect.c +++ b/libobs/graphics/effect.c @@ -21,7 +21,7 @@ #include "vec3.h" #include "vec4.h" -void effect_destroy(effect_t effect) +void gs_effect_destroy(gs_effect_t effect) { if (effect) { effect_free(effect); @@ -29,12 +29,12 @@ void effect_destroy(effect_t effect) } } -technique_t effect_gettechnique(effect_t effect, const char *name) +gs_technique_t gs_effect_get_technique(gs_effect_t effect, const char *name) { if (!effect) return NULL; for (size_t i = 0; i < effect->techniques.num; i++) { - struct effect_technique *tech = effect->techniques.array+i; + struct gs_effect_technique *tech = effect->techniques.array+i; if (strcmp(tech->name, name) == 0) return tech; } @@ -42,7 +42,7 @@ technique_t effect_gettechnique(effect_t effect, const char *name) return NULL; } -size_t technique_begin(technique_t tech) +size_t gs_technique_begin(gs_technique_t tech) { if (!tech) return 0; @@ -52,12 +52,12 @@ size_t technique_begin(technique_t tech) return tech->passes.num; } -void technique_end(technique_t tech) +void gs_technique_end(gs_technique_t tech) { if (!tech) return; struct gs_effect *effect = tech->effect; - struct effect_param *params = effect->params.array; + struct gs_effect_param *params = effect->params.array; size_t i; gs_load_vertexshader(NULL); @@ -67,7 +67,7 @@ void technique_end(technique_t tech) tech->effect->graphics->cur_effect = NULL; for (i = 0; i < effect->params.num; i++) { - struct effect_param *param = params+i; + struct gs_effect_param *param = params+i; da_free(param->cur_val); param->changed = false; @@ -90,8 +90,8 @@ static void upload_shader_params(struct darray *pass_params, bool changed_only) for (i = 0; i < pass_params->num; i++) { struct pass_shaderparam *param = params+i; - struct effect_param *eparam = param->eparam; - sparam_t sparam = param->sparam; + struct gs_effect_param *eparam = param->eparam; + gs_sparam_t sparam = param->sparam; if (changed_only && !eparam->changed) continue; @@ -103,7 +103,7 @@ static void upload_shader_params(struct darray *pass_params, bool changed_only) continue; } - shader_setval(sparam, eparam->cur_val.array, + gs_shader_set_val(sparam, eparam->cur_val.array, eparam->cur_val.num); } } @@ -125,16 +125,16 @@ static inline void upload_parameters(struct gs_effect *effect, reset_params(pshader_params); } -void effect_updateparams(effect_t effect) +void gs_effect_update_params(gs_effect_t effect) { if (effect) upload_parameters(effect, true); } -bool technique_beginpass(technique_t tech, size_t idx) +bool gs_technique_begin_pass(gs_technique_t tech, size_t idx) { - struct effect_pass *passes; - struct effect_pass *cur_pass; + struct gs_effect_pass *passes; + struct gs_effect_pass *cur_pass; if (!tech || idx >= tech->passes.num) return false; @@ -150,16 +150,16 @@ bool technique_beginpass(technique_t tech, size_t idx) return true; } -bool technique_beginpassbyname(technique_t tech, +bool gs_technique_begin_pass_by_name(gs_technique_t tech, const char *name) { if (!tech) return false; for (size_t i = 0; i < tech->passes.num; i++) { - struct effect_pass *pass = tech->passes.array+i; + struct gs_effect_pass *pass = tech->passes.array+i; if (strcmp(pass->name, name) == 0) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); return true; } } @@ -173,19 +173,19 @@ static inline void clear_tex_params(struct darray *in_params) for (size_t i = 0; i < in_params->num; i++) { struct pass_shaderparam *param = params+i; - struct shader_param_info info; + struct gs_shader_param_info info; - shader_getparaminfo(param->sparam, &info); - if (info.type == SHADER_PARAM_TEXTURE) - shader_settexture(param->sparam, NULL); + gs_shader_get_param_info(param->sparam, &info); + if (info.type == GS_SHADER_PARAM_TEXTURE) + gs_shader_set_texture(param->sparam, NULL); } } -void technique_endpass(technique_t tech) +void gs_technique_end_pass(gs_technique_t tech) { if (!tech) return; - struct effect_pass *pass = tech->effect->cur_pass; + struct gs_effect_pass *pass = tech->effect->cur_pass; if (!pass) return; @@ -194,30 +194,30 @@ void technique_endpass(technique_t tech) tech->effect->cur_pass = NULL; } -size_t effect_numparams(effect_t effect) +size_t gs_effect_get_num_params(gs_effect_t effect) { return effect ? effect->params.num : 0; } -eparam_t effect_getparambyidx(effect_t effect, size_t param) +gs_eparam_t gs_effect_get_param_by_idx(gs_effect_t effect, size_t param) { if (!effect) return NULL; - struct effect_param *params = effect->params.array; + struct gs_effect_param *params = effect->params.array; if (param >= effect->params.num) return NULL; return params+param; } -eparam_t effect_getparambyname(effect_t effect, const char *name) +gs_eparam_t gs_effect_get_param_by_name(gs_effect_t effect, const char *name) { if (!effect) return NULL; - struct effect_param *params = effect->params.array; + struct gs_effect_param *params = effect->params.array; for (size_t i = 0; i < effect->params.num; i++) { - struct effect_param *param = params+i; + struct gs_effect_param *param = params+i; if (strcmp(param->name, name) == 0) return param; @@ -226,17 +226,18 @@ eparam_t effect_getparambyname(effect_t effect, const char *name) return NULL; } -eparam_t effect_getviewprojmatrix(effect_t effect) +gs_eparam_t gs_effect_get_viewproj_matrix(gs_effect_t effect) { return effect ? effect->view_proj : NULL; } -eparam_t effect_getworldmatrix(effect_t effect) +gs_eparam_t gs_effect_get_world_matrix(gs_effect_t effect) { return effect ? effect->world : NULL; } -void effect_getparaminfo(eparam_t param, struct effect_param_info *info) +void gs_effect_get_param_info(gs_eparam_t param, + struct gs_effect_param_info *info) { if (!param) return; @@ -245,7 +246,7 @@ void effect_getparaminfo(eparam_t param, struct effect_param_info *info) info->type = param->type; } -static inline void effect_setval_inline(eparam_t param, +static inline void effect_setval_inline(gs_eparam_t param, const void *data, size_t size) { bool size_changed; @@ -271,52 +272,52 @@ static inline void effect_setval_inline(eparam_t param, } } -void effect_setbool(eparam_t param, bool val) +void gs_effect_set_bool(gs_eparam_t param, bool val) { effect_setval_inline(param, &val, sizeof(bool)); } -void effect_setfloat(eparam_t param, float val) +void gs_effect_set_float(gs_eparam_t param, float val) { effect_setval_inline(param, &val, sizeof(float)); } -void effect_setint(eparam_t param, int val) +void gs_effect_set_int(gs_eparam_t param, int val) { effect_setval_inline(param, &val, sizeof(int)); } -void effect_setmatrix4(eparam_t param, const struct matrix4 *val) +void gs_effect_set_matrix4(gs_eparam_t param, const struct matrix4 *val) { effect_setval_inline(param, val, sizeof(struct matrix4)); } -void effect_setvec2(eparam_t param, const struct vec2 *val) +void gs_effect_set_vec2(gs_eparam_t param, const struct vec2 *val) { effect_setval_inline(param, val, sizeof(struct vec2)); } -void effect_setvec3(eparam_t param, const struct vec3 *val) +void gs_effect_set_vec3(gs_eparam_t param, const struct vec3 *val) { effect_setval_inline(param, val, sizeof(float) * 3); } -void effect_setvec4(eparam_t param, const struct vec4 *val) +void gs_effect_set_vec4(gs_eparam_t param, const struct vec4 *val) { effect_setval_inline(param, val, sizeof(struct vec4)); } -void effect_settexture(eparam_t param, texture_t val) +void gs_effect_set_texture(gs_eparam_t param, gs_texture_t val) { - effect_setval_inline(param, &val, sizeof(texture_t)); + effect_setval_inline(param, &val, sizeof(gs_texture_t)); } -void effect_setval(eparam_t param, const void *val, size_t size) +void gs_effect_set_val(gs_eparam_t param, const void *val, size_t size) { effect_setval_inline(param, val, size); } -void effect_setdefault(eparam_t param) +void gs_effect_set_default(gs_eparam_t param) { effect_setval_inline(param, param->default_val.array, param->default_val.num); diff --git a/libobs/graphics/effect.h b/libobs/graphics/effect.h index 1cb25a5ff..846ed7c82 100644 --- a/libobs/graphics/effect.h +++ b/libobs/graphics/effect.h @@ -46,28 +46,28 @@ enum effect_section { /* ------------------------------------------------------------------------- */ -struct effect_param { +struct gs_effect_param { char *name; enum effect_section section; - enum shader_param_type type; + enum gs_shader_param_type type; bool changed; DARRAY(uint8_t) cur_val; DARRAY(uint8_t) default_val; - effect_t effect; + gs_effect_t effect; /*char *full_name; float scroller_min, scroller_max, scroller_inc, scroller_mul;*/ }; -static inline void effect_param_init(struct effect_param *param) +static inline void effect_param_init(struct gs_effect_param *param) { - memset(param, 0, sizeof(struct effect_param)); + memset(param, 0, sizeof(struct gs_effect_param)); } -static inline void effect_param_free(struct effect_param *param) +static inline void effect_param_free(struct gs_effect_param *param) { bfree(param->name); //bfree(param->full_name); @@ -75,56 +75,56 @@ static inline void effect_param_free(struct effect_param *param) da_free(param->default_val); } -EXPORT void effect_param_parse_property(eparam_t param, +EXPORT void effect_param_parse_property(gs_eparam_t param, const char *property); /* ------------------------------------------------------------------------- */ struct pass_shaderparam { - struct effect_param *eparam; - sparam_t sparam; + struct gs_effect_param *eparam; + gs_sparam_t sparam; }; -struct effect_pass { +struct gs_effect_pass { char *name; enum effect_section section; - shader_t vertshader; - shader_t pixelshader; + gs_shader_t vertshader; + gs_shader_t pixelshader; DARRAY(struct pass_shaderparam) vertshader_params; DARRAY(struct pass_shaderparam) pixelshader_params; }; -static inline void effect_pass_init(struct effect_pass *pass) +static inline void effect_pass_init(struct gs_effect_pass *pass) { - memset(pass, 0, sizeof(struct effect_pass)); + memset(pass, 0, sizeof(struct gs_effect_pass)); } -static inline void effect_pass_free(struct effect_pass *pass) +static inline void effect_pass_free(struct gs_effect_pass *pass) { bfree(pass->name); da_free(pass->vertshader_params); da_free(pass->pixelshader_params); - shader_destroy(pass->vertshader); - shader_destroy(pass->pixelshader); + gs_shader_destroy(pass->vertshader); + gs_shader_destroy(pass->pixelshader); } /* ------------------------------------------------------------------------- */ -struct effect_technique { +struct gs_effect_technique { char *name; enum effect_section section; struct gs_effect *effect; - DARRAY(struct effect_pass) passes; + DARRAY(struct gs_effect_pass) passes; }; -static inline void effect_technique_init(struct effect_technique *t) +static inline void effect_technique_init(struct gs_effect_technique *t) { - memset(t, 0, sizeof(struct effect_technique)); + memset(t, 0, sizeof(struct gs_effect_technique)); } -static inline void effect_technique_free(struct effect_technique *t) +static inline void effect_technique_free(struct gs_effect_technique *t) { size_t i; for (i = 0; i < t->passes.num; i++) @@ -139,22 +139,22 @@ struct gs_effect { bool processing; char *effect_path, *effect_dir; - DARRAY(struct effect_param) params; - DARRAY(struct effect_technique) techniques; + DARRAY(struct gs_effect_param) params; + DARRAY(struct gs_effect_technique) techniques; - struct effect_technique *cur_technique; - struct effect_pass *cur_pass; + struct gs_effect_technique *cur_technique; + struct gs_effect_pass *cur_pass; - eparam_t view_proj, world, scale; + gs_eparam_t view_proj, world, scale; graphics_t graphics; }; -static inline void effect_init(effect_t effect) +static inline void effect_init(gs_effect_t effect) { memset(effect, 0, sizeof(struct gs_effect)); } -static inline void effect_free(effect_t effect) +static inline void effect_free(gs_effect_t effect) { size_t i; for (i = 0; i < effect->params.num; i++) @@ -171,8 +171,8 @@ static inline void effect_free(effect_t effect) effect->effect_dir = NULL; } -EXPORT void effect_upload_params(effect_t effect, bool changed_only); -EXPORT void effect_upload_shader_params(effect_t effect, shader_t shader, +EXPORT void effect_upload_params(gs_effect_t effect, bool changed_only); +EXPORT void effect_upload_shader_params(gs_effect_t effect, gs_shader_t shader, struct darray *pass_params, bool changed_only); #ifdef __cplusplus diff --git a/libobs/graphics/graphics-ffmpeg.c b/libobs/graphics/graphics-ffmpeg.c index 53b51ef69..dfef664ff 100644 --- a/libobs/graphics/graphics-ffmpeg.c +++ b/libobs/graphics/graphics-ffmpeg.c @@ -201,15 +201,15 @@ static inline enum gs_color_format convert_format(enum AVPixelFormat format) return GS_BGRX; } -texture_t gs_create_texture_from_file(const char *file) +gs_texture_t gs_texture_create_from_file(const char *file) { struct ffmpeg_image image; - texture_t tex = NULL; + gs_texture_t tex = NULL; if (ffmpeg_image_init(&image, file)) { uint8_t *data = malloc(image.cx * image.cy * 4); if (ffmpeg_image_decode(&image, data, image.cx * 4)) { - tex = gs_create_texture(image.cx, image.cy, + tex = gs_texture_create(image.cx, image.cy, convert_format(image.format), 1, (const uint8_t**)&data, 0); } diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c index 281a62a20..40b75bcac 100644 --- a/libobs/graphics/graphics-imports.c +++ b/libobs/graphics/graphics-imports.c @@ -40,143 +40,143 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, { bool success = true; - GRAPHICS_IMPORT(device_name); - GRAPHICS_IMPORT(device_type); + GRAPHICS_IMPORT(device_get_name); + GRAPHICS_IMPORT(device_get_type); GRAPHICS_IMPORT(device_preprocessor_name); GRAPHICS_IMPORT(device_create); GRAPHICS_IMPORT(device_destroy); - GRAPHICS_IMPORT(device_entercontext); - GRAPHICS_IMPORT(device_leavecontext); - GRAPHICS_IMPORT(device_create_swapchain); + GRAPHICS_IMPORT(device_enter_context); + GRAPHICS_IMPORT(device_leave_context); + GRAPHICS_IMPORT(device_swapchain_create); GRAPHICS_IMPORT(device_resize); - GRAPHICS_IMPORT(device_getsize); - GRAPHICS_IMPORT(device_getwidth); - GRAPHICS_IMPORT(device_getheight); - GRAPHICS_IMPORT(device_create_texture); - GRAPHICS_IMPORT(device_create_cubetexture); - GRAPHICS_IMPORT(device_create_volumetexture); - GRAPHICS_IMPORT(device_create_zstencil); - GRAPHICS_IMPORT(device_create_stagesurface); - GRAPHICS_IMPORT(device_create_samplerstate); - GRAPHICS_IMPORT(device_create_vertexshader); - GRAPHICS_IMPORT(device_create_pixelshader); - GRAPHICS_IMPORT(device_create_vertexbuffer); - GRAPHICS_IMPORT(device_create_indexbuffer); - GRAPHICS_IMPORT(device_gettexturetype); + GRAPHICS_IMPORT(device_get_size); + GRAPHICS_IMPORT(device_get_width); + GRAPHICS_IMPORT(device_get_height); + GRAPHICS_IMPORT(device_texture_create); + GRAPHICS_IMPORT(device_cubetexture_create); + GRAPHICS_IMPORT(device_voltexture_create); + GRAPHICS_IMPORT(device_zstencil_create); + GRAPHICS_IMPORT(device_stagesurface_create); + GRAPHICS_IMPORT(device_samplerstate_create); + GRAPHICS_IMPORT(device_vertexshader_create); + GRAPHICS_IMPORT(device_pixelshader_create); + GRAPHICS_IMPORT(device_vertexbuffer_create); + GRAPHICS_IMPORT(device_indexbuffer_create); + GRAPHICS_IMPORT(device_get_texture_type); GRAPHICS_IMPORT(device_load_vertexbuffer); GRAPHICS_IMPORT(device_load_indexbuffer); GRAPHICS_IMPORT(device_load_texture); GRAPHICS_IMPORT(device_load_samplerstate); GRAPHICS_IMPORT(device_load_vertexshader); GRAPHICS_IMPORT(device_load_pixelshader); - GRAPHICS_IMPORT(device_load_defaultsamplerstate); - GRAPHICS_IMPORT(device_getvertexshader); - GRAPHICS_IMPORT(device_getpixelshader); - GRAPHICS_IMPORT(device_getrendertarget); - GRAPHICS_IMPORT(device_getzstenciltarget); - GRAPHICS_IMPORT(device_setrendertarget); - GRAPHICS_IMPORT(device_setcuberendertarget); + GRAPHICS_IMPORT(device_load_default_samplerstate); + GRAPHICS_IMPORT(device_get_vertex_shader); + GRAPHICS_IMPORT(device_get_pixel_shader); + GRAPHICS_IMPORT(device_get_render_target); + GRAPHICS_IMPORT(device_get_zstencil_target); + GRAPHICS_IMPORT(device_set_render_target); + GRAPHICS_IMPORT(device_set_cube_render_target); GRAPHICS_IMPORT(device_copy_texture_region); GRAPHICS_IMPORT(device_copy_texture); GRAPHICS_IMPORT(device_stage_texture); - GRAPHICS_IMPORT(device_beginscene); + GRAPHICS_IMPORT(device_begin_scene); GRAPHICS_IMPORT(device_draw); GRAPHICS_IMPORT(device_load_swapchain); - GRAPHICS_IMPORT(device_endscene); + GRAPHICS_IMPORT(device_end_scene); GRAPHICS_IMPORT(device_clear); GRAPHICS_IMPORT(device_present); GRAPHICS_IMPORT(device_flush); - GRAPHICS_IMPORT(device_setcullmode); - GRAPHICS_IMPORT(device_getcullmode); + GRAPHICS_IMPORT(device_set_cull_mode); + GRAPHICS_IMPORT(device_get_cull_mode); GRAPHICS_IMPORT(device_enable_blending); - GRAPHICS_IMPORT(device_enable_depthtest); - GRAPHICS_IMPORT(device_enable_stenciltest); - GRAPHICS_IMPORT(device_enable_stencilwrite); + GRAPHICS_IMPORT(device_enable_depth_test); + GRAPHICS_IMPORT(device_enable_stencil_test); + GRAPHICS_IMPORT(device_enable_stencil_write); GRAPHICS_IMPORT(device_enable_color); - GRAPHICS_IMPORT(device_blendfunction); - GRAPHICS_IMPORT(device_depthfunction); - GRAPHICS_IMPORT(device_stencilfunction); - GRAPHICS_IMPORT(device_stencilop); - GRAPHICS_IMPORT(device_setviewport); - GRAPHICS_IMPORT(device_getviewport); - GRAPHICS_IMPORT(device_setscissorrect); + GRAPHICS_IMPORT(device_blend_function); + GRAPHICS_IMPORT(device_depth_function); + GRAPHICS_IMPORT(device_stencil_function); + GRAPHICS_IMPORT(device_stencil_op); + GRAPHICS_IMPORT(device_set_viewport); + GRAPHICS_IMPORT(device_get_viewport); + GRAPHICS_IMPORT(device_set_scissor_rect); GRAPHICS_IMPORT(device_ortho); GRAPHICS_IMPORT(device_frustum); GRAPHICS_IMPORT(device_projection_push); GRAPHICS_IMPORT(device_projection_pop); - GRAPHICS_IMPORT(swapchain_destroy); + GRAPHICS_IMPORT(gs_swapchain_destroy); - GRAPHICS_IMPORT(texture_destroy); - GRAPHICS_IMPORT(texture_getwidth); - GRAPHICS_IMPORT(texture_getheight); - GRAPHICS_IMPORT(texture_getcolorformat); - GRAPHICS_IMPORT(texture_map); - GRAPHICS_IMPORT(texture_unmap); - GRAPHICS_IMPORT_OPTIONAL(texture_isrect); - GRAPHICS_IMPORT(texture_getobj); + GRAPHICS_IMPORT(gs_texture_destroy); + GRAPHICS_IMPORT(gs_texture_get_width); + GRAPHICS_IMPORT(gs_texture_get_height); + GRAPHICS_IMPORT(gs_texture_get_color_format); + GRAPHICS_IMPORT(gs_texture_map); + GRAPHICS_IMPORT(gs_texture_unmap); + GRAPHICS_IMPORT_OPTIONAL(gs_texture_is_rect); + GRAPHICS_IMPORT(gs_texture_get_obj); - GRAPHICS_IMPORT(cubetexture_destroy); - GRAPHICS_IMPORT(cubetexture_getsize); - GRAPHICS_IMPORT(cubetexture_getcolorformat); + GRAPHICS_IMPORT(gs_cubetexture_destroy); + GRAPHICS_IMPORT(gs_cubetexture_get_size); + GRAPHICS_IMPORT(gs_cubetexture_get_color_format); - GRAPHICS_IMPORT(volumetexture_destroy); - GRAPHICS_IMPORT(volumetexture_getwidth); - GRAPHICS_IMPORT(volumetexture_getheight); - GRAPHICS_IMPORT(volumetexture_getdepth); - GRAPHICS_IMPORT(volumetexture_getcolorformat); + GRAPHICS_IMPORT(gs_voltexture_destroy); + GRAPHICS_IMPORT(gs_voltexture_get_width); + GRAPHICS_IMPORT(gs_voltexture_get_height); + GRAPHICS_IMPORT(gs_voltexture_getdepth); + GRAPHICS_IMPORT(gs_voltexture_get_color_format); - GRAPHICS_IMPORT(stagesurface_destroy); - GRAPHICS_IMPORT(stagesurface_getwidth); - GRAPHICS_IMPORT(stagesurface_getheight); - GRAPHICS_IMPORT(stagesurface_getcolorformat); - GRAPHICS_IMPORT(stagesurface_map); - GRAPHICS_IMPORT(stagesurface_unmap); + GRAPHICS_IMPORT(gs_stagesurface_destroy); + GRAPHICS_IMPORT(gs_stagesurface_get_width); + GRAPHICS_IMPORT(gs_stagesurface_get_height); + GRAPHICS_IMPORT(gs_stagesurface_get_color_format); + GRAPHICS_IMPORT(gs_stagesurface_map); + GRAPHICS_IMPORT(gs_stagesurface_unmap); - GRAPHICS_IMPORT(zstencil_destroy); + GRAPHICS_IMPORT(gs_zstencil_destroy); - GRAPHICS_IMPORT(samplerstate_destroy); + GRAPHICS_IMPORT(gs_samplerstate_destroy); - GRAPHICS_IMPORT(vertexbuffer_destroy); - GRAPHICS_IMPORT(vertexbuffer_flush); - GRAPHICS_IMPORT(vertexbuffer_getdata); + GRAPHICS_IMPORT(gs_vertexbuffer_destroy); + GRAPHICS_IMPORT(gs_vertexbuffer_flush); + GRAPHICS_IMPORT(gs_vertexbuffer_get_data); - GRAPHICS_IMPORT(indexbuffer_destroy); - GRAPHICS_IMPORT(indexbuffer_flush); - GRAPHICS_IMPORT(indexbuffer_getdata); - GRAPHICS_IMPORT(indexbuffer_numindices); - GRAPHICS_IMPORT(indexbuffer_gettype); + GRAPHICS_IMPORT(gs_indexbuffer_destroy); + GRAPHICS_IMPORT(gs_indexbuffer_flush); + GRAPHICS_IMPORT(gs_indexbuffer_get_data); + GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices); + GRAPHICS_IMPORT(gs_indexbuffer_get_type); - GRAPHICS_IMPORT(shader_destroy); - GRAPHICS_IMPORT(shader_numparams); - GRAPHICS_IMPORT(shader_getparambyidx); - GRAPHICS_IMPORT(shader_getparambyname); - GRAPHICS_IMPORT(shader_getviewprojmatrix); - GRAPHICS_IMPORT(shader_getworldmatrix); - GRAPHICS_IMPORT(shader_getparaminfo); - GRAPHICS_IMPORT(shader_setbool); - GRAPHICS_IMPORT(shader_setfloat); - GRAPHICS_IMPORT(shader_setint); - GRAPHICS_IMPORT(shader_setmatrix3); - GRAPHICS_IMPORT(shader_setmatrix4); - GRAPHICS_IMPORT(shader_setvec2); - GRAPHICS_IMPORT(shader_setvec3); - GRAPHICS_IMPORT(shader_setvec4); - GRAPHICS_IMPORT(shader_settexture); - GRAPHICS_IMPORT(shader_setval); - GRAPHICS_IMPORT(shader_setdefault); + GRAPHICS_IMPORT(gs_shader_destroy); + GRAPHICS_IMPORT(gs_shader_get_num_params); + GRAPHICS_IMPORT(gs_shader_get_param_by_idx); + GRAPHICS_IMPORT(gs_shader_get_param_by_name); + GRAPHICS_IMPORT(gs_shader_get_viewproj_matrix); + GRAPHICS_IMPORT(gs_shader_get_world_matrix); + GRAPHICS_IMPORT(gs_shader_get_param_info); + GRAPHICS_IMPORT(gs_shader_set_bool); + GRAPHICS_IMPORT(gs_shader_set_float); + GRAPHICS_IMPORT(gs_shader_set_int); + GRAPHICS_IMPORT(gs_shader_setmatrix3); + GRAPHICS_IMPORT(gs_shader_set_matrix4); + GRAPHICS_IMPORT(gs_shader_set_vec2); + GRAPHICS_IMPORT(gs_shader_set_vec3); + GRAPHICS_IMPORT(gs_shader_set_vec4); + GRAPHICS_IMPORT(gs_shader_set_texture); + GRAPHICS_IMPORT(gs_shader_set_val); + GRAPHICS_IMPORT(gs_shader_set_default); /* OSX/Cocoa specific functions */ #ifdef __APPLE__ - GRAPHICS_IMPORT_OPTIONAL(texture_create_from_iosurface); - GRAPHICS_IMPORT_OPTIONAL(texture_rebind_iosurface); + GRAPHICS_IMPORT_OPTIONAL(device_texture_create_from_iosurface); + GRAPHICS_IMPORT_OPTIONAL(gs_texture_rebind_iosurface); /* win32 specific functions */ #elif _WIN32 - GRAPHICS_IMPORT(gdi_texture_available); - GRAPHICS_IMPORT_OPTIONAL(device_create_gdi_texture); - GRAPHICS_IMPORT_OPTIONAL(texture_get_dc); - GRAPHICS_IMPORT_OPTIONAL(texture_release_dc); + GRAPHICS_IMPORT(device_gdi_texture_available); + GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi); + GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc); + GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc); #endif return success; diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 457882c8b..b74d0e27f 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -24,189 +24,208 @@ #include "matrix4.h" struct gs_exports { - const char *(*device_name)(void); - int (*device_type)(void); + const char *(*device_get_name)(void); + int (*device_get_type)(void); const char *(*device_preprocessor_name)(void); - int (*device_create)(device_t *device, struct gs_init_data *data); - void (*device_destroy)(device_t device); - void (*device_entercontext)(device_t device); - void (*device_leavecontext)(device_t device); - swapchain_t (*device_create_swapchain)(device_t device, + int (*device_create)(gs_device_t *device, struct gs_init_data *data); + void (*device_destroy)(gs_device_t device); + void (*device_enter_context)(gs_device_t device); + void (*device_leave_context)(gs_device_t device); + gs_swapchain_t (*device_swapchain_create)(gs_device_t device, struct gs_init_data *data); - void (*device_resize)(device_t device, uint32_t x, uint32_t y); - void (*device_getsize)(device_t device, uint32_t *x, uint32_t *y); - uint32_t (*device_getwidth)(device_t device); - uint32_t (*device_getheight)(device_t device); - texture_t (*device_create_texture)(device_t device, uint32_t width, - uint32_t height, enum gs_color_format color_format, - uint32_t levels, const uint8_t **data, uint32_t flags); - texture_t (*device_create_cubetexture)(device_t device, uint32_t size, + void (*device_resize)(gs_device_t device, uint32_t x, uint32_t y); + void (*device_get_size)(gs_device_t device, uint32_t *x, uint32_t *y); + uint32_t (*device_get_width)(gs_device_t device); + uint32_t (*device_get_height)(gs_device_t device); + gs_texture_t (*device_texture_create)(gs_device_t device, + uint32_t width, uint32_t height, enum gs_color_format color_format, uint32_t levels, const uint8_t **data, uint32_t flags); - texture_t (*device_create_volumetexture)(device_t device, + gs_texture_t (*device_cubetexture_create)(gs_device_t device, + uint32_t size, enum gs_color_format color_format, + uint32_t levels, const uint8_t **data, uint32_t flags); + gs_texture_t (*device_voltexture_create)(gs_device_t device, 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); - zstencil_t (*device_create_zstencil)(device_t device, + gs_zstencil_t (*device_zstencil_create)(gs_device_t device, uint32_t width, uint32_t height, enum gs_zstencil_format format); - stagesurf_t (*device_create_stagesurface)(device_t device, + gs_stagesurf_t (*device_stagesurface_create)(gs_device_t device, uint32_t width, uint32_t height, enum gs_color_format color_format); - samplerstate_t (*device_create_samplerstate)(device_t device, + gs_samplerstate_t (*device_samplerstate_create)(gs_device_t device, struct gs_sampler_info *info); - shader_t (*device_create_vertexshader)(device_t device, + gs_shader_t (*device_vertexshader_create)(gs_device_t device, const char *shader, const char *file, char **error_string); - shader_t (*device_create_pixelshader)(device_t device, + gs_shader_t (*device_pixelshader_create)(gs_device_t device, const char *shader, const char *file, char **error_string); - vertbuffer_t (*device_create_vertexbuffer)(device_t device, - struct vb_data *data, uint32_t flags); - indexbuffer_t (*device_create_indexbuffer)(device_t device, + gs_vertbuffer_t (*device_vertexbuffer_create)(gs_device_t device, + struct gs_vb_data *data, uint32_t flags); + gs_indexbuffer_t (*device_indexbuffer_create)(gs_device_t device, enum gs_index_type type, void *indices, size_t num, uint32_t flags); - enum gs_texture_type (*device_gettexturetype)(texture_t texture); - void (*device_load_vertexbuffer)(device_t device, - vertbuffer_t vertbuffer); - void (*device_load_indexbuffer)(device_t device, - indexbuffer_t indexbuffer); - void (*device_load_texture)(device_t device, texture_t tex, int unit); - void (*device_load_samplerstate)(device_t device, - samplerstate_t samplerstate, int unit); - void (*device_load_vertexshader)(device_t device, shader_t vertshader); - void (*device_load_pixelshader)(device_t device, shader_t pixelshader); - void (*device_load_defaultsamplerstate)(device_t device, bool b_3d, + enum gs_texture_type (*device_get_texture_type)(gs_texture_t texture); + void (*device_load_vertexbuffer)(gs_device_t device, + gs_vertbuffer_t vertbuffer); + void (*device_load_indexbuffer)(gs_device_t device, + gs_indexbuffer_t indexbuffer); + void (*device_load_texture)(gs_device_t device, gs_texture_t tex, int unit); - shader_t (*device_getvertexshader)(device_t device); - shader_t (*device_getpixelshader)(device_t device); - texture_t (*device_getrendertarget)(device_t device); - zstencil_t (*device_getzstenciltarget)(device_t device); - void (*device_setrendertarget)(device_t device, texture_t tex, - zstencil_t zstencil); - void (*device_setcuberendertarget)(device_t device, texture_t cubetex, - int side, zstencil_t zstencil); - void (*device_copy_texture)(device_t device, texture_t dst, - texture_t src); - void (*device_copy_texture_region)(device_t device, - texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, + void (*device_load_samplerstate)(gs_device_t device, + gs_samplerstate_t samplerstate, int unit); + void (*device_load_vertexshader)(gs_device_t device, + gs_shader_t vertshader); + void (*device_load_pixelshader)(gs_device_t device, + gs_shader_t pixelshader); + void (*device_load_default_samplerstate)(gs_device_t device, + bool b_3d, int unit); + gs_shader_t (*device_get_vertex_shader)(gs_device_t device); + gs_shader_t (*device_get_pixel_shader)(gs_device_t device); + gs_texture_t (*device_get_render_target)(gs_device_t device); + gs_zstencil_t (*device_get_zstencil_target)(gs_device_t device); + void (*device_set_render_target)(gs_device_t device, gs_texture_t tex, + gs_zstencil_t zstencil); + void (*device_set_cube_render_target)(gs_device_t device, + gs_texture_t cubetex, int side, gs_zstencil_t zstencil); + void (*device_copy_texture)(gs_device_t device, gs_texture_t dst, + gs_texture_t src); + void (*device_copy_texture_region)(gs_device_t device, + 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); - void (*device_stage_texture)(device_t device, stagesurf_t dst, - texture_t src); - void (*device_beginscene)(device_t device); - void (*device_draw)(device_t device, enum gs_draw_mode draw_mode, + void (*device_stage_texture)(gs_device_t device, gs_stagesurf_t dst, + gs_texture_t src); + void (*device_begin_scene)(gs_device_t device); + void (*device_draw)(gs_device_t device, enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts); - void (*device_endscene)(device_t device); - void (*device_load_swapchain)(device_t device, swapchain_t swaphchain); - void (*device_clear)(device_t device, uint32_t clear_flags, + void (*device_end_scene)(gs_device_t device); + void (*device_load_swapchain)(gs_device_t device, + gs_swapchain_t swaphchain); + void (*device_clear)(gs_device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); - void (*device_present)(device_t device); - void (*device_flush)(device_t device); - void (*device_setcullmode)(device_t device, enum gs_cull_mode mode); - enum gs_cull_mode (*device_getcullmode)(device_t device); - void (*device_enable_blending)(device_t device, bool enable); - void (*device_enable_depthtest)(device_t device, bool enable); - void (*device_enable_stenciltest)(device_t device, bool enable); - void (*device_enable_stencilwrite)(device_t device, bool enable); - void (*device_enable_color)(device_t device, bool red, bool green, + void (*device_present)(gs_device_t device); + void (*device_flush)(gs_device_t device); + void (*device_set_cull_mode)(gs_device_t device, + enum gs_cull_mode mode); + enum gs_cull_mode (*device_get_cull_mode)(gs_device_t device); + void (*device_enable_blending)(gs_device_t device, bool enable); + void (*device_enable_depth_test)(gs_device_t device, bool enable); + void (*device_enable_stencil_test)(gs_device_t device, bool enable); + void (*device_enable_stencil_write)(gs_device_t device, bool enable); + void (*device_enable_color)(gs_device_t device, bool red, bool green, bool blue, bool alpha); - void (*device_blendfunction)(device_t device, enum gs_blend_type src, - enum gs_blend_type dest); - void (*device_depthfunction)(device_t device, enum gs_depth_test test); - void (*device_stencilfunction)(device_t device, + void (*device_blend_function)(gs_device_t device, + enum gs_blend_type src, enum gs_blend_type dest); + void (*device_depth_function)(gs_device_t device, + enum gs_depth_test test); + void (*device_stencil_function)(gs_device_t device, enum gs_stencil_side side, enum gs_depth_test test); - void (*device_stencilop)(device_t device, enum gs_stencil_side side, - enum gs_stencil_op fail, enum gs_stencil_op zfail, - enum gs_stencil_op zpass); - void (*device_setviewport)(device_t device, int x, int y, int width, + void (*device_stencil_op)(gs_device_t device, enum gs_stencil_side side, + enum gs_stencil_op_type fail, + enum gs_stencil_op_type zfail, + enum gs_stencil_op_type zpass); + void (*device_set_viewport)(gs_device_t device, int x, int y, int width, int height); - void (*device_getviewport)(device_t device, struct gs_rect *rect); - void (*device_setscissorrect)(device_t device, struct gs_rect *rect); - void (*device_ortho)(device_t device, float left, float right, + void (*device_get_viewport)(gs_device_t device, struct gs_rect *rect); + void (*device_set_scissor_rect)(gs_device_t device, + struct gs_rect *rect); + void (*device_ortho)(gs_device_t device, float left, float right, float top, float bottom, float znear, float zfar); - void (*device_frustum)(device_t device, float left, float right, + void (*device_frustum)(gs_device_t device, float left, float right, float top, float bottom, float znear, float zfar); - void (*device_projection_push)(device_t device); - void (*device_projection_pop)(device_t device); + void (*device_projection_push)(gs_device_t device); + void (*device_projection_pop)(gs_device_t device); - void (*swapchain_destroy)(swapchain_t swapchain); + void (*gs_swapchain_destroy)(gs_swapchain_t swapchain); - void (*texture_destroy)(texture_t tex); - uint32_t (*texture_getwidth)(texture_t tex); - uint32_t (*texture_getheight)(texture_t tex); - enum gs_color_format (*texture_getcolorformat)(texture_t tex); - bool (*texture_map)(texture_t tex, uint8_t **ptr, + void (*gs_texture_destroy)(gs_texture_t tex); + uint32_t (*gs_texture_get_width)(gs_texture_t tex); + uint32_t (*gs_texture_get_height)(gs_texture_t tex); + enum gs_color_format (*gs_texture_get_color_format)(gs_texture_t tex); + bool (*gs_texture_map)(gs_texture_t tex, uint8_t **ptr, uint32_t *linesize); - void (*texture_unmap)(texture_t tex); - bool (*texture_isrect)(texture_t tex); - void *(*texture_getobj)(texture_t tex); + void (*gs_texture_unmap)(gs_texture_t tex); + bool (*gs_texture_is_rect)(gs_texture_t tex); + void *(*gs_texture_get_obj)(gs_texture_t tex); - void (*cubetexture_destroy)(texture_t cubetex); - uint32_t (*cubetexture_getsize)(texture_t cubetex); - enum gs_color_format (*cubetexture_getcolorformat)(texture_t cubetex); + void (*gs_cubetexture_destroy)(gs_texture_t cubetex); + uint32_t (*gs_cubetexture_get_size)(gs_texture_t cubetex); + enum gs_color_format (*gs_cubetexture_get_color_format)( + gs_texture_t cubetex); - void (*volumetexture_destroy)(texture_t voltex); - uint32_t (*volumetexture_getwidth)(texture_t voltex); - uint32_t (*volumetexture_getheight)(texture_t voltex); - uint32_t (*volumetexture_getdepth)(texture_t voltex); - enum gs_color_format (*volumetexture_getcolorformat)(texture_t voltex); + void (*gs_voltexture_destroy)(gs_texture_t voltex); + uint32_t (*gs_voltexture_get_width)(gs_texture_t voltex); + uint32_t (*gs_voltexture_get_height)(gs_texture_t voltex); + uint32_t (*gs_voltexture_getdepth)(gs_texture_t voltex); + enum gs_color_format (*gs_voltexture_get_color_format)( + gs_texture_t voltex); - void (*stagesurface_destroy)(stagesurf_t stagesurf); - uint32_t (*stagesurface_getwidth)(stagesurf_t stagesurf); - uint32_t (*stagesurface_getheight)(stagesurf_t stagesurf); - enum gs_color_format (*stagesurface_getcolorformat)( - stagesurf_t stagesurf); - bool (*stagesurface_map)(stagesurf_t stagesurf, + void (*gs_stagesurface_destroy)(gs_stagesurf_t stagesurf); + uint32_t (*gs_stagesurface_get_width)(gs_stagesurf_t stagesurf); + uint32_t (*gs_stagesurface_get_height)(gs_stagesurf_t stagesurf); + enum gs_color_format (*gs_stagesurface_get_color_format)( + gs_stagesurf_t stagesurf); + bool (*gs_stagesurface_map)(gs_stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize); - void (*stagesurface_unmap)(stagesurf_t stagesurf); + void (*gs_stagesurface_unmap)(gs_stagesurf_t stagesurf); - void (*zstencil_destroy)(zstencil_t zstencil); + void (*gs_zstencil_destroy)(gs_zstencil_t zstencil); - void (*samplerstate_destroy)(samplerstate_t samplerstate); + void (*gs_samplerstate_destroy)(gs_samplerstate_t samplerstate); - void (*vertexbuffer_destroy)(vertbuffer_t vertbuffer); - void (*vertexbuffer_flush)(vertbuffer_t vertbuffer); - struct vb_data *(*vertexbuffer_getdata)(vertbuffer_t vertbuffer); + void (*gs_vertexbuffer_destroy)(gs_vertbuffer_t vertbuffer); + void (*gs_vertexbuffer_flush)(gs_vertbuffer_t vertbuffer); + struct gs_vb_data *(*gs_vertexbuffer_get_data)( + gs_vertbuffer_t vertbuffer); - void (*indexbuffer_destroy)(indexbuffer_t indexbuffer); - void (*indexbuffer_flush)(indexbuffer_t indexbuffer); - void *(*indexbuffer_getdata)(indexbuffer_t indexbuffer); - size_t (*indexbuffer_numindices)(indexbuffer_t indexbuffer); - enum gs_index_type (*indexbuffer_gettype)(indexbuffer_t indexbuffer); + void (*gs_indexbuffer_destroy)(gs_indexbuffer_t indexbuffer); + void (*gs_indexbuffer_flush)(gs_indexbuffer_t indexbuffer); + void *(*gs_indexbuffer_get_data)(gs_indexbuffer_t indexbuffer); + size_t (*gs_indexbuffer_get_num_indices)(gs_indexbuffer_t indexbuffer); + enum gs_index_type (*gs_indexbuffer_get_type)( + gs_indexbuffer_t indexbuffer); - void (*shader_destroy)(shader_t shader); - int (*shader_numparams)(shader_t shader); - sparam_t (*shader_getparambyidx)(shader_t shader, uint32_t param); - sparam_t (*shader_getparambyname)(shader_t shader, const char *name); - sparam_t (*shader_getviewprojmatrix)(shader_t shader); - sparam_t (*shader_getworldmatrix)(shader_t shader); - void (*shader_getparaminfo)(sparam_t param, - struct shader_param_info *info); - void (*shader_setbool)(sparam_t param, bool val); - void (*shader_setfloat)(sparam_t param, float val); - void (*shader_setint)(sparam_t param, int val); - void (*shader_setmatrix3)(sparam_t param, const struct matrix3 *val); - void (*shader_setmatrix4)(sparam_t param, const struct matrix4 *val); - void (*shader_setvec2)(sparam_t param, const struct vec2 *val); - void (*shader_setvec3)(sparam_t param, const struct vec3 *val); - void (*shader_setvec4)(sparam_t param, const struct vec4 *val); - void (*shader_settexture)(sparam_t param, texture_t val); - void (*shader_setval)(sparam_t param, const void *val, size_t size); - void (*shader_setdefault)(sparam_t param); + void (*gs_shader_destroy)(gs_shader_t shader); + int (*gs_shader_get_num_params)(gs_shader_t shader); + gs_sparam_t (*gs_shader_get_param_by_idx)(gs_shader_t shader, + uint32_t param); + gs_sparam_t (*gs_shader_get_param_by_name)(gs_shader_t shader, + const char *name); + gs_sparam_t (*gs_shader_get_viewproj_matrix)(gs_shader_t shader); + gs_sparam_t (*gs_shader_get_world_matrix)(gs_shader_t shader); + void (*gs_shader_get_param_info)(gs_sparam_t param, + struct gs_shader_param_info *info); + void (*gs_shader_set_bool)(gs_sparam_t param, bool val); + void (*gs_shader_set_float)(gs_sparam_t param, float val); + void (*gs_shader_set_int)(gs_sparam_t param, int val); + void (*gs_shader_setmatrix3)(gs_sparam_t param, + const struct matrix3 *val); + void (*gs_shader_set_matrix4)(gs_sparam_t param, + const struct matrix4 *val); + void (*gs_shader_set_vec2)(gs_sparam_t param, const struct vec2 *val); + void (*gs_shader_set_vec3)(gs_sparam_t param, const struct vec3 *val); + void (*gs_shader_set_vec4)(gs_sparam_t param, const struct vec4 *val); + void (*gs_shader_set_texture)(gs_sparam_t param, gs_texture_t val); + void (*gs_shader_set_val)(gs_sparam_t param, const void *val, + size_t size); + void (*gs_shader_set_default)(gs_sparam_t param); #ifdef __APPLE__ /* OSX/Cocoa specific functions */ - texture_t (*texture_create_from_iosurface)(device_t dev, void *iosurf); - bool (*texture_rebind_iosurface)(texture_t texture, void *iosurf); + gs_texture_t (*device_texture_create_from_iosurface)(gs_device_t dev, + void *iosurf); + bool (*gs_texture_rebind_iosurface)(gs_texture_t texture, void *iosurf); #elif _WIN32 - bool (*gdi_texture_available)(void); - texture_t (*device_create_gdi_texture)(device_t device, + bool (*device_gdi_texture_available)(void); + gs_texture_t (*device_texture_create_gdi)(gs_device_t device, uint32_t width, uint32_t height); - void *(*texture_get_dc)(texture_t gdi_tex); - void (*texture_release_dc)(texture_t gdi_tex); + void *(*gs_texture_get_dc)(gs_texture_t gdi_tex); + void (*gs_texture_release_dc)(gs_texture_t gdi_tex); #endif }; @@ -218,7 +237,7 @@ struct blend_state { struct graphics_subsystem { void *module; - device_t device; + gs_device_t device; struct gs_exports exports; DARRAY(struct gs_rect) viewport_stack; @@ -229,11 +248,11 @@ struct graphics_subsystem { struct matrix4 projection; struct gs_effect *cur_effect; - vertbuffer_t sprite_buffer; + gs_vertbuffer_t sprite_buffer; bool using_immediate; - struct vb_data *vbd; - vertbuffer_t immediate_vertbuffer; + struct gs_vb_data *vbd; + gs_vertbuffer_t immediate_vertbuffer; DARRAY(struct vec3) verts; DARRAY(struct vec3) norms; DARRAY(uint32_t) colors; diff --git a/libobs/graphics/graphics-magick.c b/libobs/graphics/graphics-magick.c index 86b4db4d2..a0caf4dba 100644 --- a/libobs/graphics/graphics-magick.c +++ b/libobs/graphics/graphics-magick.c @@ -14,9 +14,9 @@ void gs_free_image_deps() MagickCoreTerminus(); } -texture_t gs_create_texture_from_file(const char *file) +gs_texture_t gs_texture_create_from_file(const char *file) { - texture_t tex = NULL; + gs_texture_t tex = NULL; ImageInfo *info; ExceptionInfo *exception; Image *image; @@ -37,7 +37,7 @@ texture_t gs_create_texture_from_file(const char *file) ExportImagePixels(image, 0, 0, cx, cy, "BGRA", CharPixel, data, exception); if (exception->severity == UndefinedException) - tex = gs_create_texture(cx, cy, GS_BGRA, 1, + tex = gs_texture_create(cx, cy, GS_BGRA, 1, (const uint8_t**)&data, 0); else blog(LOG_WARNING, "magickcore warning/error getting " diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index d55775910..831eaa7b5 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -44,21 +44,21 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, static bool graphics_init_immediate_vb(struct graphics_subsystem *graphics) { - struct vb_data *vbd; + struct gs_vb_data *vbd; - vbd = vbdata_create(); + vbd = gs_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 = bmalloc(sizeof(struct gs_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); + device_vertexbuffer_create(graphics->device, vbd, GS_DYNAMIC); if (!graphics->immediate_vertbuffer) return false; @@ -67,13 +67,13 @@ static bool graphics_init_immediate_vb(struct graphics_subsystem *graphics) static bool graphics_init_sprite_vb(struct graphics_subsystem *graphics) { - struct vb_data *vbd; + struct gs_vb_data *vbd; - vbd = vbdata_create(); + vbd = gs_vbdata_create(); vbd->num = 4; vbd->points = bmalloc(sizeof(struct vec3) * 4); vbd->num_tex = 1; - vbd->tvarray = bmalloc(sizeof(struct tvertarray)); + vbd->tvarray = bmalloc(sizeof(struct gs_tvertarray)); vbd->tvarray[0].width = 2; vbd->tvarray[0].array = bmalloc(sizeof(struct vec2) * 4); @@ -81,7 +81,7 @@ static bool graphics_init_sprite_vb(struct graphics_subsystem *graphics) memset(vbd->tvarray[0].array, 0, sizeof(struct vec2) * 4); graphics->sprite_buffer = graphics->exports. - device_create_vertexbuffer(graphics->device, vbd, GS_DYNAMIC); + device_vertexbuffer_create(graphics->device, vbd, GS_DYNAMIC); if (!graphics->sprite_buffer) return false; @@ -95,7 +95,7 @@ static bool graphics_init(struct graphics_subsystem *graphics) matrix4_identity(&top_mat); da_push_back(graphics->matrix_stack, &top_mat); - graphics->exports.device_entercontext(graphics->device); + graphics->exports.device_enter_context(graphics->device); if (!graphics_init_immediate_vb(graphics)) return false; @@ -104,13 +104,13 @@ static bool graphics_init(struct graphics_subsystem *graphics) if (pthread_mutex_init(&graphics->mutex, NULL) != 0) return false; - graphics->exports.device_blendfunction(graphics->device, + graphics->exports.device_blend_function(graphics->device, GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA); graphics->cur_blend_state.enabled = true; graphics->cur_blend_state.src = GS_BLEND_SRCALPHA; graphics->cur_blend_state.dest = GS_BLEND_INVSRCALPHA; - graphics->exports.device_leavecontext(graphics->device); + graphics->exports.device_leave_context(graphics->device); gs_init_image_deps(); return true; @@ -160,12 +160,13 @@ void gs_destroy(graphics_t graphics) return; while (thread_graphics) - gs_leavecontext(); + gs_leave_context(); if (graphics->device) { - graphics->exports.device_entercontext(graphics->device); - graphics->exports.vertexbuffer_destroy(graphics->sprite_buffer); - graphics->exports.vertexbuffer_destroy( + graphics->exports.device_enter_context(graphics->device); + graphics->exports.gs_vertexbuffer_destroy( + graphics->sprite_buffer); + graphics->exports.gs_vertexbuffer_destroy( graphics->immediate_vertbuffer); graphics->exports.device_destroy(graphics->device); } @@ -180,51 +181,54 @@ void gs_destroy(graphics_t graphics) gs_free_image_deps(); } -void gs_entercontext(graphics_t graphics) +void gs_enter_context(graphics_t graphics) { if (!graphics) return; bool is_current = thread_graphics == graphics; if (thread_graphics && !is_current) { while (thread_graphics) - gs_leavecontext(); + gs_leave_context(); } if (!is_current) { pthread_mutex_lock(&graphics->mutex); - graphics->exports.device_entercontext(graphics->device); + graphics->exports.device_enter_context(graphics->device); thread_graphics = graphics; } os_atomic_inc_long(&graphics->ref); } -void gs_leavecontext(void) +void gs_leave_context(void) { if (thread_graphics) { if (!os_atomic_dec_long(&thread_graphics->ref)) { graphics_t graphics = thread_graphics; - graphics->exports.device_leavecontext(graphics->device); + graphics->exports.device_leave_context( + graphics->device); pthread_mutex_unlock(&graphics->mutex); thread_graphics = NULL; } } } -graphics_t gs_getcontext(void) +graphics_t gs_get_context(void) { return thread_graphics; } -const char *gs_device_name(void) +const char *gs_get_device_name(void) { - return thread_graphics ? thread_graphics->exports.device_name() : NULL; + return thread_graphics ? + thread_graphics->exports.device_get_name() : NULL; } -int gs_device_type(void) +int gs_get_device_type(void) { - return thread_graphics ? thread_graphics->exports.device_type() : -1; + return thread_graphics ? + thread_graphics->exports.device_get_type() : -1; } static inline struct matrix4 *top_matrix(graphics_t graphics) @@ -366,7 +370,7 @@ static inline void reset_immediate_arrays(graphics_t graphics) da_init(graphics->texverts[i]); } -void gs_renderstart(bool b_new) +void gs_render_start(bool b_new) { graphics_t graphics = thread_graphics; if (!graphics) @@ -376,9 +380,9 @@ void gs_renderstart(bool b_new) reset_immediate_arrays(graphics); if (b_new) { - graphics->vbd = vbdata_create(); + graphics->vbd = gs_vbdata_create(); } else { - graphics->vbd = vertexbuffer_getdata( + graphics->vbd = gs_vertexbuffer_get_data( graphics->immediate_vertbuffer); memset(graphics->vbd->colors, 0xFF, sizeof(uint32_t) * IMMEDIATE_COUNT); @@ -400,7 +404,7 @@ 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) +void gs_render_stop(enum gs_draw_mode mode) { graphics_t graphics = thread_graphics; size_t i, num; @@ -416,7 +420,7 @@ void gs_renderstop(enum gs_draw_mode mode) da_free(graphics->colors); for (i = 0; i < 16; i++) da_free(graphics->texverts[i]); - vbdata_destroy(graphics->vbd); + gs_vbdata_destroy(graphics->vbd); } return; @@ -424,27 +428,27 @@ void gs_renderstop(enum gs_draw_mode mode) if (graphics->norms.num && (graphics->norms.num != graphics->verts.num)) { - blog(LOG_ERROR, "gs_renderstop: normal count does " + blog(LOG_ERROR, "gs_render_stop: 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_ERROR, "gs_renderstop: color count does " + blog(LOG_ERROR, "gs_render_stop: 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_ERROR, "gs_renderstop: texture vertex count does " + blog(LOG_ERROR, "gs_render_stop: 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); + gs_vertexbuffer_flush(graphics->immediate_vertbuffer); gs_load_vertexbuffer(graphics->immediate_vertbuffer); gs_load_indexbuffer(NULL); @@ -452,19 +456,19 @@ void gs_renderstop(enum gs_draw_mode mode) reset_immediate_arrays(graphics); } else { - vertbuffer_t vb = gs_rendersave(); + gs_vertbuffer_t vb = gs_render_save(); gs_load_vertexbuffer(vb); gs_load_indexbuffer(NULL); gs_draw(mode, 0, 0); - vertexbuffer_destroy(vb); + gs_vertexbuffer_destroy(vb); } graphics->vbd = NULL; } -vertbuffer_t gs_rendersave(void) +gs_vertbuffer_t gs_render_save(void) { graphics_t graphics = thread_graphics; size_t num_tex, i; @@ -476,7 +480,7 @@ vertbuffer_t gs_rendersave(void) return NULL; if (!graphics->verts.num) { - vbdata_destroy(graphics->vbd); + gs_vbdata_destroy(graphics->vbd); return NULL; } @@ -492,7 +496,7 @@ vertbuffer_t gs_rendersave(void) if (graphics->vbd->num_tex) { graphics->vbd->tvarray = - bmalloc(sizeof(struct tvertarray) * num_tex); + bmalloc(sizeof(struct gs_tvertarray) * num_tex); for (i = 0; i < num_tex; i++) { graphics->vbd->tvarray[i].width = 2; @@ -503,7 +507,7 @@ vertbuffer_t gs_rendersave(void) reset_immediate_arrays(graphics); - return gs_create_vertexbuffer(graphics->vbd, 0); + return gs_vertexbuffer_create(graphics->vbd, 0); } void gs_vertex2f(float x, float y) @@ -610,21 +614,21 @@ void gs_texcoord2v(const struct vec2 *v, int unit) da_push_back(graphics->texverts[unit], v); } -input_t gs_getinput(void) +input_t gs_get_input(void) { /* TODO */ return NULL; } -effect_t gs_geteffect(void) +gs_effect_t gs_get_effect(void) { return thread_graphics ? thread_graphics->cur_effect : NULL; } -effect_t gs_create_effect_from_file(const char *file, char **error_string) +gs_effect_t gs_effect_create_from_file(const char *file, char **error_string) { char *file_string; - effect_t effect = NULL; + gs_effect_t effect = NULL; if (!thread_graphics || !file) return NULL; @@ -635,13 +639,13 @@ effect_t gs_create_effect_from_file(const char *file, char **error_string) return NULL; } - effect = gs_create_effect(file_string, file, error_string); + effect = gs_effect_create(file_string, file, error_string); bfree(file_string); return effect; } -effect_t gs_create_effect(const char *effect_string, const char *filename, +gs_effect_t gs_effect_create(const char *effect_string, const char *filename, char **error_string) { if (!thread_graphics || !effect_string) @@ -659,7 +663,7 @@ effect_t gs_create_effect(const char *effect_string, const char *filename, if (error_string) *error_string = error_data_buildstring( &parser.cfp.error_list); - effect_destroy(effect); + gs_effect_destroy(effect); effect = NULL; } @@ -667,13 +671,14 @@ effect_t gs_create_effect(const char *effect_string, const char *filename, return effect; } -shader_t gs_create_vertexshader_from_file(const char *file, char **error_string) +gs_shader_t gs_vertexshader_create_from_file(const char *file, + char **error_string) { if (!thread_graphics || !file) return NULL; char *file_string; - shader_t shader = NULL; + gs_shader_t shader = NULL; file_string = os_quick_read_utf8_file(file); if (!file_string) { @@ -682,16 +687,17 @@ shader_t gs_create_vertexshader_from_file(const char *file, char **error_string) return NULL; } - shader = gs_create_vertexshader(file_string, file, error_string); + shader = gs_vertexshader_create(file_string, file, error_string); bfree(file_string); return shader; } -shader_t gs_create_pixelshader_from_file(const char *file, char **error_string) +gs_shader_t gs_pixelshader_create_from_file(const char *file, + char **error_string) { char *file_string; - shader_t shader = NULL; + gs_shader_t shader = NULL; if (!thread_graphics || !file) return NULL; @@ -703,7 +709,7 @@ shader_t gs_create_pixelshader_from_file(const char *file, char **error_string) return NULL; } - shader = gs_create_pixelshader(file_string, file, error_string); + shader = gs_pixelshader_create(file_string, file, error_string); bfree(file_string); return shader; @@ -732,7 +738,7 @@ static inline void assign_sprite_uv(float *start, float *end, bool flip) } } -static void build_sprite(struct vb_data *data, float fcx, float fcy, +static void build_sprite(struct gs_vb_data *data, float fcx, float fcy, float start_u, float end_u, float start_v, float end_v) { struct vec2 *tvarray = data->tvarray[0].array; @@ -747,8 +753,8 @@ static void build_sprite(struct vb_data *data, float fcx, float fcy, vec2_set(tvarray+3, end_u, end_v); } -static inline void build_sprite_norm(struct vb_data *data, float fcx, float fcy, - uint32_t flip) +static inline void build_sprite_norm(struct gs_vb_data *data, float fcx, + float fcy, uint32_t flip) { float start_u, end_u; float start_v, end_v; @@ -758,52 +764,52 @@ static inline void build_sprite_norm(struct vb_data *data, float fcx, float fcy, build_sprite(data, fcx, fcy, start_u, end_u, start_v, end_v); } -static inline void build_sprite_rect(struct vb_data *data, texture_t tex, +static inline void build_sprite_rect(struct gs_vb_data *data, gs_texture_t tex, float fcx, float fcy, uint32_t flip) { float start_u, end_u; float start_v, end_v; - float width = (float)texture_getwidth(tex); - float height = (float)texture_getheight(tex); + float width = (float)gs_texture_get_width(tex); + float height = (float)gs_texture_get_height(tex); assign_sprite_rect(&start_u, &end_u, width, (flip & GS_FLIP_U) != 0); assign_sprite_rect(&start_v, &end_v, height, (flip & GS_FLIP_V) != 0); build_sprite(data, fcx, fcy, start_u, end_u, start_v, end_v); } -void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width, +void gs_draw_sprite(gs_texture_t tex, uint32_t flip, uint32_t width, uint32_t height) { graphics_t graphics = thread_graphics; float fcx, fcy; - struct vb_data *data; + struct gs_vb_data *data; assert(tex); if (!tex || !thread_graphics) return; - if (gs_gettexturetype(tex) != GS_TEXTURE_2D) { + if (gs_get_texture_type(tex) != GS_TEXTURE_2D) { blog(LOG_ERROR, "A sprite must be a 2D texture"); return; } - fcx = width ? (float)width : (float)texture_getwidth(tex); - fcy = height ? (float)height : (float)texture_getheight(tex); + fcx = width ? (float)width : (float)gs_texture_get_width(tex); + fcy = height ? (float)height : (float)gs_texture_get_height(tex); - data = vertexbuffer_getdata(graphics->sprite_buffer); - if (texture_isrect(tex)) + data = gs_vertexbuffer_get_data(graphics->sprite_buffer); + if (gs_texture_is_rect(tex)) build_sprite_rect(data, tex, fcx, fcy, flip); else build_sprite_norm(data, fcx, fcy, flip); - vertexbuffer_flush(graphics->sprite_buffer); + gs_vertexbuffer_flush(graphics->sprite_buffer); 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, +void gs_draw_cube_backdrop(gs_texture_t cubetex, const struct quat *rot, float left, float right, float top, float bottom, float znear) { /* TODO */ @@ -816,25 +822,25 @@ void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot, UNUSED_PARAMETER(znear); } -void gs_resetviewport(void) +void gs_reset_viewport(void) { uint32_t cx, cy; assert(thread_graphics != NULL); - gs_getsize(&cx, &cy); + gs_get_size(&cx, &cy); - gs_setviewport(0, 0, (int)cx, (int)cy); + gs_set_viewport(0, 0, (int)cx, (int)cy); } -void gs_set2dmode(void) +void gs_set_2d_mode(void) { uint32_t cx, cy; assert(thread_graphics != NULL); - gs_getsize(&cx, &cy); + gs_get_size(&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) +void gs_set_3d_mode(double fovy, double znear, double zvar) { /* TODO */ UNUSED_PARAMETER(fovy); @@ -848,7 +854,7 @@ void gs_viewport_push(void) struct gs_rect *rect = da_push_back_new( thread_graphics->viewport_stack); - gs_getviewport(rect); + gs_get_viewport(rect); } void gs_viewport_pop(void) @@ -858,12 +864,12 @@ void gs_viewport_pop(void) return; rect = da_end(thread_graphics->viewport_stack); - gs_setviewport(rect->x, rect->y, rect->cx, rect->cy); + gs_set_viewport(rect->x, rect->y, rect->cx, rect->cy); da_pop_back(thread_graphics->viewport_stack); } -void texture_setimage(texture_t tex, const uint8_t *data, uint32_t linesize, - bool flip) +void gs_texture_set_image(gs_texture_t tex, const uint8_t *data, + uint32_t linesize, bool flip) { uint8_t *ptr; uint32_t linesize_out; @@ -874,9 +880,9 @@ void texture_setimage(texture_t tex, const uint8_t *data, uint32_t linesize, if (!thread_graphics || !tex) return; - height = (int32_t)texture_getheight(tex); + height = (int32_t)gs_texture_get_height(tex); - if (!texture_map(tex, &ptr, &linesize_out)) + if (!gs_texture_map(tex, &ptr, &linesize_out)) return; row_copy = (linesize < linesize_out) ? linesize : linesize_out; @@ -897,11 +903,11 @@ void texture_setimage(texture_t tex, const uint8_t *data, uint32_t linesize, row_copy); } - texture_unmap(tex); + gs_texture_unmap(tex); } -void cubetexture_setimage(texture_t cubetex, uint32_t side, const void *data, - uint32_t linesize, bool invert) +void gs_cubetexture_set_image(gs_texture_t cubetex, uint32_t side, + const void *data, uint32_t linesize, bool invert) { /* TODO */ UNUSED_PARAMETER(cubetex); @@ -938,7 +944,7 @@ void gs_reset_blend_state(void) if (graphics->cur_blend_state.src != GS_BLEND_SRCALPHA || graphics->cur_blend_state.dest != GS_BLEND_INVSRCALPHA) - gs_blendfunction(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA); + gs_blend_function(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA); } /* ------------------------------------------------------------------------- */ @@ -951,12 +957,12 @@ const char *gs_preprocessor_name(void) return graphics->exports.device_preprocessor_name(); } -swapchain_t gs_create_swapchain(struct gs_init_data *data) +gs_swapchain_t gs_swapchain_create(struct gs_init_data *data) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_swapchain(graphics->device, + return graphics->exports.device_swapchain_create(graphics->device, data); } @@ -968,28 +974,28 @@ void gs_resize(uint32_t x, uint32_t y) graphics->exports.device_resize(graphics->device, x, y); } -void gs_getsize(uint32_t *x, uint32_t *y) +void gs_get_size(uint32_t *x, uint32_t *y) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_getsize(graphics->device, x, y); + graphics->exports.device_get_size(graphics->device, x, y); } -uint32_t gs_getwidth(void) +uint32_t gs_get_width(void) { graphics_t graphics = thread_graphics; if (!graphics) return 0; - return graphics->exports.device_getwidth(graphics->device); + return graphics->exports.device_get_width(graphics->device); } -uint32_t gs_getheight(void) +uint32_t gs_get_height(void) { graphics_t graphics = thread_graphics; if (!graphics) return 0; - return graphics->exports.device_getheight(graphics->device); + return graphics->exports.device_get_height(graphics->device); } static inline bool is_pow2(uint32_t size) @@ -997,13 +1003,13 @@ 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, +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) { graphics_t graphics = thread_graphics; bool pow2tex = is_pow2(width) && is_pow2(height); - bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1); + bool uses_mipmaps = (flags & GS_BUILD_MIPMAPS || levels != 1); if (!graphics) return NULL; @@ -1014,28 +1020,28 @@ texture_t gs_create_texture(uint32_t width, uint32_t height, "mipmaps for this texture."); uses_mipmaps = false; - flags &= ~GS_BUILDMIPMAPS; + flags &= ~GS_BUILD_MIPMAPS; levels = 1; } - if (uses_mipmaps && flags & GS_RENDERTARGET) { + if (uses_mipmaps && flags & GS_RENDER_TARGET) { blog(LOG_WARNING, "Cannot use mipmaps with render targets. " "Disabling mipmaps for this texture."); - flags &= ~GS_BUILDMIPMAPS; + flags &= ~GS_BUILD_MIPMAPS; levels = 1; } - return graphics->exports.device_create_texture(graphics->device, + return graphics->exports.device_texture_create(graphics->device, width, height, color_format, levels, data, flags); } -texture_t gs_create_cubetexture(uint32_t size, +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) { graphics_t graphics = thread_graphics; bool pow2tex = is_pow2(size); - bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1); + bool uses_mipmaps = (flags & GS_BUILD_MIPMAPS || levels != 1); if (!graphics) return NULL; @@ -1046,112 +1052,112 @@ texture_t gs_create_cubetexture(uint32_t size, "mipmaps for this texture."); uses_mipmaps = false; - flags &= ~GS_BUILDMIPMAPS; + flags &= ~GS_BUILD_MIPMAPS; levels = 1; } - if (uses_mipmaps && flags & GS_RENDERTARGET) { + if (uses_mipmaps && flags & GS_RENDER_TARGET) { blog(LOG_WARNING, "Cannot use mipmaps with render targets. " "Disabling mipmaps for this texture."); - flags &= ~GS_BUILDMIPMAPS; + flags &= ~GS_BUILD_MIPMAPS; levels = 1; data = NULL; } - return graphics->exports.device_create_cubetexture(graphics->device, + return graphics->exports.device_cubetexture_create(graphics->device, size, color_format, levels, data, flags); } -texture_t gs_create_volumetexture(uint32_t width, uint32_t height, +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) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_volumetexture(graphics->device, + return graphics->exports.device_voltexture_create(graphics->device, width, height, depth, color_format, levels, data, flags); } -zstencil_t gs_create_zstencil(uint32_t width, uint32_t height, +gs_zstencil_t gs_zstencil_create(uint32_t width, uint32_t height, enum gs_zstencil_format format) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_zstencil(graphics->device, + return graphics->exports.device_zstencil_create(graphics->device, width, height, format); } -stagesurf_t gs_create_stagesurface(uint32_t width, uint32_t height, +gs_stagesurf_t gs_stagesurface_create(uint32_t width, uint32_t height, enum gs_color_format color_format) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_stagesurface(graphics->device, + return graphics->exports.device_stagesurface_create(graphics->device, width, height, color_format); } -samplerstate_t gs_create_samplerstate(struct gs_sampler_info *info) +gs_samplerstate_t gs_samplerstate_create(struct gs_sampler_info *info) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_samplerstate(graphics->device, + return graphics->exports.device_samplerstate_create(graphics->device, info); } -shader_t gs_create_vertexshader(const char *shader, const char *file, +gs_shader_t gs_vertexshader_create(const char *shader, const char *file, char **error_string) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_vertexshader(graphics->device, + return graphics->exports.device_vertexshader_create(graphics->device, shader, file, error_string); } -shader_t gs_create_pixelshader(const char *shader, +gs_shader_t gs_pixelshader_create(const char *shader, const char *file, char **error_string) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_pixelshader(graphics->device, + return graphics->exports.device_pixelshader_create(graphics->device, shader, file, error_string); } -vertbuffer_t gs_create_vertexbuffer(struct vb_data *data, +gs_vertbuffer_t gs_vertexbuffer_create(struct gs_vb_data *data, uint32_t flags) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_vertexbuffer(graphics->device, + return graphics->exports.device_vertexbuffer_create(graphics->device, data, flags); } -indexbuffer_t gs_create_indexbuffer(enum gs_index_type type, +gs_indexbuffer_t gs_indexbuffer_create(enum gs_index_type type, void *indices, size_t num, uint32_t flags) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_create_indexbuffer(graphics->device, + return graphics->exports.device_indexbuffer_create(graphics->device, type, indices, num, flags); } -enum gs_texture_type gs_gettexturetype(texture_t texture) +enum gs_texture_type gs_get_texture_type(gs_texture_t texture) { graphics_t graphics = thread_graphics; if (!graphics) return GS_TEXTURE_2D; - return graphics->exports.device_gettexturetype(texture); + return graphics->exports.device_get_texture_type(texture); } -void gs_load_vertexbuffer(vertbuffer_t vertbuffer) +void gs_load_vertexbuffer(gs_vertbuffer_t vertbuffer) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1160,7 +1166,7 @@ void gs_load_vertexbuffer(vertbuffer_t vertbuffer) vertbuffer); } -void gs_load_indexbuffer(indexbuffer_t indexbuffer) +void gs_load_indexbuffer(gs_indexbuffer_t indexbuffer) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1169,7 +1175,7 @@ void gs_load_indexbuffer(indexbuffer_t indexbuffer) indexbuffer); } -void gs_load_texture(texture_t tex, int unit) +void gs_load_texture(gs_texture_t tex, int unit) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1177,7 +1183,7 @@ void gs_load_texture(texture_t tex, int unit) graphics->exports.device_load_texture(graphics->device, tex, unit); } -void gs_load_samplerstate(samplerstate_t samplerstate, int unit) +void gs_load_samplerstate(gs_samplerstate_t samplerstate, int unit) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1186,7 +1192,7 @@ void gs_load_samplerstate(samplerstate_t samplerstate, int unit) samplerstate, unit); } -void gs_load_vertexshader(shader_t vertshader) +void gs_load_vertexshader(gs_shader_t vertshader) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1195,7 +1201,7 @@ void gs_load_vertexshader(shader_t vertshader) vertshader); } -void gs_load_pixelshader(shader_t pixelshader) +void gs_load_pixelshader(gs_shader_t pixelshader) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1204,66 +1210,67 @@ void gs_load_pixelshader(shader_t pixelshader) pixelshader); } -void gs_load_defaultsamplerstate(bool b_3d, int unit) +void gs_load_default_samplerstate(bool b_3d, int unit) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_load_defaultsamplerstate(graphics->device, + graphics->exports.device_load_default_samplerstate(graphics->device, b_3d, unit); } -shader_t gs_getvertexshader(void) +gs_shader_t gs_get_vertex_shader(void) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_getvertexshader(graphics->device); + return graphics->exports.device_get_vertex_shader(graphics->device); } -shader_t gs_getpixelshader(void) +gs_shader_t gs_get_pixel_shader(void) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_getpixelshader(graphics->device); + return graphics->exports.device_get_pixel_shader(graphics->device); } -texture_t gs_getrendertarget(void) +gs_texture_t gs_get_render_target(void) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_getrendertarget(graphics->device); + return graphics->exports.device_get_render_target(graphics->device); } -zstencil_t gs_getzstenciltarget(void) +gs_zstencil_t gs_get_zstencil_target(void) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - return graphics->exports.device_getzstenciltarget(graphics->device); + return graphics->exports.device_get_zstencil_target(graphics->device); } -void gs_setrendertarget(texture_t tex, zstencil_t zstencil) +void gs_set_render_target(gs_texture_t tex, gs_zstencil_t zstencil) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_setrendertarget(graphics->device, tex, + graphics->exports.device_set_render_target(graphics->device, tex, zstencil); } -void gs_setcuberendertarget(texture_t cubetex, int side, zstencil_t zstencil) +void gs_set_cube_render_target(gs_texture_t cubetex, int side, + gs_zstencil_t zstencil) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_setcuberendertarget(graphics->device, cubetex, - side, zstencil); + graphics->exports.device_set_cube_render_target(graphics->device, + cubetex, side, zstencil); } -void gs_copy_texture(texture_t dst, texture_t src) +void gs_copy_texture(gs_texture_t dst, gs_texture_t src) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1271,8 +1278,8 @@ void gs_copy_texture(texture_t dst, texture_t src) graphics->exports.device_copy_texture(graphics->device, dst, src); } -void gs_copy_texture_region(texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, +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) { graphics_t graphics = thread_graphics; @@ -1283,7 +1290,7 @@ void gs_copy_texture_region(texture_t dst, uint32_t dst_x, uint32_t dst_y, src, src_x, src_y, src_w, src_h); } -void gs_stage_texture(stagesurf_t dst, texture_t src) +void gs_stage_texture(gs_stagesurf_t dst, gs_texture_t src) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1291,12 +1298,12 @@ void gs_stage_texture(stagesurf_t dst, texture_t src) graphics->exports.device_stage_texture(graphics->device, dst, src); } -void gs_beginscene(void) +void gs_begin_scene(void) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_beginscene(graphics->device); + graphics->exports.device_begin_scene(graphics->device); } void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert, @@ -1309,15 +1316,15 @@ void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert, start_vert, num_verts); } -void gs_endscene(void) +void gs_end_scene(void) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_endscene(graphics->device); + graphics->exports.device_end_scene(graphics->device); } -void gs_load_swapchain(swapchain_t swapchain) +void gs_load_swapchain(gs_swapchain_t swapchain) { graphics_t graphics = thread_graphics; if (!graphics) return; @@ -1349,20 +1356,20 @@ void gs_flush(void) graphics->exports.device_flush(graphics->device); } -void gs_setcullmode(enum gs_cull_mode mode) +void gs_set_cull_mode(enum gs_cull_mode mode) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_setcullmode(graphics->device, mode); + graphics->exports.device_set_cull_mode(graphics->device, mode); } -enum gs_cull_mode gs_getcullmode(void) +enum gs_cull_mode gs_get_cull_mode(void) { graphics_t graphics = thread_graphics; if (!graphics) return GS_NEITHER; - return graphics->exports.device_getcullmode(graphics->device); + return graphics->exports.device_get_cull_mode(graphics->device); } void gs_enable_blending(bool enable) @@ -1374,28 +1381,28 @@ void gs_enable_blending(bool enable) graphics->exports.device_enable_blending(graphics->device, enable); } -void gs_enable_depthtest(bool enable) +void gs_enable_depth_test(bool enable) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_enable_depthtest(graphics->device, enable); + graphics->exports.device_enable_depth_test(graphics->device, enable); } -void gs_enable_stenciltest(bool enable) +void gs_enable_stencil_test(bool enable) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_enable_stenciltest(graphics->device, enable); + graphics->exports.device_enable_stencil_test(graphics->device, enable); } -void gs_enable_stencilwrite(bool enable) +void gs_enable_stencil_write(bool enable) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_enable_stencilwrite(graphics->device, enable); + graphics->exports.device_enable_stencil_write(graphics->device, enable); } void gs_enable_color(bool red, bool green, bool blue, bool alpha) @@ -1407,65 +1414,65 @@ void gs_enable_color(bool red, bool green, bool blue, bool alpha) blue, alpha); } -void gs_blendfunction(enum gs_blend_type src, enum gs_blend_type dest) +void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest) { graphics_t graphics = thread_graphics; if (!graphics) return; graphics->cur_blend_state.src = src; graphics->cur_blend_state.dest = dest; - graphics->exports.device_blendfunction(graphics->device, src, dest); + graphics->exports.device_blend_function(graphics->device, src, dest); } -void gs_depthfunction(enum gs_depth_test test) +void gs_depth_function(enum gs_depth_test test) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_depthfunction(graphics->device, test); + graphics->exports.device_depth_function(graphics->device, test); } -void gs_stencilfunction(enum gs_stencil_side side, enum gs_depth_test test) +void gs_stencil_function(enum gs_stencil_side side, enum gs_depth_test test) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_stencilfunction(graphics->device, side, test); + graphics->exports.device_stencil_function(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) +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) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_stencilop(graphics->device, side, fail, zfail, + graphics->exports.device_stencil_op(graphics->device, side, fail, zfail, zpass); } -void gs_setviewport(int x, int y, int width, int height) +void gs_set_viewport(int x, int y, int width, int height) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_setviewport(graphics->device, x, y, width, + graphics->exports.device_set_viewport(graphics->device, x, y, width, height); } -void gs_getviewport(struct gs_rect *rect) +void gs_get_viewport(struct gs_rect *rect) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_getviewport(graphics->device, rect); + graphics->exports.device_get_viewport(graphics->device, rect); } -void gs_setscissorrect(struct gs_rect *rect) +void gs_set_scissor_rect(struct gs_rect *rect) { graphics_t graphics = thread_graphics; if (!graphics) return; - graphics->exports.device_setscissorrect(graphics->device, rect); + graphics->exports.device_set_scissor_rect(graphics->device, rect); } void gs_ortho(float left, float right, float top, float bottom, float znear, @@ -1504,430 +1511,434 @@ void gs_projection_pop(void) graphics->exports.device_projection_pop(graphics->device); } -void swapchain_destroy(swapchain_t swapchain) +void gs_swapchain_destroy(gs_swapchain_t swapchain) { graphics_t graphics = thread_graphics; if (!graphics || !swapchain) return; - graphics->exports.swapchain_destroy(swapchain); + graphics->exports.gs_swapchain_destroy(swapchain); } -void shader_destroy(shader_t shader) +void gs_shader_destroy(gs_shader_t shader) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return; - graphics->exports.shader_destroy(shader); + graphics->exports.gs_shader_destroy(shader); } -int shader_numparams(shader_t shader) +int gs_shader_get_num_params(gs_shader_t shader) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return 0; - return graphics->exports.shader_numparams(shader); + return graphics->exports.gs_shader_get_num_params(shader); } -sparam_t shader_getparambyidx(shader_t shader, uint32_t param) +gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, uint32_t param) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return NULL; - return graphics->exports.shader_getparambyidx(shader, param); + return graphics->exports.gs_shader_get_param_by_idx(shader, param); } -sparam_t shader_getparambyname(shader_t shader, const char *name) +gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, const char *name) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return NULL; - return graphics->exports.shader_getparambyname(shader, name); + return graphics->exports.gs_shader_get_param_by_name(shader, name); } -sparam_t shader_getviewprojmatrix(shader_t shader) +gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return NULL; - return graphics->exports.shader_getviewprojmatrix(shader); + return graphics->exports.gs_shader_get_viewproj_matrix(shader); } -sparam_t shader_getworldmatrix(shader_t shader) +gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader) { graphics_t graphics = thread_graphics; if (!graphics || !shader) return NULL; - return graphics->exports.shader_getworldmatrix(shader); + return graphics->exports.gs_shader_get_world_matrix(shader); } -void shader_getparaminfo(sparam_t param, struct shader_param_info *info) +void gs_shader_get_param_info(gs_sparam_t param, + struct gs_shader_param_info *info) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_getparaminfo(param, info); + graphics->exports.gs_shader_get_param_info(param, info); } -void shader_setbool(sparam_t param, bool val) +void gs_shader_set_bool(gs_sparam_t param, bool val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setbool(param, val); + graphics->exports.gs_shader_set_bool(param, val); } -void shader_setfloat(sparam_t param, float val) +void gs_shader_set_float(gs_sparam_t param, float val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setfloat(param, val); + graphics->exports.gs_shader_set_float(param, val); } -void shader_setint(sparam_t param, int val) +void gs_shader_set_int(gs_sparam_t param, int val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setint(param, val); + graphics->exports.gs_shader_set_int(param, val); } -void shader_setmatrix3(sparam_t param, const struct matrix3 *val) +void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setmatrix3(param, val); + graphics->exports.gs_shader_setmatrix3(param, val); } -void shader_setmatrix4(sparam_t param, const struct matrix4 *val) +void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setmatrix4(param, val); + graphics->exports.gs_shader_set_matrix4(param, val); } -void shader_setvec2(sparam_t param, const struct vec2 *val) +void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setvec2(param, val); + graphics->exports.gs_shader_set_vec2(param, val); } -void shader_setvec3(sparam_t param, const struct vec3 *val) +void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setvec3(param, val); + graphics->exports.gs_shader_set_vec3(param, val); } -void shader_setvec4(sparam_t param, const struct vec4 *val) +void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setvec4(param, val); + graphics->exports.gs_shader_set_vec4(param, val); } -void shader_settexture(sparam_t param, texture_t val) +void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_settexture(param, val); + graphics->exports.gs_shader_set_texture(param, val); } -void shader_setval(sparam_t param, const void *val, size_t size) +void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setval(param, val, size); + graphics->exports.gs_shader_set_val(param, val, size); } -void shader_setdefault(sparam_t param) +void gs_shader_set_default(gs_sparam_t param) { graphics_t graphics = thread_graphics; if (!graphics || !param) return; - graphics->exports.shader_setdefault(param); + graphics->exports.gs_shader_set_default(param); } -void texture_destroy(texture_t tex) +void gs_texture_destroy(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return; - graphics->exports.texture_destroy(tex); + graphics->exports.gs_texture_destroy(tex); } -uint32_t texture_getwidth(texture_t tex) +uint32_t gs_texture_get_width(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return 0; - return graphics->exports.texture_getwidth(tex); + return graphics->exports.gs_texture_get_width(tex); } -uint32_t texture_getheight(texture_t tex) +uint32_t gs_texture_get_height(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return 0; - return graphics->exports.texture_getheight(tex); + return graphics->exports.gs_texture_get_height(tex); } -enum gs_color_format texture_getcolorformat(texture_t tex) +enum gs_color_format gs_texture_get_color_format(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return GS_UNKNOWN; - return graphics->exports.texture_getcolorformat(tex); + return graphics->exports.gs_texture_get_color_format(tex); } -bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize) +bool gs_texture_map(gs_texture_t tex, uint8_t **ptr, uint32_t *linesize) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return false; - return graphics->exports.texture_map(tex, ptr, linesize); + return graphics->exports.gs_texture_map(tex, ptr, linesize); } -void texture_unmap(texture_t tex) +void gs_texture_unmap(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return; - graphics->exports.texture_unmap(tex); + graphics->exports.gs_texture_unmap(tex); } -bool texture_isrect(texture_t tex) +bool gs_texture_is_rect(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return false; - if (graphics->exports.texture_isrect) - return graphics->exports.texture_isrect(tex); + if (graphics->exports.gs_texture_is_rect) + return graphics->exports.gs_texture_is_rect(tex); else return false; } -void *texture_getobj(texture_t tex) +void *gs_texture_get_obj(gs_texture_t tex) { graphics_t graphics = thread_graphics; if (!graphics || !tex) return NULL; - return graphics->exports.texture_getobj(tex); + return graphics->exports.gs_texture_get_obj(tex); } -void cubetexture_destroy(texture_t cubetex) +void gs_cubetexture_destroy(gs_texture_t cubetex) { graphics_t graphics = thread_graphics; if (!graphics || !cubetex) return; - graphics->exports.cubetexture_destroy(cubetex); + graphics->exports.gs_cubetexture_destroy(cubetex); } -uint32_t cubetexture_getsize(texture_t cubetex) +uint32_t gs_cubetexture_get_size(gs_texture_t cubetex) { graphics_t graphics = thread_graphics; if (!graphics || !cubetex) return 0; - return graphics->exports.cubetexture_getsize(cubetex); + return graphics->exports.gs_cubetexture_get_size(cubetex); } -enum gs_color_format cubetexture_getcolorformat(texture_t cubetex) +enum gs_color_format gs_cubetexture_get_color_format(gs_texture_t cubetex) { graphics_t graphics = thread_graphics; if (!graphics || !cubetex) return GS_UNKNOWN; - return graphics->exports.cubetexture_getcolorformat(cubetex); + return graphics->exports.gs_cubetexture_get_color_format(cubetex); } -void volumetexture_destroy(texture_t voltex) +void gs_voltexture_destroy(gs_texture_t voltex) { graphics_t graphics = thread_graphics; if (!graphics || !voltex) return; - graphics->exports.volumetexture_destroy(voltex); + graphics->exports.gs_voltexture_destroy(voltex); } -uint32_t volumetexture_getwidth(texture_t voltex) +uint32_t gs_voltexture_get_width(gs_texture_t voltex) { graphics_t graphics = thread_graphics; if (!graphics || !voltex) return 0; - return graphics->exports.volumetexture_getwidth(voltex); + return graphics->exports.gs_voltexture_get_width(voltex); } -uint32_t volumetexture_getheight(texture_t voltex) +uint32_t gs_voltexture_get_height(gs_texture_t voltex) { graphics_t graphics = thread_graphics; if (!graphics || !voltex) return 0; - return graphics->exports.volumetexture_getheight(voltex); + return graphics->exports.gs_voltexture_get_height(voltex); } -uint32_t volumetexture_getdepth(texture_t voltex) +uint32_t gs_voltexture_getdepth(gs_texture_t voltex) { graphics_t graphics = thread_graphics; if (!graphics || !voltex) return 0; - return graphics->exports.volumetexture_getdepth(voltex); + return graphics->exports.gs_voltexture_getdepth(voltex); } -enum gs_color_format volumetexture_getcolorformat(texture_t voltex) +enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex) { graphics_t graphics = thread_graphics; if (!graphics || !voltex) return GS_UNKNOWN; - return graphics->exports.volumetexture_getcolorformat(voltex); + return graphics->exports.gs_voltexture_get_color_format(voltex); } -void stagesurface_destroy(stagesurf_t stagesurf) +void gs_stagesurface_destroy(gs_stagesurf_t stagesurf) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return; - graphics->exports.stagesurface_destroy(stagesurf); + graphics->exports.gs_stagesurface_destroy(stagesurf); } -uint32_t stagesurface_getwidth(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return 0; - return graphics->exports.stagesurface_getwidth(stagesurf); + return graphics->exports.gs_stagesurface_get_width(stagesurf); } -uint32_t stagesurface_getheight(stagesurf_t stagesurf) +uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return 0; - return graphics->exports.stagesurface_getheight(stagesurf); + return graphics->exports.gs_stagesurface_get_height(stagesurf); } -enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf) +enum gs_color_format gs_stagesurface_get_color_format(gs_stagesurf_t stagesurf) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return GS_UNKNOWN; - return graphics->exports.stagesurface_getcolorformat(stagesurf); + return graphics->exports.gs_stagesurface_get_color_format(stagesurf); } -bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize) +bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data, + uint32_t *linesize) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return false; - return graphics->exports.stagesurface_map(stagesurf, data, linesize); + return graphics->exports.gs_stagesurface_map(stagesurf, data, linesize); } -void stagesurface_unmap(stagesurf_t stagesurf) +void gs_stagesurface_unmap(gs_stagesurf_t stagesurf) { graphics_t graphics = thread_graphics; if (!graphics || !stagesurf) return; - graphics->exports.stagesurface_unmap(stagesurf); + graphics->exports.gs_stagesurface_unmap(stagesurf); } -void zstencil_destroy(zstencil_t zstencil) +void gs_zstencil_destroy(gs_zstencil_t zstencil) { if (!thread_graphics || !zstencil) return; - thread_graphics->exports.zstencil_destroy(zstencil); + thread_graphics->exports.gs_zstencil_destroy(zstencil); } -void samplerstate_destroy(samplerstate_t samplerstate) +void gs_samplerstate_destroy(gs_samplerstate_t samplerstate) { if (!thread_graphics || !samplerstate) return; - thread_graphics->exports.samplerstate_destroy(samplerstate); + thread_graphics->exports.gs_samplerstate_destroy(samplerstate); } -void vertexbuffer_destroy(vertbuffer_t vertbuffer) +void gs_vertexbuffer_destroy(gs_vertbuffer_t vertbuffer) { graphics_t graphics = thread_graphics; if (!graphics || !vertbuffer) return; - graphics->exports.vertexbuffer_destroy(vertbuffer); + graphics->exports.gs_vertexbuffer_destroy(vertbuffer); } -void vertexbuffer_flush(vertbuffer_t vertbuffer) +void gs_vertexbuffer_flush(gs_vertbuffer_t vertbuffer) { if (!thread_graphics || !vertbuffer) return; - thread_graphics->exports.vertexbuffer_flush(vertbuffer); + thread_graphics->exports.gs_vertexbuffer_flush(vertbuffer); } -struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer) +struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vertbuffer) { if (!thread_graphics || !vertbuffer) return NULL; - return thread_graphics->exports.vertexbuffer_getdata(vertbuffer); + return thread_graphics->exports.gs_vertexbuffer_get_data(vertbuffer); } -void indexbuffer_destroy(indexbuffer_t indexbuffer) +void gs_indexbuffer_destroy(gs_indexbuffer_t indexbuffer) { graphics_t graphics = thread_graphics; if (!graphics || !indexbuffer) return; - graphics->exports.indexbuffer_destroy(indexbuffer); + graphics->exports.gs_indexbuffer_destroy(indexbuffer); } -void indexbuffer_flush(indexbuffer_t indexbuffer) +void gs_indexbuffer_flush(gs_indexbuffer_t indexbuffer) { if (!thread_graphics || !indexbuffer) return; - thread_graphics->exports.indexbuffer_flush(indexbuffer); + thread_graphics->exports.gs_indexbuffer_flush(indexbuffer); } -void *indexbuffer_getdata(indexbuffer_t indexbuffer) +void *gs_indexbuffer_get_data(gs_indexbuffer_t indexbuffer) { if (!thread_graphics || !indexbuffer) return NULL; - return thread_graphics->exports.indexbuffer_getdata(indexbuffer); + return thread_graphics->exports.gs_indexbuffer_get_data(indexbuffer); } -size_t indexbuffer_numindices(indexbuffer_t indexbuffer) +size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t indexbuffer) { if (!thread_graphics || !indexbuffer) return 0; - return thread_graphics->exports.indexbuffer_numindices(indexbuffer); + return thread_graphics->exports.gs_indexbuffer_get_num_indices( + indexbuffer); } -enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer) +enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t indexbuffer) { if (!thread_graphics || !indexbuffer) return (enum gs_index_type)0; - return thread_graphics->exports.indexbuffer_gettype(indexbuffer); + return thread_graphics->exports.gs_indexbuffer_get_type(indexbuffer); } #ifdef __APPLE__ /** Platform specific functions */ -texture_t gs_create_texture_from_iosurface(void *iosurf) +gs_texture_t gs_texture_create_from_iosurface(void *iosurf) { graphics_t graphics = thread_graphics; if (!graphics || !iosurf || - !graphics->exports.texture_create_from_iosurface) + !graphics->exports.device_texture_create_from_iosurface) return NULL; - return graphics->exports.texture_create_from_iosurface( + return graphics->exports.device_texture_create_from_iosurface( graphics->device, iosurf); } -bool texture_rebind_iosurface(texture_t texture, void *iosurf) +bool gs_texture_rebind_iosurface(gs_texture_t texture, void *iosurf) { graphics_t graphics = thread_graphics; - if (!graphics || !iosurf || !graphics->exports.texture_rebind_iosurface) + if (!graphics || !iosurf || + !graphics->exports.gs_texture_rebind_iosurface) return false; - return graphics->exports.texture_rebind_iosurface(texture, iosurf); + return graphics->exports.gs_texture_rebind_iosurface(texture, iosurf); } #elif _WIN32 @@ -1937,38 +1948,38 @@ bool gs_gdi_texture_available(void) if (!thread_graphics) return false; - return thread_graphics->exports.gdi_texture_available(); + return thread_graphics->exports.device_gdi_texture_available(); } /** creates a windows GDI-lockable texture */ -texture_t gs_create_gdi_texture(uint32_t width, uint32_t height) +gs_texture_t gs_texture_create_gdi(uint32_t width, uint32_t height) { graphics_t graphics = thread_graphics; if (!graphics) return NULL; - if (graphics->exports.device_create_gdi_texture) - return graphics->exports.device_create_gdi_texture( + if (graphics->exports.device_texture_create_gdi) + return graphics->exports.device_texture_create_gdi( graphics->device, width, height); return NULL; } -void *texture_get_dc(texture_t gdi_tex) +void *gs_texture_get_dc(gs_texture_t gdi_tex) { if (!thread_graphics || !gdi_tex) return NULL; - if (thread_graphics->exports.texture_get_dc) - return thread_graphics->exports.texture_get_dc(gdi_tex); + if (thread_graphics->exports.gs_texture_get_dc) + return thread_graphics->exports.gs_texture_get_dc(gdi_tex); return NULL; } -void texture_release_dc(texture_t gdi_tex) +void gs_texture_release_dc(gs_texture_t gdi_tex) { if (!thread_graphics || !gdi_tex) return; - if (thread_graphics->exports.texture_release_dc) - thread_graphics->exports.texture_release_dc(gdi_tex); + if (thread_graphics->exports.gs_texture_release_dc) + thread_graphics->exports.gs_texture_release_dc(gdi_tex); } #endif diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 4404c2747..3020cd099 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -124,7 +124,7 @@ enum gs_stencil_side { GS_STENCIL_BOTH }; -enum gs_stencil_op { +enum gs_stencil_op_type { GS_KEEP, GS_ZERO, GS_REPLACE, @@ -168,12 +168,12 @@ enum gs_texture_type { GS_TEXTURE_CUBE }; -struct tvertarray { +struct gs_tvertarray { size_t width; void *array; }; -struct vb_data { +struct gs_vb_data { size_t num; struct vec3 *points; struct vec3 *normals; @@ -181,15 +181,15 @@ struct vb_data { uint32_t *colors; size_t num_tex; - struct tvertarray *tvarray; + struct gs_tvertarray *tvarray; }; -static inline struct vb_data *vbdata_create(void) +static inline struct gs_vb_data *gs_vbdata_create(void) { - return (struct vb_data*)bzalloc(sizeof(struct vb_data)); + return (struct gs_vb_data*)bzalloc(sizeof(struct gs_vb_data)); } -static inline void vbdata_destroy(struct vb_data *data) +static inline void gs_vbdata_destroy(struct gs_vb_data *data) { uint32_t i; if (!data) @@ -239,154 +239,161 @@ struct gs_sampler_state; struct gs_shader; struct gs_swap_chain; struct gs_texrender; -struct shader_param; +struct gs_shader_param; struct gs_effect; -struct effect_technique; -struct effect_pass; -struct effect_param; +struct gs_effect_technique; +struct gs_effect_pass; +struct gs_effect_param; struct gs_device; struct graphics_subsystem; -typedef struct gs_texture *texture_t; -typedef struct gs_stage_surface *stagesurf_t; -typedef struct gs_zstencil_buffer *zstencil_t; -typedef struct gs_vertex_buffer *vertbuffer_t; -typedef struct gs_index_buffer *indexbuffer_t; -typedef struct gs_sampler_state *samplerstate_t; -typedef struct gs_swap_chain *swapchain_t; -typedef struct gs_texture_render *texrender_t; -typedef struct gs_shader *shader_t; -typedef struct shader_param *sparam_t; -typedef struct gs_effect *effect_t; -typedef struct effect_technique *technique_t; -typedef struct effect_param *eparam_t; -typedef struct gs_device *device_t; -typedef struct graphics_subsystem *graphics_t; +typedef struct gs_texture *gs_texture_t; +typedef struct gs_stage_surface *gs_stagesurf_t; +typedef struct gs_zstencil_buffer *gs_zstencil_t; +typedef struct gs_vertex_buffer *gs_vertbuffer_t; +typedef struct gs_index_buffer *gs_indexbuffer_t; +typedef struct gs_sampler_state *gs_samplerstate_t; +typedef struct gs_swap_chain *gs_swapchain_t; +typedef struct gs_texture_render *gs_texrender_t; +typedef struct gs_shader *gs_shader_t; +typedef struct gs_shader_param *gs_sparam_t; +typedef struct gs_effect *gs_effect_t; +typedef struct gs_effect_technique *gs_technique_t; +typedef struct gs_effect_param *gs_eparam_t; +typedef struct gs_device *gs_device_t; +typedef struct graphics_subsystem *graphics_t; /* --------------------------------------------------- * shader functions * --------------------------------------------------- */ -enum shader_param_type { - SHADER_PARAM_UNKNOWN, - SHADER_PARAM_BOOL, - SHADER_PARAM_FLOAT, - SHADER_PARAM_INT, - SHADER_PARAM_STRING, - SHADER_PARAM_VEC2, - SHADER_PARAM_VEC3, - SHADER_PARAM_VEC4, - SHADER_PARAM_MATRIX4X4, - SHADER_PARAM_TEXTURE, +enum gs_shader_param_type { + GS_SHADER_PARAM_UNKNOWN, + GS_SHADER_PARAM_BOOL, + GS_SHADER_PARAM_FLOAT, + GS_SHADER_PARAM_INT, + GS_SHADER_PARAM_STRING, + GS_SHADER_PARAM_VEC2, + GS_SHADER_PARAM_VEC3, + GS_SHADER_PARAM_VEC4, + GS_SHADER_PARAM_MATRIX4X4, + GS_SHADER_PARAM_TEXTURE, }; -struct shader_param_info { - enum shader_param_type type; +struct gs_shader_param_info { + enum gs_shader_param_type type; const char *name; }; -enum shader_type { - SHADER_VERTEX, - SHADER_PIXEL, +enum gs_shader_type { + GS_SHADER_VERTEX, + GS_SHADER_PIXEL, }; -EXPORT void shader_destroy(shader_t shader); +EXPORT void gs_shader_destroy(gs_shader_t shader); -EXPORT int shader_numparams(shader_t shader); -EXPORT sparam_t shader_getparambyidx(shader_t shader, uint32_t param); -EXPORT sparam_t shader_getparambyname(shader_t shader, const char *name); +EXPORT int gs_shader_get_num_params(gs_shader_t shader); +EXPORT gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, + uint32_t param); +EXPORT gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, + const char *name); -EXPORT sparam_t shader_getviewprojmatrix(shader_t shader); -EXPORT sparam_t shader_getworldmatrix(shader_t shader); +EXPORT gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader); +EXPORT gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader); -EXPORT void shader_getparaminfo(sparam_t param, struct shader_param_info *info); -EXPORT void shader_setbool(sparam_t param, bool val); -EXPORT void shader_setfloat(sparam_t param, float val); -EXPORT void shader_setint(sparam_t param, int val); -EXPORT void shader_setmatrix3(sparam_t param, const struct matrix3 *val); -EXPORT void shader_setmatrix4(sparam_t param, const struct matrix4 *val); -EXPORT void shader_setvec2(sparam_t param, const struct vec2 *val); -EXPORT void shader_setvec3(sparam_t param, const struct vec3 *val); -EXPORT void shader_setvec4(sparam_t param, const struct vec4 *val); -EXPORT void shader_settexture(sparam_t param, texture_t val); -EXPORT void shader_setval(sparam_t param, const void *val, size_t size); -EXPORT void shader_setdefault(sparam_t param); +EXPORT void gs_shader_get_param_info(gs_sparam_t param, + struct gs_shader_param_info *info); +EXPORT void gs_shader_set_bool(gs_sparam_t param, bool val); +EXPORT void gs_shader_set_float(gs_sparam_t param, float val); +EXPORT void gs_shader_set_int(gs_sparam_t param, int val); +EXPORT void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val); +EXPORT void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val); +EXPORT void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val); +EXPORT void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val); +EXPORT void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val); +EXPORT void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val); +EXPORT void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size); +EXPORT void gs_shader_set_default(gs_sparam_t param); /* --------------------------------------------------- * effect functions * --------------------------------------------------- */ -/*enum effect_property_type { - EFFECT_NONE, - EFFECT_BOOL, - EFFECT_FLOAT, - EFFECT_COLOR, - EFFECT_TEXTURE +/*enum gs_effect_property_type { + GS_EFFECT_NONE, + GS_EFFECT_BOOL, + GS_EFFECT_FLOAT, + GS_EFFECT_COLOR, + GS_EFFECT_TEXTURE };*/ -struct effect_param_info { +struct gs_effect_param_info { const char *name; - enum shader_param_type type; + enum gs_shader_param_type type; /* const char *full_name; - enum effect_property_type prop_type; + enum gs_effect_property_type prop_type; float min, max, inc, mul; */ }; -EXPORT void effect_destroy(effect_t effect); +EXPORT void gs_effect_destroy(gs_effect_t effect); -EXPORT technique_t effect_gettechnique(effect_t effect, const char *name); - -EXPORT size_t technique_begin(technique_t technique); -EXPORT void technique_end(technique_t technique); -EXPORT bool technique_beginpass(technique_t technique, size_t pass); -EXPORT bool technique_beginpassbyname(technique_t technique, +EXPORT gs_technique_t gs_effect_get_technique(gs_effect_t effect, const char *name); -EXPORT void technique_endpass(technique_t technique); -EXPORT size_t effect_numparams(effect_t effect); -EXPORT eparam_t effect_getparambyidx(effect_t effect, size_t param); -EXPORT eparam_t effect_getparambyname(effect_t effect, const char *name); +EXPORT size_t gs_technique_begin(gs_technique_t technique); +EXPORT void gs_technique_end(gs_technique_t technique); +EXPORT bool gs_technique_begin_pass(gs_technique_t technique, size_t pass); +EXPORT bool gs_technique_begin_pass_by_name(gs_technique_t technique, + const char *name); +EXPORT void gs_technique_end_pass(gs_technique_t technique); + +EXPORT size_t gs_effect_get_num_params(gs_effect_t effect); +EXPORT gs_eparam_t gs_effect_get_param_by_idx(gs_effect_t effect, size_t param); +EXPORT gs_eparam_t gs_effect_get_param_by_name(gs_effect_t effect, + const char *name); /** used internally */ -EXPORT void effect_updateparams(effect_t effect); +EXPORT void gs_effect_update_params(gs_effect_t effect); -EXPORT eparam_t effect_getviewprojmatrix(effect_t effect); -EXPORT eparam_t effect_getworldmatrix(effect_t effect); +EXPORT gs_eparam_t gs_effect_get_viewproj_matrix(gs_effect_t effect); +EXPORT gs_eparam_t gs_effect_get_world_matrix(gs_effect_t effect); -EXPORT void effect_getparaminfo(eparam_t param, struct effect_param_info *info); -EXPORT void effect_setbool(eparam_t param, bool val); -EXPORT void effect_setfloat(eparam_t param, float val); -EXPORT void effect_setint(eparam_t param, int val); -EXPORT void effect_setmatrix4(eparam_t param, const struct matrix4 *val); -EXPORT void effect_setvec2(eparam_t param, const struct vec2 *val); -EXPORT void effect_setvec3(eparam_t param, const struct vec3 *val); -EXPORT void effect_setvec4(eparam_t param, const struct vec4 *val); -EXPORT void effect_settexture(eparam_t param, texture_t val); -EXPORT void effect_setval(eparam_t param, const void *val, size_t size); -EXPORT void effect_setdefault(eparam_t param); +EXPORT void gs_effect_get_param_info(gs_eparam_t param, + struct gs_effect_param_info *info); +EXPORT void gs_effect_set_bool(gs_eparam_t param, bool val); +EXPORT void gs_effect_set_float(gs_eparam_t param, float val); +EXPORT void gs_effect_set_int(gs_eparam_t param, int val); +EXPORT void gs_effect_set_matrix4(gs_eparam_t param, const struct matrix4 *val); +EXPORT void gs_effect_set_vec2(gs_eparam_t param, const struct vec2 *val); +EXPORT void gs_effect_set_vec3(gs_eparam_t param, const struct vec3 *val); +EXPORT void gs_effect_set_vec4(gs_eparam_t param, const struct vec4 *val); +EXPORT void gs_effect_set_texture(gs_eparam_t param, gs_texture_t val); +EXPORT void gs_effect_set_val(gs_eparam_t param, const void *val, size_t size); +EXPORT void gs_effect_set_default(gs_eparam_t param); /* --------------------------------------------------- * texture render helper functions * --------------------------------------------------- */ -EXPORT texrender_t texrender_create(enum gs_color_format format, +EXPORT gs_texrender_t gs_texrender_create(enum gs_color_format format, enum gs_zstencil_format zsformat); -EXPORT void texrender_destroy(texrender_t texrender); -EXPORT bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy); -EXPORT void texrender_end(texrender_t texrender); -EXPORT void texrender_reset(texrender_t texrender); -EXPORT texture_t texrender_gettexture(texrender_t texrender); +EXPORT void gs_texrender_destroy(gs_texrender_t texrender); +EXPORT bool gs_texrender_begin(gs_texrender_t texrender, uint32_t cx, + uint32_t cy); +EXPORT void gs_texrender_end(gs_texrender_t texrender); +EXPORT void gs_texrender_reset(gs_texrender_t texrender); +EXPORT gs_texture_t gs_texrender_get_texture(gs_texrender_t texrender); /* --------------------------------------------------- * graphics subsystem * --------------------------------------------------- */ -#define GS_BUILDMIPMAPS (1<<0) -#define GS_DYNAMIC (1<<1) -#define GS_RENDERTARGET (1<<2) -#define GS_GL_DUMMYTEX (1<<3) /**<< texture with no allocated texture data */ +#define GS_BUILD_MIPMAPS (1<<0) +#define GS_DYNAMIC (1<<1) +#define GS_RENDER_TARGET (1<<2) +#define GS_GL_DUMMYTEX (1<<3) /**<< texture with no allocated texture data */ /* ---------------- */ /* global functions */ @@ -420,16 +427,16 @@ struct gs_init_data { #define GS_DEVICE_OPENGL 1 #define GS_DEVICE_DIRECT3D_11 2 -EXPORT const char *gs_device_name(void); -EXPORT int gs_device_type(void); +EXPORT const char *gs_get_device_name(void); +EXPORT int gs_get_device_type(void); EXPORT int gs_create(graphics_t *graphics, const char *module, struct gs_init_data *data); EXPORT void gs_destroy(graphics_t graphics); -EXPORT void gs_entercontext(graphics_t graphics); -EXPORT void gs_leavecontext(void); -EXPORT graphics_t gs_getcontext(void); +EXPORT void gs_enter_context(graphics_t graphics); +EXPORT void gs_leave_context(void); +EXPORT graphics_t gs_get_context(void); EXPORT void gs_matrix_push(void); EXPORT void gs_matrix_pop(void); @@ -446,9 +453,9 @@ EXPORT void gs_matrix_rotaa4f(float x, float y, float z, float angle); EXPORT void gs_matrix_translate3f(float x, float y, float z); EXPORT void gs_matrix_scale3f(float x, float y, float z); -EXPORT void gs_renderstart(bool b_new); -EXPORT void gs_renderstop(enum gs_draw_mode mode); -EXPORT vertbuffer_t gs_rendersave(void); +EXPORT void gs_render_start(bool b_new); +EXPORT void gs_render_stop(enum gs_draw_mode mode); +EXPORT gs_vertbuffer_t gs_render_save(void); EXPORT void gs_vertex2f(float x, float y); EXPORT void gs_vertex3f(float x, float y, float z); EXPORT void gs_normal3f(float x, float y, float z); @@ -460,20 +467,20 @@ EXPORT void gs_normal3v(const struct vec3 *v); EXPORT void gs_color4v(const struct vec4 *v); EXPORT void gs_texcoord2v(const struct vec2 *v, int unit); -EXPORT input_t gs_getinput(void); -EXPORT effect_t gs_geteffect(void); +EXPORT input_t gs_get_input(void); +EXPORT gs_effect_t gs_get_effect(void); -EXPORT effect_t gs_create_effect_from_file(const char *file, +EXPORT gs_effect_t gs_effect_create_from_file(const char *file, char **error_string); -EXPORT effect_t gs_create_effect(const char *effect_string, +EXPORT gs_effect_t gs_effect_create(const char *effect_string, const char *filename, char **error_string); -EXPORT shader_t gs_create_vertexshader_from_file(const char *file, +EXPORT gs_shader_t gs_vertexshader_create_from_file(const char *file, char **error_string); -EXPORT shader_t gs_create_pixelshader_from_file(const char *file, +EXPORT gs_shader_t gs_pixelshader_create_from_file(const char *file, char **error_string); -EXPORT texture_t gs_create_texture_from_file(const char *file); +EXPORT gs_texture_t gs_texture_create_from_file(const char *file); #define GS_FLIP_U (1<<0) #define GS_FLIP_V (1<<1) @@ -485,26 +492,26 @@ EXPORT texture_t gs_create_texture_from_file(const char *file); * The flip value specifies whether the texture shoudl be flipped on the U or V * axis with GS_FLIP_U and GS_FLIP_V. */ -EXPORT void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width, +EXPORT void gs_draw_sprite(gs_texture_t tex, uint32_t flip, uint32_t width, uint32_t height); -EXPORT void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot, +EXPORT void gs_draw_cube_backdrop(gs_texture_t cubetex, const struct quat *rot, float left, float right, float top, float bottom, float znear); /** sets the viewport to current swap chain size */ -EXPORT void gs_resetviewport(void); +EXPORT void gs_reset_viewport(void); /** sets default screen-sized orthographich mode */ -EXPORT void gs_set2dmode(void); +EXPORT void gs_set_2d_mode(void); /** sets default screen-sized perspective mode */ -EXPORT void gs_set3dmode(double fovy, double znear, double zvar); +EXPORT void gs_set_3d_mode(double fovy, double znear, double zvar); EXPORT void gs_viewport_push(void); EXPORT void gs_viewport_pop(void); -EXPORT void texture_setimage(texture_t tex, const uint8_t *data, +EXPORT void gs_texture_set_image(gs_texture_t tex, const uint8_t *data, uint32_t linesize, bool invert); -EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side, +EXPORT void gs_cubetexture_set_image(gs_texture_t cubetex, uint32_t side, const void *data, uint32_t linesize, bool invert); EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar); @@ -514,104 +521,106 @@ EXPORT void gs_reset_blend_state(void); /* -------------------------- */ /* library-specific functions */ -EXPORT swapchain_t gs_create_swapchain(struct gs_init_data *data); +EXPORT gs_swapchain_t gs_swapchain_create(struct gs_init_data *data); EXPORT void gs_resize(uint32_t x, uint32_t y); -EXPORT void gs_getsize(uint32_t *x, uint32_t *y); -EXPORT uint32_t gs_getwidth(void); -EXPORT uint32_t gs_getheight(void); +EXPORT void gs_get_size(uint32_t *x, uint32_t *y); +EXPORT uint32_t gs_get_width(void); +EXPORT uint32_t gs_get_height(void); -EXPORT texture_t gs_create_texture(uint32_t width, uint32_t height, +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); -EXPORT texture_t gs_create_cubetexture(uint32_t size, +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); -EXPORT texture_t gs_create_volumetexture(uint32_t width, uint32_t height, +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 zstencil_t gs_create_zstencil(uint32_t width, uint32_t height, +EXPORT gs_zstencil_t gs_zstencil_create(uint32_t width, uint32_t height, enum gs_zstencil_format format); -EXPORT stagesurf_t gs_create_stagesurface(uint32_t width, uint32_t height, +EXPORT gs_stagesurf_t gs_stagesurface_create(uint32_t width, uint32_t height, enum gs_color_format color_format); -EXPORT samplerstate_t gs_create_samplerstate(struct gs_sampler_info *info); +EXPORT gs_samplerstate_t gs_samplerstate_create(struct gs_sampler_info *info); -EXPORT shader_t gs_create_vertexshader(const char *shader, +EXPORT gs_shader_t gs_vertexshader_create(const char *shader, const char *file, char **error_string); -EXPORT shader_t gs_create_pixelshader(const char *shader, +EXPORT gs_shader_t gs_pixelshader_create(const char *shader, const char *file, char **error_string); -EXPORT vertbuffer_t gs_create_vertexbuffer(struct vb_data *data, +EXPORT gs_vertbuffer_t gs_vertexbuffer_create(struct gs_vb_data *data, uint32_t flags); -EXPORT indexbuffer_t gs_create_indexbuffer(enum gs_index_type type, +EXPORT gs_indexbuffer_t gs_indexbuffer_create(enum gs_index_type type, void *indices, size_t num, uint32_t flags); -EXPORT enum gs_texture_type gs_gettexturetype(texture_t texture); +EXPORT enum gs_texture_type gs_get_texture_type(gs_texture_t texture); -EXPORT void gs_load_vertexbuffer(vertbuffer_t vertbuffer); -EXPORT void gs_load_indexbuffer(indexbuffer_t indexbuffer); -EXPORT void gs_load_texture(texture_t tex, int unit); -EXPORT void gs_load_samplerstate(samplerstate_t samplerstate, int unit); -EXPORT void gs_load_vertexshader(shader_t vertshader); -EXPORT void gs_load_pixelshader(shader_t pixelshader); +EXPORT void gs_load_vertexbuffer(gs_vertbuffer_t vertbuffer); +EXPORT void gs_load_indexbuffer(gs_indexbuffer_t indexbuffer); +EXPORT void gs_load_texture(gs_texture_t tex, int unit); +EXPORT void gs_load_samplerstate(gs_samplerstate_t samplerstate, int unit); +EXPORT void gs_load_vertexshader(gs_shader_t vertshader); +EXPORT void gs_load_pixelshader(gs_shader_t pixelshader); -EXPORT void gs_load_defaultsamplerstate(bool b_3d, int unit); +EXPORT void gs_load_default_samplerstate(bool b_3d, int unit); -EXPORT shader_t gs_getvertexshader(void); -EXPORT shader_t gs_getpixelshader(void); +EXPORT gs_shader_t gs_get_vertex_shader(void); +EXPORT gs_shader_t gs_get_pixel_shader(void); -EXPORT texture_t gs_getrendertarget(void); -EXPORT zstencil_t gs_getzstenciltarget(void); +EXPORT gs_texture_t gs_get_render_target(void); +EXPORT gs_zstencil_t gs_get_zstencil_target(void); -EXPORT void gs_setrendertarget(texture_t tex, zstencil_t zstencil); -EXPORT void gs_setcuberendertarget(texture_t cubetex, int side, - zstencil_t zstencil); +EXPORT void gs_set_render_target(gs_texture_t tex, gs_zstencil_t zstencil); +EXPORT void gs_set_cube_render_target(gs_texture_t cubetex, int side, + gs_zstencil_t zstencil); -EXPORT void gs_copy_texture(texture_t dst, texture_t src); +EXPORT void gs_copy_texture(gs_texture_t dst, gs_texture_t src); EXPORT void gs_copy_texture_region( - texture_t dst, uint32_t dst_x, uint32_t dst_y, - texture_t src, uint32_t src_x, uint32_t src_y, + 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_stage_texture(stagesurf_t dst, texture_t src); +EXPORT void gs_stage_texture(gs_stagesurf_t dst, gs_texture_t src); -EXPORT void gs_beginscene(void); +EXPORT void gs_begin_scene(void); EXPORT void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts); -EXPORT void gs_endscene(void); +EXPORT void gs_end_scene(void); #define GS_CLEAR_COLOR (1<<0) #define GS_CLEAR_DEPTH (1<<1) #define GS_CLEAR_STENCIL (1<<2) -EXPORT void gs_load_swapchain(swapchain_t swapchain); +EXPORT void gs_load_swapchain(gs_swapchain_t swapchain); EXPORT void gs_clear(uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); EXPORT void gs_present(void); EXPORT void gs_flush(void); -EXPORT void gs_setcullmode(enum gs_cull_mode mode); -EXPORT enum gs_cull_mode gs_getcullmode(void); +EXPORT void gs_set_cull_mode(enum gs_cull_mode mode); +EXPORT enum gs_cull_mode gs_get_cull_mode(void); EXPORT void gs_enable_blending(bool enable); -EXPORT void gs_enable_depthtest(bool enable); -EXPORT void gs_enable_stenciltest(bool enable); -EXPORT void gs_enable_stencilwrite(bool enable); +EXPORT void gs_enable_depth_test(bool enable); +EXPORT void gs_enable_stencil_test(bool enable); +EXPORT void gs_enable_stencil_write(bool enable); EXPORT void gs_enable_color(bool red, bool green, bool blue, bool alpha); -EXPORT void gs_blendfunction(enum gs_blend_type src, enum gs_blend_type dest); -EXPORT void gs_depthfunction(enum gs_depth_test test); +EXPORT void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest); +EXPORT void gs_depth_function(enum gs_depth_test test); -EXPORT void gs_stencilfunction(enum gs_stencil_side side, +EXPORT void gs_stencil_function(enum gs_stencil_side side, enum gs_depth_test test); -EXPORT void gs_stencilop(enum gs_stencil_side side, enum gs_stencil_op fail, - enum gs_stencil_op zfail, enum gs_stencil_op zpass); +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 void gs_setviewport(int x, int y, int width, int height); -EXPORT void gs_getviewport(struct gs_rect *rect); -EXPORT void gs_setscissorrect(struct gs_rect *rect); +EXPORT void gs_set_viewport(int x, int y, int width, int height); +EXPORT void gs_get_viewport(struct gs_rect *rect); +EXPORT void gs_set_scissor_rect(struct gs_rect *rect); EXPORT void gs_ortho(float left, float right, float top, float bottom, float znear, float zfar); @@ -621,72 +630,75 @@ EXPORT void gs_frustum(float left, float right, float top, float bottom, EXPORT void gs_projection_push(void); EXPORT void gs_projection_pop(void); -EXPORT void swapchain_destroy(swapchain_t swapchain); +EXPORT void gs_swapchain_destroy(gs_swapchain_t swapchain); -EXPORT void texture_destroy(texture_t tex); -EXPORT uint32_t texture_getwidth(texture_t tex); -EXPORT uint32_t texture_getheight(texture_t tex); -EXPORT enum gs_color_format texture_getcolorformat(texture_t tex); -EXPORT bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize); -EXPORT void texture_unmap(texture_t tex); +EXPORT void gs_texture_destroy(gs_texture_t tex); +EXPORT uint32_t gs_texture_get_width(gs_texture_t tex); +EXPORT uint32_t gs_texture_get_height(gs_texture_t tex); +EXPORT enum gs_color_format gs_texture_get_color_format(gs_texture_t tex); +EXPORT bool gs_texture_map(gs_texture_t tex, uint8_t **ptr, + uint32_t *linesize); +EXPORT void gs_texture_unmap(gs_texture_t tex); /** special-case function (GL only) - specifies whether the texture is a * GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture * coordinates, doesn't support mipmapping, and requires address clamping */ -EXPORT bool texture_isrect(texture_t tex); +EXPORT bool gs_texture_is_rect(gs_texture_t tex); /** * Gets a pointer to the context-specific object associated with the texture. * For example, for GL, this is a GLuint*. For D3D11, ID3D11Texture2D*. */ -EXPORT void *texture_getobj(texture_t tex); +EXPORT void *gs_texture_get_obj(gs_texture_t tex); -EXPORT void cubetexture_destroy(texture_t cubetex); -EXPORT uint32_t cubetexture_getsize(texture_t cubetex); -EXPORT enum gs_color_format cubetexture_getcolorformat(texture_t cubetex); +EXPORT void gs_cubetexture_destroy(gs_texture_t cubetex); +EXPORT uint32_t gs_cubetexture_get_size(gs_texture_t cubetex); +EXPORT enum gs_color_format gs_cubetexture_get_color_format( + gs_texture_t cubetex); -EXPORT void volumetexture_destroy(texture_t voltex); -EXPORT uint32_t volumetexture_getwidth(texture_t voltex); -EXPORT uint32_t volumetexture_getheight(texture_t voltex); -EXPORT uint32_t volumetexture_getdepth(texture_t voltex); -EXPORT enum gs_color_format volumetexture_getcolorformat(texture_t voltex); +EXPORT void gs_voltexture_destroy(gs_texture_t voltex); +EXPORT uint32_t gs_voltexture_get_width(gs_texture_t voltex); +EXPORT uint32_t gs_voltexture_get_height(gs_texture_t voltex); +EXPORT uint32_t gs_voltexture_getdepth(gs_texture_t voltex); +EXPORT enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex); -EXPORT void stagesurface_destroy(stagesurf_t stagesurf); -EXPORT uint32_t stagesurface_getwidth(stagesurf_t stagesurf); -EXPORT uint32_t stagesurface_getheight(stagesurf_t stagesurf); -EXPORT enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf); -EXPORT bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, +EXPORT void gs_stagesurface_destroy(gs_stagesurf_t stagesurf); +EXPORT uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf); +EXPORT uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf); +EXPORT enum gs_color_format gs_stagesurface_get_color_format( + gs_stagesurf_t stagesurf); +EXPORT bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize); -EXPORT void stagesurface_unmap(stagesurf_t stagesurf); +EXPORT void gs_stagesurface_unmap(gs_stagesurf_t stagesurf); -EXPORT void zstencil_destroy(zstencil_t zstencil); +EXPORT void gs_zstencil_destroy(gs_zstencil_t zstencil); -EXPORT void samplerstate_destroy(samplerstate_t samplerstate); +EXPORT void gs_samplerstate_destroy(gs_samplerstate_t samplerstate); -EXPORT void vertexbuffer_destroy(vertbuffer_t vertbuffer); -EXPORT void vertexbuffer_flush(vertbuffer_t vertbuffer); -EXPORT struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer); +EXPORT void gs_vertexbuffer_destroy(gs_vertbuffer_t vertbuffer); +EXPORT void gs_vertexbuffer_flush(gs_vertbuffer_t vertbuffer); +EXPORT struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vertbuffer); -EXPORT void indexbuffer_destroy(indexbuffer_t indexbuffer); -EXPORT void indexbuffer_flush(indexbuffer_t indexbuffer); -EXPORT void *indexbuffer_getdata(indexbuffer_t indexbuffer); -EXPORT size_t indexbuffer_numindices(indexbuffer_t indexbuffer); -EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer); +EXPORT void gs_indexbuffer_destroy(gs_indexbuffer_t indexbuffer); +EXPORT void gs_indexbuffer_flush(gs_indexbuffer_t indexbuffer); +EXPORT void *gs_indexbuffer_get_data(gs_indexbuffer_t indexbuffer); +EXPORT size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t indexbuffer); +EXPORT enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t indexbuffer); #ifdef __APPLE__ /** platform specific function for creating (GL_TEXTURE_RECTANGLE) textures * from shared surface resources */ -EXPORT texture_t gs_create_texture_from_iosurface(void *iosurf); -EXPORT bool texture_rebind_iosurface(texture_t texture, void *iosurf); +EXPORT gs_texture_t gs_texture_create_from_iosurface(void *iosurf); +EXPORT bool gs_texture_rebind_iosurface(gs_texture_t texture, void *iosurf); #elif _WIN32 EXPORT bool gs_gdi_texture_available(void); /** creates a windows GDI-lockable texture */ -EXPORT texture_t gs_create_gdi_texture(uint32_t width, uint32_t height); +EXPORT gs_texture_t gs_texture_create_gdi(uint32_t width, uint32_t height); -EXPORT void *texture_get_dc(texture_t gdi_tex); -EXPORT void texture_release_dc(texture_t gdi_tex); +EXPORT void *gs_texture_get_dc(gs_texture_t gdi_tex); +EXPORT void gs_texture_release_dc(gs_texture_t gdi_tex); #endif @@ -723,7 +735,7 @@ static inline bool gs_is_compressed_format(enum gs_color_format format) return (format == GS_DXT1 || format == GS_DXT3 || format == GS_DXT5); } -static inline uint32_t gs_num_total_levels(uint32_t width, uint32_t height) +static inline uint32_t gs_get_total_levels(uint32_t width, uint32_t height) { uint32_t size = width > height ? width : height; uint32_t num_levels = 0; diff --git a/libobs/graphics/shader-parser.c b/libobs/graphics/shader-parser.c index dfd71617a..7e3452865 100644 --- a/libobs/graphics/shader-parser.c +++ b/libobs/graphics/shader-parser.c @@ -17,28 +17,28 @@ #include "shader-parser.h" -enum shader_param_type get_shader_param_type(const char *type) +enum gs_shader_param_type get_shader_param_type(const char *type) { if (strcmp(type, "float") == 0) - return SHADER_PARAM_FLOAT; + return GS_SHADER_PARAM_FLOAT; else if (strcmp(type, "float2") == 0) - return SHADER_PARAM_VEC2; + return GS_SHADER_PARAM_VEC2; else if (strcmp(type, "float3") == 0) - return SHADER_PARAM_VEC3; + return GS_SHADER_PARAM_VEC3; else if (strcmp(type, "float4") == 0) - return SHADER_PARAM_VEC4; + return GS_SHADER_PARAM_VEC4; else if (astrcmp_n(type, "texture", 7) == 0) - return SHADER_PARAM_TEXTURE; + return GS_SHADER_PARAM_TEXTURE; else if (strcmp(type, "float4x4") == 0) - return SHADER_PARAM_MATRIX4X4; + return GS_SHADER_PARAM_MATRIX4X4; else if (strcmp(type, "bool") == 0) - return SHADER_PARAM_BOOL; + return GS_SHADER_PARAM_BOOL; else if (strcmp(type, "int") == 0) - return SHADER_PARAM_INT; + return GS_SHADER_PARAM_INT; else if (strcmp(type, "string") == 0) - return SHADER_PARAM_STRING; + return GS_SHADER_PARAM_STRING; - return SHADER_PARAM_UNKNOWN; + return GS_SHADER_PARAM_UNKNOWN; } enum gs_sample_filter get_sample_filter(const char *filter) diff --git a/libobs/graphics/shader-parser.h b/libobs/graphics/shader-parser.h index 9b7396742..5e8f07c5d 100644 --- a/libobs/graphics/shader-parser.h +++ b/libobs/graphics/shader-parser.h @@ -24,7 +24,7 @@ extern "C" { #endif -EXPORT enum shader_param_type get_shader_param_type(const char *type); +EXPORT enum gs_shader_param_type get_shader_param_type(const char *type); EXPORT enum gs_sample_filter get_sample_filter(const char *filter); EXPORT enum gs_address_mode get_address_mode(const char *address_mode); diff --git a/libobs/graphics/texture-render.c b/libobs/graphics/texture-render.c index 577f38474..25008ad77 100644 --- a/libobs/graphics/texture-render.c +++ b/libobs/graphics/texture-render.c @@ -24,8 +24,8 @@ #include "graphics.h" struct gs_texture_render { - texture_t target, prev_target; - zstencil_t zs, prev_zs; + gs_texture_t target, prev_target; + gs_zstencil_t zs, prev_zs; uint32_t cx, cy; @@ -35,7 +35,7 @@ struct gs_texture_render { bool rendered; }; -texrender_t texrender_create(enum gs_color_format format, +gs_texrender_t gs_texrender_create(enum gs_color_format format, enum gs_zstencil_format zsformat) { struct gs_texture_render *texrender; @@ -46,38 +46,38 @@ texrender_t texrender_create(enum gs_color_format format, return texrender; } -void texrender_destroy(texrender_t texrender) +void gs_texrender_destroy(gs_texrender_t texrender) { if (texrender) { - texture_destroy(texrender->target); - zstencil_destroy(texrender->zs); + gs_texture_destroy(texrender->target); + gs_zstencil_destroy(texrender->zs); bfree(texrender); } } -static bool texrender_resetbuffer(texrender_t texrender, uint32_t cx, +static bool texrender_resetbuffer(gs_texrender_t texrender, uint32_t cx, uint32_t cy) { if (!texrender) return false; - texture_destroy(texrender->target); - zstencil_destroy(texrender->zs); + gs_texture_destroy(texrender->target); + gs_zstencil_destroy(texrender->zs); texrender->target = NULL; texrender->zs = NULL; texrender->cx = cx; texrender->cy = cy; - texrender->target = gs_create_texture(cx, cy, texrender->format, - 1, NULL, GS_RENDERTARGET); + texrender->target = gs_texture_create(cx, cy, texrender->format, + 1, NULL, GS_RENDER_TARGET); if (!texrender->target) return false; if (texrender->zsformat != GS_ZS_NONE) { - texrender->zs = gs_create_zstencil(cx, cy, texrender->zsformat); + texrender->zs = gs_zstencil_create(cx, cy, texrender->zsformat); if (!texrender->zs) { - texture_destroy(texrender->target); + gs_texture_destroy(texrender->target); texrender->target = NULL; return false; @@ -87,15 +87,15 @@ static bool texrender_resetbuffer(texrender_t texrender, uint32_t cx, return true; } -bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy) +bool gs_texrender_begin(gs_texrender_t texrender, uint32_t cx, uint32_t cy) { if (!texrender || texrender->rendered) return false; if (cx == 0) - cx = gs_getwidth(); + cx = gs_get_width(); if (cy == 0) - cy = gs_getheight(); + cy = gs_get_height(); assert(cx && cy); if (!cx || !cy) @@ -110,21 +110,21 @@ bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy) gs_matrix_push(); gs_matrix_identity(); - texrender->prev_target = gs_getrendertarget(); - texrender->prev_zs = gs_getzstenciltarget(); - gs_setrendertarget(texrender->target, texrender->zs); + texrender->prev_target = gs_get_render_target(); + texrender->prev_zs = gs_get_zstencil_target(); + gs_set_render_target(texrender->target, texrender->zs); - gs_setviewport(0, 0, texrender->cx, texrender->cy); + gs_set_viewport(0, 0, texrender->cx, texrender->cy); return true; } -void texrender_end(texrender_t texrender) +void gs_texrender_end(gs_texrender_t texrender) { if (!texrender) return; - gs_setrendertarget(texrender->prev_target, texrender->prev_zs); + gs_set_render_target(texrender->prev_target, texrender->prev_zs); gs_matrix_pop(); gs_projection_pop(); @@ -133,13 +133,13 @@ void texrender_end(texrender_t texrender) texrender->rendered = true; } -void texrender_reset(texrender_t texrender) +void gs_texrender_reset(gs_texrender_t texrender) { if (texrender) texrender->rendered = false; } -texture_t texrender_gettexture(texrender_t texrender) +gs_texture_t gs_texrender_get_texture(gs_texrender_t texrender) { return texrender ? texrender->target : NULL; } diff --git a/libobs/obs-display.c b/libobs/obs-display.c index e1a789bc7..ef956bd3b 100644 --- a/libobs/obs-display.c +++ b/libobs/obs-display.c @@ -25,7 +25,7 @@ bool obs_display_init(struct obs_display *display, pthread_mutex_init_value(&display->draw_callbacks_mutex); if (graphics_data) { - display->swap = gs_create_swapchain(graphics_data); + display->swap = gs_swapchain_create(graphics_data); if (!display->swap) { blog(LOG_ERROR, "obs_display_init: Failed to " "create swap chain"); @@ -48,7 +48,7 @@ obs_display_t obs_display_create(struct gs_init_data *graphics_data) { struct obs_display *display = bzalloc(sizeof(struct obs_display)); - gs_entercontext(obs->video.graphics); + gs_enter_context(obs->video.graphics); if (!graphics_data->num_backbuffers) graphics_data->num_backbuffers = 1; @@ -66,7 +66,7 @@ obs_display_t obs_display_create(struct gs_init_data *graphics_data) pthread_mutex_unlock(&obs->data.displays_mutex); } - gs_leavecontext(); + gs_leave_context(); return display; } @@ -77,7 +77,7 @@ void obs_display_free(obs_display_t display) da_free(display->draw_callbacks); if (display->swap) { - swapchain_destroy(display->swap); + gs_swapchain_destroy(display->swap); display->swap = NULL; } } @@ -149,24 +149,24 @@ static inline void render_display_begin(struct obs_display *display) display->size_changed = false; } - gs_beginscene(); + gs_begin_scene(); vec4_set(&clear_color, 0.3f, 0.3f, 0.3f, 1.0f); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL, &clear_color, 1.0f, 0); - gs_enable_depthtest(false); + gs_enable_depth_test(false); /* gs_enable_blending(false); */ - gs_setcullmode(GS_NEITHER); + gs_set_cull_mode(GS_NEITHER); gs_ortho(0.0f, (float)display->cx, 0.0f, (float)display->cy, -100.0f, 100.0f); - gs_setviewport(0, 0, display->cx, display->cy); + gs_set_viewport(0, 0, display->cx, display->cy); } static inline void render_display_end() { - gs_endscene(); + gs_end_scene(); gs_present(); } diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 9bd9d7239..2afe1658e 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -113,7 +113,7 @@ extern void obs_view_free(struct obs_view *view); struct obs_display { bool size_changed; uint32_t cx, cy; - swapchain_t swap; + gs_swapchain_t swap; pthread_mutex_t draw_callbacks_mutex; DARRAY(struct draw_callback) draw_callbacks; @@ -131,19 +131,19 @@ extern void obs_display_free(struct obs_display *display); struct obs_core_video { graphics_t graphics; - stagesurf_t copy_surfaces[NUM_TEXTURES]; - texture_t render_textures[NUM_TEXTURES]; - texture_t output_textures[NUM_TEXTURES]; - texture_t convert_textures[NUM_TEXTURES]; + gs_stagesurf_t copy_surfaces[NUM_TEXTURES]; + gs_texture_t render_textures[NUM_TEXTURES]; + gs_texture_t output_textures[NUM_TEXTURES]; + gs_texture_t convert_textures[NUM_TEXTURES]; bool textures_rendered[NUM_TEXTURES]; bool textures_output[NUM_TEXTURES]; bool textures_copied[NUM_TEXTURES]; bool textures_converted[NUM_TEXTURES]; struct obs_source_frame convert_frames[NUM_TEXTURES]; - effect_t default_effect; - effect_t solid_effect; - effect_t conversion_effect; - stagesurf_t mapped_surface; + gs_effect_t default_effect; + gs_effect_t solid_effect; + gs_effect_t conversion_effect; + gs_stagesurf_t mapped_surface; int cur_texture; video_t video; @@ -339,8 +339,8 @@ struct obs_source { float transition_volume; /* async video data */ - texture_t async_texture; - texrender_t async_convert_texrender; + gs_texture_t async_texture; + gs_texrender_t async_convert_texrender; bool async_gpu_conversion; enum video_format async_format; enum gs_color_format async_texture_format; @@ -362,7 +362,7 @@ struct obs_source { struct obs_source *filter_target; DARRAY(struct obs_source*) filters; pthread_mutex_t filter_mutex; - texrender_t filter_texrender; + gs_texrender_t filter_texrender; bool rendering_filter; }; diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index daeaffb61..29c2ab897 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -297,7 +297,7 @@ static inline bool source_size_changed(struct obs_scene_item *item) return item->last_width != width || item->last_height != height; } -static void scene_video_render(void *data, effect_t effect) +static void scene_video_render(void *data, gs_effect_t effect) { struct obs_scene *scene = data; struct obs_scene_item *item; diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 47f887f79..35a4c058e 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -241,10 +241,10 @@ void obs_source_destroy(struct obs_source *source) for (i = 0; i < source->video_frames.num; i++) obs_source_frame_destroy(source->video_frames.array[i]); - gs_entercontext(obs->video.graphics); - texrender_destroy(source->async_convert_texrender); - texture_destroy(source->async_texture); - gs_leavecontext(); + gs_enter_context(obs->video.graphics); + gs_texrender_destroy(source->async_convert_texrender); + gs_texture_destroy(source->async_texture); + gs_leave_context(); for (i = 0; i < MAX_AV_PLANES; i++) bfree(source->audio_data.data[i]); @@ -252,7 +252,7 @@ void obs_source_destroy(struct obs_source *source) audio_line_destroy(source->audio_line); audio_resampler_destroy(source->resampler); - texrender_destroy(source->filter_texrender); + gs_texrender_destroy(source->filter_texrender); da_free(source->video_frames); da_free(source->filters); pthread_mutex_destroy(&source->filter_mutex); @@ -499,7 +499,7 @@ void obs_source_video_tick(obs_source_t source, float seconds) /* reset the filter render texture information once every frame */ if (source->filter_texrender) - texrender_reset(source->filter_texrender); + gs_texrender_reset(source->filter_texrender); if (source->context.data && source->info.video_tick) source->info.video_tick(source->context.data, seconds); @@ -772,17 +772,17 @@ static inline bool set_async_texture_size(struct obs_source *source, return true; } - texture_destroy(source->async_texture); - texrender_destroy(source->async_convert_texrender); + gs_texture_destroy(source->async_texture); + gs_texrender_destroy(source->async_convert_texrender); source->async_convert_texrender = NULL; if (cur != CONVERT_NONE && init_gpu_conversion(source, frame)) { source->async_gpu_conversion = true; source->async_convert_texrender = - texrender_create(GS_BGRX, GS_ZS_NONE); + gs_texrender_create(GS_BGRX, GS_ZS_NONE); - source->async_texture = gs_create_texture( + source->async_texture = gs_texture_create( source->async_convert_width, source->async_convert_height, source->async_texture_format, @@ -793,7 +793,7 @@ static inline bool set_async_texture_size(struct obs_source *source, frame->format); source->async_gpu_conversion = false; - source->async_texture = gs_create_texture( + source->async_texture = gs_texture_create( frame->width, frame->height, format, 1, NULL, GS_DYNAMIC); } @@ -806,18 +806,18 @@ static inline bool set_async_texture_size(struct obs_source *source, return true; } -static void upload_raw_frame(texture_t tex, +static void upload_raw_frame(gs_texture_t tex, const struct obs_source_frame *frame) { switch (get_convert_type(frame->format)) { case CONVERT_422_U: case CONVERT_422_Y: - texture_setimage(tex, frame->data[0], + gs_texture_set_image(tex, frame->data[0], frame->linesize[0], false); break; case CONVERT_420: - texture_setimage(tex, frame->data[0], + gs_texture_set_image(tex, frame->data[0], frame->width, false); break; @@ -860,19 +860,19 @@ static const char *select_conversion_technique(enum video_format format) return NULL; } -static inline void set_eparam(effect_t effect, const char *name, float val) +static inline void set_eparam(gs_effect_t effect, const char *name, float val) { - eparam_t param = effect_getparambyname(effect, name); - effect_setfloat(param, val); + gs_eparam_t param = gs_effect_get_param_by_name(effect, name); + gs_effect_set_float(param, val); } static bool update_async_texrender(struct obs_source *source, const struct obs_source_frame *frame) { - texture_t tex = source->async_texture; - texrender_t texrender = source->async_convert_texrender; + gs_texture_t tex = source->async_texture; + gs_texrender_t texrender = source->async_convert_texrender; - texrender_reset(texrender); + gs_texrender_reset(texrender); upload_raw_frame(tex, frame); @@ -882,17 +882,17 @@ static bool update_async_texrender(struct obs_source *source, float convert_width = (float)source->async_convert_width; float convert_height = (float)source->async_convert_height; - effect_t conv = obs->video.conversion_effect; - technique_t tech = effect_gettechnique(conv, + gs_effect_t conv = obs->video.conversion_effect; + gs_technique_t tech = gs_effect_get_technique(conv, select_conversion_technique(frame->format)); - if (!texrender_begin(texrender, cx, cy)) + if (!gs_texrender_begin(texrender, cx, cy)) return false; - technique_begin(tech); - technique_beginpass(tech, 0); + gs_technique_begin(tech); + gs_technique_begin_pass(tech, 0); - effect_settexture(effect_getparambyname(conv, "image"), tex); + gs_effect_set_texture(gs_effect_get_param_by_name(conv, "image"), tex); set_eparam(conv, "width", (float)cx); set_eparam(conv, "height", (float)cy); set_eparam(conv, "width_i", 1.0f / cx); @@ -916,10 +916,10 @@ static bool update_async_texrender(struct obs_source *source, gs_draw_sprite(tex, 0, cx, cy); - technique_endpass(tech); - technique_end(tech); + gs_technique_end_pass(tech); + gs_technique_end(tech); - texrender_end(texrender); + gs_texrender_end(texrender); return true; } @@ -927,8 +927,8 @@ static bool update_async_texrender(struct obs_source *source, static bool update_async_texture(struct obs_source *source, const struct obs_source_frame *frame) { - texture_t tex = source->async_texture; - texrender_t texrender = source->async_convert_texrender; + gs_texture_t tex = source->async_texture; + gs_texrender_t texrender = source->async_convert_texrender; enum convert_type type = get_convert_type(frame->format); uint8_t *ptr; uint32_t linesize; @@ -947,12 +947,12 @@ static bool update_async_texture(struct obs_source *source, return update_async_texrender(source, frame); if (type == CONVERT_NONE) { - texture_setimage(tex, frame->data[0], frame->linesize[0], + gs_texture_set_image(tex, frame->data[0], frame->linesize[0], false); return true; } - if (!texture_map(tex, &ptr, &linesize)) + if (!gs_texture_map(tex, &ptr, &linesize)) return false; if (type == CONVERT_420) @@ -973,57 +973,57 @@ static bool update_async_texture(struct obs_source *source, decompress_422(frame->data[0], frame->linesize[0], 0, frame->height, ptr, linesize, false); - texture_unmap(tex); + gs_texture_unmap(tex); return true; } static inline void obs_source_draw_texture(struct obs_source *source, - effect_t effect, float *color_matrix, + gs_effect_t effect, float *color_matrix, float const *color_range_min, float const *color_range_max) { - texture_t tex = source->async_texture; - eparam_t param; + gs_texture_t tex = source->async_texture; + gs_eparam_t param; if (source->async_convert_texrender) - tex = texrender_gettexture(source->async_convert_texrender); + tex = gs_texrender_get_texture(source->async_convert_texrender); if (color_range_min) { size_t const size = sizeof(float) * 3; - param = effect_getparambyname(effect, "color_range_min"); - effect_setval(param, color_range_min, size); + param = gs_effect_get_param_by_name(effect, "color_range_min"); + gs_effect_set_val(param, color_range_min, size); } if (color_range_max) { size_t const size = sizeof(float) * 3; - param = effect_getparambyname(effect, "color_range_max"); - effect_setval(param, color_range_max, size); + param = gs_effect_get_param_by_name(effect, "color_range_max"); + gs_effect_set_val(param, color_range_max, size); } if (color_matrix) { - param = effect_getparambyname(effect, "color_matrix"); - effect_setval(param, color_matrix, sizeof(float) * 16); + param = gs_effect_get_param_by_name(effect, "color_matrix"); + gs_effect_set_val(param, color_matrix, sizeof(float) * 16); } - param = effect_getparambyname(effect, "image"); - effect_settexture(param, tex); + param = gs_effect_get_param_by_name(effect, "image"); + gs_effect_set_texture(param, tex); gs_draw_sprite(tex, source->async_flip ? GS_FLIP_V : 0, 0, 0); } static void obs_source_draw_async_texture(struct obs_source *source) { - effect_t effect = gs_geteffect(); - bool yuv = format_is_yuv(source->async_format); - bool limited_range = yuv && !source->async_full_range; - const char *type = yuv ? "DrawMatrix" : "Draw"; - bool def_draw = (!effect); - technique_t tech = NULL; + gs_effect_t effect = gs_get_effect(); + bool yuv = format_is_yuv(source->async_format); + bool limited_range = yuv && !source->async_full_range; + const char *type = yuv ? "DrawMatrix" : "Draw"; + bool def_draw = (!effect); + gs_technique_t tech = NULL; if (def_draw) { effect = obs_get_default_effect(); - tech = effect_gettechnique(effect, type); - technique_begin(tech); - technique_beginpass(tech, 0); + tech = gs_effect_get_technique(effect, type); + gs_technique_begin(tech); + gs_technique_begin_pass(tech, 0); } obs_source_draw_texture(source, effect, @@ -1032,8 +1032,8 @@ static void obs_source_draw_async_texture(struct obs_source *source) limited_range ? source->async_color_range_max : NULL); if (def_draw) { - technique_endpass(tech); - technique_end(tech); + gs_technique_end_pass(tech); + gs_technique_end(tech); } } @@ -1063,19 +1063,19 @@ static inline void obs_source_render_filters(obs_source_t source) static inline void obs_source_default_render(obs_source_t source, bool color_matrix) { - effect_t effect = obs->video.default_effect; - const char *tech_name = color_matrix ? "DrawMatrix" : "Draw"; - technique_t tech = effect_gettechnique(effect, tech_name); - size_t passes, i; + gs_effect_t effect = obs->video.default_effect; + const char *tech_name = color_matrix ? "DrawMatrix" : "Draw"; + gs_technique_t tech = gs_effect_get_technique(effect, tech_name); + size_t passes, i; - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (i = 0; i < passes; i++) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); if (source->context.data) source->info.video_render(source->context.data, effect); - technique_endpass(tech); + gs_technique_end_pass(tech); } - technique_end(tech); + gs_technique_end(tech); } static inline void obs_source_main_render(obs_source_t source) @@ -1091,7 +1091,7 @@ static inline void obs_source_main_render(obs_source_t source) obs_source_default_render(source, color_matrix); else if (source->context.data) source->info.video_render(source->context.data, - custom_draw ? NULL : gs_geteffect()); + custom_draw ? NULL : gs_get_effect()); } void obs_source_video_render(obs_source_t source) @@ -1652,42 +1652,42 @@ const char *obs_source_get_id(obs_source_t source) return source ? source->info.id : NULL; } -static inline void render_filter_bypass(obs_source_t target, effect_t effect, +static inline void render_filter_bypass(obs_source_t target, gs_effect_t effect, bool use_matrix) { const char *tech_name = use_matrix ? "DrawMatrix" : "Draw"; - technique_t tech = effect_gettechnique(effect, tech_name); + gs_technique_t tech = gs_effect_get_technique(effect, tech_name); size_t passes, i; - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (i = 0; i < passes; i++) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); obs_source_video_render(target); - technique_endpass(tech); + gs_technique_end_pass(tech); } - technique_end(tech); + gs_technique_end(tech); } -static inline void render_filter_tex(texture_t tex, effect_t effect, +static inline void render_filter_tex(gs_texture_t tex, gs_effect_t effect, uint32_t width, uint32_t height, bool use_matrix) { const char *tech_name = use_matrix ? "DrawMatrix" : "Draw"; - technique_t tech = effect_gettechnique(effect, tech_name); - eparam_t image = effect_getparambyname(effect, "image"); + gs_technique_t tech = gs_effect_get_technique(effect, tech_name); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); size_t passes, i; - effect_settexture(image, tex); + gs_effect_set_texture(image, tex); - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (i = 0; i < passes; i++) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); gs_draw_sprite(tex, width, height, 0); - technique_endpass(tech); + gs_technique_end_pass(tech); } - technique_end(tech); + gs_technique_end(tech); } -void obs_source_process_filter(obs_source_t filter, effect_t effect, +void obs_source_process_filter(obs_source_t filter, gs_effect_t effect, uint32_t width, uint32_t height, enum gs_color_format format, enum obs_allow_direct_render allow_direct) { @@ -1718,21 +1718,21 @@ void obs_source_process_filter(obs_source_t filter, effect_t effect, } if (!filter->filter_texrender) - filter->filter_texrender = texrender_create(format, + filter->filter_texrender = gs_texrender_create(format, GS_ZS_NONE); - if (texrender_begin(filter->filter_texrender, cx, cy)) { + if (gs_texrender_begin(filter->filter_texrender, cx, cy)) { gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -100.0f, 100.0f); if (expects_def && parent == target) obs_source_default_render(parent, use_matrix); else obs_source_video_render(target); - texrender_end(filter->filter_texrender); + gs_texrender_end(filter->filter_texrender); } /* --------------------------- */ - render_filter_tex(texrender_gettexture(filter->filter_texrender), + render_filter_tex(gs_texrender_get_texture(filter->filter_texrender), effect, width, height, use_matrix); } diff --git a/libobs/obs-source.h b/libobs/obs-source.h index 90c1d28c0..20636a7b0 100644 --- a/libobs/obs-source.h +++ b/libobs/obs-source.h @@ -222,7 +222,7 @@ struct obs_source_info { * be NULL, and the source is expected to process with * an effect manually. */ - void (*video_render)(void *data, effect_t effect); + void (*video_render)(void *data, gs_effect_t effect); /** * Called to filter raw async video data. diff --git a/libobs/obs-video.c b/libobs/obs-video.c index 478a1e9d7..e7d1ca839 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -58,7 +58,7 @@ static inline void render_displays(void) if (!obs->data.valid) return; - gs_entercontext(obs->video.graphics); + gs_enter_context(obs->video.graphics); /* render extra displays/swaps */ pthread_mutex_lock(&obs->data.displays_mutex); @@ -74,23 +74,23 @@ static inline void render_displays(void) /* render main display */ render_display(&obs->video.main_display); - gs_leavecontext(); + gs_leave_context(); } static inline void set_render_size(uint32_t width, uint32_t height) { - gs_enable_depthtest(false); + gs_enable_depth_test(false); gs_enable_blending(false); - gs_setcullmode(GS_NEITHER); + gs_set_cull_mode(GS_NEITHER); gs_ortho(0.0f, (float)width, 0.0f, (float)height, -100.0f, 100.0f); - gs_setviewport(0, 0, width, height); + gs_set_viewport(0, 0, width, height); } static inline void unmap_last_surface(struct obs_core_video *video) { if (video->mapped_surface) { - stagesurface_unmap(video->mapped_surface); + gs_stagesurface_unmap(video->mapped_surface); video->mapped_surface = NULL; } } @@ -101,7 +101,7 @@ static inline void render_main_texture(struct obs_core_video *video, struct vec4 clear_color; vec4_set(&clear_color, 0.0f, 0.0f, 0.0f, 1.0f); - gs_setrendertarget(video->render_textures[cur_texture], NULL); + gs_set_render_target(video->render_textures[cur_texture], NULL); gs_clear(GS_CLEAR_COLOR, &clear_color, 1.0f, 0); set_render_size(video->base_width, video->base_height); @@ -113,22 +113,23 @@ static inline void render_main_texture(struct obs_core_video *video, static inline void render_output_texture(struct obs_core_video *video, int cur_texture, int prev_texture) { - texture_t texture = video->render_textures[prev_texture]; - texture_t target = video->output_textures[cur_texture]; - uint32_t width = texture_getwidth(target); - uint32_t height = texture_getheight(target); + gs_texture_t texture = video->render_textures[prev_texture]; + gs_texture_t target = video->output_textures[cur_texture]; + uint32_t width = gs_texture_get_width(target); + uint32_t height = gs_texture_get_height(target); /* TODO: replace with actual downscalers or unpackers */ - effect_t effect = video->default_effect; - technique_t tech = effect_gettechnique(effect, "DrawMatrix"); - eparam_t image = effect_getparambyname(effect, "image"); - eparam_t matrix = effect_getparambyname(effect, "color_matrix"); + gs_effect_t effect = video->default_effect; + gs_technique_t tech = gs_effect_get_technique(effect, "DrawMatrix"); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); + gs_eparam_t matrix = gs_effect_get_param_by_name(effect, + "color_matrix"); size_t passes, i; if (!video->textures_rendered[prev_texture]) return; - gs_setrendertarget(target, NULL); + gs_set_render_target(target, NULL); set_render_size(width, height); /* TODO: replace with programmable code */ @@ -140,38 +141,38 @@ static inline void render_output_texture(struct obs_core_video *video, 0.000000f, 0.000000f, 0.000000f, 1.000000f }; - effect_setval(matrix, mat_val, sizeof(mat_val)); - effect_settexture(image, texture); + gs_effect_set_val(matrix, mat_val, sizeof(mat_val)); + gs_effect_set_texture(image, texture); - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (i = 0; i < passes; i++) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); gs_draw_sprite(texture, 0, width, height); - technique_endpass(tech); + gs_technique_end_pass(tech); } - technique_end(tech); + gs_technique_end(tech); video->textures_output[cur_texture] = true; } -static inline void set_eparam(effect_t effect, const char *name, float val) +static inline void set_eparam(gs_effect_t effect, const char *name, float val) { - eparam_t param = effect_getparambyname(effect, name); - effect_setfloat(param, val); + gs_eparam_t param = gs_effect_get_param_by_name(effect, name); + gs_effect_set_float(param, val); } static void render_convert_texture(struct obs_core_video *video, int cur_texture, int prev_texture) { - texture_t texture = video->output_textures[prev_texture]; - texture_t target = video->convert_textures[cur_texture]; - float fwidth = (float)video->output_width; - float fheight = (float)video->output_height; - size_t passes, i; + gs_texture_t texture = video->output_textures[prev_texture]; + gs_texture_t target = video->convert_textures[cur_texture]; + float fwidth = (float)video->output_width; + float fheight = (float)video->output_height; + size_t passes, i; - effect_t effect = video->conversion_effect; - eparam_t image = effect_getparambyname(effect, "image"); - technique_t tech = effect_gettechnique(effect, + gs_effect_t effect = video->conversion_effect; + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); + gs_technique_t tech = gs_effect_get_technique(effect, video->conversion_tech); if (!video->textures_output[prev_texture]) @@ -189,19 +190,19 @@ static void render_convert_texture(struct obs_core_video *video, set_eparam(effect, "height_d2_i", 1.0f / (fheight * 0.5f)); set_eparam(effect, "input_height", (float)video->conversion_height); - effect_settexture(image, texture); + gs_effect_set_texture(image, texture); - gs_setrendertarget(target, NULL); + gs_set_render_target(target, NULL); set_render_size(video->output_width, video->conversion_height); - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (i = 0; i < passes; i++) { - technique_beginpass(tech, i); + gs_technique_begin_pass(tech, i); gs_draw_sprite(texture, 0, video->output_width, video->conversion_height); - technique_endpass(tech); + gs_technique_end_pass(tech); } - technique_end(tech); + gs_technique_end(tech); video->textures_converted[cur_texture] = true; } @@ -209,9 +210,9 @@ static void render_convert_texture(struct obs_core_video *video, static inline void stage_output_texture(struct obs_core_video *video, int cur_texture, int prev_texture) { - texture_t texture; + gs_texture_t texture; bool texture_ready; - stagesurf_t copy = video->copy_surfaces[cur_texture]; + gs_stagesurf_t copy = video->copy_surfaces[cur_texture]; if (video->gpu_conversion) { texture = video->convert_textures[prev_texture]; @@ -234,10 +235,10 @@ static inline void stage_output_texture(struct obs_core_video *video, static inline void render_video(struct obs_core_video *video, int cur_texture, int prev_texture) { - gs_beginscene(); + gs_begin_scene(); - gs_enable_depthtest(false); - gs_setcullmode(GS_NEITHER); + gs_enable_depth_test(false); + gs_set_cull_mode(GS_NEITHER); render_main_texture(video, cur_texture); render_output_texture(video, cur_texture, prev_texture); @@ -246,21 +247,21 @@ static inline void render_video(struct obs_core_video *video, int cur_texture, stage_output_texture(video, cur_texture, prev_texture); - gs_setrendertarget(NULL, NULL); + gs_set_render_target(NULL, NULL); gs_enable_blending(true); - gs_endscene(); + gs_end_scene(); } static inline bool download_frame(struct obs_core_video *video, int prev_texture, struct video_data *frame) { - stagesurf_t surface = video->copy_surfaces[prev_texture]; + gs_stagesurf_t surface = video->copy_surfaces[prev_texture]; if (!video->textures_copied[prev_texture]) return false; - if (!stagesurface_map(surface, &frame->data[0], &frame->linesize[0])) + if (!gs_stagesurface_map(surface, &frame->data[0], &frame->linesize[0])) return false; video->mapped_surface = surface; @@ -413,12 +414,12 @@ static inline void output_frame(uint64_t timestamp) memset(&frame, 0, sizeof(struct video_data)); frame.timestamp = timestamp; - gs_entercontext(video->graphics); + gs_enter_context(video->graphics); render_video(video, cur_texture, prev_texture); frame_ready = download_frame(video, prev_texture, &frame); - gs_leavecontext(); + gs_leave_context(); if (frame_ready) output_video_data(video, &frame, cur_texture); diff --git a/libobs/obs.c b/libobs/obs.c index c6014cf6d..f57c8625d 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -146,9 +146,9 @@ static bool obs_init_gpu_conversion(struct obs_video_info *ovi) } for (size_t i = 0; i < NUM_TEXTURES; i++) { - video->convert_textures[i] = gs_create_texture( + video->convert_textures[i] = gs_texture_create( ovi->output_width, video->conversion_height, - GS_RGBA, 1, NULL, GS_RENDERTARGET); + GS_RGBA, 1, NULL, GS_RENDER_TARGET); if (!video->convert_textures[i]) return false; @@ -166,22 +166,22 @@ static bool obs_init_textures(struct obs_video_info *ovi) size_t i; for (i = 0; i < NUM_TEXTURES; i++) { - video->copy_surfaces[i] = gs_create_stagesurface( + video->copy_surfaces[i] = gs_stagesurface_create( ovi->output_width, output_height, GS_RGBA); if (!video->copy_surfaces[i]) return false; - video->render_textures[i] = gs_create_texture( + video->render_textures[i] = gs_texture_create( ovi->base_width, ovi->base_height, - GS_RGBA, 1, NULL, GS_RENDERTARGET); + GS_RGBA, 1, NULL, GS_RENDER_TARGET); if (!video->render_textures[i]) return false; - video->output_textures[i] = gs_create_texture( + video->output_textures[i] = gs_texture_create( ovi->output_width, ovi->output_height, - GS_RGBA, 1, NULL, GS_RENDERTARGET); + GS_RGBA, 1, NULL, GS_RENDER_TARGET); if (!video->output_textures[i]) return false; @@ -217,20 +217,20 @@ static int obs_init_graphics(struct obs_video_info *ovi) } } - gs_entercontext(video->graphics); + gs_enter_context(video->graphics); char *filename = find_libobs_data_file("default.effect"); - video->default_effect = gs_create_effect_from_file(filename, + video->default_effect = gs_effect_create_from_file(filename, NULL); bfree(filename); filename = find_libobs_data_file("solid.effect"); - video->solid_effect = gs_create_effect_from_file(filename, + video->solid_effect = gs_effect_create_from_file(filename, NULL); bfree(filename); filename = find_libobs_data_file("format_conversion.effect"); - video->conversion_effect = gs_create_effect_from_file(filename, + video->conversion_effect = gs_effect_create_from_file(filename, NULL); bfree(filename); @@ -241,7 +241,7 @@ static int obs_init_graphics(struct obs_video_info *ovi) if (!video->conversion_effect) success = false; - gs_leavecontext(); + gs_leave_context(); return success ? OBS_VIDEO_SUCCESS : OBS_VIDEO_FAIL; } @@ -276,14 +276,14 @@ static int obs_init_video(struct obs_video_info *ovi) video->main_display.cx = ovi->window_width; video->main_display.cy = ovi->window_height; - gs_entercontext(video->graphics); + gs_enter_context(video->graphics); if (ovi->gpu_conversion && !obs_init_gpu_conversion(ovi)) return OBS_VIDEO_FAIL; if (!obs_init_textures(ovi)) return OBS_VIDEO_FAIL; - gs_leavecontext(); + gs_leave_context(); errorcode = pthread_create(&video->video_thread, NULL, obs_video_thread, obs); @@ -338,18 +338,18 @@ static void obs_free_video(void) if (!video->graphics) return; - gs_entercontext(video->graphics); + gs_enter_context(video->graphics); if (video->mapped_surface) { - stagesurface_unmap(video->mapped_surface); + gs_stagesurface_unmap(video->mapped_surface); video->mapped_surface = NULL; } for (size_t i = 0; i < NUM_TEXTURES; i++) { - stagesurface_destroy(video->copy_surfaces[i]); - texture_destroy(video->render_textures[i]); - texture_destroy(video->convert_textures[i]); - texture_destroy(video->output_textures[i]); + gs_stagesurface_destroy(video->copy_surfaces[i]); + gs_texture_destroy(video->render_textures[i]); + gs_texture_destroy(video->convert_textures[i]); + gs_texture_destroy(video->output_textures[i]); obs_source_frame_free(&video->convert_frames[i]); video->copy_surfaces[i] = NULL; @@ -358,7 +358,7 @@ static void obs_free_video(void) video->output_textures[i] = NULL; } - gs_leavecontext(); + gs_leave_context(); video->cur_texture = 0; } @@ -369,14 +369,14 @@ static void obs_free_graphics(void) struct obs_core_video *video = &obs->video; if (video->graphics) { - gs_entercontext(video->graphics); + gs_enter_context(video->graphics); - effect_destroy(video->default_effect); - effect_destroy(video->solid_effect); - effect_destroy(video->conversion_effect); + gs_effect_destroy(video->default_effect); + gs_effect_destroy(video->solid_effect); + gs_effect_destroy(video->conversion_effect); video->default_effect = NULL; - gs_leavecontext(); + gs_leave_context(); gs_destroy(video->graphics); video->graphics = NULL; @@ -812,13 +812,13 @@ bool obs_enum_service_types(size_t idx, const char **id) void obs_enter_graphics(void) { if (obs && obs->video.graphics) - gs_entercontext(obs->video.graphics); + gs_enter_context(obs->video.graphics); } void obs_leave_graphics(void) { if (obs && obs->video.graphics) - gs_leavecontext(); + gs_leave_context(); } audio_t obs_get_audio(void) @@ -1075,13 +1075,13 @@ obs_service_t obs_get_service_by_name(const char *name) &obs->data.services_mutex); } -effect_t obs_get_default_effect(void) +gs_effect_t obs_get_default_effect(void) { if (!obs) return NULL; return obs->video.default_effect; } -effect_t obs_get_solid_effect(void) +gs_effect_t obs_get_solid_effect(void) { if (!obs) return NULL; return obs->video.solid_effect; diff --git a/libobs/obs.h b/libobs/obs.h index 9e0aed0a1..3657b2ab3 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -450,10 +450,10 @@ EXPORT obs_encoder_t obs_get_encoder_by_name(const char *name); EXPORT obs_service_t obs_get_service_by_name(const char *name); /** Returns the default effect for generic RGB/YUV drawing */ -EXPORT effect_t obs_get_default_effect(void); +EXPORT gs_effect_t obs_get_default_effect(void); /** Returns the solid effect for drawing solid colors */ -EXPORT effect_t obs_get_solid_effect(void); +EXPORT gs_effect_t obs_get_solid_effect(void); /** Returns the primary obs signal handler */ EXPORT signal_handler_t obs_get_signal_handler(void); @@ -727,7 +727,7 @@ EXPORT void obs_source_release_frame(obs_source_t source, struct obs_source_frame *frame); /** Default RGB filter handler for generic effect filters */ -EXPORT void obs_source_process_filter(obs_source_t filter, effect_t effect, +EXPORT void obs_source_process_filter(obs_source_t filter, gs_effect_t effect, uint32_t width, uint32_t height, enum gs_color_format format, enum obs_allow_direct_render allow_direct); diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 4a46b5b2a..865686d7c 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -494,20 +494,20 @@ void OBSBasic::InitPrimitives() { obs_enter_graphics(); - gs_renderstart(true); + gs_render_start(true); gs_vertex2f(0.0f, 0.0f); gs_vertex2f(0.0f, 1.0f); gs_vertex2f(1.0f, 1.0f); gs_vertex2f(1.0f, 0.0f); gs_vertex2f(0.0f, 0.0f); - box = gs_rendersave(); + box = gs_render_save(); - gs_renderstart(true); + gs_render_start(true); for (int i = 0; i <= 360; i += (360/20)) { float pos = RAD(float(i)); gs_vertex2f(cosf(pos), sinf(pos)); } - circle = gs_rendersave(); + circle = gs_render_save(); obs_leave_graphics(); } @@ -590,8 +590,8 @@ OBSBasic::~OBSBasic() ui->scenes->clear(); obs_enter_graphics(); - vertexbuffer_destroy(box); - vertexbuffer_destroy(circle); + gs_vertexbuffer_destroy(box); + gs_vertexbuffer_destroy(circle); obs_leave_graphics(); obs_shutdown(); @@ -1070,16 +1070,16 @@ void OBSBasic::DrawBackdrop(float cx, float cy) if (!box) return; - effect_t solid = obs_get_solid_effect(); - eparam_t color = effect_getparambyname(solid, "color"); - technique_t tech = effect_gettechnique(solid, "Solid"); + gs_effect_t solid = obs_get_solid_effect(); + gs_eparam_t color = gs_effect_get_param_by_name(solid, "color"); + gs_technique_t tech = gs_effect_get_technique(solid, "Solid"); vec4 colorVal; vec4_set(&colorVal, 0.0f, 0.0f, 0.0f, 1.0f); - effect_setvec4(color, &colorVal); + gs_effect_set_vec4(color, &colorVal); - technique_begin(tech); - technique_beginpass(tech, 0); + gs_technique_begin(tech); + gs_technique_begin_pass(tech, 0); gs_matrix_push(); gs_matrix_identity(); gs_matrix_scale3f(float(cx), float(cy), 1.0f); @@ -1088,8 +1088,8 @@ void OBSBasic::DrawBackdrop(float cx, float cy) gs_draw(GS_TRISTRIP, 0, 0); gs_matrix_pop(); - technique_endpass(tech); - technique_end(tech); + gs_technique_end_pass(tech); + gs_technique_end(tech); gs_load_vertexbuffer(nullptr); } @@ -1111,7 +1111,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy) gs_ortho(0.0f, float(ovi.base_width), 0.0f, float(ovi.base_height), -100.0f, 100.0f); - gs_setviewport(window->previewX, window->previewY, + gs_set_viewport(window->previewX, window->previewY, window->previewCX, window->previewCY); window->DrawBackdrop(float(ovi.base_width), float(ovi.base_height)); @@ -1128,7 +1128,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy) gs_ortho(-window->previewX, right, -window->previewY, bottom, -100.0f, 100.0f); - gs_resetviewport(); + gs_reset_viewport(); window->ui->preview->DrawSceneEditing(); diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index 91465366c..c1d1d6c53 100644 --- a/obs/window-basic-main.hpp +++ b/obs/window-basic-main.hpp @@ -79,8 +79,8 @@ private: obs_encoder_t aac = nullptr; obs_encoder_t x264 = nullptr; - vertbuffer_t box = nullptr; - vertbuffer_t circle = nullptr; + gs_vertbuffer_t box = nullptr; + gs_vertbuffer_t circle = nullptr; bool sceneChanging = false; diff --git a/obs/window-basic-preview.cpp b/obs/window-basic-preview.cpp index dd43d64fa..adeebab6c 100644 --- a/obs/window-basic-preview.cpp +++ b/obs/window-basic-preview.cpp @@ -729,15 +729,15 @@ void OBSBasicPreview::DrawSceneEditing() { OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); - effect_t solid = obs_get_solid_effect(); - technique_t tech = effect_gettechnique(solid, "Solid"); + gs_effect_t solid = obs_get_solid_effect(); + gs_technique_t tech = gs_effect_get_technique(solid, "Solid"); vec4 color; vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f); - effect_setvec4(effect_getparambyname(solid, "color"), &color); + gs_effect_set_vec4(gs_effect_get_param_by_name(solid, "color"), &color); - technique_begin(tech); - technique_beginpass(tech, 0); + gs_technique_begin(tech); + gs_technique_begin_pass(tech, 0); OBSScene scene = main->GetCurrentScene(); if (scene) @@ -745,6 +745,6 @@ void OBSBasicPreview::DrawSceneEditing() gs_load_vertexbuffer(nullptr); - technique_endpass(tech); - technique_end(tech); + gs_technique_end_pass(tech); + gs_technique_end(tech); } diff --git a/obs/window-basic-properties.cpp b/obs/window-basic-properties.cpp index 21acf7d1b..77848bb12 100644 --- a/obs/window-basic-properties.cpp +++ b/obs/window-basic-properties.cpp @@ -91,7 +91,7 @@ void OBSBasicProperties::DrawPreview(void *data, uint32_t cx, uint32_t cy) gs_projection_push(); gs_ortho(0.0f, float(sourceCX), 0.0f, float(sourceCY), -100.0f, 100.0f); - gs_setviewport(x, y, newCX, newCY); + gs_set_viewport(x, y, newCX, newCY); obs_source_video_render(window->source); diff --git a/plugins/image-source/image-source.c b/plugins/image-source/image-source.c index 7af771716..c5b27311c 100644 --- a/plugins/image-source/image-source.c +++ b/plugins/image-source/image-source.c @@ -7,7 +7,7 @@ struct image_source { obs_source_t source; - texture_t tex; + gs_texture_t tex; uint32_t cx; uint32_t cy; }; @@ -25,15 +25,15 @@ static void image_source_update(void *data, obs_data_t settings) obs_enter_graphics(); if (context->tex) { - texture_destroy(context->tex); + gs_texture_destroy(context->tex); context->tex = NULL; } if (file && *file) { - context->tex = gs_create_texture_from_file(file); + context->tex = gs_texture_create_from_file(file); if (context->tex) { - context->cx = texture_getwidth(context->tex); - context->cy = texture_getheight(context->tex); + context->cx = gs_texture_get_width(context->tex); + context->cy = gs_texture_get_height(context->tex); } else { warn("failed to load texture '%s'", file); context->cx = 0; @@ -58,7 +58,7 @@ static void image_source_destroy(void *data) struct image_source *context = data; obs_enter_graphics(); - texture_destroy(context->tex); + gs_texture_destroy(context->tex); obs_leave_graphics(); bfree(context); @@ -76,14 +76,15 @@ static uint32_t image_source_getheight(void *data) return context->cy; } -static void image_source_render(void *data, effect_t effect) +static void image_source_render(void *data, gs_effect_t effect) { struct image_source *context = data; if (!context->tex) return; gs_reset_blend_state(); - effect_settexture(effect_getparambyname(effect, "image"), context->tex); + gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), + context->tex); gs_draw_sprite(context->tex, 0, context->cx, context->cy); } diff --git a/plugins/linux-xcomposite/plugin-main.cpp b/plugins/linux-xcomposite/plugin-main.cpp index 08e4b7c36..face55d7c 100644 --- a/plugins/linux-xcomposite/plugin-main.cpp +++ b/plugins/linux-xcomposite/plugin-main.cpp @@ -19,7 +19,7 @@ static void xcompcap_video_tick(void* data, float seconds) cc->tick(seconds); } -static void xcompcap_video_render(void* data, effect_t effect) +static void xcompcap_video_render(void* data, gs_effect_t effect) { XCompcapMain* cc = (XCompcapMain*)data; cc->render(effect); diff --git a/plugins/linux-xcomposite/xcompcap-main.cpp b/plugins/linux-xcomposite/xcompcap-main.cpp index 0d6c44ab4..6ca58a0da 100644 --- a/plugins/linux-xcomposite/xcompcap-main.cpp +++ b/plugins/linux-xcomposite/xcompcap-main.cpp @@ -137,8 +137,8 @@ struct XCompcapMain_private Pixmap pixmap; GLXPixmap glxpixmap; - texture_t tex; - texture_t gltex; + gs_texture_t tex; + gs_texture_t gltex; pthread_mutex_t lock; pthread_mutexattr_t lockattr; @@ -160,7 +160,7 @@ XCompcapMain::~XCompcapMain() ObsGsContextHolder obsctx; if (p->tex) { - texture_destroy(p->tex); + gs_texture_destroy(p->tex); p->tex = 0; } @@ -210,7 +210,7 @@ static Window getWindowFromString(std::string wstr) static void xcc_cleanup(XCompcapMain_private *p) { if (p->gltex) { - texture_destroy(p->gltex); + gs_texture_destroy(p->gltex); p->gltex = 0; } @@ -303,7 +303,7 @@ void XCompcapMain::updateSettings(obs_data_t settings) } if (p->tex) - texture_destroy(p->tex); + gs_texture_destroy(p->tex); uint8_t *texData = new uint8_t[width() * height() * 4]; @@ -316,13 +316,13 @@ void XCompcapMain::updateSettings(obs_data_t settings) const uint8_t* texDataArr[] = { texData, 0 }; - p->tex = gs_create_texture(width(), height(), cf, 1, + p->tex = gs_texture_create(width(), height(), cf, 1, texDataArr, 0); delete[] texData; if (p->swapRedBlue) { - GLuint tex = *(GLuint*)texture_getobj(p->tex); + GLuint tex = *(GLuint*)gs_texture_get_obj(p->tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); @@ -387,10 +387,10 @@ void XCompcapMain::updateSettings(obs_data_t settings) XFree(configs); - p->gltex = gs_create_texture(p->width, p->height, cf, 1, 0, + p->gltex = gs_texture_create(p->width, p->height, cf, 1, 0, GS_GL_DUMMYTEX); - GLuint gltex = *(GLuint*)texture_getobj(p->gltex); + GLuint gltex = *(GLuint*)gs_texture_get_obj(p->gltex); glBindTexture(GL_TEXTURE_2D, gltex); glXBindTexImageEXT(xdisp, p->glxpixmap, GLX_FRONT_LEFT_EXT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -430,15 +430,15 @@ void XCompcapMain::tick(float seconds) obs_leave_graphics(); } -void XCompcapMain::render(effect_t effect) +void XCompcapMain::render(gs_effect_t effect) { PLock lock(&p->lock, true); if (!lock.isLocked() || !p->tex) return; - eparam_t image = effect_getparambyname(effect, "image"); - effect_settexture(image, p->tex); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); + gs_effect_set_texture(image, p->tex); gs_enable_blending(false); gs_draw_sprite(p->tex, 0, 0, 0); diff --git a/plugins/linux-xcomposite/xcompcap-main.h b/plugins/linux-xcomposite/xcompcap-main.h index 5bf64a215..e0f63062d 100644 --- a/plugins/linux-xcomposite/xcompcap-main.h +++ b/plugins/linux-xcomposite/xcompcap-main.h @@ -17,7 +17,7 @@ class XCompcapMain void updateSettings(obs_data_t settings); void tick(float seconds); - void render(effect_t effect); + void render(gs_effect_t effect); uint32_t width(); uint32_t height(); diff --git a/plugins/linux-xshm/xcursor.c b/plugins/linux-xshm/xcursor.c index 411ec73f9..d948dbb9d 100644 --- a/plugins/linux-xshm/xcursor.c +++ b/plugins/linux-xshm/xcursor.c @@ -48,13 +48,13 @@ static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) { if (data->tex && data->last_height == xc->width && data->last_width == xc->height) { - texture_setimage(data->tex, (const uint8_t *) pixels, + gs_texture_set_image(data->tex, (const uint8_t *) pixels, xc->width * sizeof(uint32_t), False); } else { if (data->tex) - texture_destroy(data->tex); + gs_texture_destroy(data->tex); - data->tex = gs_create_texture(xc->width, xc->height, + data->tex = gs_texture_create(xc->width, xc->height, GS_BGRA, 1, (const uint8_t **) &pixels, GS_DYNAMIC); } @@ -76,7 +76,7 @@ xcursor_t *xcursor_init(Display *dpy) { void xcursor_destroy(xcursor_t *data) { if (data->tex) - texture_destroy(data->tex); + gs_texture_destroy(data->tex); bfree(data); } @@ -93,17 +93,17 @@ void xcursor_tick(xcursor_t *data) { void xcursor_render(xcursor_t *data) { /* TODO: why do i need effects ? */ - effect_t effect = gs_geteffect(); - eparam_t image = effect_getparambyname(effect, "image"); + gs_effect_t effect = gs_get_effect(); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); - effect_settexture(image, data->tex); + gs_effect_set_texture(image, data->tex); gs_matrix_push(); gs_matrix_translate3f(-data->pos_x, -data->pos_y, 0); gs_enable_blending(True); - gs_blendfunction(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA); + gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA); gs_draw_sprite(data->tex, 0, 0, 0); gs_matrix_pop(); diff --git a/plugins/linux-xshm/xcursor.h b/plugins/linux-xshm/xcursor.h index 1fed9ce28..6e97e7f30 100644 --- a/plugins/linux-xshm/xcursor.h +++ b/plugins/linux-xshm/xcursor.h @@ -30,7 +30,7 @@ typedef struct { unsigned long last_serial; uint_fast32_t last_width; uint_fast32_t last_height; - texture_t tex; + gs_texture_t tex; int_fast32_t x_org; int_fast32_t y_org; diff --git a/plugins/linux-xshm/xshm-input.c b/plugins/linux-xshm/xshm-input.c index 6b2610a40..81f30e464 100644 --- a/plugins/linux-xshm/xshm-input.c +++ b/plugins/linux-xshm/xshm-input.c @@ -35,7 +35,7 @@ struct xshm_data { int_fast32_t width, height; xshm_t *xshm; - texture_t texture; + gs_texture_t texture; bool show_cursor; xcursor_t *cursor; @@ -53,8 +53,8 @@ static void xshm_resize_texture(struct xshm_data *data) obs_enter_graphics(); if (data->texture) - texture_destroy(data->texture); - data->texture = gs_create_texture(data->width, data->height, + gs_texture_destroy(data->texture); + data->texture = gs_texture_create(data->width, data->height, GS_BGRA, 1, NULL, GS_DYNAMIC); obs_leave_graphics(); @@ -186,7 +186,7 @@ static void xshm_destroy(void *vptr) obs_enter_graphics(); if (data->texture) - texture_destroy(data->texture); + gs_texture_destroy(data->texture); if (data->cursor) xcursor_destroy(data->cursor); @@ -249,7 +249,7 @@ static void xshm_video_tick(void *vptr, float seconds) XShmGetImage(data->dpy, XRootWindowOfScreen(data->screen), data->xshm->image, data->x_org, data->y_org, AllPlanes); - texture_setimage(data->texture, (void *) data->xshm->image->data, + gs_texture_set_image(data->texture, (void *) data->xshm->image->data, data->width * 4, false); xcursor_tick(data->cursor); @@ -260,15 +260,15 @@ static void xshm_video_tick(void *vptr, float seconds) /** * Render the capture data */ -static void xshm_video_render(void *vptr, effect_t effect) +static void xshm_video_render(void *vptr, gs_effect_t effect) { XSHM_DATA(vptr); if (!data->xshm) return; - eparam_t image = effect_getparambyname(effect, "image"); - effect_settexture(image, data->texture); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); + gs_effect_set_texture(image, data->texture); gs_enable_blending(false); gs_draw_sprite(data->texture, 0, 0, 0); diff --git a/plugins/mac-capture/mac-display-capture.m b/plugins/mac-capture/mac-display-capture.m index 4dbdcb821..4f6f1f024 100644 --- a/plugins/mac-capture/mac-display-capture.m +++ b/plugins/mac-capture/mac-display-capture.m @@ -9,9 +9,9 @@ struct display_capture { obs_source_t source; - samplerstate_t sampler; - effect_t draw_effect; - texture_t tex; + gs_samplerstate_t sampler; + gs_effect_t draw_effect; + gs_texture_t tex; unsigned display; uint32_t width, height; @@ -32,7 +32,7 @@ static void destroy_display_stream(struct display_capture *dc) } if (dc->tex) { - texture_destroy(dc->tex); + gs_texture_destroy(dc->tex); dc->tex = NULL; } @@ -68,9 +68,9 @@ static void display_capture_destroy(void *data) destroy_display_stream(dc); if (dc->sampler) - samplerstate_destroy(dc->sampler); + gs_samplerstate_destroy(dc->sampler); if (dc->draw_effect) - effect_destroy(dc->draw_effect); + gs_effect_destroy(dc->draw_effect); obs_leave_graphics(); @@ -178,12 +178,12 @@ static void *display_capture_create(obs_data_t settings, .address_w = GS_ADDRESS_CLAMP, .max_anisotropy = 1, }; - dc->sampler = gs_create_samplerstate(&info); + dc->sampler = gs_samplerstate_create(&info); if (!dc->sampler) goto fail; char *effect_file = obs_module_file("draw_rect.effect"); - dc->draw_effect = gs_create_effect_from_file(effect_file, NULL); + dc->draw_effect = gs_effect_create_from_file(effect_file, NULL); bfree(effect_file); if (!dc->draw_effect) goto fail; @@ -225,9 +225,9 @@ static void display_capture_video_tick(void *data, float seconds) obs_enter_graphics(); if (dc->tex) - texture_rebind_iosurface(dc->tex, dc->prev); + gs_texture_rebind_iosurface(dc->tex, dc->prev); else - dc->tex = gs_create_texture_from_iosurface(dc->prev); + dc->tex = gs_texture_create_from_iosurface(dc->prev); obs_leave_graphics(); if (prev_prev) { @@ -236,7 +236,7 @@ static void display_capture_video_tick(void *data, float seconds) } } -static void display_capture_video_render(void *data, effect_t effect) +static void display_capture_video_render(void *data, gs_effect_t effect) { UNUSED_PARAMETER(effect); @@ -246,16 +246,17 @@ static void display_capture_video_render(void *data, effect_t effect) return; gs_load_samplerstate(dc->sampler, 0); - technique_t tech = effect_gettechnique(dc->draw_effect, "Default"); - effect_settexture(effect_getparambyidx(dc->draw_effect, 1), + gs_technique_t tech = gs_effect_get_technique(dc->draw_effect, + "Default"); + gs_effect_set_texture(gs_effect_get_param_by_idx(dc->draw_effect, 1), dc->tex); - technique_begin(tech); - technique_beginpass(tech, 0); + gs_technique_begin(tech); + gs_technique_begin_pass(tech, 0); gs_draw_sprite(dc->tex, 0, 0, 0); - technique_endpass(tech); - technique_end(tech); + gs_technique_end_pass(tech); + gs_technique_end(tech); } static const char *display_capture_getname(void) diff --git a/plugins/win-capture/dc-capture.c b/plugins/win-capture/dc-capture.c index 8ac57aee7..134c66952 100644 --- a/plugins/win-capture/dc-capture.c +++ b/plugins/win-capture/dc-capture.c @@ -7,11 +7,11 @@ static inline void init_textures(struct dc_capture *capture) { for (int i = 0; i < capture->num_textures; i++) { if (capture->compatibility) - capture->textures[i] = gs_create_texture( + capture->textures[i] = gs_texture_create( capture->width, capture->height, GS_BGRA, 1, NULL, GS_DYNAMIC); else - capture->textures[i] = gs_create_gdi_texture( + capture->textures[i] = gs_texture_create_gdi( capture->width, capture->height); if (!capture->textures[i]) { @@ -79,7 +79,7 @@ void dc_capture_free(struct dc_capture *capture) obs_enter_graphics(); for (int i = 0; i < capture->num_textures; i++) - texture_destroy(capture->textures[i]); + gs_texture_destroy(capture->textures[i]); obs_leave_graphics(); @@ -126,16 +126,16 @@ static inline HDC dc_capture_get_dc(struct dc_capture *capture) if (capture->compatibility) return capture->hdc; else - return texture_get_dc(capture->textures[capture->cur_tex]); + return gs_texture_get_dc(capture->textures[capture->cur_tex]); } static inline void dc_capture_release_dc(struct dc_capture *capture) { if (capture->compatibility) { - texture_setimage(capture->textures[capture->cur_tex], + gs_texture_set_image(capture->textures[capture->cur_tex], capture->bits, capture->width*4, false); } else { - texture_release_dc(capture->textures[capture->cur_tex]); + gs_texture_release_dc(capture->textures[capture->cur_tex]); } } @@ -175,30 +175,30 @@ void dc_capture_capture(struct dc_capture *capture, HWND window) capture->textures_written[capture->cur_tex] = true; } -static void draw_texture(struct dc_capture *capture, int id, effect_t effect) +static void draw_texture(struct dc_capture *capture, int id, gs_effect_t effect) { - texture_t texture = capture->textures[id]; - technique_t tech = effect_gettechnique(effect, "Draw"); - eparam_t image = effect_getparambyname(effect, "image"); + gs_texture_t texture = capture->textures[id]; + gs_technique_t tech = gs_effect_get_technique(effect, "Draw"); + gs_eparam_t image = gs_effect_get_param_by_name(effect, "image"); size_t passes; - effect_settexture(image, texture); + gs_effect_set_texture(image, texture); - passes = technique_begin(tech); + passes = gs_technique_begin(tech); for (size_t i = 0; i < passes; i++) { - if (technique_beginpass(tech, i)) { + if (gs_technique_begin_pass(tech, i)) { if (capture->compatibility) gs_draw_sprite(texture, GS_FLIP_V, 0, 0); else gs_draw_sprite(texture, 0, 0, 0); - technique_endpass(tech); + gs_technique_end_pass(tech); } } - technique_end(tech); + gs_technique_end(tech); } -void dc_capture_render(struct dc_capture *capture, effect_t effect) +void dc_capture_render(struct dc_capture *capture, gs_effect_t effect) { int last_tex = (capture->cur_tex > 0) ? capture->cur_tex-1 : capture->num_textures-1; @@ -210,9 +210,9 @@ void dc_capture_render(struct dc_capture *capture, effect_t effect) draw_texture(capture, last_tex, effect); } -effect_t create_opaque_effect(void) +gs_effect_t create_opaque_effect(void) { - effect_t opaque_effect; + gs_effect_t opaque_effect; char *effect_file; char *error_string = NULL; @@ -225,7 +225,7 @@ effect_t create_opaque_effect(void) obs_enter_graphics(); - opaque_effect = gs_create_effect_from_file(effect_file, &error_string); + opaque_effect = gs_effect_create_from_file(effect_file, &error_string); if (!opaque_effect) { if (error_string) diff --git a/plugins/win-capture/dc-capture.h b/plugins/win-capture/dc-capture.h index 213a74b90..c943836ca 100644 --- a/plugins/win-capture/dc-capture.h +++ b/plugins/win-capture/dc-capture.h @@ -8,24 +8,24 @@ #define NUM_TEXTURES 2 struct dc_capture { - int cur_tex; - texture_t textures[NUM_TEXTURES]; - bool textures_written[NUM_TEXTURES]; - int x, y; - uint32_t width; - uint32_t height; - int num_textures; + int cur_tex; + gs_texture_t textures[NUM_TEXTURES]; + bool textures_written[NUM_TEXTURES]; + int x, y; + uint32_t width; + uint32_t height; + int num_textures; - bool compatibility; - HDC hdc; - HBITMAP bmp, old_bmp; - BYTE *bits; + bool compatibility; + HDC hdc; + HBITMAP bmp, old_bmp; + BYTE *bits; - bool capture_cursor; - bool cursor_captured; - CURSORINFO ci; + bool capture_cursor; + bool cursor_captured; + CURSORINFO ci; - bool valid; + bool valid; }; extern void dc_capture_init(struct dc_capture *capture, int x, int y, @@ -34,6 +34,6 @@ extern void dc_capture_init(struct dc_capture *capture, int x, int y, extern void dc_capture_free(struct dc_capture *capture); extern void dc_capture_capture(struct dc_capture *capture, HWND window); -extern void dc_capture_render(struct dc_capture *capture, effect_t effect); +extern void dc_capture_render(struct dc_capture *capture, gs_effect_t effect); -extern effect_t create_opaque_effect(void); +extern gs_effect_t create_opaque_effect(void); diff --git a/plugins/win-capture/monitor-capture.c b/plugins/win-capture/monitor-capture.c index 7bf44a205..6e458231b 100644 --- a/plugins/win-capture/monitor-capture.c +++ b/plugins/win-capture/monitor-capture.c @@ -10,7 +10,7 @@ struct monitor_capture { struct dc_capture data; - effect_t opaque_effect; + gs_effect_t opaque_effect; }; struct monitor_info { @@ -95,7 +95,7 @@ static void monitor_capture_destroy(void *data) obs_enter_graphics(); dc_capture_free(&capture->data); - effect_destroy(capture->opaque_effect); + gs_effect_destroy(capture->opaque_effect); obs_leave_graphics(); @@ -112,7 +112,7 @@ static void monitor_capture_defaults(obs_data_t settings) static void *monitor_capture_create(obs_data_t settings, obs_source_t source) { struct monitor_capture *capture; - effect_t opaque_effect = create_opaque_effect(); + gs_effect_t opaque_effect = create_opaque_effect(); if (!opaque_effect) return NULL; @@ -137,7 +137,7 @@ static void monitor_capture_tick(void *data, float seconds) UNUSED_PARAMETER(seconds); } -static void monitor_capture_render(void *data, effect_t effect) +static void monitor_capture_render(void *data, gs_effect_t effect) { struct monitor_capture *capture = data; dc_capture_render(&capture->data, capture->opaque_effect); diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index 487cf2301..7ad86532d 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -33,7 +33,7 @@ struct window_capture { float resize_timer; - effect_t opaque_effect; + gs_effect_t opaque_effect; HWND window; RECT last_rect; @@ -311,7 +311,7 @@ static const char *wc_getname(void) static void *wc_create(obs_data_t settings, obs_source_t source) { struct window_capture *wc; - effect_t opaque_effect = create_opaque_effect(); + gs_effect_t opaque_effect = create_opaque_effect(); if (!opaque_effect) return NULL; @@ -335,7 +335,7 @@ static void wc_destroy(void *data) bfree(wc->executable); obs_enter_graphics(); - effect_destroy(wc->opaque_effect); + gs_effect_destroy(wc->opaque_effect); obs_leave_graphics(); bfree(wc); @@ -441,7 +441,7 @@ static void wc_tick(void *data, float seconds) obs_leave_graphics(); } -static void wc_render(void *data, effect_t effect) +static void wc_render(void *data, gs_effect_t effect) { struct window_capture *wc = data; dc_capture_render(&wc->capture, wc->opaque_effect); diff --git a/test/test-input/test-filter.c b/test/test-input/test-filter.c index 01370f393..9d5b5ec6a 100644 --- a/test/test-input/test-filter.c +++ b/test/test-input/test-filter.c @@ -2,7 +2,7 @@ struct test_filter { obs_source_t source; - effect_t whatever; + gs_effect_t whatever; }; static const char *filter_getname(void) @@ -17,7 +17,7 @@ static void filter_destroy(void *data) if (tf) { obs_enter_graphics(); - effect_destroy(tf->whatever); + gs_effect_destroy(tf->whatever); bfree(tf); obs_leave_graphics(); @@ -34,7 +34,7 @@ static void *filter_create(obs_data_t settings, obs_source_t source) effect_file = obs_module_file("test.effect"); tf->source = source; - tf->whatever = gs_create_effect_from_file(effect_file, NULL); + tf->whatever = gs_effect_create_from_file(effect_file, NULL); bfree(effect_file); if (!tf->whatever) { filter_destroy(tf); @@ -47,7 +47,7 @@ static void *filter_create(obs_data_t settings, obs_source_t source) return tf; } -static void filter_render(void *data, effect_t effect) +static void filter_render(void *data, gs_effect_t effect) { struct test_filter *tf = data; obs_source_process_filter(tf->source, tf->whatever, 0, 0, GS_RGBA,