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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #70: raster tile rendering as toggleable mode from vector
- Loading branch information
Showing
24 changed files
with
604 additions
and
196 deletions.
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,28 @@ | ||
#ifndef LLMR_RENDERER_SHADER_RASTER | ||
#define LLMR_RENDERER_SHADER_RASTER | ||
|
||
#include <llmr/shader/shader.hpp> | ||
|
||
namespace llmr { | ||
|
||
class RasterShader : public Shader { | ||
public: | ||
RasterShader(); | ||
|
||
void bind(char *offset); | ||
|
||
void setImage(int32_t image); | ||
void setOpacity(float opacity); | ||
|
||
private: | ||
int32_t a_pos = -1; | ||
|
||
int32_t image = -1; | ||
int32_t u_image = -1; | ||
float opacity = 0.0f; | ||
float u_opacity = 0.0f; | ||
}; | ||
|
||
} | ||
|
||
#endif |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ enum { | |
PATTERN_SHADER, | ||
PLAIN_SHADER, | ||
POINT_SHADER, | ||
RASTER_SHADER, | ||
SHADER_COUNT | ||
}; | ||
|
||
|
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,72 @@ | ||
#ifndef LLMR_UTIL_RASTER | ||
#define LLMR_UTIL_RASTER | ||
|
||
#include <llmr/util/animation.hpp> | ||
#include <llmr/util/texturepool.hpp> | ||
|
||
#include <string> | ||
#include <mutex> | ||
|
||
namespace llmr { | ||
|
||
class Raster : public std::enable_shared_from_this<Raster> { | ||
|
||
public: | ||
~Raster(); | ||
|
||
// load image data | ||
void load(const std::string& data); | ||
|
||
// set shared texture pool | ||
void setTexturepool(Texturepool* texturepool); | ||
|
||
// bind current texture | ||
void bind(bool linear = false); | ||
|
||
// loaded status | ||
operator bool() const; | ||
|
||
// animations | ||
void beginFadeInAnimation(); | ||
bool needsAnimation() const; | ||
void updateAnimations(); | ||
|
||
public: | ||
// loaded image dimensions | ||
uint32_t width = 0, height = 0; | ||
|
||
// has been uploaded to texture | ||
bool textured = false; | ||
|
||
// the uploaded texture | ||
uint32_t texture = 0; | ||
|
||
// texture opacity | ||
double opacity = 0; | ||
|
||
private: | ||
// load raw pixels | ||
void loadImage(const std::string& data); | ||
|
||
private: | ||
mutable std::mutex mtx; | ||
|
||
// raw pixels have been loaded | ||
bool loaded = false; | ||
|
||
// shared texture pool | ||
Texturepool* texturepool = nullptr; | ||
|
||
// min/mag filter | ||
uint32_t filter = 0; | ||
|
||
// the raw pixels | ||
char *img = nullptr; | ||
|
||
// fade in animation | ||
std::shared_ptr<util::animation> fade_animation = nullptr; | ||
}; | ||
|
||
} | ||
|
||
#endif |
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,25 @@ | ||
#ifndef LLMR_UTIL_TEXTUREPOOL | ||
#define LLMR_UTIL_TEXTUREPOOL | ||
|
||
#include <llmr/util/noncopyable.hpp> | ||
#include <llmr/platform/gl.hpp> | ||
|
||
#include <set> | ||
#include <mutex> | ||
|
||
namespace llmr { | ||
|
||
class Texturepool : private util::noncopyable { | ||
|
||
public: | ||
GLuint getTextureID(); | ||
void removeTextureID(GLuint texture_id); | ||
void clearTextureIDs(); | ||
|
||
private: | ||
std::set<GLuint> texture_ids; | ||
}; | ||
|
||
} | ||
|
||
#endif |
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
Oops, something went wrong.