00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifdef WIN32
00021 #include <windows.h>
00022 #endif
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
00040 0)
00041 #else
00042 new PBufferStreams())
00043 #endif
00044 {
00045 }
00046
00047 std::string name() const { return "arb"; }
00048 std::string version() const { return "1.0"; }
00049 };
00050
00051 #ifdef WIN32
00052 static ArbBackend* backend = 0;
00053
00054 extern "C"
00055 BOOL APIENTRY DllMain(HANDLE hModule,
00056 DWORD ul_reason_for_call,
00057 LPVOID lpReserved)
00058 {
00059 switch (ul_reason_for_call) {
00060 case DLL_PROCESS_ATTACH:
00061 if (backend) return TRUE;
00062 backend = new ArbBackend();
00063 break;
00064 case DLL_THREAD_ATTACH:
00065 case DLL_THREAD_DETACH:
00066 break;
00067 case DLL_PROCESS_DETACH:
00068 delete backend;
00069 break;
00070 default:
00071 break;
00072 }
00073 return TRUE;
00074 }
00075
00076 #endif // WIN32
00077
00078
00079 }
00080
00081 extern "C" {
00082 using namespace shgl;
00083 #ifdef WIN32
00084 __declspec(dllexport)
00085 #endif
00086 ArbBackend* shBackend_libsharb_instantiate()
00087 {
00088 return new ArbBackend();
00089 }
00090
00091 #ifdef WIN32
00092 __declspec(dllexport)
00093 #endif
00094 int shBackend_libsharb_target_cost(const std::string& target)
00095 {
00096 if ("arb:vertex" == target) return 1;
00097 if ("arb:fragment" == target) return 1;
00098 #ifndef __APPLE__
00099 if ("arb:stream" == target) return 1;
00100 #else
00101 if ("arb:stream" == target) return 0;
00102 #endif
00103
00104 if (("gpu:vertex" == target) || ("gpu:fragment" == target)) return 2;
00105 if (("vertex" == target) || ("fragment" == target)) return 2;
00106 if (("*:vertex" == target) || ("*:fragment" == target)) return 2;
00107
00108 #ifndef __APPLE__
00109 if ("gpu:stream" == target) return 5;
00110 if ("*:stream" == target) return 5;
00111 if ("stream" == target) return 5;
00112 #else
00113 if ("gpu:stream" == target) return 0;
00114 if ("*:stream" == target) return 0;
00115 if ("stream" == target) return 0;
00116 #endif
00117
00118
00119 return 0;
00120 }
00121 }