nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef TEMPLATEPRIMITIVEBUFFER_H 00024 #define TEMPLATEPRIMITIVEBUFFER_H 00025 00026 namespace nux 00027 { 00028 00029 class IOpenGLVertexBuffer; 00030 class IOpenGLIndexBuffer; 00031 class GpuDevice; 00032 00033 typedef struct 00034 { 00035 Vector4 v0; 00036 Vector4 v1; 00037 Vector4 v2; 00038 Vector4 v3; 00039 } QuadAttributeParam; 00040 00041 class TemplateQuadBuffer 00042 { 00043 public: 00044 TemplateQuadBuffer (GpuDevice *, ShaderType Type = SHADER_TYPE_GLSL, int NumQuads = 256); 00045 ~TemplateQuadBuffer(); 00047 void BindAttribute (INT AttributeLocation, UINT AttributeIndex); 00049 00050 #if (NUX_ENABLE_CG_SHADERS) 00051 void BindCGAttribute (CGparameter AttributeLocation, UINT AttributeIndex); 00052 void UnBindCGAttribute (CGparameter AttributeLocation); 00053 #endif 00054 void UnBindAttribute (INT AttributeLocation); 00055 void UnBind(); 00056 void Render (INT NumPrimitives); 00058 00062 void SetPerQuadAttribute (UINT AttributeIndex, INT Num, Vector4 *); 00063 00065 00068 void SetPerVertexAttribute (UINT AttributeIndex, INT Num, Vector4 *pVector); 00069 void UnSetQuadAttribute (UINT AttributeIndex); 00070 00071 void SetNumQuads (int NumQuads); 00072 int GetNumQuads() const; 00073 00074 protected: 00075 //IOpenGLVertexBuffer* m_VB; 00076 ObjectPtr<IOpenGLIndexBuffer> m_IB; 00077 void FormatQuads(); 00078 00079 private: 00080 00081 ShaderType m_ShaderType; 00082 ObjectPtr<IOpenGLVertexBuffer> VertexAttributeBuffer[16]; 00083 GpuDevice *m_pDeviceFactory; 00084 INT m_NumVertex; 00085 INT m_NumQuad; 00086 }; 00087 00088 } 00089 00090 #endif //TEMPLATEPRIMITIVEBUFFER_H 00091