1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2010. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* %CopyrightEnd%
*/
#include "erl_driver.h"
/* Wrap everything from glext.h so we are not dependent on the user version of it */
#ifndef _WIN32
# include <dlfcn.h>
#endif
#ifdef _WIN32
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#elif defined(HAVE_GL_GL_H)
#include <GL/gl.h>
# include <GL/glu.h>
#elif defined(HAVE_OPENGL_GL_H)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef CALLBACK
# define CALLBACK
#endif
#ifdef _WIN32
# ifndef _GLUfuncptr
// Visual studio CPP ++ compiler
# define _GLUfuncptr void (_stdcall *)()
# endif
#endif
#ifdef _GLUfuncptr
# define GLUfuncptr _GLUfuncptr
#elif defined(TESS_CB_TIGER_STYLE)
# define GLUfuncptr GLvoid (*)(...)
#else
# define GLUfuncptr GLvoid (*)()
#endif
/* Some new GL types (eliminates the need for glext.h) */
#ifndef HAVE_GLINTPTR
#ifndef HAVE_GLINTPTRARB
# include <stddef.h>
/* GL types for handling large vertex buffer objects */
typedef ptrdiff_t GLintptrARB;
typedef ptrdiff_t GLsizeiptrARB;
#endif /* HAVE_GLINTPTRARB */
typedef GLintptrARB GLintptr;
typedef GLsizeiptrARB GLsizeiptr;
#endif /* HAVE_GLINTPTR */
#ifndef HAVE_GLCHAR
# ifndef HAVE_GLCHARARB
/* GL types for handling shader object handles and characters */
typedef char GLcharARB; /* native character */
typedef unsigned int GLhandleARB; /* shader object handle */
#endif /* HAVE_GLCHARARB */
typedef GLcharARB GLchar;
#endif
#ifndef HAVE_GLHALFARB
/* GL types for "half" precision (s10e5) float data in host memory */
typedef unsigned short GLhalfARB;
#endif
/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
/* (as used in the GLX_OML_sync_control extension). */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <inttypes.h>
#elif defined(__sun__)
#include <inttypes.h>
#if defined(__STDC__)
#if defined(__arch64__)
typedef long int int64_t;
typedef unsigned long int uint64_t;
#else
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#endif /* __arch64__ */
#endif /* __STDC__ */
#elif defined( __VMS )
#include <inttypes.h>
#elif defined(__SCO__) || defined(__USLC__)
#include <stdint.h>
#elif defined(__UNIXOS2__) || defined(__SOL64__)
typedef long int int32_t;
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#elif defined(WIN32) && defined(_MSC_VER)
typedef long int int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif defined(WIN32) && defined(__GNUC__)
#include <stdint.h>
#else
#include <inttypes.h> /* Fallback option */
#endif
#ifndef HAVE_GLINT64EXT
typedef int64_t GLint64EXT;
typedef uint64_t GLuint64EXT;
#endif
/* External Api */
#ifdef _WIN32
extern "C" __declspec(dllexport) int egl_init_opengl(void *);
extern "C" __declspec(dllexport) void egl_dispatch(int, char *, ErlDrvPort, ErlDrvTermData, char **);
#else
extern "C" int egl_init_opengl(void *);
extern "C" void egl_dispatch(int, char *, ErlDrvPort, ErlDrvTermData, char **);
#endif
/* internal */
int erl_tess_impl(char* buff, ErlDrvPort port, ErlDrvTermData caller);
void gl_error();
extern int gl_error_op;
extern ErlDrvTermData gl_active;
|