mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 09:39:15 +00:00
changed gs_draw_sprite to allow custom sizes, added output textures to the core, and adjusted the test code to accommodate the changes
This commit is contained in:
parent
32e34ffe25
commit
58810f9806
|
@ -675,7 +675,8 @@ static inline void build_sprite(struct vb_data *data, float fcx, float fcy,
|
|||
vec2_set(tvarray+3, end_u, end_v);
|
||||
}
|
||||
|
||||
void gs_draw_sprite(texture_t tex, uint32_t flip)
|
||||
void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
float fcx, fcy;
|
||||
|
@ -688,8 +689,8 @@ void gs_draw_sprite(texture_t tex, uint32_t flip)
|
|||
return;
|
||||
}
|
||||
|
||||
fcx = (float)texture_getwidth(tex);
|
||||
fcy = (float)texture_getheight(tex);
|
||||
fcx = width ? (float)width : (float)texture_getwidth(tex);
|
||||
fcy = height ? (float)height : (float)texture_getheight(tex);
|
||||
|
||||
data = vertexbuffer_getdata(graphics->sprite_buffer);
|
||||
build_sprite(data, fcx, fcy, flip);
|
||||
|
|
|
@ -429,7 +429,6 @@ struct gs_init_data {
|
|||
uint32_t adapter;
|
||||
};
|
||||
|
||||
|
||||
EXPORT int gs_create(graphics_t *graphics, const char *module,
|
||||
struct gs_init_data *data);
|
||||
EXPORT void gs_destroy(graphics_t graphics);
|
||||
|
@ -490,7 +489,15 @@ EXPORT texture_t gs_create_volumetexture_from_file(const char *flie,
|
|||
#define GS_FLIP_U (1<<0)
|
||||
#define GS_FLIP_V (1<<1)
|
||||
|
||||
EXPORT void gs_draw_sprite(texture_t tex, uint32_t flip);
|
||||
/**
|
||||
* Draws a 2D sprite
|
||||
*
|
||||
* If width or height is 0, the width or height of the texture will be used.
|
||||
* 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,
|
||||
uint32_t height);
|
||||
|
||||
EXPORT void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot,
|
||||
float left, float right, float top, float bottom, float znear);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "obs-module.h"
|
||||
#include "obs-source.h"
|
||||
#include "obs-output.h"
|
||||
/*#include "obs-service.h"*/
|
||||
#include "obs-service.h"
|
||||
|
||||
#define NUM_TEXTURES 2
|
||||
|
||||
|
@ -46,6 +46,8 @@ struct obs_display {
|
|||
struct obs_video {
|
||||
graphics_t graphics;
|
||||
stagesurf_t copy_surfaces[NUM_TEXTURES];
|
||||
texture_t render_textures[NUM_TEXTURES];
|
||||
texture_t output_textures[NUM_TEXTURES];
|
||||
effect_t default_effect;
|
||||
bool textures_copied[NUM_TEXTURES];
|
||||
bool copy_mapped;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "media-io/format-conversion.h"
|
||||
#include "util/platform.h"
|
||||
#include "graphics/matrix3.h"
|
||||
#include "graphics/vec3.h"
|
||||
|
||||
#include "obs.h"
|
||||
#include "obs-data.h"
|
||||
|
@ -452,7 +454,7 @@ static void obs_source_draw_texture(texture_t tex, struct source_frame *frame)
|
|||
param = effect_getparambyname(effect, "diffuse");
|
||||
effect_settexture(effect, param, tex);
|
||||
|
||||
gs_draw_sprite(tex, frame->flip ? GS_FLIP_V : 0);
|
||||
gs_draw_sprite(tex, frame->flip ? GS_FLIP_V : 0, 0, 0);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
|
|
|
@ -41,14 +41,16 @@ static void CreateOBS(NSWindow *win)
|
|||
|
||||
struct obs_video_info ovi;
|
||||
ovi.adapter = 0;
|
||||
ovi.base_width = cx;
|
||||
ovi.base_height = cy;
|
||||
ovi.fps_num = 30000;
|
||||
ovi.fps_den = 1001;
|
||||
ovi.graphics_module = "libobs-opengl";
|
||||
ovi.output_format = VIDEO_FORMAT_RGBA;
|
||||
ovi.base_width = cx;
|
||||
ovi.base_height = cy;
|
||||
ovi.output_width = cx;
|
||||
ovi.output_height = cy;
|
||||
ovi.window_width = cx;
|
||||
ovi.window_height = cy;
|
||||
ovi.window.view = [win contentView];
|
||||
|
||||
if (!obs_reset_video(&ovi))
|
||||
|
@ -142,15 +144,15 @@ static void test()
|
|||
|
||||
/* ------------------------------------------------------ */
|
||||
/* create source */
|
||||
SourceContext source = autorelease(obs_source_create(SOURCE_INPUT,
|
||||
"random", NULL));
|
||||
SourceContext source = autorelease(obs_source_create(
|
||||
SOURCE_INPUT, "random", NULL));
|
||||
if (!source)
|
||||
throw "Couldn't create random test source";
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
/* create filter */
|
||||
SourceContext filter = autorelease(obs_source_create(SOURCE_FILTER,
|
||||
"test", NULL));
|
||||
SourceContext filter = autorelease(obs_source_create(
|
||||
SOURCE_FILTER, "test", NULL));
|
||||
if (!filter)
|
||||
throw "Couldn't create test filter";
|
||||
obs_source_filter_add(source.get(), filter.get());
|
||||
|
|
|
@ -78,7 +78,7 @@ void test_video_render(struct test_filter *tf)
|
|||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
|
||||
gs_draw_sprite(tex, 0);
|
||||
gs_draw_sprite(tex, 0, 0, 0);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
|
|
|
@ -77,7 +77,7 @@ void random_video_render(struct random_tex *rt, obs_source_t filter_target)
|
|||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
|
||||
gs_draw_sprite(rt->texture, 0);
|
||||
gs_draw_sprite(rt->texture, 0, 0, 0);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
|
|
|
@ -78,6 +78,8 @@ static void CreateOBS(HWND hwnd)
|
|||
ovi.fps_num = 30000;
|
||||
ovi.fps_den = 1001;
|
||||
ovi.graphics_module = "libobs-opengl";
|
||||
ovi.window_width = rc.right;
|
||||
ovi.window_height = rc.bottom;
|
||||
ovi.output_format = VIDEO_FORMAT_RGBA;
|
||||
ovi.output_width = rc.right;
|
||||
ovi.output_height = rc.bottom;
|
||||
|
|
Loading…
Reference in a new issue