Added missing launcher
[mupen64plus-pandora.git] / gles2glide64 / src / Glitch64 / main.h
... / ...
CommitLineData
1/*
2* Glide64 - Glide video plugin for Nintendo 64 emulators.
3* Copyright (c) 2002 Dave2001
4* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
5*
6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2 of the License, or
9* any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program; if not, write to the Free Software
18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21#ifndef MAIN_H
22#define MAIN_H
23
24#include <m64p_types.h>
25
26#define LOG(...) // WriteLog(M64MSG_VERBOSE, __VA_ARGS__)
27#define LOGINFO(...) WriteLog(M64MSG_INFO, __VA_ARGS__)
28#ifdef __cplusplus
29extern "C" {
30#endif
31void WriteLog(m64p_msg_level level, const char *msg, ...);
32#ifdef __cplusplus
33}
34#endif
35
36
37#ifndef _WIN32
38//#define VPDEBUG
39#endif
40#ifdef VPDEBUG
41void dump_tex(int id);
42void dump_start();
43void dump_stop();
44extern int dumping;
45#endif
46
47#define zscale 1.0f
48
49typedef struct _wrapper_config
50{
51 int res;
52 int fbo;
53 int anisofilter;
54 int vram_size;
55} wrapper_config;
56extern wrapper_config config;
57
58
59// VP added this utility function
60// returns the bytes per pixel of a given GR texture format
61int grTexFormatSize(int fmt);
62
63extern int packed_pixels_support;
64extern int ati_sucks;
65extern float largest_supported_anisotropy;
66
67extern int default_texture; // the infamous "32*1024*1024" is now configurable
68extern int depth_texture;
69void set_depth_shader();
70void set_bw_shader();
71extern float invtex[2];
72extern int buffer_cleared; // mark that the buffer has been cleared, used to check if we need to reload the texture buffer content
73
74#ifdef _WIN32
75#include <windows.h>
76extern "C" {
77 #include <SDL_opengl.h>
78 extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
79 extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
80 extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
81 extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
82 extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
83 extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
84 extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
85 extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
86 extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
87 extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
88 extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
89 extern PFNGLFOGCOORDFEXTPROC glFogCoordfEXT;
90 extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
91 extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
92 extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
93 extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
94 extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
95 extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
96 extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
97 extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
98 extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
99 extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
100 extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
101 extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
102 extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
103 extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
104 extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
105 extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
106 typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
107}
108#else
109#include <stdio.h>
110//#define printf(...)
111#define GL_GLEXT_PROTOTYPES
112#include <SDL_opengles2.h>
113#endif // _WIN32
114#include "glide.h"
115#include "glState.cpp"
116
117void display_warning(const unsigned char *text, ...);
118void display_warning(const char *text, ...);
119void init_geometry();
120void init_textures();
121void init_combiner();
122void free_textures();
123void updateCombiner(int i);
124void updateCombinera(int i);
125void remove_tex(unsigned int idmin, unsigned int idmax);
126void add_tex(unsigned int id);
127
128#ifdef _WIN32
129extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
130extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
131extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
132extern PFNGLFOGCOORDFPROC glFogCoordfEXT;
133
134extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
135extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
136extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
137extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
138extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
139extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
140extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
141extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
142extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
143extern PFNGLUNIFORM4IARBPROC glUniform4iARB;
144extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
145extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
146extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
147extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
148extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
149extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
150#endif
151void check_compile(GLuint shader);
152void check_link(GLuint program);
153void vbo_enable();
154void vbo_disable();
155
156//Vertex Attribute Locations
157#define POSITION_ATTR 0
158#define COLOUR_ATTR 1
159#define TEXCOORD_0_ATTR 2
160#define TEXCOORD_1_ATTR 3
161#define FOG_ATTR 4
162
163extern int w_buffer_mode;
164extern int nbTextureUnits;
165extern int width, height, widtho, heighto;
166extern int tex0_width, tex0_height, tex1_width, tex1_height;
167extern float texture_env_color[4];
168extern int fog_enabled;
169extern float lambda;
170extern int need_lambda[2];
171extern float lambda_color[2][4];
172extern int inverted_culling;
173extern int culling_mode;
174extern int render_to_texture;
175extern int lfb_color_fmt;
176extern int need_to_compile;
177extern int blackandwhite0;
178extern int blackandwhite1;
179extern int TMU_SIZE;
180
181extern int blend_func_separate_support;
182extern int fog_coord_support;
183//extern int pbuffer_support;
184extern int glsl_support;
185extern unsigned int pBufferAddress;
186extern int viewport_width, viewport_height, viewport_offset, nvidia_viewport_hack;
187extern int UMAmode;
188
189void grChromaRangeExt(GrColor_t color0, GrColor_t color1, FxU32 mode);
190void grChromaRangeModeExt(GrChromakeyMode_t mode);
191void grTexChromaRangeExt(GrChipID_t tmu, GrColor_t color0, GrColor_t color1, GrTexChromakeyMode_t mode);
192void grTexChromaModeExt(GrChipID_t tmu, GrChromakeyMode_t mode);
193void updateTexture();
194void reloadTexture();
195void free_combiners();
196void compile_shader();
197void set_lambda();
198void set_copy_shader();
199void disable_textureSizes();
200
201// config functions
202
203//FX_ENTRY void FX_CALL grConfigWrapperExt(HINSTANCE instance, HWND hwnd);
204FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
205FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
206FX_ENTRY char ** FX_CALL grQueryResolutionsExt(FxI32*);
207FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
208FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*);
209
210int getFullScreenWidth();
211int getFullScreenHeight();
212
213// ZIGGY framebuffer copy extension
214// allow to copy the depth or color buffer from back/front to front/back
215#define GR_FBCOPY_MODE_DEPTH 0
216#define GR_FBCOPY_MODE_COLOR 1
217#define GR_FBCOPY_BUFFER_BACK 0
218#define GR_FBCOPY_BUFFER_FRONT 1
219FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h,
220 int buffer_from, int buffer_to, int mode);
221
222
223// COMBINE extension
224
225typedef FxU32 GrCCUColor_t;
226typedef FxU32 GrACUColor_t;
227typedef FxU32 GrTCCUColor_t;
228typedef FxU32 GrTACUColor_t;
229
230typedef FxU32 GrCombineMode_t;
231#define GR_FUNC_MODE_ZERO 0x00
232#define GR_FUNC_MODE_X 0x01
233#define GR_FUNC_MODE_ONE_MINUS_X 0x02
234#define GR_FUNC_MODE_NEGATIVE_X 0x03
235#define GR_FUNC_MODE_X_MINUS_HALF 0x04
236
237#define GR_CMBX_ZERO 0x00
238#define GR_CMBX_TEXTURE_ALPHA 0x01
239#define GR_CMBX_ALOCAL 0x02
240#define GR_CMBX_AOTHER 0x03
241#define GR_CMBX_B 0x04
242#define GR_CMBX_CONSTANT_ALPHA 0x05
243#define GR_CMBX_CONSTANT_COLOR 0x06
244#define GR_CMBX_DETAIL_FACTOR 0x07
245#define GR_CMBX_ITALPHA 0x08
246#define GR_CMBX_ITRGB 0x09
247#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a
248#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b
249#define GR_CMBX_LOD_FRAC 0x0c
250#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d
251#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e
252#define GR_CMBX_TEXTURE_RGB 0x0f
253#define GR_CMBX_TMU_CALPHA 0x10
254#define GR_CMBX_TMU_CCOLOR 0x11
255
256
257FX_ENTRY void FX_CALL
258grColorCombineExt(GrCCUColor_t a, GrCombineMode_t a_mode,
259 GrCCUColor_t b, GrCombineMode_t b_mode,
260 GrCCUColor_t c, FxBool c_invert,
261 GrCCUColor_t d, FxBool d_invert,
262 FxU32 shift, FxBool invert);
263
264FX_ENTRY void FX_CALL
265grAlphaCombineExt(GrACUColor_t a, GrCombineMode_t a_mode,
266 GrACUColor_t b, GrCombineMode_t b_mode,
267 GrACUColor_t c, FxBool c_invert,
268 GrACUColor_t d, FxBool d_invert,
269 FxU32 shift, FxBool invert);
270
271FX_ENTRY void FX_CALL
272grTexColorCombineExt(GrChipID_t tmu,
273 GrTCCUColor_t a, GrCombineMode_t a_mode,
274 GrTCCUColor_t b, GrCombineMode_t b_mode,
275 GrTCCUColor_t c, FxBool c_invert,
276 GrTCCUColor_t d, FxBool d_invert,
277 FxU32 shift, FxBool invert);
278
279FX_ENTRY void FX_CALL
280grTexAlphaCombineExt(GrChipID_t tmu,
281 GrTACUColor_t a, GrCombineMode_t a_mode,
282 GrTACUColor_t b, GrCombineMode_t b_mode,
283 GrTACUColor_t c, FxBool c_invert,
284 GrTACUColor_t d, FxBool d_invert,
285 FxU32 shift, FxBool invert);
286
287FX_ENTRY void FX_CALL
288grConstantColorValueExt(GrChipID_t tmu,
289 GrColor_t value);
290
291#define CHECK_FRAMEBUFFER_STATUS() \
292{\
293 GLenum status; \
294 status = glCheckFramebufferStatus(GL_FRAMEBUFFER); \
295 /*display_warning("%x\n", status);*/\
296 switch(status) { \
297 case GL_FRAMEBUFFER_COMPLETE: \
298 /*display_warning("framebuffer complete!\n");*/\
299 break; \
300 case GL_FRAMEBUFFER_UNSUPPORTED: \
301 display_warning("framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n");\
302 /* you gotta choose different formats */ \
303 /*assert(0);*/ \
304 break; \
305 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: \
306 display_warning("framebuffer INCOMPLETE_ATTACHMENT\n");\
307 break; \
308 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: \
309 display_warning("framebuffer FRAMEBUFFER_MISSING_ATTACHMENT\n");\
310 break; \
311 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: \
312 display_warning("framebuffer FRAMEBUFFER_DIMENSIONS\n");\
313 break; \
314 default: \
315 break; \
316 /* programming error; will fail on all hardware */ \
317 /*assert(0);*/ \
318 }\
319}
320
321#ifdef VPDEBUG
322#define LOGGING
323#endif
324
325#ifdef LOGGING
326void OPEN_LOG();
327void CLOSE_LOG();
328//void LOG(const char *text, ...);
329#else // LOGGING
330#define OPEN_LOG()
331#define CLOSE_LOG()
332//#define LOG
333#endif // LOGGING
334
335#endif