This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
C++ bindings for OpenGL #6468
Merged
Merged
C++ bindings for OpenGL #6468
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <mbgl/gl/color_mode.hpp> | ||
#include <mbgl/gl/gl.hpp> | ||
#include <mbgl/util/traits.hpp> | ||
|
||
namespace mbgl { | ||
namespace gl { | ||
|
||
static_assert(underlying_type(ColorMode::BlendEquation::Add) == GL_FUNC_ADD, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::BlendEquation::Subtract) == GL_FUNC_SUBTRACT, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::BlendEquation::ReverseSubtract) == GL_FUNC_REVERSE_SUBTRACT, "OpenGL enum mismatch"); | ||
|
||
static_assert(underlying_type(ColorMode::Zero) == GL_ZERO, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::One) == GL_ONE, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::SrcColor) == GL_SRC_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusSrcColor) == GL_ONE_MINUS_SRC_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::DstColor) == GL_DST_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusDstColor) == GL_ONE_MINUS_DST_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::SrcAlpha) == GL_SRC_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusSrcAlpha) == GL_ONE_MINUS_SRC_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::DstAlpha) == GL_DST_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusDstAlpha) == GL_ONE_MINUS_DST_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::ConstantColor) == GL_CONSTANT_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusConstantColor) == GL_ONE_MINUS_CONSTANT_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::ConstantAlpha) == GL_CONSTANT_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusConstantAlpha) == GL_ONE_MINUS_CONSTANT_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::SrcAlphaSaturate) == GL_SRC_ALPHA_SATURATE, "OpenGL enum mismatch"); | ||
|
||
static_assert(underlying_type(ColorMode::Zero) == GL_ZERO, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::One) == GL_ONE, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::SrcColor) == GL_SRC_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusSrcColor) == GL_ONE_MINUS_SRC_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::DstColor) == GL_DST_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusDstColor) == GL_ONE_MINUS_DST_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::SrcAlpha) == GL_SRC_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusSrcAlpha) == GL_ONE_MINUS_SRC_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::DstAlpha) == GL_DST_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusDstAlpha) == GL_ONE_MINUS_DST_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::ConstantColor) == GL_CONSTANT_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusConstantColor) == GL_ONE_MINUS_CONSTANT_COLOR, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::ConstantAlpha) == GL_CONSTANT_ALPHA, "OpenGL enum mismatch"); | ||
static_assert(underlying_type(ColorMode::OneMinusConstantAlpha) == GL_ONE_MINUS_CONSTANT_ALPHA, "OpenGL enum mismatch"); | ||
|
||
} // namespace gl | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#pragma once | ||
|
||
#include <mbgl/util/variant.hpp> | ||
#include <mbgl/util/color.hpp> | ||
|
||
namespace mbgl { | ||
namespace gl { | ||
|
||
class ColorMode { | ||
public: | ||
enum class BlendEquation { | ||
Add = 0x8006, | ||
Subtract = 0x800A, | ||
ReverseSubtract = 0x800B | ||
}; | ||
|
||
enum BlendFactor { | ||
Zero = 0x0000, | ||
One = 0x0001, | ||
SrcColor = 0x0300, | ||
OneMinusSrcColor = 0x0301, | ||
SrcAlpha = 0x0302, | ||
OneMinusSrcAlpha = 0x0303, | ||
DstAlpha = 0x0304, | ||
OneMinusDstAlpha = 0x0305, | ||
DstColor = 0x0306, | ||
OneMinusDstColor = 0x0307, | ||
SrcAlphaSaturate = 0x0308, | ||
ConstantColor = 0x8001, | ||
OneMinusConstantColor = 0x8002, | ||
ConstantAlpha = 0x8003, | ||
OneMinusConstantAlpha = 0x8004 | ||
}; | ||
|
||
template <BlendEquation E> | ||
struct ConstantBlend { | ||
static constexpr BlendEquation equation = E; | ||
static constexpr BlendFactor srcFactor = One; | ||
static constexpr BlendFactor dstFactor = One; | ||
}; | ||
|
||
template <BlendEquation E> | ||
struct LinearBlend { | ||
static constexpr BlendEquation equation = E; | ||
BlendFactor srcFactor; | ||
BlendFactor dstFactor; | ||
}; | ||
|
||
struct Replace { | ||
static constexpr BlendEquation equation = BlendEquation::Add; | ||
static constexpr BlendFactor srcFactor = One; | ||
static constexpr BlendFactor dstFactor = One; | ||
}; | ||
|
||
using Add = LinearBlend<BlendEquation::Add>; | ||
using Subtract = LinearBlend<BlendEquation::Subtract>; | ||
using ReverseSubtract = LinearBlend<BlendEquation::ReverseSubtract>; | ||
|
||
using BlendFunction = variant< | ||
Replace, | ||
Add, | ||
Subtract, | ||
ReverseSubtract>; | ||
|
||
BlendFunction blendFunction; | ||
Color blendColor; | ||
|
||
struct Mask { | ||
bool r; | ||
bool g; | ||
bool b; | ||
bool a; | ||
}; | ||
|
||
Mask mask; | ||
|
||
static ColorMode disabled() { | ||
return ColorMode { Replace(), {}, { false, false, false, false } }; | ||
} | ||
|
||
static ColorMode unblended() { | ||
return ColorMode { Replace(), {}, { true, true, true, true } }; | ||
} | ||
|
||
static ColorMode alphaBlended() { | ||
return ColorMode { Add { One, OneMinusSrcAlpha }, {}, { true, true, true, true } }; | ||
} | ||
}; | ||
|
||
constexpr bool operator!=(const ColorMode::Mask& a, const ColorMode::Mask& b) { | ||
return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a; | ||
} | ||
|
||
} // namespace gl | ||
} // namespace mbgl |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one moved to the
Drawable
constructor. I just dropped "vertex type is too big", because it was kind of silly.