snes9x/gtk/src/gtk_display_driver_opengl.h

95 lines
2.8 KiB
C
Raw Normal View History

2010-09-25 17:46:12 +02:00
#ifndef __GTK_DISPLAY_DRIVER_OPENGL_H
#define __GTK_DISPLAY_DRIVER_OPENGL_H
#include "gtk_s9x.h"
#include "gtk_display_driver.h"
#include <epoxy/gl.h>
#include "gtk_opengl_context.h"
2018-10-15 21:04:28 +02:00
#ifdef GDK_WINDOWING_X11
#include "gtk_glx_context.h"
2018-10-15 21:04:28 +02:00
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include "gtk_wayland_egl_context.h"
#endif
2018-05-11 01:47:55 +02:00
#include "shaders/glsl.h"
2010-09-25 17:46:12 +02:00
#define PBO_FMT_16 0
#define PBO_FMT_24 1
#define PBO_FMT_32 2
#define BUFFER_OFFSET(i) ((char *) NULL + (i))
#ifdef __BIG_ENDIAN__
/* We have to reverse the bytes on MSB systems. This can be slow */
/* GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367 */
#define PBO_BGRA_NATIVE_ORDER 0x8367
#else
#define PBO_BGRA_NATIVE_ORDER GL_UNSIGNED_BYTE
#endif
#define PBO_GET_FORMAT(x) (((x) == PBO_FMT_32) ? GL_BGRA : GL_RGB)
#define PBO_GET_PACKING(x) (((x) == PBO_FMT_16) ? GL_UNSIGNED_SHORT_5_6_5 : (((x) == PBO_FMT_24) ? GL_UNSIGNED_BYTE : PBO_BGRA_NATIVE_ORDER))
2010-09-25 17:46:12 +02:00
class S9xOpenGLDisplayDriver : public S9xDisplayDriver
{
public:
S9xOpenGLDisplayDriver (Snes9xWindow *window, Snes9xConfig *config);
void refresh (int width, int height);
int init ();
void deinit ();
void clear_buffers ();
2018-05-05 00:12:22 +02:00
void update (int width, int height, int yoffset);
uint16 *get_next_buffer ();
uint16 *get_current_buffer ();
2010-09-25 17:46:12 +02:00
void push_buffer (uint16 *src);
void reconfigure (int width, int height);
void *get_parameters ();
2018-05-13 18:02:52 +02:00
void save (const char *filename);
static int query_availability ();
2010-09-25 17:46:12 +02:00
private:
int opengl_defaults ();
void swap_buffers ();
int pbos_available ();
int shaders_available ();
int load_shaders (const char *);
2010-09-25 17:46:12 +02:00
void update_texture_size (int width, int height);
int init_gl ();
void resize ();
2010-09-26 11:19:15 +02:00
GLint texture_width;
GLint texture_height;
GLfloat vertices[8];
GLfloat texcoords[8];
GLuint texmap;
GLuint pbo;
GLuint program;
GLuint fragment_shader;
GLuint vertex_shader;
2010-09-25 17:46:12 +02:00
2010-09-26 11:19:15 +02:00
int dyn_resizing;
int using_pbos;
int using_shaders;
int initialized;
2010-09-25 17:46:12 +02:00
2018-05-11 01:47:55 +02:00
int using_glsl_shaders;
GLSLShader *glsl_shader;
2018-10-15 21:04:28 +02:00
GdkWindow *gdk_window;
int output_window_width;
int output_window_height;
OpenGLContext *context;
2018-10-15 21:04:28 +02:00
#ifdef GDK_WINDOWING_X11
GTKGLXContext glx;
2018-10-15 21:04:28 +02:00
#endif
#ifdef GDK_WINDOWING_WAYLAND
WaylandEGLContext wl;
#endif
2010-09-25 17:46:12 +02:00
};
#endif /* __GTK_DISPLAY_DRIVER_OPENGL_H */