KGLLib
shader.h
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2008 Rivo Laks <rivolaks@hot.ee> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef KGLLIB_SHADER_H 00019 #define KGLLIB_SHADER_H 00020 00021 #include "kgllib.h" 00022 00023 00024 class QString; 00025 class QByteArray; 00026 00027 namespace KGLLib 00028 { 00029 00040 class KGLLIB_EXPORT Shader 00041 { 00042 public: 00048 Shader(GLenum type); 00054 Shader(GLenum type, const QString& filename); 00060 virtual ~Shader(); 00061 00066 void setSource(const QString& source); 00067 void setSource(const QByteArray& source); 00068 00074 bool compile(); 00075 00076 bool isValid() const { return mValid; } 00077 bool isCompiled() const { return mCompiled; } 00085 char* compileLog() const { return mCompileLog; } 00086 00087 GLenum type() const { return mType; } 00088 GLuint glId() const { return mGLId; } 00089 00090 00091 protected: 00092 void init(GLenum type); 00093 00094 protected: 00095 GLuint mGLId; 00096 GLenum mType; 00097 bool mValid; 00098 bool mCompiled; 00099 char* mCompileLog; 00100 }; 00101 00106 class KGLLIB_EXPORT VertexShader : public Shader 00107 { 00108 public: 00109 VertexShader(); 00110 VertexShader(const QString& filename); 00111 }; 00112 00117 class KGLLIB_EXPORT FragmentShader : public Shader 00118 { 00119 public: 00120 FragmentShader(); 00121 FragmentShader(const QString& filename); 00122 }; 00123 00124 } 00125 00126 #endif
KDE 4.2 API Reference