Skip to content

Commit ea1511b

Browse files
committed
ecere/gfx/drivers/GL3/GLMultiDraw: Moving GLMultiDraw and GLArrayTexture classes to ecere library
1 parent db791fc commit ea1511b

File tree

5 files changed

+128
-93
lines changed

5 files changed

+128
-93
lines changed

butterbur/src/opengl/ButterburShader.ec

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,82 @@ import "VersionedShader"
1010

1111
private: // FIXME: eC bug
1212

13-
define squishFactorAttribute = 7;
14-
define drawIDAttribute = 8;
15-
define posOffsetAttribute = 9;
16-
17-
define transform0Attribute = 10;
18-
define transform1Attribute = 11;
19-
define transform2Attribute = 12;
20-
define transform3Attribute = 13;
13+
define squishFactorAttribute = 100;
14+
15+
Size resetDisplaySize;
16+
Size displaySize;
17+
DisplaySystem displaySystem;
18+
Display glDisplay;
19+
20+
GLCapabilities glCaps;
21+
bool glCaps_nonPow2Textures, glCaps_vertexBuffer, glCaps_quads, glCaps_intAndDouble, glCaps_legacyFormats, glCaps_compatible, glCaps_vertexPointer;
22+
bool glCaps_shaders, glCaps_fixedFunction, glCaps_immediate, glCaps_legacy, glCaps_pointSize, glCaps_frameBuffer, glCaps_vao, glCaps_select;
23+
24+
int glVersion;
25+
int glMinorVersion;
26+
27+
uint defaultVAO;
28+
29+
#ifdef _DEBUG
30+
void checkGLErrors( const char *file, int line )
31+
{
32+
int e, nCount = 0;
33+
while((e = glGetError()) && nCount++ < 10)
34+
PrintLn("GL error ", e, "! (at ", file, ":", line, ")");
35+
}
36+
#endif
37+
38+
bool loadedGLExts;
39+
40+
uint tempTexFBO; // TODO: Free this on termination... glDeleteFramebuffers(1, &tempTexFBO);
41+
42+
// FIXME: This is currently duplicated here from Ecere's OGL display driver because there is no other mechanism to access defualt VAO
43+
class TempOGLDisplay : struct
44+
{
45+
GLCapabilities capabilities, originalCapabilities;
46+
bool compat;
47+
int version;
48+
ColorAlpha * flippingBuffer;
49+
int flipBufH, flipBufW;
50+
bool depthWrite;
51+
int x, y;
52+
uint vao;
53+
int maxTMU;
54+
}
55+
56+
public void setupGL(Display display)
57+
{
58+
GLCapabilities caps = display.glCapabilities;
59+
void * data = display.driverData;
60+
61+
glDisplay = display;
62+
displaySystem = display.displaySystem;
63+
64+
displaySize = { display.width, display.height };
65+
resetDisplaySize = displaySize;
66+
67+
SETCAPS(caps);
68+
69+
defaultVAO = ((TempOGLDisplay)data).vao;
70+
if(!loadedGLExts)
71+
{
72+
#if defined(__LUMIN__)
73+
// TODO: !
74+
loadedGLExts = true;
75+
glVersion = 4;
76+
glMinorVersion = 5;
77+
#elif defined(__ANDROID__)
78+
loadedGLExts = true;
79+
glVersion = 3;
80+
glMinorVersion = 2;
81+
#else
82+
ogl_LoadFunctions();
83+
loadedGLExts = true;
84+
glVersion = ogl_GetMajorVersion();
85+
glMinorVersion = ogl_GetMinorVersion();
86+
#endif
87+
}
88+
}
2189

2290
public class ButterburShaderBits : uint64
2391
{

butterbur/src/presentation/DrawingManager.ec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ public import IMPORT_STATIC "ecere"
33
#include "gl123es.h"
44

55
import "Presentation"
6-
import "GLMultiDraw"
76
import "ButterburShader"
87
import "TIManager"
98

ecere/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ _ECSOURCES1 = \
113113
src/gfx/drivers/LFBDisplayDriver.ec \
114114
$(if $(or $(LINUX_TARGET),$(OSX_TARGET)),src/gfx/drivers/NCursesDisplayDriver.ec,) \
115115
$(if $(DISABLE_GL),,src/gfx/drivers/OpenGLDisplayDriver.ec) \
116+
$(if $(DISABLE_GL),,src/gfx/drivers/gl3/GLMultiDraw.ec) \
116117
$(if $(WINDOWS_TARGET),src/gfx/drivers/Win32BitmapPrinterDisplayDriver.ec,)
117118
_ECSOURCES2 = \
118119
$(if ,src/gfx/drivers/CocoaOpenGLDisplayDriver.ec,) \
@@ -798,6 +799,9 @@ $(OBJ)ETC2Format.sym: src/gfx/bitmaps/ETC2Format.ec
798799
$(OBJ)glab.sym: src/gfx/drivers/gl3/glab.ec
799800
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/glab.ec -o $(OBJ)glab.sym
800801

802+
$(OBJ)GLMultiDraw.sym: src/gfx/drivers/gl3/GLMultiDraw.ec
803+
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/GLMultiDraw.ec -o $(OBJ)GLMultiDraw.sym
804+
801805
$(OBJ)immediate.sym: src/gfx/drivers/gl3/immediate.ec
802806
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/immediate.ec -o $(OBJ)immediate.sym
803807

@@ -1258,6 +1262,9 @@ $(OBJ)ETC2Format.c: src/gfx/bitmaps/ETC2Format.ec $(OBJ)ETC2Format.sym | $(SYMBO
12581262
$(OBJ)glab.c: src/gfx/drivers/gl3/glab.ec $(OBJ)glab.sym | $(SYMBOLS)
12591263
$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/glab.ec -o $(OBJ)glab.c -symbols $(OBJ)
12601264

1265+
$(OBJ)GLMultiDraw.c: src/gfx/drivers/gl3/GLMultiDraw.ec $(OBJ)GLMultiDraw.sym | $(SYMBOLS)
1266+
$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/GLMultiDraw.ec -o $(OBJ)GLMultiDraw.c -symbols $(OBJ)
1267+
12611268
$(OBJ)immediate.c: src/gfx/drivers/gl3/immediate.ec $(OBJ)immediate.sym | $(SYMBOLS)
12621269
$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/immediate.ec -o $(OBJ)immediate.c -symbols $(OBJ)
12631270

@@ -2063,6 +2070,9 @@ $(OBJ)gl_compat_4_4.o: src/gfx/drivers/gl3/gl_compat_4_4.c
20632070
$(OBJ)glab.o: $(OBJ)glab.c
20642071
$(CC) $(CFLAGS) $(PRJ_CFLAGS) -c $(OBJ)glab.c -o $(OBJ)glab.o
20652072

2073+
$(OBJ)GLMultiDraw.o: $(OBJ)GLMultiDraw.c
2074+
$(CC) $(CFLAGS) $(PRJ_CFLAGS) -c $(OBJ)GLMultiDraw.c -o $(OBJ)GLMultiDraw.o
2075+
20662076
$(OBJ)immediate.o: $(OBJ)immediate.c
20672077
$(CC) $(CFLAGS) $(PRJ_CFLAGS) -c $(OBJ)immediate.c -o $(OBJ)immediate.o
20682078

ecere/ecere.epj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,12 @@
13291329
}
13301330
}
13311331
]
1332+
},
1333+
{
1334+
"FileName" : "GLMultiDraw.ec",
1335+
"Options" : {
1336+
"ExcludeFromBuild" : false
1337+
}
13321338
}
13331339
],
13341340
"Configurations" : [

butterbur/src/opengl/GLMultiDraw.ec renamed to ecere/src/gfx/drivers/gl3/GLMultiDraw.ec

Lines changed: 36 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
public import IMPORT_STATIC "ecere"
1+
#if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
2+
3+
import "OpenGLDisplayDriver"
24

35
#include "gl123es.h"
46

@@ -8,83 +10,18 @@ public import IMPORT_STATIC "ecere"
810
#define GL_R16 GL_LUMINANCE
911
#endif
1012

11-
import "ButterburShader"
13+
public define drawIDAttribute = 7;
14+
public define posOffsetAttribute = 8;
15+
16+
public define transform0Attribute = 9;
17+
public define transform1Attribute = 10;
18+
public define transform2Attribute = 11;
19+
public define transform3Attribute = 12;
1220

1321
private:
1422

1523
// #define CLIENT_MEM_COMMANDS // Defined as a work-around for Intel driver that does not seem to support indirect commands buffers?
1624

17-
GLCapabilities glCaps;
18-
bool glCaps_nonPow2Textures, glCaps_vertexBuffer, glCaps_quads, glCaps_intAndDouble, glCaps_legacyFormats, glCaps_compatible, glCaps_vertexPointer;
19-
bool glCaps_shaders, glCaps_fixedFunction, glCaps_immediate, glCaps_legacy, glCaps_pointSize, glCaps_frameBuffer, glCaps_vao, glCaps_select;
20-
21-
int glVersion;
22-
int glMinorVersion;
23-
24-
uint defaultVAO;
25-
26-
#ifdef _DEBUG
27-
void checkGLErrors( const char *file, int line )
28-
{
29-
int e, nCount = 0;
30-
while((e = glGetError()) && nCount++ < 10)
31-
PrintLn("GL error ", e, "! (at ", file, ":", line, ")");
32-
}
33-
#endif
34-
35-
// FIXME: This is currently duplicated here from Ecere's OGL display driver because there is no other mechanism to access defualt VAO
36-
class TempOGLDisplay : struct
37-
{
38-
GLCapabilities capabilities, originalCapabilities;
39-
bool compat;
40-
int version;
41-
ColorAlpha * flippingBuffer;
42-
int flipBufH, flipBufW;
43-
bool depthWrite;
44-
int x, y;
45-
uint vao;
46-
int maxTMU;
47-
}
48-
49-
Size resetDisplaySize;
50-
Size displaySize;
51-
DisplaySystem displaySystem;
52-
Display glDisplay;
53-
54-
public void setupGL(Display display)
55-
{
56-
GLCapabilities caps = display.glCapabilities;
57-
void * data = display.driverData;
58-
59-
glDisplay = display;
60-
displaySystem = display.displaySystem;
61-
62-
displaySize = { display.width, display.height };
63-
resetDisplaySize = displaySize;
64-
65-
SETCAPS(caps);
66-
67-
defaultVAO = ((TempOGLDisplay)data).vao;
68-
if(!loadedGLExts)
69-
{
70-
#if defined(__LUMIN__)
71-
// TODO: !
72-
loadedGLExts = true;
73-
glVersion = 4;
74-
glMinorVersion = 5;
75-
#elif defined(__ANDROID__)
76-
loadedGLExts = true;
77-
glVersion = 3;
78-
glMinorVersion = 2;
79-
#else
80-
ogl_LoadFunctions();
81-
loadedGLExts = true;
82-
glVersion = ogl_GetMajorVersion();
83-
glMinorVersion = ogl_GetMinorVersion();
84-
#endif
85-
}
86-
}
87-
8825
#define GL_CLAMP_TO_EDGE 0x812F
8926

9027
#if defined _GLES1
@@ -95,11 +32,7 @@ public void setupGL(Display display)
9532
#define glClampFunction(version) (version >= 2 ? GL_CLAMP_TO_EDGE : GL_CLAMP)
9633
#endif
9734

98-
bool loadedGLExts;
99-
100-
uint tempTexFBO; // TODO: Free this on termination... glDeleteFramebuffers(1, &tempTexFBO);
101-
102-
struct FreeSpots
35+
public struct FreeSpots
10336
{
10437
uint size;
10538
int * spots;
@@ -159,17 +92,28 @@ struct FreeSpots
15992
size = count;
16093
}
16194
}
162-
}
95+
};
16396

97+
default:
98+
#if defined(_GLES3)
99+
int glVersion = 3;
100+
#elif defined(_GLES2)
101+
int glVersion = 2;
102+
#elif defined(_GLES)
103+
int glVersion = 1;
104+
#else
105+
int glVersion = 0;
106+
#endif
107+
private:
164108

165-
struct GLArrayTexture
109+
public struct GLArrayTexture
166110
{
167111
uint texture;
168112
uint width, height, numLayers;
169113
uint numLevels;
170114
bool maxLevel;
171115
int format;
172-
private FreeSpots spots;
116+
/*private */FreeSpots spots;
173117

174118
void free()
175119
{
@@ -203,6 +147,12 @@ struct GLArrayTexture
203147
glDeleteTextures(1, &texture);
204148
texture = 0;
205149
}*/
150+
151+
#if !defined(_GLES) && !defined(_GLES2) && !defined(_GLES3)
152+
if(!glVersion)
153+
glVersion = ogl_GetMajorVersion();
154+
#endif
155+
206156
if(!texture)
207157
glGenTextures(1, &texture);
208158

@@ -354,7 +304,7 @@ struct GLArrayTexture
354304
}
355305
};
356306

357-
struct GLDrawCommand
307+
public struct GLDrawCommand
358308
{
359309
uint count;
360310
uint instanceCount;
@@ -363,7 +313,7 @@ struct GLDrawCommand
363313
uint baseInstance;
364314
};
365315

366-
struct GLMultiDraw
316+
public struct GLMultiDraw
367317
{
368318
GLMB indexGLMB;
369319
GLMB vertexGLMB;
@@ -598,9 +548,11 @@ struct GLMultiDraw
598548
}
599549
};
600550

601-
void GLMultisampling(bool value)
551+
public void GLMultisampling(bool value)
602552
{
603553
#if !defined(_GLES) && !defined(_GLES2)
604554
(value ? glEnable : glDisable)(GL_MULTISAMPLE);
605555
#endif
606556
}
557+
558+
#endif

0 commit comments

Comments
 (0)