Update to v103r20 release.

byuu says:

Changelog:

  - ruby/audio/xaudio2: ported to new ruby API
  - ruby/video/cgl: ported to new ruby API (untested, won't compile)
  - ruby/video/directdraw: ported to new ruby API
  - ruby/video/gdi: ported to new ruby API
  - ruby/video/glx: ported to new ruby API
  - ruby/video/wgl: ported to new ruby API
  - ruby/video/opengl: code cleanups

The macOS CGL driver is sure to have compilation errors. If someone will
post the compilation error log, I can hopefully fix it in one or two
iterations of WIPs.

I am unable to test the Xorg GLX driver, because my FreeBSD desktop
video card drivers do not support OpenGL 3.2. If the driver doesn't
work, I'm going to need help tracking down what broke from the older
releases.

The real fun is still yet to come ... all the Linux-only drivers, where
I don't have a single Linux machine to test with.

Todo:

  - libco/fiber
  - libco/ucontext (I should really just delete this)
  - tomoko: hide main UI window when in exclusive fullscreen mode
This commit is contained in:
Tim Allen
2017-07-24 15:23:40 +10:00
parent 8be474b0ac
commit d5c09c9ab1
28 changed files with 744 additions and 830 deletions

View File

@@ -10,7 +10,7 @@ auto OpenGL::shader(const string& pathname) -> void {
absoluteWidth = 0, absoluteHeight = 0;
relativeWidth = 0, relativeHeight = 0;
unsigned historySize = 0;
uint historySize = 0;
if(pathname) {
auto document = BML::unserialize(file::read({pathname, "manifest.bml"}));
@@ -38,7 +38,7 @@ auto OpenGL::shader(const string& pathname) -> void {
}
for(auto node : document.find("program")) {
unsigned n = programs.size();
uint n = programs.size();
programs(n).bind(this, node, pathname);
}
}
@@ -51,7 +51,7 @@ auto OpenGL::shader(const string& pathname) -> void {
allocateHistory(historySize);
}
auto OpenGL::allocateHistory(unsigned size) -> void {
auto OpenGL::allocateHistory(uint size) -> void {
for(auto& frame : history) glDeleteTextures(1, &frame.texture);
history.reset();
while(size--) {
@@ -65,11 +65,6 @@ auto OpenGL::allocateHistory(unsigned size) -> void {
}
}
auto OpenGL::lock(uint32_t*& data, unsigned& pitch) -> bool {
pitch = width * sizeof(uint32_t);
return data = buffer;
}
auto OpenGL::clear() -> void {
for(auto& p : programs) {
glUseProgram(p.program);
@@ -83,7 +78,12 @@ auto OpenGL::clear() -> void {
glClear(GL_COLOR_BUFFER_BIT);
}
auto OpenGL::refresh() -> void {
auto OpenGL::lock(uint32_t*& data, uint& pitch) -> bool {
pitch = width * sizeof(uint32_t);
return data = buffer;
}
auto OpenGL::output() -> void {
clear();
glActiveTexture(GL_TEXTURE0);
@@ -92,15 +92,15 @@ auto OpenGL::refresh() -> void {
struct Source {
GLuint texture;
unsigned width, height;
uint width, height;
GLuint filter, wrap;
};
vector<Source> sources;
sources.prepend({texture, width, height, filter, wrap});
for(auto& p : programs) {
unsigned targetWidth = p.absoluteWidth ? p.absoluteWidth : outputWidth;
unsigned targetHeight = p.absoluteHeight ? p.absoluteHeight : outputHeight;
uint targetWidth = p.absoluteWidth ? p.absoluteWidth : outputWidth;
uint targetHeight = p.absoluteHeight ? p.absoluteHeight : outputHeight;
if(p.relativeWidth) targetWidth = sources[0].width * p.relativeWidth;
if(p.relativeHeight) targetHeight = sources[0].height * p.relativeHeight;
@@ -115,7 +115,7 @@ auto OpenGL::refresh() -> void {
glrUniform4f("targetSize", targetWidth, targetHeight, 1.0 / targetWidth, 1.0 / targetHeight);
glrUniform4f("outputSize", outputWidth, outputHeight, 1.0 / outputWidth, 1.0 / outputHeight);
unsigned aid = 0;
uint aid = 0;
for(auto& frame : history) {
glrUniform1i({"history[", aid, "]"}, aid);
glrUniform4f({"historySize[", aid, "]"}, frame.width, frame.height, 1.0 / frame.width, 1.0 / frame.height);
@@ -124,7 +124,7 @@ auto OpenGL::refresh() -> void {
glrParameters(frame.filter, frame.wrap);
}
unsigned bid = 0;
uint bid = 0;
for(auto& source : sources) {
glrUniform1i({"source[", bid, "]"}, aid + bid);
glrUniform4f({"sourceSize[", bid, "]"}, source.width, source.height, 1.0 / source.width, 1.0 / source.height);
@@ -133,7 +133,7 @@ auto OpenGL::refresh() -> void {
glrParameters(source.filter, source.wrap);
}
unsigned cid = 0;
uint cid = 0;
for(auto& pixmap : p.pixmaps) {
glrUniform1i({"pixmap[", cid, "]"}, aid + bid + cid);
glrUniform4f({"pixmapSize[", bid, "]"}, pixmap.width, pixmap.height, 1.0 / pixmap.width, 1.0 / pixmap.height);
@@ -151,8 +151,8 @@ auto OpenGL::refresh() -> void {
sources.prepend({p.texture, p.width, p.height, p.filter, p.wrap});
}
unsigned targetWidth = absoluteWidth ? absoluteWidth : outputWidth;
unsigned targetHeight = absoluteHeight ? absoluteHeight : outputHeight;
uint targetWidth = absoluteWidth ? absoluteWidth : outputWidth;
uint targetHeight = absoluteHeight ? absoluteHeight : outputHeight;
if(relativeWidth) targetWidth = sources[0].width * relativeWidth;
if(relativeHeight) targetHeight = sources[0].height * relativeHeight;
@@ -180,7 +180,7 @@ auto OpenGL::refresh() -> void {
}
}
auto OpenGL::init() -> bool {
auto OpenGL::initialize() -> bool {
if(!OpenGLBind()) return false;
glDisable(GL_ALPHA_TEST);
@@ -203,8 +203,8 @@ auto OpenGL::init() -> bool {
return initialized = true;
}
auto OpenGL::term() -> void {
if(initialized == false) return;
auto OpenGL::terminate() -> void {
if(!initialized) return;
shader(""); //release shader resources (eg frame[] history)
OpenGLSurface::release();
if(buffer) { delete[] buffer; buffer = nullptr; }

View File

@@ -27,8 +27,8 @@ struct OpenGLTexture {
auto getType() const -> GLuint;
GLuint texture = 0;
unsigned width = 0;
unsigned height = 0;
uint width = 0;
uint height = 0;
GLuint format = GL_RGBA8;
GLuint filter = GL_LINEAR;
GLuint wrap = GL_CLAMP_TO_BORDER;
@@ -36,9 +36,9 @@ struct OpenGLTexture {
struct OpenGLSurface : OpenGLTexture {
auto allocate() -> void;
auto size(unsigned width, unsigned height) -> void;
auto size(uint width, uint height) -> void;
auto release() -> void;
auto render(unsigned sourceWidth, unsigned sourceHeight, unsigned targetWidth, unsigned targetHeight) -> void;
auto render(uint sourceWidth, uint sourceHeight, uint targetWidth, uint targetHeight) -> void;
GLuint program = 0;
GLuint framebuffer = 0;
@@ -55,10 +55,10 @@ struct OpenGLProgram : OpenGLSurface {
auto parse(OpenGL* instance, string& source) -> void;
auto release() -> void;
unsigned phase = 0; //frame counter
unsigned modulo = 0; //frame counter modulus
unsigned absoluteWidth = 0;
unsigned absoluteHeight = 0;
uint phase = 0; //frame counter
uint modulo = 0; //frame counter modulus
uint absoluteWidth = 0;
uint absoluteHeight = 0;
double relativeWidth = 0;
double relativeHeight = 0;
vector<OpenGLTexture> pixmaps;
@@ -66,18 +66,18 @@ struct OpenGLProgram : OpenGLSurface {
struct OpenGL : OpenGLProgram {
auto shader(const string& pathname) -> void;
auto allocateHistory(unsigned size) -> void;
auto lock(uint32_t*& data, unsigned& pitch) -> bool;
auto allocateHistory(uint size) -> void;
auto clear() -> void;
auto refresh() -> void;
auto init() -> bool;
auto term() -> void;
auto lock(uint32_t*& data, uint& pitch) -> bool;
auto output() -> void;
auto initialize() -> bool;
auto terminate() -> void;
vector<OpenGLProgram> programs;
vector<OpenGLTexture> history;
GLuint inputFormat = GL_RGBA8;
unsigned outputWidth = 0;
unsigned outputHeight = 0;
uint outputWidth = 0;
uint outputHeight = 0;
struct Setting {
string name;
string value;

View File

@@ -47,7 +47,7 @@ auto OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
GLuint texture;
glGenTextures(1, &texture);
unsigned n = pixmaps.size();
uint n = pixmaps.size();
pixmaps(n).texture = texture;
pixmaps(n).width = image.width();
pixmaps(n).height = image.height();
@@ -58,7 +58,7 @@ auto OpenGLProgram::bind(OpenGL* instance, const Markup::Node& node, const strin
if(leaf["filter"]) pixmaps(n).filter = glrFilter(leaf["filter"].text());
if(leaf["wrap"]) pixmaps(n).wrap = glrWrap(leaf["wrap"].text());
unsigned w = glrSize(image.width()), h = glrSize(image.height());
uint w = glrSize(image.width()), h = glrSize(image.height());
uint32_t* buffer = new uint32_t[w * h]();
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, pixmaps(n).format, w, h, 0, pixmaps(n).getFormat(), pixmaps(n).getType(), buffer);

View File

@@ -4,7 +4,7 @@ auto OpenGLSurface::allocate() -> void {
glGenBuffers(3, &vbo[0]);
}
auto OpenGLSurface::size(unsigned w, unsigned h) -> void {
auto OpenGLSurface::size(uint w, uint h) -> void {
if(width == w && height == h) return;
width = w, height = h;
w = glrSize(w), h = glrSize(h);
@@ -37,7 +37,7 @@ auto OpenGLSurface::release() -> void {
width = 0, height = 0;
}
auto OpenGLSurface::render(unsigned sourceWidth, unsigned sourceHeight, unsigned targetWidth, unsigned targetHeight) -> void {
auto OpenGLSurface::render(uint sourceWidth, uint sourceHeight, uint targetWidth, uint targetHeight) -> void {
glViewport(0, 0, targetWidth, targetHeight);
float w = (float)sourceWidth / (float)glrSize(sourceWidth);
@@ -70,7 +70,7 @@ auto OpenGLSurface::render(unsigned sourceWidth, unsigned sourceHeight, unsigned
};
GLfloat positions[4 * 4];
for(unsigned n = 0; n < 16; n += 4) {
for(uint n = 0; n < 16; n += 4) {
Matrix::Multiply(&positions[n], &vertices[n], 1, 4, modelViewProjection, 4, 4);
}

View File

@@ -1,4 +1,4 @@
static auto glrSize(unsigned size) -> unsigned {
static auto glrSize(uint size) -> uint {
return size;
//return bit::round(size); //return nearest power of two
}
@@ -28,7 +28,7 @@ static auto glrWrap(const string& wrap) -> GLuint {
return GL_CLAMP_TO_BORDER;
}
static auto glrModulo(unsigned modulo) -> unsigned {
static auto glrModulo(uint modulo) -> uint {
if(modulo) return modulo;
return 300; //divisible by 2, 3, 4, 5, 6, 10, 12, 15, 20, 25, 30, 50, 60, 100, 150
}