profiler & misc cleanup
This commit is contained in:
parent
6a61dc60f1
commit
619c07853f
3 changed files with 55 additions and 49 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include "of3dGraphics.h"
|
#include "of3dGraphics.h"
|
||||||
#include "ofFileUtils.h"
|
#include "ofFileUtils.h"
|
||||||
#include "ofGraphics.h"
|
#include "ofGraphics.h"
|
||||||
|
#include "ofxProfiler.h"
|
||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
#include <GLES3/gl3.h>
|
#include <GLES3/gl3.h>
|
||||||
|
|
||||||
|
@ -139,6 +140,7 @@ bool MsdfAtlasLayerCombo::hasChildren(){
|
||||||
|
|
||||||
// unique
|
// unique
|
||||||
void MsdfAtlasLayerCombo::draw(){
|
void MsdfAtlasLayerCombo::draw(){
|
||||||
|
OFX_PROFILER_FUNCTION()
|
||||||
int elements = 0;
|
int elements = 0;
|
||||||
for(const auto & layer : layers){
|
for(const auto & layer : layers){
|
||||||
elements += layer->nElements;
|
elements += layer->nElements;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "ofGraphics.h"
|
#include "ofGraphics.h"
|
||||||
#include "ofGraphicsConstants.h"
|
#include "ofGraphicsConstants.h"
|
||||||
#include "ofUtils.h"
|
#include "ofUtils.h"
|
||||||
|
#include "ofxProfiler.h"
|
||||||
|
|
||||||
namespace ofxVariableLab {
|
namespace ofxVariableLab {
|
||||||
|
|
||||||
|
@ -318,6 +319,7 @@ void MsdfLayer::collectCharacter(const char character,
|
||||||
glm::vec4 color,
|
glm::vec4 color,
|
||||||
ofxVariableLab::FontVariation fontVariation){
|
ofxVariableLab::FontVariation fontVariation){
|
||||||
|
|
||||||
|
OFX_PROFILER_FUNCTION()
|
||||||
const ofImage & atlasImage = atlas->getAtlasImage();
|
const ofImage & atlasImage = atlas->getAtlasImage();
|
||||||
ofNode n = node;
|
ofNode n = node;
|
||||||
n.setScale(n.getScale() * scaleFactor);
|
n.setScale(n.getScale() * scaleFactor);
|
||||||
|
@ -349,15 +351,15 @@ void MsdfLayer::collectCharacter(const char character,
|
||||||
// FIXME: make sure this does not happen
|
// FIXME: make sure this does not happen
|
||||||
ofLogError("MsdfLayer::draw") << "y smaller 0, this is not good" << endl;
|
ofLogError("MsdfLayer::draw") << "y smaller 0, this is not good" << endl;
|
||||||
}
|
}
|
||||||
double pl_a, pb_a, pr_a, pt_a;
|
//double pl_a, pb_a, pr_a, pt_a;
|
||||||
double pl_b, pb_b, pr_b, pt_b;
|
//double pl_b, pb_b, pr_b, pt_b;
|
||||||
gg_a.getQuadPlaneBounds(pl_a, pb_a, pr_a, pt_a);
|
//gg_a.getQuadPlaneBounds(pl_a, pb_a, pr_a, pt_a);
|
||||||
gg_b.getQuadPlaneBounds(pl_b, pb_b, pr_b, pt_b);
|
//gg_b.getQuadPlaneBounds(pl_b, pb_b, pr_b, pt_b);
|
||||||
|
|
||||||
float w = glm::mix(float(w_a), float(w_b), mix);
|
float w = glm::mix(float(w_a), float(w_b), mix);
|
||||||
float h = glm::mix(float(h_a), float(h_b), mix);
|
float h = glm::mix(float(h_a), float(h_b), mix);
|
||||||
float pl = glm::mix(float(pl_a), float(pl_b), mix);
|
//float pl = glm::mix(float(pl_a), float(pl_b), mix);
|
||||||
float pt = glm::mix(float(pt_a), float(pt_b), mix);
|
//float pt = glm::mix(float(pt_a), float(pt_b), mix);
|
||||||
|
|
||||||
//float magic = atlas->settings.scale;
|
//float magic = atlas->settings.scale;
|
||||||
//getVFlip(settings.vFlipBehaviour,
|
//getVFlip(settings.vFlipBehaviour,
|
||||||
|
@ -369,15 +371,6 @@ void MsdfLayer::collectCharacter(const char character,
|
||||||
//n.move(pl * magic, -1 * pt * magic, 0);
|
//n.move(pl * magic, -1 * pt * magic, 0);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
glm::vec2 translation_a = glm::vec2(float(x_a) / float(atlas_w),
|
|
||||||
float(y_a) / float(atlas_h));
|
|
||||||
glm::vec2 scale_a = glm::vec2(float(w_a) / float(atlas_w),
|
|
||||||
float(h_a) / float(atlas_h));
|
|
||||||
glm::vec2 translation_b = glm::vec2(float(x_b) / float(atlas_w),
|
|
||||||
float(y_b) / float(atlas_h));
|
|
||||||
glm::vec2 scale_b = glm::vec2(float(w_b) / float(atlas_w),
|
|
||||||
float(h_b) / float(atlas_h));
|
|
||||||
|
|
||||||
glm::vec4 p0 = n.getGlobalTransformMatrix() * glm::vec4(0, 0, 0, 1);
|
glm::vec4 p0 = n.getGlobalTransformMatrix() * glm::vec4(0, 0, 0, 1);
|
||||||
glm::vec4 p1 = n.getGlobalTransformMatrix() * glm::vec4(0, h, 0, 1);
|
glm::vec4 p1 = n.getGlobalTransformMatrix() * glm::vec4(0, h, 0, 1);
|
||||||
glm::vec4 p2 = n.getGlobalTransformMatrix() * glm::vec4(w, h, 0, 1);
|
glm::vec4 p2 = n.getGlobalTransformMatrix() * glm::vec4(w, h, 0, 1);
|
||||||
|
@ -387,6 +380,16 @@ void MsdfLayer::collectCharacter(const char character,
|
||||||
|| isInside(camera, p1)
|
|| isInside(camera, p1)
|
||||||
|| isInside(camera, p2)
|
|| isInside(camera, p2)
|
||||||
|| isInside(camera, p3)){
|
|| isInside(camera, p3)){
|
||||||
|
OFX_PROFILER_SCOPE("prepare vertices / indices");
|
||||||
|
|
||||||
|
glm::vec2 translation_a = glm::vec2(float(x_a) / float(atlas_w),
|
||||||
|
float(y_a) / float(atlas_h));
|
||||||
|
glm::vec2 scale_a = glm::vec2(float(w_a) / float(atlas_w),
|
||||||
|
float(h_a) / float(atlas_h));
|
||||||
|
glm::vec2 translation_b = glm::vec2(float(x_b) / float(atlas_w),
|
||||||
|
float(y_b) / float(atlas_h));
|
||||||
|
glm::vec2 scale_b = glm::vec2(float(w_b) / float(atlas_w),
|
||||||
|
float(h_b) / float(atlas_h));
|
||||||
|
|
||||||
glm::vec2 uv0_a = translation_a;
|
glm::vec2 uv0_a = translation_a;
|
||||||
glm::vec2 uv0_b = translation_b;
|
glm::vec2 uv0_b = translation_b;
|
||||||
|
@ -396,36 +399,39 @@ void MsdfLayer::collectCharacter(const char character,
|
||||||
glm::vec2 uv2_b = scale_b + translation_b;
|
glm::vec2 uv2_b = scale_b + translation_b;
|
||||||
glm::vec2 uv3_a = glm::vec2(scale_a.x, 0) + translation_a;
|
glm::vec2 uv3_a = glm::vec2(scale_a.x, 0) + translation_a;
|
||||||
glm::vec2 uv3_b = glm::vec2(scale_b.x, 0) + translation_b;
|
glm::vec2 uv3_b = glm::vec2(scale_b.x, 0) + translation_b;
|
||||||
int32_t base = static_cast <int32_t>(vertices.size());
|
for(int i = 0; i < 1; i++){
|
||||||
vertices.push_back(BufferVertex{
|
float distance = 200;
|
||||||
{p0.x, p0.y, p0.z, p0.w},
|
int32_t base = static_cast <int32_t>(vertices.size());
|
||||||
{uv0_a.x, uv0_a.y},
|
vertices.push_back(BufferVertex{
|
||||||
{uv0_b.x, uv0_b.y},
|
{p0.x, p0.y + i * distance, p0.z, p0.w},
|
||||||
{color.r, color.g, color.b, color.a},
|
{uv0_a.x, uv0_a.y},
|
||||||
mix
|
{uv0_b.x, uv0_b.y},
|
||||||
});
|
{color.r, color.g, color.b, color.a},
|
||||||
vertices.push_back(BufferVertex{
|
mix
|
||||||
{p1.x, p1.y, p1.z, p1.w},
|
});
|
||||||
{uv1_a.x, uv1_a.y},
|
vertices.push_back(BufferVertex{
|
||||||
{uv1_b.x, uv1_b.y},
|
{p1.x, p1.y + i * distance, p1.z, p1.w},
|
||||||
{color.r, color.g, color.b, color.a},
|
{uv1_a.x, uv1_a.y},
|
||||||
mix
|
{uv1_b.x, uv1_b.y},
|
||||||
});
|
{color.r, color.g, color.b, color.a},
|
||||||
vertices.push_back(BufferVertex{
|
mix
|
||||||
{p2.x, p2.y, p2.z, p2.w},
|
});
|
||||||
{uv2_a.x, uv2_a.y},
|
vertices.push_back(BufferVertex{
|
||||||
{uv2_b.x, uv2_b.y},
|
{p2.x, p2.y + i * distance, p2.z, p2.w},
|
||||||
{color.r, color.g, color.b, color.a},
|
{uv2_a.x, uv2_a.y},
|
||||||
mix
|
{uv2_b.x, uv2_b.y},
|
||||||
});
|
{color.r, color.g, color.b, color.a},
|
||||||
vertices.push_back(BufferVertex{
|
mix
|
||||||
{p3.x, p3.y, p3.z, p3.w},
|
});
|
||||||
{uv3_a.x, uv3_a.y},
|
vertices.push_back(BufferVertex{
|
||||||
{uv3_b.x, uv3_b.y},
|
{p3.x, p3.y + i * distance, p3.z, p3.w},
|
||||||
{color.r, color.g, color.b, color.a},
|
{uv3_a.x, uv3_a.y},
|
||||||
mix
|
{uv3_b.x, uv3_b.y},
|
||||||
});
|
{color.r, color.g, color.b, color.a},
|
||||||
indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base});
|
mix
|
||||||
|
});
|
||||||
|
indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base});
|
||||||
|
}
|
||||||
nElements++;
|
nElements++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
#include "ofAppRunner.h"
|
#include "ofAppRunner.h"
|
||||||
#include "of3dGraphics.h"
|
#include "of3dGraphics.h"
|
||||||
|
#include "ofxProfiler.h"
|
||||||
#include "ofCamera.h"
|
#include "ofCamera.h"
|
||||||
#include "ofUtils.h"
|
#include "ofUtils.h"
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
|
@ -168,12 +169,9 @@ static bool isInside(float px, float py, float x, float y, float w, float h){
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isInside(const ofCamera & camera, const glm::vec4 & position){
|
static bool isInside(const ofCamera & camera, const glm::vec4 & position){
|
||||||
|
OFX_PROFILER_FUNCTION()
|
||||||
const auto & viewport = ofGetCurrentRenderer()->getCurrentViewport();
|
const auto & viewport = ofGetCurrentRenderer()->getCurrentViewport();
|
||||||
glm::vec3 screenPosition = camera.worldToScreen(position);
|
glm::vec3 screenPosition = camera.worldToScreen(position);
|
||||||
glm::vec3 cameraPosition = camera.worldToCamera(position);
|
|
||||||
//glm::mat4 clipSpaceToWorld = camera.getGlobalTransformMatrix() * glm::inverse(camera.getProjectionMatrix(viewport));
|
|
||||||
//glm::mat4 worldToClipSpace = camera.getProjectionMatrix(viewport);
|
|
||||||
//glm::vec4 worldSpacePosition = position * worldToClipSpace;
|
|
||||||
if(screenPosition.x >= 0.0f && screenPosition.x <= ofGetWidth()
|
if(screenPosition.x >= 0.0f && screenPosition.x <= ofGetWidth()
|
||||||
&& screenPosition.y >= 0.0f && screenPosition.y <= ofGetHeight()
|
&& screenPosition.y >= 0.0f && screenPosition.y <= ofGetHeight()
|
||||||
&& screenPosition.z <= 1.0f){
|
&& screenPosition.z <= 1.0f){
|
||||||
|
|
Loading…
Reference in a new issue