00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Kutumov Alexey * 00003 * ru.pixel@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program 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 * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00033 #ifndef __gl_glsl_uniform__header__ 00034 #define __gl_glsl_uniform__header__ 00035 00036 #include "gpucalc/application.h" 00037 #include "gpucalc/log_manager.h" 00038 #include "gpucalc/uniform.h" 00039 #include "gpucalc/shader.h" 00040 00041 #include <GL/glew.h> 00042 00043 namespace gpucalc 00044 { 00045 00046 00047 const char _GLGLSLUniformClassName [] = "GLGLSLUniform"; 00048 00049 00050 class GLGLSLUniform: public Uniform 00051 { 00052 00053 OBJ_DISABLE_COPY(GLGLSLUniform) 00054 00055 00056 friend class GLGLSLShaderSystem; 00057 00058 00059 public: 00060 GLGLSLUniform(const std::string & UniformName): 00061 Object(_GLGLSLUniformClassName, UniformName), Uniform(_GLGLSLUniformClassName, UniformName), mIsUploadedToGPU(false), 00062 mUniformType(UT_NOT_UNIFORM), mPointer(0), mSampler(0) 00063 { 00064 } 00065 00066 00067 void uploadToGPU() 00068 { 00069 mIsUploadedToGPU = true; 00070 } 00071 00072 00073 bool isUploadedToGPU() const 00074 { 00075 return mIsUploadedToGPU; 00076 } 00077 00078 00079 void initialize() 00080 { 00081 // does nothing 00082 } 00083 00084 00085 bool isInitialized() const 00086 { 00087 return true; 00088 } 00089 00090 00091 Uniform::UniformType getUniformType() const 00092 { 00093 return mUniformType; 00094 } 00095 00096 00097 Texture * getSampler() const 00098 { 00099 assert(mSampler && "GLGLSLUniform:\t returning uninitialized Sampler!!!"); 00100 return mSampler; 00101 } 00102 00103 00104 void * pointer() const 00105 { 00106 assert(mPointer && "GLGLSLUniform:\t returning uninitialized pointer!!!"); 00107 return mPointer; 00108 } 00109 00110 00111 private: 00112 bool mIsUploadedToGPU; 00113 00114 00115 Uniform::UniformType mUniformType; 00116 00117 00118 mutable void * mPointer; 00119 00120 00121 mutable Texture * mSampler; 00122 }; 00123 } 00124 00125 #endif