Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

dispmap.cpp

Go to the documentation of this file.
00001 // dispmap.cpp
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #include "dispmap.h"
00011 
00012 
00013 DisplacementMap::DisplacementMap(int w, int h) :
00014     width(w), height(h), disp(NULL)
00015 {
00016     disp = new float[width * height];
00017 }
00018 
00019 DisplacementMap::~DisplacementMap()
00020 {
00021     if (disp != NULL)
00022         delete[] disp;
00023 }
00024 
00025 
00026 void DisplacementMap::clear()
00027 {
00028     int size = width * height;
00029     for (int i = 0; i < size; i++)
00030         disp[i] = 0.0f;
00031 }
00032 
00033 
00034 void DisplacementMap::generate(DisplacementMapFunc func, void* info)
00035 {
00036     for (int i = 0; i < height; i++)
00037     {
00038         for (int j = 0; j < width; j++)
00039         {
00040             disp[i * width + j] = func((float) j / (float) width,
00041                                        (float) i / (float) height, info);
00042         }
00043     }
00044 }

Generated on Sat Jan 14 22:30:27 2006 for Celestia by  doxygen 1.4.1