Skip to content

Commit c3661c0

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

File tree

6 files changed

+136
-100
lines changed

6 files changed

+136
-100
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" : [

ecere/src/gfx/drivers/OpenGLDisplayDriver.ec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,15 @@ private:
194194

195195

196196
// ********** Errors and Debugging **********
197-
/*
197+
#ifdef _DEBUG
198198
void CheckGLErrors(const String s, int l)
199199
{
200200
int e, nCount = 0;
201201
while((e = glGetError()) && nCount++ < 10)
202202
printf("GL error %d! (%s:%d)\n", e, s, l);
203203
}
204-
*/
204+
#endif
205+
205206
#ifdef GL_DEBUGGING
206207
#ifndef APIENTRY
207208
#define APIENTRY

0 commit comments

Comments
 (0)