From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/texture__near_8cpp-source.html | 186 ++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 docs/doxygen/nel/texture__near_8cpp-source.html (limited to 'docs/doxygen/nel/texture__near_8cpp-source.html') diff --git a/docs/doxygen/nel/texture__near_8cpp-source.html b/docs/doxygen/nel/texture__near_8cpp-source.html new file mode 100644 index 00000000..88cb6720 --- /dev/null +++ b/docs/doxygen/nel/texture__near_8cpp-source.html @@ -0,0 +1,186 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

texture_near.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 
+00029 #include "3d/texture_near.h"
+00030 using namespace NLMISC;
+00031 
+00032 namespace NL3D 
+00033 {
+00034 
+00035 
+00036 // ***************************************************************************
+00037 CTextureNear::CTextureNear(sint size)
+00038 {
+00039         nlassert(size>=NL_TILE_LIGHTMAP_SIZE);
+00040         nlassert(NLMISC::isPowerOf2(size));
+00041 
+00042         // The near texture always reside in memory...
+00043         // NB: this is simplier like that, and this is not a problem, since only 1 or 2 Mo are allocated :o)
+00044         setReleasable(false);
+00045         // create the bitmap.
+00046         CBitmap::resize(size, size, CBitmap::RGBA);
+00047         // Format of texture, 32 bits and no mipmaps.
+00048         setUploadFormat(ITexture::RGBA8888);
+00049         setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
+00050 
+00051         // Fill the array of free tiles.
+00052         uint    nbTilesByLine= size/NL_TILE_LIGHTMAP_SIZE;
+00053         _FreeTiles.resize(nbTilesByLine*nbTilesByLine);
+00054         _AvailableTiles.resize(nbTilesByLine*nbTilesByLine);
+00055         for(sint i=0;i<(sint)_FreeTiles.size();i++)
+00056         {
+00057                 // This tile is free!!
+00058                 _FreeTiles[i]=i;
+00059                 _AvailableTiles[i]= true;
+00060         }
+00061 
+00062 }
+00063 
+00064 // ***************************************************************************
+00065 sint                    CTextureNear::getNbAvailableTiles()
+00066 {
+00067         return _FreeTiles.size();
+00068 }
+00069 // ***************************************************************************
+00070 uint                    CTextureNear::getTileAndFillRect(CRGBA  map[NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE])
+00071 {
+00072         nlassert(getNbAvailableTiles()>0);
+00073         uint    id= _FreeTiles.back();
+00074         // This tile is now more free.
+00075         _AvailableTiles[id]= false;
+00076         _FreeTiles.pop_back();
+00077 
+00078         // Fill the texture
+00079         refillRect(id, map);
+00080 
+00081         return id;
+00082 }
+00083 
+00084 // ***************************************************************************
+00085 void                    CTextureNear::refillRect(uint id, CRGBA  map[NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE])
+00086 {
+00087         uint    dstWidth= getWidth();
+00088         // Copy the map into the texture
+00089         uint    nbTilesByLine= dstWidth/NL_TILE_LIGHTMAP_SIZE;
+00090         uint    s= id% nbTilesByLine;
+00091         uint    t= id/ nbTilesByLine;
+00092         s*= NL_TILE_LIGHTMAP_SIZE;
+00093         t*= NL_TILE_LIGHTMAP_SIZE;
+00094         CRGBA   *src= map;
+00095         CRGBA   *dst= (CRGBA*)&(*getPixels().begin());
+00096         dst+= t*dstWidth+s;
+00097         for(sint n= NL_TILE_LIGHTMAP_SIZE;n>0;n--, src+= NL_TILE_LIGHTMAP_SIZE, dst+= dstWidth)
+00098         {
+00099                 memcpy(dst, src, NL_TILE_LIGHTMAP_SIZE*sizeof(CRGBA));
+00100         }
+00101 
+00102         // Invalidate the rectangle.
+00103         ITexture::touchRect(CRect(s, t, NL_TILE_LIGHTMAP_SIZE, NL_TILE_LIGHTMAP_SIZE));
+00104 }
+00105 
+00106 // ***************************************************************************
+00107 void                    CTextureNear::releaseTile(uint id)
+00108 {
+00109         nlassert(!_AvailableTiles[id]);
+00110         // This tile is now free.
+00111         _AvailableTiles[id]= true;
+00112         // insert this tile at the end of the free list.
+00113         _FreeTiles.push_back(id);
+00114 }
+00115 
+00116 
+00117 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1