[core] Modern C++ bindings for OpenGL

This commit is contained in:
John Firebaugh
2016-09-26 12:53:32 -07:00
parent a4c82b8a3b
commit 0e57d10d77
97 changed files with 2233 additions and 1857 deletions

View File

@@ -94,7 +94,7 @@ StencilFunc::Type StencilFunc::Get() {
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_FUNC, &func));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_REF, &ref));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask));
return { static_cast<StencilTestFunction>(func), ref, static_cast<StencilMaskValue>(mask) };
return { static_cast<uint32_t>(func), ref, static_cast<uint32_t>(mask) };
}
const constexpr StencilTest::Type StencilTest::Default;
@@ -122,17 +122,17 @@ StencilOp::Type StencilOp::Get() {
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_FAIL, &sfail));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &dpfail));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &dppass));
return { static_cast<StencilTestOperation>(sfail), static_cast<StencilTestOperation>(dpfail),
static_cast<StencilTestOperation>(dppass) };
return { static_cast<StencilMode::Op>(sfail), static_cast<StencilMode::Op>(dpfail),
static_cast<StencilMode::Op>(dppass) };
}
const constexpr DepthRange::Type DepthRange::Default;
void DepthRange::Set(const Type& value) {
#if MBGL_USE_GLES2
MBGL_CHECK_ERROR(glDepthRangef(value.near, value.far));
MBGL_CHECK_ERROR(glDepthRangef(value.min, value.max));
#else
MBGL_CHECK_ERROR(glDepthRange(value.near, value.far));
MBGL_CHECK_ERROR(glDepthRange(value.min, value.max));
#endif
}
@@ -178,6 +178,18 @@ Blend::Type Blend::Get() {
return blend;
}
const constexpr BlendEquation::Type BlendEquation::Default;
void BlendEquation::Set(const Type& value) {
MBGL_CHECK_ERROR(glBlendEquation(static_cast<GLenum>(value)));
}
BlendEquation::Type BlendEquation::Get() {
GLint blend;
MBGL_CHECK_ERROR(glGetIntegerv(GL_BLEND_EQUATION_RGB, &blend));
return static_cast<Type>(blend);
}
const constexpr BlendFunc::Type BlendFunc::Default;
void BlendFunc::Set(const Type& value) {
@@ -189,8 +201,8 @@ BlendFunc::Type BlendFunc::Get() {
GLint sfactor, dfactor;
MBGL_CHECK_ERROR(glGetIntegerv(GL_BLEND_SRC_ALPHA, &sfactor));
MBGL_CHECK_ERROR(glGetIntegerv(GL_BLEND_DST_ALPHA, &dfactor));
return { static_cast<BlendSourceFactor>(sfactor),
static_cast<BlendDestinationFactor>(dfactor) };
return { static_cast<ColorMode::BlendFactor>(sfactor),
static_cast<ColorMode::BlendFactor>(dfactor) };
}
const constexpr BlendColor::Type BlendColor::Default;
@@ -340,6 +352,18 @@ BindVertexArray::Type BindVertexArray::Get() {
#if not MBGL_USE_GLES2
const constexpr PointSize::Type PointSize::Default;
void PointSize::Set(const Type& value) {
MBGL_CHECK_ERROR(glPointSize(value));
}
PointSize::Type PointSize::Get() {
GLfloat pointSize;
MBGL_CHECK_ERROR(glGetFloatv(GL_POINT_SIZE, &pointSize));
return pointSize;
}
const constexpr PixelZoom::Type PixelZoom::Default;
void PixelZoom::Set(const Type& value) {