Fix redundant glTexEnv calls
[neverball] / share / solid_draw.h
1 /*
2  * Copyright (C) 2003 Robert Kooima
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #ifndef SOLID_DRAW_H
16 #define SOLID_DRAW_H
17
18 #include "glext.h"
19 #include "solid_base.h"
20 #include "solid_vary.h"
21
22 /*
23  * Rendered solid data.
24  */
25
26 /*---------------------------------------------------------------------------*/
27
28 struct d_vert
29 {
30     float p[3];
31     float n[3];
32     float t[2];
33 };
34
35 struct d_geom
36 {
37     GLushort i;
38     GLushort j;
39     GLushort k;
40 };
41
42 /*---------------------------------------------------------------------------*/
43
44 struct d_mtrl
45 {
46     const struct b_mtrl *base;
47
48     GLuint d;                              /* 32-bit diffuse color cache     */
49     GLuint a;                              /* 32-bit ambient color cache     */
50     GLuint s;                              /* 32-bit specular color cache    */
51     GLuint e;                              /* 32-bit emissive color cache    */
52     GLuint h;                              /* 32-bit specular exponent cache */
53     GLuint o;                              /* OpenGL texture object          */
54 };
55
56 struct d_mesh
57 {
58     const struct d_mtrl *mp;
59
60     GLuint vbo;                                /* Vertex  buffer object      */
61     GLuint ebo;                                /* Element buffer object      */
62     GLuint ebc;                                /* Element buffer count       */
63 };
64
65 struct d_body
66 {
67     const struct b_body *base;
68
69     int pass[5];
70     int mc;
71
72     struct d_mesh *mv;
73 };
74
75 struct s_draw
76 {
77     const struct s_base *base;
78     const struct s_vary *vary;
79
80     int mc;
81     int bc;
82
83     struct d_mtrl *mv;
84     struct d_body *bv;
85
86     GLuint bill;
87
88     int reflective;
89     int shadow_ui;
90 };
91
92 /*---------------------------------------------------------------------------*/
93
94 /*
95  * This structure holds rendering state shared between separate
96  * SOLs. I am aware that the name leaves much to be desired.
97  */
98
99 struct s_rend
100 {
101     const struct d_mtrl *mp;
102 };
103
104 /*---------------------------------------------------------------------------*/
105
106 int  sol_load_draw(struct s_draw *, const struct s_vary *, int);
107 void sol_free_draw(struct s_draw *);
108
109 void sol_draw_enable(struct s_rend *);
110 void sol_draw_disable(struct s_rend *);
111
112 void sol_load_mtrl(struct d_mtrl *, const struct b_mtrl *);
113 void sol_free_mtrl(struct d_mtrl *);
114
115 void sol_apply_mtrl(const struct d_mtrl *, struct s_rend *);
116
117 void sol_back(const struct s_draw *, struct s_rend *, float, float, float);
118 void sol_refl(const struct s_draw *, struct s_rend *);
119 void sol_draw(const struct s_draw *, struct s_rend *, int, int);
120 void sol_bill(const struct s_draw *, struct s_rend *, const float *, float);
121
122 void sol_fade(const struct s_draw *, float);
123
124 /*---------------------------------------------------------------------------*/
125
126 struct s_full
127 {
128     struct s_base base;
129     struct s_vary vary;
130     struct s_draw draw;
131 };
132
133 int  sol_load_full(struct s_full *, const char *, int);
134 void sol_free_full(struct s_full *);
135
136 /*---------------------------------------------------------------------------*/
137
138 #endif