ArbBackend.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 "Arb.hpp"
00027 #include "GlTextures.hpp"
00028 #include "GlBackend.hpp"
00029 
00030 #include "PBufferStreams.hpp"
00031 
00032 namespace shgl {
00033 
00034 struct ArbBackend : public GlBackend {
00035   ArbBackend()
00036     : GlBackend(new ArbCodeStrategy(),
00037                 new GlTextures(),
00038 #ifdef __APPLE__
00039                 // For now...
00040                 0,
00041 #else
00042                 new PBufferStreams(),
00043 #endif
00044                 "arb", "1.0")
00045   {
00046   }
00047 };
00048 
00049 #ifdef _WIN32
00050 
00051 extern "C"
00052 BOOL APIENTRY DllMain(HANDLE hModule, 
00053                       DWORD  ul_reason_for_call, 
00054                       LPVOID lpReserved)
00055 {
00056   return TRUE;
00057 }
00058 
00059 #endif // _WIN32
00060 
00061 
00062 }
00063 
00064 extern "C" {
00065   using namespace shgl;
00066 #ifdef _WIN32
00067   __declspec(dllexport) 
00068 #endif
00069   ArbBackend* shBackend_libsharb_instantiate() 
00070   {
00071     return new ArbBackend();
00072   }
00073 
00074 #ifdef _WIN32
00075   __declspec(dllexport) 
00076 #endif
00077   int shBackend_libsharb_target_cost(const std::string& target) 
00078   {
00079     if ("arb:vertex" == target)   return 1;
00080     if ("arb:fragment" == target) return 1;
00081 #ifndef __APPLE__
00082     if ("arb:stream" == target)   return 1;
00083 #else
00084     if ("arb:stream" == target)   return 0;
00085 #endif
00086 
00087     if (("gpu:vertex" == target) || ("gpu:fragment" == target)) return 2;
00088     if (("vertex" == target) || ("fragment" == target))         return 2;
00089     if (("*:vertex" == target) || ("*:fragment" == target))     return 2;
00090 
00091 #ifndef __APPLE__
00092     if ("gpu:stream" == target) return 5;
00093     if ("*:stream" == target)   return 5;
00094     if ("stream" == target)     return 5;
00095 #else
00096     if ("gpu:stream" == target) return 0;
00097     if ("*:stream" == target)   return 0;
00098     if ("stream" == target)     return 0;
00099 #endif
00100     
00101 
00102     return 0;
00103   }
00104 }

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