janwas
7cb82ada2f
premake: document extra_params ogl: remove EXT_ symbols, use glext instead adts: move cache into separate file (also remove old cache impl) move SDL files in sysdep/win to libraries/SDL ScopeTimerAccrue: change #ifdef spaghetti into templated policy class app_hooks, define VOID_FUNC to FUNC(.., (void) ) look at stalk walk code; any reason not to work on Win64? replace ERR_TEX_CODEC_CANNOT_HANDLE with INFO_* - not an error. also ERR_SYM_SUPPRESS_OUTPUT ERR_SYM_SINGLE_SYMBOL_LIMIT wdbg_sym: only import RtlCaptureContext once (not every walk_stack) add sys_last_error (!GetLastError on win32); converts to text in display_error, also show sys_last_error and errno app_hooks: move i18n impl out (belongs in pyrogenesis) fixes to string_s test. refs #124 This was SVN commit r4020.
168 lines
4.3 KiB
C
168 lines
4.3 KiB
C
/**
|
|
* =========================================================================
|
|
* File : ogl.h
|
|
* Project : 0 A.D.
|
|
* Description : OpenGL helper functions.
|
|
*
|
|
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
* =========================================================================
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2002-2005 Jan Wassenberg
|
|
*
|
|
* Redistribution and/or modification are also permitted under the
|
|
* terms of the GNU General Public License as published by the
|
|
* Free Software Foundation (version 2 or later, at your option).
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
*/
|
|
|
|
#ifndef __OGL_H__
|
|
#define __OGL_H__
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if OS_WIN
|
|
// wgl.h is a private header and should only be included from here.
|
|
// if this isn't defined, it'll complain.
|
|
#define WGL_HEADER_NEEDED
|
|
#include "lib/sysdep/win/wgl.h"
|
|
#endif
|
|
|
|
|
|
//
|
|
// bring in the platform's OpenGL headers (with fixes, if necessary)
|
|
//
|
|
|
|
#if OS_MACOSX || OS_MAC
|
|
# include <OpenGL/gl.h>
|
|
# include <OpenGL/glu.h>
|
|
#else
|
|
# include <GL/gl.h>
|
|
# include <GL/glu.h>
|
|
#endif
|
|
|
|
// if gl.h provides real prototypes for 1.2 / 1.3 functions,
|
|
// exclude the corresponding function pointers in glext_funcs.h
|
|
#ifdef GL_VERSION_1_2
|
|
#define REAL_GL_1_2
|
|
#endif
|
|
#ifdef GL_VERSION_1_3
|
|
#define REAL_GL_1_3
|
|
#endif
|
|
|
|
// this must come after GL/gl.h include, so we can't combine the
|
|
// including GL/glext.h.
|
|
#undef GL_GLEXT_PROTOTYPES
|
|
|
|
#if OS_MACOSX || OS_MAC
|
|
# include <OpenGL/glext.h>
|
|
#else
|
|
# include <GL/glext.h>
|
|
# if OS_WIN
|
|
# include <GL/wglext.h>
|
|
# define GL_TEXTURE_IMAGE_SIZE_ARB 0x86A0
|
|
# endif
|
|
#endif
|
|
|
|
|
|
//
|
|
// extensions
|
|
//
|
|
|
|
// check if the extension <ext> is supported by the OpenGL implementation.
|
|
// takes subsequently added core support for some extensions into account.
|
|
extern bool oglHaveExtension(const char* ext);
|
|
|
|
// check if the OpenGL implementation is at least at <version>.
|
|
// (format: "%d.%d" major minor)
|
|
extern bool oglHaveVersion(const char* version);
|
|
|
|
// check if all given extension strings (passed as const char* parameters,
|
|
// terminated by a 0 pointer) are supported by the OpenGL implementation,
|
|
// as determined by oglHaveExtension.
|
|
// returns 0 if all are present; otherwise, the first extension in the
|
|
// list that's not supported (useful for reporting errors).
|
|
//
|
|
// note: dummy parameter is necessary to access parameter va_list.
|
|
//
|
|
// rationale: see source.
|
|
extern const char* oglHaveExtensions(int dummy, ...);
|
|
|
|
// return a C string of unspecified length containing a space-separated
|
|
// list of all extensions the OpenGL implementation advertises.
|
|
// (useful for crash logs).
|
|
extern const char* oglExtList(void);
|
|
|
|
|
|
#if OS_WIN
|
|
# define CALL_CONV __stdcall
|
|
#else
|
|
# define CALL_CONV
|
|
#endif
|
|
|
|
#define FUNC(ret, name, params) extern ret (CALL_CONV *p##name) params;
|
|
#define FUNC2(ret, nameARB, nameCore, version, params) extern ret (CALL_CONV *p##nameARB) params;
|
|
#include "glext_funcs.h"
|
|
#undef FUNC2
|
|
#undef FUNC
|
|
|
|
// leave CALL_CONV defined for ogl.cpp
|
|
|
|
|
|
//
|
|
// implementation limits / feature detect
|
|
//
|
|
|
|
extern int ogl_max_tex_size; // [pixels]
|
|
extern int ogl_max_tex_units; // limit on GL_TEXTUREn
|
|
|
|
// set sysdep/gfx.h gfx_card and gfx_drv_ver. called by gfx_detect.
|
|
//
|
|
// fails if OpenGL not ready for use.
|
|
// gfx_card and gfx_drv_ver are unchanged on failure.
|
|
extern LibError ogl_get_gfx_info(void);
|
|
|
|
|
|
//
|
|
// misc
|
|
//
|
|
|
|
// in non-release builds, enable oglCheck, which breaks into the debugger
|
|
// if an OpenGL error was raised since the last call.
|
|
// add these calls everywhere to close in on the error cause.
|
|
//
|
|
// reports a bogus invalid_operation error if called before OpenGL is
|
|
// initialized, so don't!
|
|
#ifndef NDEBUG
|
|
extern void oglCheck(void);
|
|
#else
|
|
# define oglCheck()
|
|
#endif
|
|
|
|
// ignore and reset the specified error (as returned by glGetError).
|
|
// any other errors that have occurred are reported as oglCheck would.
|
|
//
|
|
// this is useful for suppressing annoying error messages, e.g.
|
|
// "invalid enum" for GL_CLAMP_TO_EDGE even though we've already
|
|
// warned the user that their OpenGL implementation is too old.
|
|
extern void oglSquelchError(GLenum err_to_ignore);
|
|
|
|
|
|
// call before using any of the above, and after each video mode change.
|
|
//
|
|
// fails if OpenGL not ready for use.
|
|
extern void oglInit(void);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // #ifndef __OGL_H__
|