/* * ldrawparser.cpp * legotown3d * * Created by Nico Bernold on 08.01.05. * Copyright 2005 __MyCompanyName__. All rights reserved. * */ #include "heightMapTerrain.h" HeightMapTerrain::HeightMapTerrain() { } HeightMapTerrain::~HeightMapTerrain() { } bool HeightMapTerrain::loadBitmap(char* fileName) { return bitmap = SDL_LoadBMP(fileName); } bool HeightMapTerrain::createDisplayLists(int width, int height, int levelOfDetail) { if (bitmap == NULL) return false; cout << "bitmap-dimensions: " << bitmap->w << "x" << bitmap->h << endl; if (bitmap->w % width != 0) return false; if (bitmap->h % height != 0) return false; if (levelOfDetail < 1 || levelOfDetail > 10) return false; int howManyListsWide = bitmap->w / width; int howManyListsHigh = bitmap->h / height; // calculate how many displayLists we'll create displayListCount = howManyListsWide * howManyListsHigh; cout << "lists-information: " << howManyListsWide << " * " << howManyListsHigh << " = " << displayListCount << " display lists." << endl; displayListStart = glGenLists(displayListCount); if (displayListStart == 0) { cout << "could not generate " << displayListCount << " display lists. exiting. " << endl; return false; } int i,j; for (i=0; ipixels[z * bitmap->h + x]); color = &bitmap->format->palette->colors[index]; SDL_UnlockSurface(bitmap); return color->r; */ }