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
|
#ifndef _OBJECT_H
#define _OBJECT_H 1
#include "main/event.h"
#include "main/mainloop.h"
#include "opengl/texture.h"
#include "math/array.h"
#if defined(WIN32) || defined(__CYGWIN__)
#include <windows.h>
#endif
#include <GL/gl.h>
#ifndef APIENTRY
#define APIENTRY
#endif
/* from GLext.h */
typedef void (APIENTRY *PFNGLACTIVETEXTUREARBPROC)(GLenum texture);
typedef void (APIENTRY *PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum texture);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2FVARBPROC)(GLenum target, const GLfloat *v);
typedef void (APIENTRY *PFNGLLOCKARRAYSEXTPROC)(GLint first, GLsizei count);
typedef void (APIENTRY *PFNGLUNLOCKARRAYSEXTPROC)(void);
typedef void (APIENTRY *PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
struct vertex {
float x, y, z;
};
struct normal {
float nx, ny, nz;
};
struct texcoord {
float u, v;
};
class Object : public Event
{
protected:
Array<vertex> vertices;
Array<normal> normals;
Array<texcoord> texcoords, *ctexcoords[2];
Array<int> faces;
Array<GLfloat> *tv;
bool pure_indices;
bool pretrans, precolor;
int vertices_per_face;
Texture *tex[2];
enum gentype { none, linmap, envmap } texgen[2];
float texstr0;
bool has_multitexture;
bool has_compiled_vertex_array;
bool has_draw_range_elements;
bool has_rescale_normal;
bool additive_blend, no_zbuffer;
/* texunit 1 parameters (for multitexture) */
GLenum tu1combine, tu1s0, tu1o0, tu1s1, tu1o1, tu1s2, tu1o2;
/* pass 2 blending functions (for non-multitexture) */
GLenum p2sf, p2df;
bool p2light;
/* stencil mask, primarily for halos (0x0 not to stencil) */
int stencil_mask;
/* be sure to have unit length normals for this ;-) */
bool draw_halo;
float halo_length;
struct vertex *halo_vert;
/* for RTG compatibility */
bool inverse_rotorder;
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB;
PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElementsEXT;
void setup_drawing(float progress);
virtual void draw_object();
virtual void draw_object(bool textures, bool normals);
void add_vertex(const struct vertex v);
void add_normal(const struct normal n);
void add_texcoord(const struct texcoord tc);
void add_face(const int a, const int b, const int c);
void add_face(const int a, const int b, const int c, const int d);
void unlock_object();
void setup_vertex_arrays(bool textures, bool normals);
public:
Object(MainLoop *ml, const char *title, const char *elem, Hashtable *attr);
virtual ~Object();
virtual void start_effect();
virtual void draw_scene(float progress);
virtual void end_effect();
};
#endif /* !defined(_OBJECT_H) */
|