GlslBackend.cpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2006 Serious Hack Inc.
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., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifdef _WIN32
00021 #include <windows.h>
00022 #endif /* _WIN32 */
00023 
00024 #include <iostream>
00025 
00026 #include "Glsl.hpp"
00027 #include "GlTextures.hpp"
00028 #include "GlBackend.hpp"
00029 #include "PBufferStreams.hpp"
00030 
00031 namespace shgl {
00032 
00033 struct GlslBackend : public GlBackend {
00034   GlslBackend()
00035     : GlBackend(new GlslCodeStrategy(),
00036                 new GlTextures(),
00037 #ifdef __APPLE__
00038                 0,
00039 #else
00040                 new PBufferStreams(),
00041 #endif
00042                 "glsl", "1.0")
00043   {
00044   }
00045 };
00046 
00047 #ifdef _WIN32
00048 
00049 extern "C"
00050 BOOL APIENTRY DllMain(HANDLE hModule, 
00051                       DWORD  ul_reason_for_call, 
00052                       LPVOID lpReserved)
00053 {
00054   return TRUE;
00055 }
00056 #endif // _WIN32
00057 
00058 }
00059 
00060 extern "C" {
00061   using namespace shgl;
00062 
00063 #ifdef _WIN32
00064   __declspec(dllexport) 
00065 #endif
00066   GlslBackend* shBackend_libshglsl_instantiate()
00067   {
00068     return new GlslBackend();
00069   }
00070 
00071 #ifdef _WIN32
00072   __declspec(dllexport) 
00073 #endif
00074   int shBackend_libshglsl_target_cost(const std::string& target)
00075   {
00076     if ("glsl:vertex" == target)   return 1;
00077     if ("glsl:fragment" == target) return 1;
00078 #ifndef __APPLE__
00079     if ("glsl:stream" == target)   return 1;
00080 #else
00081     if ("glsl:stream" == target)   return 0;
00082 #endif
00083     
00084     if (("gpu:vertex" == target) || ("gpu:fragment" == target)) return 5;
00085     if (("vertex" == target) || ("fragment" == target))         return 5;
00086     if (("*:vertex" == target) || ("*:fragment" == target))     return 5;
00087 
00088 #ifndef __APPLE__
00089     if ("gpu:stream" == target) return 10;
00090     if ("*:stream" == target)   return 10;
00091     if ("stream" == target)     return 10;
00092 #else
00093     if ("gpu:stream" == target) return 0;
00094     if ("*:stream" == target)   return 0;
00095     if ("stream" == target)     return 0;
00096 #endif
00097 
00098     return 0;
00099   }
00100 }
00101 

Generated on Thu Feb 16 14:51:28 2006 for Sh by  doxygen 1.4.6