void device_enable_stenciltest(device_t device, bool enable) { if (enable) gl_enable(GL_STENCIL_TEST); else gl_disable(GL_STENCIL_TEST); }
device_t device_create(struct gs_init_data *info) { struct gs_device *device = bmalloc(sizeof(struct gs_device)); memset(device, 0, sizeof(struct gs_device)); device->plat = gl_platform_create(device, info); if (!device->plat) goto fail; glGenProgramPipelines(1, &device->pipeline); if (!gl_success("glGenProgramPipelines")) goto fail; glBindProgramPipeline(device->pipeline); if (!gl_success("glBindProgramPipeline")) goto fail; #ifdef _DEBUG glEnable(GL_DEBUG_OUTPUT); if (glGetError() == GL_INVALID_ENUM) blog(LOG_DEBUG, "OpenGL debug information not available"); #endif gl_enable(GL_CULL_FACE); device_leavecontext(device); device->cur_swap = gl_platform_getswap(device->plat); return device; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); return NULL; }
void device_enable_blending(device_t device, bool enable) { if (enable) gl_enable(GL_BLEND); else gl_disable(GL_BLEND); }
void device_enable_depthtest(device_t device, bool enable) { if (enable) gl_enable(GL_DEPTH_TEST); else gl_disable(GL_DEPTH_TEST); }
static bool gl_init_extensions(struct gs_device* device) { if (!ogl_IsVersionGEQ(2, 1)) { blog(LOG_ERROR, "obs-studio requires OpenGL version 2.1 or " "higher."); return false; } gl_enable_debug(); if (!ogl_IsVersionGEQ(3, 0) && !ogl_ext_ARB_framebuffer_object) { blog(LOG_ERROR, "OpenGL extension ARB_framebuffer_object " "is required."); return false; } if (ogl_IsVersionGEQ(3, 2) || ogl_ext_ARB_seamless_cube_map) { gl_enable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } if (!ogl_IsVersionGEQ(4, 1) && !ogl_ext_ARB_separate_shader_objects) { blog(LOG_ERROR, "OpenGL extension ARB_separate_shader_objects " "is required."); return false; } if (ogl_IsVersionGEQ(4, 3) || ogl_ext_ARB_copy_image) device->copy_type = COPY_TYPE_ARB; else if (ogl_ext_NV_copy_image) device->copy_type = COPY_TYPE_NV; else device->copy_type = COPY_TYPE_FBO_BLIT; /* ?? */ return true; }
device_t device_create(struct gs_init_data *info) { struct gs_device *device = bmalloc(sizeof(struct gs_device)); memset(device, 0, sizeof(struct gs_device)); device->plat = gl_platform_create(device, info); if (!device->plat) goto fail; if (!gl_init_extensions(device)) goto fail; gl_enable(GL_CULL_FACE); glGenProgramPipelines(1, &device->pipeline); if (!gl_success("glGenProgramPipelines")) goto fail; glBindProgramPipeline(device->pipeline); if (!gl_success("glBindProgramPipeline")) goto fail; device_leavecontext(device); device->cur_swap = gl_platform_getswap(device->plat); return device; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); return NULL; }
static bool gl_init_extensions(struct gs_device* device) { if (!GLAD_GL_VERSION_2_1) { blog(LOG_ERROR, "obs-studio requires OpenGL version 2.1 or " "higher."); return false; } gl_enable_debug(); if (!GLAD_GL_VERSION_3_0 && !GLAD_GL_ARB_framebuffer_object) { blog(LOG_ERROR, "OpenGL extension ARB_framebuffer_object " "is required."); return false; } if (GLAD_GL_VERSION_3_2 || GLAD_GL_ARB_seamless_cube_map) { gl_enable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } if (!GLAD_GL_VERSION_4_1 && !GLAD_GL_ARB_separate_shader_objects) { blog(LOG_ERROR, "OpenGL extension ARB_separate_shader_objects " "is required."); return false; } if (GLAD_GL_VERSION_4_3 || GLAD_GL_ARB_copy_image) device->copy_type = COPY_TYPE_ARB; else if (GLAD_GL_NV_copy_image) device->copy_type = COPY_TYPE_NV; else device->copy_type = COPY_TYPE_FBO_BLIT; return true; }
int device_create(gs_device_t **p_device, uint32_t adapter) { struct gs_device *device = bzalloc(sizeof(struct gs_device)); int errorcode = GS_ERROR_FAIL; device->plat = gl_platform_create(device, adapter); if (!device->plat) goto fail; if (!gl_init_extensions(device)) { errorcode = GS_ERROR_NOT_SUPPORTED; goto fail; } gl_enable(GL_CULL_FACE); device_leave_context(device); device->cur_swap = NULL; *p_device = device; return GS_SUCCESS; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); *p_device = NULL; return errorcode; }
void device_enable_stencil_test(gs_device_t device, bool enable) { if (enable) gl_enable(GL_STENCIL_TEST); else gl_disable(GL_STENCIL_TEST); UNUSED_PARAMETER(device); }
void device_enable_depth_test(gs_device_t device, bool enable) { if (enable) gl_enable(GL_DEPTH_TEST); else gl_disable(GL_DEPTH_TEST); UNUSED_PARAMETER(device); }
void device_enable_blending(gs_device_t device, bool enable) { if (enable) gl_enable(GL_BLEND); else gl_disable(GL_BLEND); UNUSED_PARAMETER(device); }
static void gl_enable_debug() { if (GLAD_GL_VERSION_4_3) { glDebugMessageCallback(gl_debug_proc, NULL); gl_enable(GL_DEBUG_OUTPUT); } else if (GLAD_GL_ARB_debug_output) { glDebugMessageCallbackARB(gl_debug_proc, NULL); } else { blog(LOG_DEBUG, "Failed to set GL debug callback as it is " "not supported."); } }
static void gl_enable_debug() { /* Perhaps we should create GLEW contexts? */ if (ogl_IsVersionGEQ(4, 3)) { glDebugMessageCallback(gl_debug_proc, NULL); gl_enable(GL_DEBUG_OUTPUT); } else if (ogl_ext_ARB_debug_output) { glDebugMessageCallbackARB(gl_debug_proc, NULL); } else { blog(LOG_DEBUG, "Failed to set GL debug callback as it is " "not supported."); } }
void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect) { UNUSED_PARAMETER(device); if (rect != NULL) { glScissor(rect->x, rect->y, rect->cx, rect->cy); if (gl_success("glScissor") && gl_enable(GL_SCISSOR_TEST)) return; } else if (gl_disable(GL_SCISSOR_TEST)) { return; } blog(LOG_ERROR, "device_set_scissor_rect (GL) failed"); }
void device_setcullmode(device_t device, enum gs_cull_mode mode) { if (device->cur_cull_mode == mode) return; if (device->cur_cull_mode == GS_NEITHER) gl_enable(GL_CULL_FACE); device->cur_cull_mode = mode; if (mode == GS_BACK) gl_cull_face(GL_BACK); else if (mode == GS_FRONT) gl_cull_face(GL_FRONT); else gl_disable(GL_CULL_FACE); }
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; device->plat = gl_platform_create(device, info); if (!device->plat) goto fail; if (!gl_init_extensions(device)) { errorcode = GS_ERROR_NOT_SUPPORTED; goto fail; } gl_enable(GL_CULL_FACE); glGenProgramPipelines(1, &device->pipeline); if (!gl_success("glGenProgramPipelines")) goto fail; glBindProgramPipeline(device->pipeline); if (!gl_success("glBindProgramPipeline")) goto fail; device_leave_context(device); device->cur_swap = gl_platform_getswap(device->plat); *p_device = device; return GS_SUCCESS; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); *p_device = NULL; return errorcode; }
void gl_Enable( GLcontext* ctx, GLenum cap ) { gl_enable( ctx, cap, GL_TRUE ); }
void gl_Disable( GLcontext* ctx, GLenum cap ) { gl_enable( ctx, cap, GL_FALSE ); }