Back to index

nux  3.0.0
GpuDeviceShader.cpp
Go to the documentation of this file.
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 #include "GLResource.h"
00024 #include "GpuDevice.h"
00025 #include "GLDeviceObjects.h"
00026 #include "GLResourceManager.h"
00027 
00028 #include "GLTextureResourceManager.h"
00029 #include "GLVertexResourceManager.h"
00030 #include "GLDeviceFrameBufferObject.h"
00031 #include "GLTemplatePrimitiveBuffer.h"
00032 #include "GraphicsEngine.h"
00033 
00034 namespace nux
00035 {
00036   ObjectPtr<IOpenGLShaderProgram> GpuDevice::CreateShaderProgram()
00037   {
00038     IOpenGLShaderProgram *ptr;
00039     CreateShaderProgram((IOpenGLShaderProgram **) &ptr);
00040     ObjectPtr<IOpenGLShaderProgram> h = ObjectPtr<IOpenGLShaderProgram> (ptr);
00041     ptr->UnReference();
00042     return h;
00043   }
00044 
00045   int GpuDevice::CreateShaderProgram(IOpenGLShaderProgram **ppShaderProgram)
00046   {
00047     *ppShaderProgram = new IOpenGLShaderProgram();
00048 
00049     return OGL_OK;
00050   }
00051 
00052   ObjectPtr<IOpenGLVertexShader> GpuDevice::CreateVertexShader()
00053   {
00054     IOpenGLVertexShader *ptr;
00055     CreateVertexShader((IOpenGLVertexShader **) &ptr);
00056     ObjectPtr<IOpenGLVertexShader> h = ObjectPtr<IOpenGLVertexShader> (ptr);
00057     ptr->UnReference();
00058     return h;
00059   }
00060 
00061   int GpuDevice::CreateVertexShader(IOpenGLVertexShader **ppVertexShader)
00062   {
00063     *ppVertexShader = new IOpenGLVertexShader();
00064 
00065     return OGL_OK;
00066   }
00067 
00068   ObjectPtr<IOpenGLPixelShader> GpuDevice::CreatePixelShader()
00069   {
00070     IOpenGLPixelShader *ptr;
00071     CreatePixelShader((IOpenGLPixelShader **) &ptr);
00072     ObjectPtr<IOpenGLPixelShader> h = ObjectPtr<IOpenGLPixelShader> (ptr);
00073     ptr->UnReference();
00074     return h;
00075   }
00076 
00077   int GpuDevice::CreatePixelShader(IOpenGLPixelShader **ppPixelShader)
00078   {
00079     *ppPixelShader = new IOpenGLPixelShader();
00080 
00081     return OGL_OK;
00082   }
00083 
00084   ObjectPtr<IOpenGLAsmShaderProgram> GpuDevice::CreateAsmShaderProgram()
00085   {
00086     IOpenGLAsmShaderProgram *ptr;
00087     CreateAsmShaderProgram((IOpenGLAsmShaderProgram **) &ptr);
00088     ObjectPtr<IOpenGLAsmShaderProgram> h = ObjectPtr<IOpenGLAsmShaderProgram> (ptr);
00089     ptr->UnReference();
00090     return h;
00091   }
00092 
00093   int GpuDevice::CreateAsmShaderProgram(IOpenGLAsmShaderProgram **ppAsmShaderProgram)
00094   {
00095     *ppAsmShaderProgram = new IOpenGLAsmShaderProgram();
00096 
00097     return OGL_OK;
00098   }
00099 
00100   ObjectPtr<IOpenGLAsmVertexShader> GpuDevice::CreateAsmVertexShader()
00101   {
00102     IOpenGLAsmVertexShader *ptr;
00103     CreateAsmVertexShader((IOpenGLAsmVertexShader **) &ptr);
00104     ObjectPtr<IOpenGLAsmVertexShader> h = ObjectPtr<IOpenGLAsmVertexShader> (ptr);
00105     ptr->UnReference();
00106     return h;
00107   }
00108 
00109   int GpuDevice::CreateAsmVertexShader(IOpenGLAsmVertexShader **ppAsmVertexShader)
00110   {
00111     *ppAsmVertexShader = new IOpenGLAsmVertexShader();
00112 
00113     return OGL_OK;
00114   }
00115 
00116   ObjectPtr<IOpenGLAsmPixelShader> GpuDevice::CreateAsmPixelShader()
00117   {
00118     IOpenGLAsmPixelShader *ptr;
00119     CreateAsmPixelShader((IOpenGLAsmPixelShader **) &ptr);
00120     ObjectPtr<IOpenGLAsmPixelShader> h = ObjectPtr<IOpenGLAsmPixelShader> (ptr);
00121     ptr->UnReference();
00122     return h;
00123   }
00124 
00125   int GpuDevice::CreateAsmPixelShader(IOpenGLAsmPixelShader **ppAsmPixelShader)
00126   {
00127     *ppAsmPixelShader = new IOpenGLAsmPixelShader();
00128 
00129     return OGL_OK;
00130   }
00131 
00132 #if (NUX_ENABLE_CG_SHADERS)
00133 
00134   ObjectPtr<ICgVertexShader> GpuDevice::CreateCGVertexShader()
00135   {
00136     ICgVertexShader *ptr;
00137     CreateCGVertexShader((ICgVertexShader **) &ptr);
00138     ObjectPtr<ICgVertexShader> h = ptr;
00139     ptr->UnReference();
00140     return h;
00141   }
00142 
00143   int GpuDevice::CreateCGVertexShader(ICgVertexShader **ppCgVertexShader)
00144   {
00145     *ppCgVertexShader = new ICgVertexShader();
00146 
00147     return OGL_OK;
00148   }
00149 
00150   ObjectPtr<ICgPixelShader> GpuDevice::CreateCGPixelShader()
00151   {
00152     ICgPixelShader *ptr;
00153     CreateCGPixelShader((ICgPixelShader **) &ptr);
00154     ObjectPtr<ICgPixelShader> h = ptr;
00155     ptr->UnReference();
00156     return h;
00157   }
00158 
00159   int GpuDevice::CreateCGPixelShader(ICgPixelShader **ppCgPixelShader)
00160   {
00161     *ppCgPixelShader = new ICgPixelShader();
00162 
00163     return OGL_OK;
00164   }
00165 #endif
00166 }