1 /* RetroArch - A frontend for libretro.
2 * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3 * copyright (c) 2011-2017 - Daniel De Matteis
4 * copyright (c) 2016-2019 - Brad Parker
5 *
6 * RetroArch is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU General Public License as published by the Free Software Found-
8 * ation, either version 3 of the License, or (at your option) any later version.
9 *
10 * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with RetroArch.
15 * If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef __GL1_COMMON_H
19 #define __GL1_COMMON_H
20
21 #include <retro_environment.h>
22 #include <retro_inline.h>
23 #include <gfx/math/matrix_4x4.h>
24
25 #if defined(__APPLE__)
26 #include <OpenGL/gl.h>
27 #include <OpenGL/glext.h>
28 #else
29 #if defined(_WIN32) && !defined(_XBOX)
30 #define WIN32_LEAN_AND_MEAN
31 #include <windows.h>
32 #endif
33 #ifdef VITA
34 #include <vitaGL.h>
35 #else
36 #include <GL/gl.h>
37 #include <GL/glext.h>
38 #endif
39 #endif
40
41 #include "../../retroarch.h"
42
43 #ifdef VITA
44 #define GL_RGBA8 GL_RGBA
45 #define GL_RGB8 GL_RGB
46 #define GL_BGRA_EXT GL_RGBA // Currently unsupported in vitaGL
47 #define GL_CLAMP GL_CLAMP_TO_EDGE
48 #endif
49
50 #define RARCH_GL1_INTERNAL_FORMAT32 GL_RGBA8
51 #define RARCH_GL1_TEXTURE_TYPE32 GL_BGRA_EXT
52 #define RARCH_GL1_FORMAT32 GL_UNSIGNED_BYTE
53
54 struct string_list;
55
56 typedef struct gl1
57 {
58 bool fullscreen;
59 bool menu_rgb32;
60 bool menu_size_changed;
61 bool rgb32;
62 bool supports_bgra;
63 bool keep_aspect;
64 bool should_resize;
65 bool menu_texture_enable;
66 bool menu_texture_full_screen;
67 bool have_sync;
68 bool smooth;
69 bool menu_smooth;
70 bool overlay_enable;
71 bool overlay_full_screen;
72 bool shared_context_use;
73
74 int version_major;
75 int version_minor;
76
77
78 unsigned video_width;
79 unsigned video_height;
80 unsigned video_pitch;
81 unsigned screen_width;
82 unsigned screen_height;
83 unsigned menu_width;
84 unsigned menu_height;
85 unsigned menu_pitch;
86 unsigned video_bits;
87 unsigned menu_bits;
88 unsigned vp_out_width;
89 unsigned vp_out_height;
90 unsigned tex_index; /* For use with PREV. */
91 unsigned textures;
92 unsigned rotation;
93 unsigned overlays;
94
95 GLuint tex;
96 GLuint menu_tex;
97
98 struct video_viewport vp;
99 struct video_coords coords;
100 math_matrix_4x4 mvp, mvp_no_rot;
101
102 void *ctx_data;
103 const gfx_ctx_driver_t *ctx_driver;
104 struct string_list *extensions;
105 struct video_tex_info tex_info;
106 void *readback_buffer_screenshot;
107 GLuint *overlay_tex;
108 float *overlay_vertex_coord;
109 float *overlay_tex_coord;
110 float *overlay_color_coord;
111 const float *vertex_ptr;
112 const float *white_color_ptr;
113 unsigned char *menu_frame;
114 unsigned char *video_buf;
115 unsigned char *menu_video_buf;
116 GLuint texture[GFX_MAX_TEXTURES];
117 } gl1_t;
118
gl1_bind_texture(GLuint id,GLint wrap_mode,GLint mag_filter,GLint min_filter)119 static INLINE void gl1_bind_texture(GLuint id, GLint wrap_mode, GLint mag_filter,
120 GLint min_filter)
121 {
122 glBindTexture(GL_TEXTURE_2D, id);
123 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode);
124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode);
125 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
126 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
127 }
128
129 #endif
130