2023-03-31 20:20:27 +02:00
|
|
|
#ifndef SC_DISPLAY_H
|
|
|
|
|
#define SC_DISPLAY_H
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2024-12-20 20:58:41 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <libavutil/frame.h>
|
2025-07-11 09:42:03 +02:00
|
|
|
#include <SDL3/SDL.h>
|
2023-03-31 20:20:27 +02:00
|
|
|
|
|
|
|
|
#include "coords.h"
|
|
|
|
|
#include "opengl.h"
|
2023-11-19 01:06:59 +01:00
|
|
|
#include "options.h"
|
2023-03-31 20:20:27 +02:00
|
|
|
|
2023-04-05 16:04:03 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
|
# define SC_DISPLAY_FORCE_OPENGL_CORE_PROFILE
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-31 20:20:27 +02:00
|
|
|
struct sc_display {
|
|
|
|
|
SDL_Renderer *renderer;
|
|
|
|
|
SDL_Texture *texture;
|
|
|
|
|
|
|
|
|
|
struct sc_opengl gl;
|
2023-04-05 16:04:03 +02:00
|
|
|
#ifdef SC_DISPLAY_FORCE_OPENGL_CORE_PROFILE
|
2025-07-25 12:22:09 +02:00
|
|
|
SDL_GLContext gl_context;
|
2023-04-05 16:04:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
2023-03-31 20:20:27 +02:00
|
|
|
bool mipmaps;
|
2025-07-11 09:42:03 +02:00
|
|
|
uint32_t texture_id; // only set if mipmaps is enabled
|
2023-05-08 18:16:38 +02:00
|
|
|
|
|
|
|
|
struct {
|
2025-07-03 19:04:09 +02:00
|
|
|
#define SC_DISPLAY_PENDING_FLAG_TEXTURE 1
|
2023-05-08 18:16:38 +02:00
|
|
|
#define SC_DISPLAY_PENDING_FLAG_FRAME 2
|
|
|
|
|
int8_t flags;
|
2025-07-03 19:04:09 +02:00
|
|
|
struct {
|
|
|
|
|
struct sc_size size;
|
2025-07-10 23:07:45 +02:00
|
|
|
enum AVColorSpace color_space;
|
2025-07-03 19:04:09 +02:00
|
|
|
enum AVColorRange color_range;
|
|
|
|
|
} texture;
|
2023-05-08 18:16:38 +02:00
|
|
|
AVFrame *frame;
|
|
|
|
|
} pending;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum sc_display_result {
|
|
|
|
|
SC_DISPLAY_RESULT_OK,
|
|
|
|
|
SC_DISPLAY_RESULT_PENDING,
|
|
|
|
|
SC_DISPLAY_RESULT_ERROR,
|
2023-03-31 20:20:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool
|
2024-04-07 16:01:26 +02:00
|
|
|
sc_display_init(struct sc_display *display, SDL_Window *window,
|
|
|
|
|
SDL_Surface *icon_novideo, bool mipmaps);
|
2023-03-31 20:20:27 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
sc_display_destroy(struct sc_display *display);
|
|
|
|
|
|
2023-05-08 18:16:38 +02:00
|
|
|
enum sc_display_result
|
2025-07-03 19:04:09 +02:00
|
|
|
sc_display_prepare_texture(struct sc_display *display, struct sc_size size,
|
2025-07-10 23:07:45 +02:00
|
|
|
enum AVColorSpace color_space,
|
2025-07-03 19:04:09 +02:00
|
|
|
enum AVColorRange color_range);
|
2023-03-31 20:20:27 +02:00
|
|
|
|
2023-05-08 18:16:38 +02:00
|
|
|
enum sc_display_result
|
2023-03-31 20:20:27 +02:00
|
|
|
sc_display_update_texture(struct sc_display *display, const AVFrame *frame);
|
|
|
|
|
|
2023-05-08 18:16:38 +02:00
|
|
|
enum sc_display_result
|
2023-03-31 20:20:27 +02:00
|
|
|
sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
2023-11-19 01:06:59 +01:00
|
|
|
enum sc_orientation orientation);
|
2023-03-31 20:20:27 +02:00
|
|
|
|
|
|
|
|
#endif
|