1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
/* bzflag
* Copyright (c) 1993-2012 Tim Riker
* Writen By Jeffrey Myers
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef __OPENGLUTILS_H__
#define __OPENGLUTILS_H__
#include "common.h"
// system headers
#include <string>
#include <map>
#include <vector>
// common headers
#include "bzfgl.h"
#include "vectors.h"
class BzMaterial;
class OpenGLGState;
#define INVALID_GL_ID 0xffffffff
extern void bzMat2gstate(const BzMaterial* bzmat, OpenGLGState& gstate,
fvec4& color, const fvec4*& colorPtr);
extern bool parseBlendFactors(const std::string& s, GLenum& src, GLenum& dst);
extern float getFloatColor(int val);
extern void setColor(float dstColor[3], int r, int g, int b);
extern void glSetColor(const float c[3], float alpha = 1.0f);
extern void glTranslatefv(const float v[3]);
typedef enum {
eCenter,
eLowerLeft,
eLowerRight,
eUpperLeft,
eUpperRight,
eCenterLeft,
eCenterRight,
eCenterTop,
eCenterBottom
} eAlignment;
extern void glQuad(float x, float y, eAlignment align, float scale = 1.0f);
extern void glLineRing(float radius, float width = 1.0f);
// draw an outline box with the outside at the bounds, and inset by the thickness
extern void glOutlineBoxCP(float thickness, float centerX, float centerY,
float width, float height, float depth = 0.0f);
inline void glOutlineBoxCP(float t, int x, int y, int w, int h, int d = 0) {
glOutlineBoxCP(t, (float)x, (float)y, (float)w, (float)h, (float)d);
}
extern void glOutlineBoxHV(float thickness, float minX, float minY,
float maxX, float maxY, float depth = 0.0f);
inline void glOutlineBoxHV(float t, int minX, int minY, int maxX, int maxY, int d = 0) {
glOutlineBoxHV(t, (float)minX, (float)minY, (float)maxX, (float)maxY, (float)d);
}
// draw an outline tabbed box
extern void glOutlineTabbedBox(float thickness, float minX, float minY,
float maxX, float maxY,
float tabInset, float tabWidth, float tabHeight,
float depth = 0);
// display list system
typedef unsigned int GLDisplayList;
#define _INVALID_LIST INVALID_GL_ID
class GLDisplayListCreator
{
public:
virtual ~GLDisplayListCreator() {}
virtual void buildGeometry(GLDisplayList displayList) = 0;
};
class DisplayListSystem
{
public:
static DisplayListSystem& Instance() {
static DisplayListSystem dls;
return dls;
}
~DisplayListSystem();
GLDisplayList newList(GLDisplayListCreator *creator);
void freeList(GLDisplayList displayList);
void flushLists();
void callList(GLDisplayList displayList);
void callListsV(std::vector<GLDisplayList> &displayLists);
protected:
DisplayListSystem();
typedef struct _DisplayList {
GLDisplayListCreator *creator;
unsigned int list;
} DisplayList;
std::map<GLDisplayList,DisplayList> lists;
GLDisplayList lastList;
};
#endif // __OPENGLUTILS_H__
// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8
|