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 "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