Fixes for datatype size on amd64.
[crack-attack.git] / src / obj_block.cxx
blobed75ec026bd8b412a8228659dbed85bb32b3ed6c
1 /*
2 * block.cxx
3 * Daniel Nelson - 8/31/0
5 * Copyright (C) 2006 Bjørn Lindeijer
6 * Copyright (C) 2000 Daniel Nelson
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Daniel Nelson - aluminumangel.org
23 * 174 W. 18th Ave.
24 * Columbus, OH 43210
26 * Generates the block's two display lists.
29 #include <GL/glut.h>
31 #include "glext.h"
33 #include <cstring>
35 #include "Game.h"
36 #include "Displayer.h"
37 #include "OBJModel.h"
39 GLuint Displayer::block_list;
40 GLuint Displayer::small_block_list;
41 GLuint Displayer::special_block_list;
43 GLuint Displayer::special_block_lightmap;
45 void Displayer::generateBlockDisplayList ( )
47 OBJModel *block_model = NULL;
48 OBJModel *block_model_tex = NULL;
50 if (MetaState::mode & CM_LOW_GRAPHICS) {
51 block_model = new OBJModel(GC_MODEL_DIRECTORY("crackattackcubemedres.obj"));
52 block_model_tex = new OBJModel(GC_MODEL_DIRECTORY("crackattackcubemedres_tex.obj"));
53 } else {
54 block_model = new OBJModel(GC_MODEL_DIRECTORY("crackattackcubehires.obj"));
55 block_model_tex = new OBJModel(GC_MODEL_DIRECTORY("crackattackcubehires_tex.obj"));
56 //block_model = new OBJModel(GC_MODEL_DIRECTORY("cube.obj"));
57 //block_model_tex = new OBJModel(GC_MODEL_DIRECTORY("cube.obj"));
59 block_list = glGenLists(1);
60 glNewList(block_list, GL_COMPILE);
61 block_model->render();
62 glEndList();
64 // Now let's make one for pulsing blocks (has texture coordinates)
66 special_block_list = glGenLists(1);
67 glNewList(special_block_list, GL_COMPILE);
68 block_model_tex->render();
69 glEndList();
71 delete block_model;
72 delete block_model_tex;
74 // Now let's make one at half that size and rotated
76 small_block_list = glGenLists(1);
77 glNewList(small_block_list, GL_COMPILE);
78 glPushMatrix();
79 glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
80 glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
81 glScalef(0.5f, 0.5f, 0.5f);
82 glEnable(GL_NORMALIZE);
83 glCallList(block_list);
84 glDisable(GL_NORMALIZE);
85 glPopMatrix();
86 glEndList();
88 // Now we build the special color blocks' gleam texture. A texture value of
89 // 0.6f seems to cause the special color blocks to match their standard
90 // siblings, given the specials' double color values.
92 GLubyte texture[32];
93 for (int n = 32; n--; )
94 texture[n]
95 = (GLubyte) (255.0f * (0.8f - 0.2f * cos((2.0f * PI / 32.0f) * n)));
97 glGenTextures(1, &special_block_lightmap);
99 glBindTexture(GL_TEXTURE_1D, special_block_lightmap);
101 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
102 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
103 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
105 const GLubyte* renderer = glGetString(GL_RENDERER);
106 if (strstr((char*) renderer, "DRI 20020221 Voodoo3")) {
107 std::cerr << "**********\nWARNING:"
108 "disabling call to 1d texturing on DRI 20020221 Voodoo3 renderer "
109 "since it segfaults\n**********" << std::endl;
110 return;
112 if (strstr((char*) renderer, "865G 20021115")) {
113 std::cerr << "**********\nWARNING:"
114 "disabling call to 1d texturing on 865G 20021115 renderer "
115 "since it segfaults\n**********" << std::endl;
116 return;
119 glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE, 32, GL_FALSE, GL_LUMINANCE,
120 GL_UNSIGNED_BYTE, texture);