add external resources; add alpha to plane colors
This commit is contained in:
parent
2f7a4cb602
commit
824efcc71f
|
@ -449,6 +449,15 @@ To build a WASM library that can be used to build an Emscripten version of a SPA
|
||||||
|
|
||||||
There is a detailed tutorial on using Zbar with WebAssembly at https://barkeywolf.consulting/posts/barcode-scanner-webassembly/
|
There is a detailed tutorial on using Zbar with WebAssembly at https://barkeywolf.consulting/posts/barcode-scanner-webassembly/
|
||||||
|
|
||||||
|
External Resources
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* [Khronos's OpenGL and GLSL wiki](https://www.khronos.org/opengl/wiki/Main_Page)
|
||||||
|
* [docs.gl: official OpenGL API documentation with added features](https://docs.gl)
|
||||||
|
* [MDN's list of best practices for WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices)
|
||||||
|
* [Emscripten documentation's chapter on optimizing for WebGL](https://emscripten.org/docs/optimizing/Optimizing-WebGL.html)
|
||||||
|
* [SDL wiki](https://wiki.libsdl.org)
|
||||||
|
|
||||||
Font
|
Font
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
@ -190,10 +190,6 @@ sb::Attributes::operator int() const
|
||||||
return index();
|
return index();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extend to include these attributes at the end. The argument will be automatically converted to an
|
|
||||||
* Attributes object, so the vertices can be in any of the Attributes constructor formats. If no attributes
|
|
||||||
* have been constructed or initialized, the current vertices will be set to these vertices. Otherwise,
|
|
||||||
* vertices will be inserted at the end of the current vertices. */
|
|
||||||
void sb::Attributes::add(const Attributes& other)
|
void sb::Attributes::add(const Attributes& other)
|
||||||
{
|
{
|
||||||
/* If the variant is std::monostate, these are the first attributes, so set vertices to these */
|
/* If the variant is std::monostate, these are the first attributes, so set vertices to these */
|
||||||
|
@ -236,8 +232,6 @@ void sb::Attributes::add(const Attributes& other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add attributes to the end count number of times. If count is 1, this has the same effect as the
|
|
||||||
* add function. */
|
|
||||||
void sb::Attributes::extend(const Attributes& other, std::size_t count)
|
void sb::Attributes::extend(const Attributes& other, std::size_t count)
|
||||||
{
|
{
|
||||||
while (count--)
|
while (count--)
|
||||||
|
|
|
@ -210,7 +210,15 @@ namespace sb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const Attributes&);
|
/*!
|
||||||
|
* Extend to include these attributes at the end. The argument will be automatically converted to an
|
||||||
|
* Attributes object, so the vertices can be in any of the Attributes constructor formats. If no attributes
|
||||||
|
* have been constructed or initialized, the current vertices will be set to these vertices. Otherwise,
|
||||||
|
* vertices will be inserted at the end of the current vertices.
|
||||||
|
*
|
||||||
|
* @param other attributes to add
|
||||||
|
*/
|
||||||
|
void add(const Attributes& other);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Add a 2D, 3D or 4D vertex by specifying each coordinate as a separate argument. All arguments must have
|
* Add a 2D, 3D or 4D vertex by specifying each coordinate as a separate argument. All arguments must have
|
||||||
|
@ -270,7 +278,15 @@ namespace sb
|
||||||
return std::get<std::vector<VertexType>>(vertices);
|
return std::get<std::vector<VertexType>>(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void extend(const Attributes&, std::size_t = 1);
|
/*!
|
||||||
|
* Repeatedly add attributes to the end count number of times. If count is 1, this has the same effect as the
|
||||||
|
* add function.
|
||||||
|
*
|
||||||
|
* @param other attributes to add repeatedly
|
||||||
|
* @param count number of times to repeat
|
||||||
|
*/
|
||||||
|
void extend(const Attributes& other, std::size_t count = 1);
|
||||||
|
|
||||||
void index(GLint);
|
void index(GLint);
|
||||||
GLint index() const;
|
GLint index() const;
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,8 @@ namespace sb
|
||||||
|
|
||||||
/* A gradient from magenta to yellow */
|
/* A gradient from magenta to yellow */
|
||||||
inline const static std::shared_ptr<sb::Attributes> color = std::make_shared<sb::Attributes>(sb::Attributes{
|
inline const static std::shared_ptr<sb::Attributes> color = std::make_shared<sb::Attributes>(sb::Attributes{
|
||||||
{1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, {0.8f, 0.0f, 0.3f},
|
{1.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 1.0f}, {0.8f, 0.0f, 0.3f, 1.0f},
|
||||||
{1.0f, 1.0f, 0.0f}, {0.8f, 0.0f, 0.3f}, {0.8f, 0.0f, 0.3f}
|
{1.0f, 1.0f, 0.0f, 1.0f}, {0.8f, 0.0f, 0.3f, 1.0f}, {0.8f, 0.0f, 0.3f, 1.0f}
|
||||||
});
|
});
|
||||||
|
|
||||||
Plane() : Model(std::map<std::string, std::shared_ptr<sb::Attributes>>({{"position", position}, {"uv", uv}, {"color", color}})) {}
|
Plane() : Model(std::map<std::string, std::shared_ptr<sb::Attributes>>({{"position", position}, {"uv", uv}, {"color", color}})) {}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_ttf.h"
|
#include "SDL_ttf.h"
|
||||||
#include "SDL2_rotozoom.h"
|
#include "sdl2-gfx/SDL2_rotozoom.h"
|
||||||
|
|
||||||
#include "Model.hpp"
|
#include "Model.hpp"
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
|
|
|
@ -35,7 +35,7 @@ float sb::angle_ratio(float start, float end)
|
||||||
return sb::angle_difference(start, end) / glm::pi<float>();
|
return sb::angle_difference(start, end) / glm::pi<float>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<glm::vec2> sb::bezier(const std::vector<glm::vec2> control, int resolution)
|
std::vector<glm::vec2> sb::bezier(const std::vector<glm::vec2>& control, int resolution)
|
||||||
{
|
{
|
||||||
std::vector<glm::vec2> points;
|
std::vector<glm::vec2> points;
|
||||||
points.reserve(resolution);
|
points.reserve(resolution);
|
||||||
|
|
|
@ -112,5 +112,5 @@ namespace sb
|
||||||
* @param vertices four 2D control points
|
* @param vertices four 2D control points
|
||||||
* @param resolution number of points that will be in the computed curve
|
* @param resolution number of points that will be in the computed curve
|
||||||
*/
|
*/
|
||||||
std::vector<glm::vec2> bezier(const std::vector<glm::vec2> vertices, int resolution = 30);
|
std::vector<glm::vec2> bezier(const std::vector<glm::vec2>& vertices, int resolution = 30);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue