AaronCameron.net
No ads. No Profit. No Master, But Truth.
Not a Member? - Login or Create an Account
Sunday the 20th of May 2012 @ 03:59pm
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cGLTexture.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2002  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 #ifndef _n2l4_cGLTexture_h
00026 #define _n2l4_cGLTexture_h
00027 
00028 #include "n2l/n2l.h"
00029 #include "n2l/geometry.h"
00030 
00031 namespace n2l
00032 {
00033     class cSurfaceInterface;
00034     class cSurface;
00035     class cVfsNodeInterface;
00036 
00037     /***************************************************************************
00038     A specific implementation of cTextureInterface to provide a basic
00039     OpenGL, which may be constructed from any cSurface (or derivative)
00040     instance.
00041     */
00042     class cGLTexture
00043     {
00044     public:
00045         cGLTexture( const GLenum &iFormat, const tVector2u &iSize );
00046         cGLTexture( const cSurfaceInterface &iSurface );
00047         cGLTexture( const cVfsNodeInterface &iFile );
00048         ~cGLTexture();
00049 
00050         const tVector2u &size() const;
00051         const tBool hasAlpha() const;
00052 
00053         inline void bind() const { bindTexture2D(); }
00054         void bindTexture2D() const;
00055 
00061         void refresh() const;
00062 
00063         const tBool refreshable() const { return mRefreshable; }
00064 
00065         const tBool requiresRefreshable() { return smRequiresRefreshable; }
00066         void requiresRefreshable( const tBool iRequired ) {
00067              smRequiresRefreshable = iRequired;
00068         }
00069 
00070         static const tUint bitsForFormat( const GLenum &iFormat );
00071 
00072     private:
00073         typedef tUint tGLTextureName;
00074 
00075         mutable tGLTextureName mGLName;
00076         mutable tVector2u mSize;
00077 
00078         mutable tBool mHasAlpha;
00079         mutable tBool mRefreshable;
00080 
00081         static tBool smRequiresRefreshable;
00082 
00085         cSurface *mSurface;
00086 
00087         
00088         mutable void *mRawData;
00089         mutable tUint mNumComponents;
00090         mutable GLenum mFormat;
00091         mutable GLenum mType;
00092 
00093         cGLTexture( const cGLTexture & );
00094 
00095         void readRawFromSurface( const cSurfaceInterface &iSurface ) const;
00096 
00097         void regenTexture() const;
00098 
00099         void getRawSurfaceData( const cSurfaceInterface & iSurface,
00100             tUint &oNumComponents, tUint &oWidth, tUint &oHeight,
00101             GLenum &oFormat, GLenum &oType, void *&oData ) const;
00102 
00105         const tBool isTwoToThe( const tUint iNum, tUint &oClosest ) const;
00106 
00107 //      void allocateZeroRawSurface( 
00108 
00109     }; // class
00110 
00111 }
00112 
00113 #endif
©2012 Aaron Cameron