Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GlslBackend.cpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 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                 new PBufferStreams())
00038   {
00039   }
00040 
00041   std::string name() const { return "glsl"; }
00042   std::string version() const { return "1.0"; }
00043 };
00044 
00045 #ifdef WIN32
00046 static GlslBackend* backend = 0;
00047 
00048 extern "C"
00049 BOOL APIENTRY DllMain(HANDLE hModule, 
00050                       DWORD  ul_reason_for_call, 
00051                       LPVOID lpReserved)
00052 {
00053   switch (ul_reason_for_call) {
00054   case DLL_PROCESS_ATTACH:
00055     if (backend) return TRUE;
00056     backend = new GlslBackend();
00057     break;
00058   case DLL_THREAD_ATTACH:
00059   case DLL_THREAD_DETACH:
00060           break;
00061   case DLL_PROCESS_DETACH:
00062     delete backend;
00063     break;
00064   default:
00065           break;
00066   }
00067   return TRUE;
00068 }
00069 #endif // WIN32
00070 
00071 }
00072 
00073 extern "C" {
00074   using namespace shgl;
00075 
00076 #ifdef WIN32
00077   __declspec(dllexport) 
00078 #endif
00079   GlslBackend* shBackend_libshglsl_instantiate()
00080   {
00081     return new GlslBackend();
00082   }
00083 
00084 #ifdef WIN32
00085   __declspec(dllexport) 
00086 #endif
00087   int shBackend_libshglsl_target_cost(const std::string& target)
00088   {
00089     if ("glsl:vertex" == target)   return 1;
00090     if ("glsl:fragment" == target) return 1;
00091 #ifndef __APPLE__
00092     if ("glsl:stream" == target)   return 1;
00093 #else
00094     if ("glsl:stream" == target)   return 0;
00095 #endif
00096     
00097     if (("gpu:vertex" == target) || ("gpu:fragment" == target)) return 5;
00098     if (("vertex" == target) || ("fragment" == target))         return 5;
00099     if (("*:vertex" == target) || ("*:fragment" == target))     return 5;
00100 
00101 #ifndef __APPLE__
00102     if ("gpu:stream" == target) return 10;
00103     if ("*:stream" == target)   return 10;
00104     if ("stream" == target)     return 10;
00105 #else
00106     if ("gpu:stream" == target) return 0;
00107     if ("*:stream" == target)   return 0;
00108     if ("stream" == target)     return 0;
00109 #endif
00110 
00111     return 0;
00112   }
00113 }
00114 

Generated on Thu Jul 28 17:33:00 2005 for Sh by  doxygen 1.4.3-20050530