1 /************************************************************************
2 This file is part of NE.
4 NE is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 NE is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with NE. If not, see <http://www.gnu.org/licenses/>.
16 ************************************************************************/
23 static GLuint circle
, quad
, cube
, sphere
;
34 glNewList(quad
,GL_COMPILE
);
36 glNormal3f(0.0,0.0,1.0);
37 glTexCoord2f(1.0,1.0); glVertex2f( 0.5, 0.5);
38 glTexCoord2f(0.0,1.0); glVertex2f(-0.5, 0.5);
39 glTexCoord2f(0.0,0.0); glVertex2f(-0.5,-0.5);
40 glTexCoord2f(1.0,0.0); glVertex2f( 0.5,-0.5);
45 circle
= glGenLists(1);
47 glNewList(circle
,GL_COMPILE
);
49 glBegin(GL_TRIANGLE_FAN
);
50 glNormal3f(0.0f
, 0.0f
, 1.0f
);
52 for (i
=0; i
<points
; i
++)
54 float t
= (float)i
/points
;
56 glVertex2f(0.5*cos(t
),0.5*sin(t
));
64 glNewList(cube
,GL_COMPILE
);
67 glNormal3f(0.0f
, 0.0f
, 1.0f
);
68 glTexCoord2f(0.0f
, 0.0f
); glVertex3f(-0.5f
,-0.5f
, 0.5f
);
69 glTexCoord2f(1.0f
, 0.0f
); glVertex3f( 0.5f
,-0.5f
, 0.5f
);
70 glTexCoord2f(1.0f
, 1.0f
); glVertex3f( 0.5f
, 0.5f
, 0.5f
);
71 glTexCoord2f(0.0f
, 1.0f
); glVertex3f(-0.5f
, 0.5f
, 0.5f
);
73 glNormal3f(0.0f
, 0.0f
,-1.0f
);
74 glTexCoord2f(1.0f
, 0.0f
); glVertex3f(-0.5f
,-0.5f
,-0.5f
);
75 glTexCoord2f(1.0f
, 1.0f
); glVertex3f(-0.5f
, 0.5f
,-0.5f
);
76 glTexCoord2f(0.0f
, 1.0f
); glVertex3f( 0.5f
, 0.5f
,-0.5f
);
77 glTexCoord2f(0.0f
, 0.0f
); glVertex3f( 0.5f
,-0.5f
,-0.5f
);
79 glNormal3f(0.0f
, 1.0f
, 0.0f
);
80 glTexCoord2f(0.0f
, 1.0f
); glVertex3f(-0.5f
, 0.5f
,-0.5f
);
81 glTexCoord2f(0.0f
, 0.0f
); glVertex3f(-0.5f
, 0.5f
, 0.5f
);
82 glTexCoord2f(1.0f
, 0.0f
); glVertex3f( 0.5f
, 0.5f
, 0.5f
);
83 glTexCoord2f(1.0f
, 1.0f
); glVertex3f( 0.5f
, 0.5f
,-0.5f
);
85 glNormal3f(0.0f
,-1.0f
, 0.0f
);
86 glTexCoord2f(1.0f
, 1.0f
); glVertex3f(-0.5f
,-0.5f
,-0.5f
);
87 glTexCoord2f(0.0f
, 1.0f
); glVertex3f( 0.5f
,-0.5f
,-0.5f
);
88 glTexCoord2f(0.0f
, 0.0f
); glVertex3f( 0.5f
,-0.5f
, 0.5f
);
89 glTexCoord2f(1.0f
, 0.0f
); glVertex3f(-0.5f
,-0.5f
, 0.5f
);
91 glNormal3f(1.0f
, 0.0f
, 0.0f
);
92 glTexCoord2f(1.0f
, 0.0f
); glVertex3f( 0.5f
,-0.5f
,-0.5f
);
93 glTexCoord2f(1.0f
, 1.0f
); glVertex3f( 0.5f
, 0.5f
,-0.5f
);
94 glTexCoord2f(0.0f
, 1.0f
); glVertex3f( 0.5f
, 0.5f
, 0.5f
);
95 glTexCoord2f(0.0f
, 0.0f
); glVertex3f( 0.5f
,-0.5f
, 0.5f
);
97 glNormal3f(-1.0f
, 0.0f
, 0.0f
);
98 glTexCoord2f(0.0f
, 0.0f
); glVertex3f(-0.5f
,-0.5f
,-0.5f
);
99 glTexCoord2f(1.0f
, 0.0f
); glVertex3f(-0.5f
,-0.5f
, 0.5f
);
100 glTexCoord2f(1.0f
, 1.0f
); glVertex3f(-0.5f
, 0.5f
, 0.5f
);
101 glTexCoord2f(0.0f
, 1.0f
); glVertex3f(-0.5f
, 0.5f
,-0.5f
);
107 void shapes_texturize(struct texture
*tex
, int tile
)
111 glEnable(GL_TEXTURE_2D
);
112 glMatrixMode(GL_TEXTURE
);
114 glScalef(tile
,tile
,tile
);
115 glMatrixMode(GL_MODELVIEW
);
120 glDisable(GL_TEXTURE_2D
);