AI Code?!

sotspodcast

Member
Playing with ChatGPT & I asked it to build some code for an OBS Studio plugin & the next thing I know the AI is writing code. Now, I don't know code very well, but this appears as code to me. Does anyone know if it is possible?! Or has anyone else tried creating a plugin from code written by AI? Chances are it doesn't work, but, we aren't scientisting very well if we don't try, right?
 

Attachments

  • Screenshot_20221231-060156.png
    Screenshot_20221231-060156.png
    213.4 KB · Views: 60
  • Screenshot_20221231-060506.png
    Screenshot_20221231-060506.png
    196.9 KB · Views: 63
  • Screenshot_20221231-060625.png
    Screenshot_20221231-060625.png
    256.2 KB · Views: 62

sotspodcast

Member
For example, here is a code the AI wrote to create a 3D environment plugin for OBS. Anyone with any knowledge in code, feel free to try this out. Like I said, I don't exactly know coding, but does this work?

#include <obs-module.h>
#include <graphics/matrix4.h>

#define SETTING_SCENE "scene"

struct Scene3DData {
obs_source_t *scene;
};

static const char *Scene3D_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return "3D Scene";
}

static void Scene3D_update(void *data, obs_data_t *settings)
{
struct Scene3DData *s = data;
const char *scene_name = obs_data_get_string(settings, SETTING_SCENE);
obs_source_t *new_scene = obs_get_source_by_name(scene_name);
if (new_scene) {
obs_source_release(s->scene);
s->scene = new_scene;
}
}

static void Scene3D_render(void *data, gs_effect_t *effect)
{
struct Scene3DData *s = data;
if (s->scene) {
mat4 modelview;
gs_matrix_get(&modelview);

vec3 pos = {1.0f, 0.0f, 0.0f};
gs_matrix_push();
gs_matrix_translate3fv(&pos);
obs_source_video_render(s->scene);
gs_matrix_pop();
}
}

static void Scene3D_destroy(void *data)
{
struct Scene3DData *s = data;
obs_source_release(s->scene);
bfree(s);
}

static void *Scene3D_create(obs_data_t *settings, obs_source_t *source)
{
struct Scene3DData *s = bzalloc(sizeof(struct Scene3DData));
s->scene = NULL;
Scene3D_update(s, settings);
return s;
}

static obs_properties_t *Scene3D_properties(void *unused)
{
UNUSED_PARAMETER(unused);

obs_properties_t *props = obs_properties_create();
obs_properties_add_text(props, SETTING_SCENE, "Scene", OBS_TEXT_DEFAULT);
return props;
}

struct obs_source_info Scene3D_info = {
.id = "scene_3d",
.type = OBS_SOURCE_TYPE_INPUT,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = Scene3D_get_name,
.create = Scene3D_create,
.destroy = Scene3D_destroy,
.update = Scene3D_update,
.video_render = Scene3D_render,
.get_properties = Scene3D_properties
};

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("scene-3
 
Top