]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/shaders/plugin.cpp
merge branch work back into trunk
[xonotic/netradiant.git] / plugins / shaders / plugin.cpp
1 /*
2 Copyright (c) 2001, Loki software, inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
14
15 Neither the name of Loki software nor the names of its contributors may be used
16 to endorse or promote products derived from this software without specific prior
17 written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 //
32 // Shaders Plugin
33 //
34
35 #include "plugin.h"
36
37 // =============================================================================
38 // Globals
39
40 // function tables
41 _QERFuncTable_1 g_FuncTable;
42 _QERAppDataTable g_DataTable;
43 _QERQglTable g_QglTable;
44 _QERAppShadersTable g_ShadersTable;
45 _QERFileSystemTable g_VFSTable;
46 _QERScripLibTable g_ScripLibTable;
47 _QERBrushTable g_BrushTable;
48
49 // static bool g_bInterfaceInitDone = false;
50
51 // =============================================================================
52 // SYNAPSE
53
54 CSynapseServer* g_pSynapseServer = NULL;
55 CSynapseClientShaders g_SynapseClient;
56
57 static const XMLConfigEntry_t entries[] =
58   {
59     { SHADERS_MAJOR, SYN_PROVIDE, sizeof(_QERShadersTable), NULL },
60     { VFS_MAJOR, SYN_REQUIRE, sizeof(g_VFSTable), &g_VFSTable },
61     { NULL, SYN_UNKNOWN, 0, NULL } };
62
63 #if __GNUC__ >= 4
64 #pragma GCC visibility push(default)
65 #endif
66 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
67 #if __GNUC__ >= 4
68 #pragma GCC visibility pop
69 #endif
70   if (strcmp(version, SYNAPSE_VERSION))
71   {
72     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
73     return NULL;
74   }
75   g_pSynapseServer = pServer;
76   g_pSynapseServer->IncRef();
77   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
78
79   if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
80     return NULL;
81   }
82
83   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
84   g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(_QERAppDataTable), SYN_REQUIRE, &g_DataTable);
85   g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_QglTable);
86   g_SynapseClient.AddAPI(APPSHADERS_MAJOR, NULL, sizeof(_QERAppShadersTable), SYN_REQUIRE, &g_ShadersTable);
87   g_SynapseClient.AddAPI(SCRIPLIB_MAJOR, NULL, sizeof(_QERScripLibTable), SYN_REQUIRE, &g_ScripLibTable);
88   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(_QERBrushTable), SYN_REQUIRE, &g_BrushTable);
89
90   return &g_SynapseClient;
91 }
92
93 #include "version.h"
94
95 const char* CSynapseClientShaders::GetInfo()
96 {
97   return "Q3/Half-Life shaders module built " __DATE__ " " RADIANT_VERSION;
98 }
99
100 const char* CSynapseClientShaders::GetName()
101 {
102   return "shaders";
103 }