summaryrefslogtreecommitdiff
path: root/lib/wx/c_src/egl_impl.h
blob: 5a7c76b28951c7375389f37ecb5185bf15a8b971 (plain)
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
144
145
146
147
148
149
150
151
152
/*
 * %CopyrightBegin%
 * 
 * Copyright Ericsson AB 2010-2022. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * %CopyrightEnd% 
 */

#include <erl_nif.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) && defined(HAVE_GL_GLU_H)
#include <GL/gl.h>
# include <GL/glu.h>	
#elif defined(HAVE_OPENGL_GL_H) && defined(HAVE_OPENGL_GLU_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

#ifdef _WIN64
typedef unsigned long long int egl_uword;
typedef signed   long long int egl_word;
#else
typedef unsigned long  int     egl_uword;
typedef signed   long  int     egl_word;
#endif

typedef ErlNifSInt64 egl_int64_t;
typedef ErlNifUInt64 egl_uint64_t;

/* 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

#ifndef HAVE_GLINT64EXT
typedef egl_int64_t GLint64EXT;
typedef egl_uint64_t GLuint64EXT;
#endif

#ifndef GL_ARB_sync
typedef egl_int64_t GLint64;
typedef egl_uint64_t GLuint64;
typedef struct __GLsync *GLsync;
#endif

#ifndef DEF_EGL_CMD
typedef struct egl_cmd_t {
    ErlNifEnv *env;
    ERL_NIF_TERM args[16];
    void (*fptr) (ErlNifEnv *, ErlNifPid *, ERL_NIF_TERM *);
    ErlNifPid pid;
} egl_cmd;
#endif

typedef struct {
    int op;
    const char * name;
    const char * alt;
    void * func;
    void (*nif_cb) (ErlNifEnv *, ErlNifPid *, ERL_NIF_TERM *);
} gl_fns_t;

extern gl_fns_t gl_fns[];
extern int egl_load_functions();

/* internal */
void init_tess();
void erl_tess_impl(ErlNifEnv *, ErlNifPid *, ERL_NIF_TERM *);
extern int gl_error_op;

extern ERL_NIF_TERM EGL_ATOM_OK;
extern ERL_NIF_TERM EGL_ATOM_REPLY;
extern ERL_NIF_TERM EGL_ATOM_ERROR;
extern ERL_NIF_TERM EGL_ATOM_BADARG;

#define Badarg(Op, Argc) {egl_badarg(env,self,Op,Argc); return;}

int egl_get_float(ErlNifEnv* env, ERL_NIF_TERM term, GLfloat* dp);
int egl_get_short(ErlNifEnv* env, ERL_NIF_TERM term, GLshort* dp);
int egl_get_ushort(ErlNifEnv* env, ERL_NIF_TERM term, GLushort* dp);
int egl_get_byte(ErlNifEnv* env, ERL_NIF_TERM term, GLbyte* dp);
int egl_get_ubyte(ErlNifEnv* env, ERL_NIF_TERM term, GLubyte* dp);
int egl_get_word(ErlNifEnv* env, ERL_NIF_TERM term, egl_word * dp);
int egl_get_ptr(ErlNifEnv* env, ERL_NIF_TERM term, void** dp);
ERL_NIF_TERM egl_lookup_func_func(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
void egl_badarg(ErlNifEnv* env, ErlNifPid *self, int op, const char * argc);