1 | /*
|
---|
2 | glh - is a platform-indepenedent C++ OpenGL helper library
|
---|
3 |
|
---|
4 |
|
---|
5 | Copyright (c) 2000 Cass Everitt
|
---|
6 | Copyright (c) 2000 NVIDIA Corporation
|
---|
7 | All rights reserved.
|
---|
8 |
|
---|
9 | Redistribution and use in source and binary forms, with or
|
---|
10 | without modification, are permitted provided that the following
|
---|
11 | conditions are met:
|
---|
12 |
|
---|
13 | * Redistributions of source code must retain the above
|
---|
14 | copyright notice, this list of conditions and the following
|
---|
15 | disclaimer.
|
---|
16 |
|
---|
17 | * Redistributions in binary form must reproduce the above
|
---|
18 | copyright notice, this list of conditions and the following
|
---|
19 | disclaimer in the documentation and/or other materials
|
---|
20 | provided with the distribution.
|
---|
21 |
|
---|
22 | * The names of contributors to this software may not be used
|
---|
23 | to endorse or promote products derived from this software
|
---|
24 | without specific prior written permission.
|
---|
25 |
|
---|
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
27 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
29 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
30 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
32 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
33 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
34 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
35 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
---|
36 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
37 | POSSIBILITY OF SUCH DAMAGE.
|
---|
38 |
|
---|
39 |
|
---|
40 | Cass Everitt - cass@r3.nu
|
---|
41 | */
|
---|
42 |
|
---|
43 | #ifndef GLH_GLUT_CALLFUNC_H
|
---|
44 | #define GLH_GLUT_CALLFUNC_H
|
---|
45 |
|
---|
46 | #include <string>
|
---|
47 |
|
---|
48 | #ifdef _WIN32
|
---|
49 | #define GLH_FUNC extern "C" __declspec(dllexport)
|
---|
50 | #else
|
---|
51 | #define GLH_FUNC
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | namespace glh
|
---|
56 | {
|
---|
57 |
|
---|
58 | struct library_handle
|
---|
59 | {
|
---|
60 | #ifdef _WIN32
|
---|
61 | bool init(const char * name)
|
---|
62 | {
|
---|
63 | lib = GetModuleHandle(name);
|
---|
64 | if(lib) return true;
|
---|
65 | std::string n(name);
|
---|
66 | n += ".exe";
|
---|
67 | lib = GetModuleHandle(n.c_str());
|
---|
68 |
|
---|
69 | return lib != 0;
|
---|
70 | }
|
---|
71 | void call_func(const char k, int x, int y)
|
---|
72 | {
|
---|
73 | std::string entry_name("key__");
|
---|
74 | entry_name += k;
|
---|
75 | void (*entry)(int, int) = (void (*)(int, int))GetProcAddress(lib, entry_name.c_str());
|
---|
76 | if(entry)
|
---|
77 | (*entry)(x, y);
|
---|
78 | }
|
---|
79 | HMODULE lib;
|
---|
80 | #endif
|
---|
81 | };
|
---|
82 |
|
---|
83 | }
|
---|
84 |
|
---|
85 | #endif
|
---|