16.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 35531771 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Various fixes and improvements:

* Fixed wrong picking in ViewportSplitter
* Let QuadRenderer have two quads to render, one with [-1, 1] coordinates, one with [0, 1] coordinates
* Fixed the recent fix in StringUtils (commit: fe48b9778e)
* Added stringsafe support in TextFileParser
* fixed cgt::minElem
* fixed Doxygen in fontrendering::FontAtlas
parent 205031c5
......@@ -137,7 +137,7 @@ namespace campvis {
if (_splitMode == HORIZONTAL)
_copyShader->setUniform("_viewMatrix", cgt::mat4::createTranslation(cgt::vec3(float(i) * evps.x, 0.f, 0.f)));
else if (_splitMode == VERTICAL)
_copyShader->setUniform("_viewMatrix", cgt::mat4::createTranslation(cgt::vec3(0.f, float(i) * evps.y, 0.f)));
_copyShader->setUniform("_viewMatrix", cgt::mat4::createTranslation(cgt::vec3(0.f, float(_numSubViews - i - 1) * evps.y, 0.f)));
_quad->render(GL_TRIANGLE_FAN);
}
......
......@@ -30,17 +30,24 @@ namespace campvis {
QuadRenderer::QuadRenderer()
: cgt::Singleton<QuadRenderer>()
, _quad(0)
, _quad11(nullptr)
, _quad01(nullptr)
{
_quad = GeometryDataFactory::createQuad(cgt::vec3(-1.f, -1.f, 0.f), cgt::vec3(1.f), cgt::vec3(0.f), cgt::vec3(1.f));
_quad11 = GeometryDataFactory::createQuad(cgt::vec3(-1.f, -1.f, 0.f), cgt::vec3(1.f), cgt::vec3(0.f), cgt::vec3(1.f));
_quad01 = GeometryDataFactory::createQuad(cgt::vec3(0.f), cgt::vec3(1.f), cgt::vec3(0.f), cgt::vec3(1.f));
}
QuadRenderer::~QuadRenderer() {
delete _quad;
delete _quad11;
delete _quad01;
}
void QuadRenderer::renderQuad(GLenum mode) {
_quad->render(mode);
void QuadRenderer::renderQuad11(GLenum mode) {
_quad11->render(mode);
}
void QuadRenderer::renderQuad01(GLenum mode /*= GL_TRIANGLE_FAN*/) {
_quad01->render(mode);
}
......
......@@ -46,17 +46,33 @@ namespace campvis {
*/
virtual ~QuadRenderer();
/**
* DEPRECATED: Renders a [-1, 1]^2 quad in the XY plane having texture coordinates [0, 1]^2.
* \deprecated Only there fore backwards compatibility, directly calls renderQuad11(mode).
* \param mode OpenGL rendering mode (defaults to GL_TRIANGLE_FAN).
*/
inline void renderQuad(GLenum mode = GL_TRIANGLE_FAN) {
renderQuad11(mode);
}
/**
* Renders a [-1, 1]^2 quad in the XY plane having texture coordinates [0, 1]^2.
* \param mode OpenGL rendering mode (defaults to GL_TRIANGLE_FAN).
*/
void renderQuad11(GLenum mode = GL_TRIANGLE_FAN);
/**
* Renders a [-1, 1]^2 quad in the XY plane having texture coordinates [0, 1]^2.
* \param mode OpenGL rendering mode (defaults to GL_TRIANGLE_FAN).
*/
void renderQuad(GLenum mode = GL_TRIANGLE_FAN);
void renderQuad01(GLenum mode = GL_TRIANGLE_FAN);
private:
/// Private Constructor, must be called from valid OpenGL context.
QuadRenderer();
FaceGeometry* _quad; ///< The FaceGeometry that renders the quad.
FaceGeometry* _quad11; ///< The FaceGeometry that renders the [-1, 1] quad.
FaceGeometry* _quad01; ///< The FaceGeometry that renders the [0, 1] quad.
};
#define QuadRdr cgt::Singleton<campvis::QuadRenderer>::getRef()
......
......@@ -114,7 +114,7 @@ namespace campvis {
}
// push string in quotes onto toReturn
toReturn.push_back(toPush);
toReturn.push_back(StringUtils::trim(toPush, whitespace));
// use the following if whitespace trimming is necessary in between <quote>s
//toReturn.push_back(StringUtils::trim(toPush, whitespace));
......@@ -126,7 +126,7 @@ namespace campvis {
endpos = str.find_first_of(delimiter, strpos);
toReturn.push_back(StringUtils::trim(str.substr(strpos, endpos - strpos), whitespace));
}
strpos = endpos + delimiter.length() - 1;
strpos = endpos + 1;
}
return toReturn;
}
......
......@@ -219,7 +219,7 @@ namespace campvis {
groupHierarchy.pop();
}
else {
std::vector<std::string> tokens = StringUtils::split(currentLine, delimiters);
std::vector<std::string> tokens = StringUtils::splitStringsafe(currentLine, delimiters, '"');
if (tokens.size() == 2) {
if (caseSensitiveKeys)
groupHierarchy.top()->_tokens.insert(std::make_pair(StringUtils::trim(tokens[0], whitespace), StringUtils::trim(tokens[1], whitespace)));
......
......@@ -817,7 +817,7 @@ template<class T> inline T max(const CGT_BASE_TYPE<T>& v) { \
template<class T> inline T minElem(const CGT_BASE_TYPE<T>& v) { \
size_t minElem = 0; \
for (size_t i = 1; i < v.size; ++i) \
if(v.elem[i] > v.elem[minElem]) \
if(v.elem[i] < v.elem[minElem]) \
minElem = i; \
return v.elem[minElem]; \
}
......
......@@ -78,7 +78,7 @@ namespace fontrendering {
* \param text The text to render (currently only ASCII-256 support).
* \param position Position where to start rendering the text (in normalized [-1, 1] coordinates).
* \param color Color of the text to render.
* \param scale Additional transformation matrix that is applied to each rendered vertex.
* \param transformationMatrix Additional transformation matrix that is applied to each rendered vertex.
*/
void renderText(const std::string& text, const cgt::vec2& position, const cgt::vec4& color, const cgt::mat4& transformationMatrix = cgt::mat4::identity);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment