2013-05-10 16:59:30 +00:00
|
|
|
#ifndef GL_HPP__
|
|
|
|
#define GL_HPP__
|
|
|
|
|
2013-05-11 17:03:51 +00:00
|
|
|
#if defined(_WIN32) && !defined(_XBOX)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2013-05-10 16:59:30 +00:00
|
|
|
#define GL_GLEXT_PROTOTYPES
|
|
|
|
#if defined(GLES)
|
2013-05-12 12:00:58 +00:00
|
|
|
#ifdef IOS
|
|
|
|
#include <OpenGLES/ES2/gl.h>
|
|
|
|
#else
|
2013-05-10 16:59:30 +00:00
|
|
|
#include <GLES2/gl2.h>
|
2013-05-12 12:00:58 +00:00
|
|
|
#endif
|
2013-05-12 14:08:57 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#include <OpenGL/glext.h>
|
2013-05-18 02:39:12 +00:00
|
|
|
#elif defined(__CELLOS_LV2__)
|
|
|
|
#include <PSGL/psgl.h>
|
|
|
|
#include <PSGL/psglu.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
extern void _jsEnableVertexAttribArrayNV(GLuint index);
|
|
|
|
extern void _jsDisableVertexAttribArrayNV(GLuint index);
|
|
|
|
extern void _jsVertexAttribPointerNV(GLuint index,
|
|
|
|
GLint fsize, GLenum type,
|
|
|
|
GLboolean normalized,
|
|
|
|
GLsizei stride, const GLvoid* pointer);
|
|
|
|
#define glEnableVertexAttribArray _jsEnableVertexAttribArrayNV
|
|
|
|
#define glDisableVertexAttribArray _jsDisableVertexAttribArrayNV
|
|
|
|
#define glVertexAttribPointer _jsVertexAttribPointerNV
|
|
|
|
#define glGenerateMipmap glGenerateMipmapOES
|
|
|
|
#define glBindFramebuffer glBindFramebufferOES
|
|
|
|
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
2013-05-10 16:59:30 +00:00
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <map>
|
2013-05-11 17:58:05 +00:00
|
|
|
#include <stdio.h>
|
2013-05-11 18:31:37 +00:00
|
|
|
#include <string>
|
2013-05-10 16:59:30 +00:00
|
|
|
#include "libretro.h"
|
2013-05-11 17:53:10 +00:00
|
|
|
#include "shared.hpp"
|
2013-05-10 16:59:30 +00:00
|
|
|
|
2013-05-11 16:30:41 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define decltype(type) typeof(type)
|
|
|
|
#endif
|
|
|
|
|
2013-05-12 11:27:04 +00:00
|
|
|
#ifdef GLES
|
|
|
|
#define SYM(sym) sym
|
|
|
|
#else
|
2013-05-10 16:59:30 +00:00
|
|
|
#define SYM(sym) (::GL::symbol<decltype(&sym)>(#sym))
|
2013-05-12 11:27:04 +00:00
|
|
|
#endif
|
2013-05-10 16:59:30 +00:00
|
|
|
|
|
|
|
namespace GL
|
|
|
|
{
|
2013-05-10 20:33:22 +00:00
|
|
|
// If true, GL context has been reset and all
|
|
|
|
// objects are invalid. Do not free their resources
|
|
|
|
// in destructors.
|
|
|
|
extern bool dead_state;
|
|
|
|
|
2013-05-10 16:59:30 +00:00
|
|
|
typedef std::map<std::string, retro_proc_address_t> SymMap;
|
|
|
|
|
|
|
|
SymMap& symbol_map();
|
|
|
|
void init_symbol_map();
|
|
|
|
|
2013-05-10 20:33:22 +00:00
|
|
|
// Discover and cache GL symbols on-the-fly.
|
|
|
|
// Avoids things like GLEW, and avoids typing out a billion symbol declarations.
|
2013-05-10 16:59:30 +00:00
|
|
|
void set_function_cb(retro_hw_get_proc_address_t);
|
|
|
|
retro_proc_address_t get_symbol(const std::string& str);
|
|
|
|
|
|
|
|
template<typename Func>
|
|
|
|
inline Func symbol(const std::string& sym)
|
|
|
|
{
|
2013-05-11 16:30:41 +00:00
|
|
|
std::map<std::string, retro_proc_address_t>& map = symbol_map();
|
2013-05-10 16:59:30 +00:00
|
|
|
|
2013-05-11 16:30:41 +00:00
|
|
|
retro_proc_address_t func = map[sym];
|
2013-05-10 16:59:30 +00:00
|
|
|
if (!func)
|
|
|
|
{
|
|
|
|
func = get_symbol(sym);
|
|
|
|
if (!func)
|
2013-05-12 11:27:04 +00:00
|
|
|
retro_stderr_print("Didn't find GL symbol: %s\n", sym.c_str());
|
2013-05-10 16:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return reinterpret_cast<Func>(func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|