Skip to content

Commit

Permalink
ecere/gfx/drivers/GL3/GLMultiDraw: Moving GLMultiDraw and GLArrayText…
Browse files Browse the repository at this point in the history
…ure classes to ecere library
  • Loading branch information
jerstlouis committed Apr 28, 2020
1 parent db791fc commit c3661c0
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 100 deletions.
84 changes: 76 additions & 8 deletions butterbur/src/opengl/ButterburShader.ec
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,82 @@ import "VersionedShader"

private: // FIXME: eC bug

define squishFactorAttribute = 7;
define drawIDAttribute = 8;
define posOffsetAttribute = 9;

define transform0Attribute = 10;
define transform1Attribute = 11;
define transform2Attribute = 12;
define transform3Attribute = 13;
define squishFactorAttribute = 100;

Size resetDisplaySize;
Size displaySize;
DisplaySystem displaySystem;
Display glDisplay;

GLCapabilities glCaps;
bool glCaps_nonPow2Textures, glCaps_vertexBuffer, glCaps_quads, glCaps_intAndDouble, glCaps_legacyFormats, glCaps_compatible, glCaps_vertexPointer;
bool glCaps_shaders, glCaps_fixedFunction, glCaps_immediate, glCaps_legacy, glCaps_pointSize, glCaps_frameBuffer, glCaps_vao, glCaps_select;

int glVersion;
int glMinorVersion;

uint defaultVAO;

#ifdef _DEBUG
void checkGLErrors( const char *file, int line )
{
int e, nCount = 0;
while((e = glGetError()) && nCount++ < 10)
PrintLn("GL error ", e, "! (at ", file, ":", line, ")");
}
#endif

bool loadedGLExts;

uint tempTexFBO; // TODO: Free this on termination... glDeleteFramebuffers(1, &tempTexFBO);

// FIXME: This is currently duplicated here from Ecere's OGL display driver because there is no other mechanism to access defualt VAO
class TempOGLDisplay : struct
{
GLCapabilities capabilities, originalCapabilities;
bool compat;
int version;
ColorAlpha * flippingBuffer;
int flipBufH, flipBufW;
bool depthWrite;
int x, y;
uint vao;
int maxTMU;
}

public void setupGL(Display display)
{
GLCapabilities caps = display.glCapabilities;
void * data = display.driverData;

glDisplay = display;
displaySystem = display.displaySystem;

displaySize = { display.width, display.height };
resetDisplaySize = displaySize;

SETCAPS(caps);

defaultVAO = ((TempOGLDisplay)data).vao;
if(!loadedGLExts)
{
#if defined(__LUMIN__)
// TODO: !
loadedGLExts = true;
glVersion = 4;
glMinorVersion = 5;
#elif defined(__ANDROID__)
loadedGLExts = true;
glVersion = 3;
glMinorVersion = 2;
#else
ogl_LoadFunctions();
loadedGLExts = true;
glVersion = ogl_GetMajorVersion();
glMinorVersion = ogl_GetMinorVersion();
#endif
}
}

public class ButterburShaderBits : uint64
{
Expand Down
1 change: 0 additions & 1 deletion butterbur/src/presentation/DrawingManager.ec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ public import IMPORT_STATIC "ecere"
#include "gl123es.h"

import "Presentation"
import "GLMultiDraw"
import "ButterburShader"
import "TIManager"

Expand Down
10 changes: 10 additions & 0 deletions ecere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ _ECSOURCES1 = \
src/gfx/drivers/LFBDisplayDriver.ec \
$(if $(or $(LINUX_TARGET),$(OSX_TARGET)),src/gfx/drivers/NCursesDisplayDriver.ec,) \
$(if $(DISABLE_GL),,src/gfx/drivers/OpenGLDisplayDriver.ec) \
$(if $(DISABLE_GL),,src/gfx/drivers/gl3/GLMultiDraw.ec) \
$(if $(WINDOWS_TARGET),src/gfx/drivers/Win32BitmapPrinterDisplayDriver.ec,)
_ECSOURCES2 = \
$(if ,src/gfx/drivers/CocoaOpenGLDisplayDriver.ec,) \
Expand Down Expand Up @@ -798,6 +799,9 @@ $(OBJ)ETC2Format.sym: src/gfx/bitmaps/ETC2Format.ec
$(OBJ)glab.sym: src/gfx/drivers/gl3/glab.ec
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/glab.ec -o $(OBJ)glab.sym

$(OBJ)GLMultiDraw.sym: src/gfx/drivers/gl3/GLMultiDraw.ec
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/GLMultiDraw.ec -o $(OBJ)GLMultiDraw.sym

$(OBJ)immediate.sym: src/gfx/drivers/gl3/immediate.ec
$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/immediate.ec -o $(OBJ)immediate.sym

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

$(OBJ)GLMultiDraw.c: src/gfx/drivers/gl3/GLMultiDraw.ec $(OBJ)GLMultiDraw.sym | $(SYMBOLS)
$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/GLMultiDraw.ec -o $(OBJ)GLMultiDraw.c -symbols $(OBJ)

$(OBJ)immediate.c: src/gfx/drivers/gl3/immediate.ec $(OBJ)immediate.sym | $(SYMBOLS)
$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) -c src/gfx/drivers/gl3/immediate.ec -o $(OBJ)immediate.c -symbols $(OBJ)

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

$(OBJ)GLMultiDraw.o: $(OBJ)GLMultiDraw.c
$(CC) $(CFLAGS) $(PRJ_CFLAGS) -c $(OBJ)GLMultiDraw.c -o $(OBJ)GLMultiDraw.o

$(OBJ)immediate.o: $(OBJ)immediate.c
$(CC) $(CFLAGS) $(PRJ_CFLAGS) -c $(OBJ)immediate.c -o $(OBJ)immediate.o

Expand Down
6 changes: 6 additions & 0 deletions ecere/ecere.epj
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,12 @@
}
}
]
},
{
"FileName" : "GLMultiDraw.ec",
"Options" : {
"ExcludeFromBuild" : false
}
}
],
"Configurations" : [
Expand Down
5 changes: 3 additions & 2 deletions ecere/src/gfx/drivers/OpenGLDisplayDriver.ec
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,15 @@ private:


// ********** Errors and Debugging **********
/*
#ifdef _DEBUG
void CheckGLErrors(const String s, int l)
{
int e, nCount = 0;
while((e = glGetError()) && nCount++ < 10)
printf("GL error %d! (%s:%d)\n", e, s, l);
}
*/
#endif

#ifdef GL_DEBUGGING
#ifndef APIENTRY
#define APIENTRY
Expand Down
Loading

0 comments on commit c3661c0

Please sign in to comment.