[DEV] update distance field test
This commit is contained in:
parent
6b4807666c
commit
5e4cce3550
@ -31,20 +31,6 @@
|
||||
TestDistanceField::TestDistanceField(void){
|
||||
addObjectType("appl::TestDistanceField");
|
||||
APPL_INFO("Create " __class__ " (start)");
|
||||
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
//m_GLprogram = ewol::resource::Program::keep("DATA:textured3D.prog");
|
||||
m_GLprogram = ewol::resource::Program::keep("DATA:fontDistanceField/font1.prog");
|
||||
if (NULL != m_GLprogram) {
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
|
||||
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
|
||||
m_GLtexID = m_GLprogram->getUniform("EW_texID");
|
||||
}
|
||||
m_DFFont = ewol::resource::DistanceFieldFont::keep("FreeMono;DejaVuSansMono;FreeSerif");
|
||||
clear();
|
||||
setExpand(bvec2(true, true));
|
||||
setFill(bvec2(true, true));
|
||||
APPL_INFO("Create " __class__ " (end)");
|
||||
@ -53,8 +39,6 @@ TestDistanceField::TestDistanceField(void){
|
||||
|
||||
TestDistanceField::~TestDistanceField(void) {
|
||||
APPL_INFO("Remove " __class__ " ...");
|
||||
ewol::resource::DistanceFieldFont::release(m_DFFont);
|
||||
ewol::resource::Program::release(m_GLprogram);
|
||||
}
|
||||
|
||||
|
||||
@ -71,38 +55,9 @@ void TestDistanceField::calculateMinMaxSize(void) {
|
||||
|
||||
|
||||
void TestDistanceField::onDraw(void) {
|
||||
//m_text1.draw();
|
||||
m_text2.draw();
|
||||
if (m_coord.size() <= 0) {
|
||||
APPL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
if (m_DFFont == NULL) {
|
||||
// this is a normale case ... the user can choice to have no image ...
|
||||
APPL_ERROR("No FONT ...");
|
||||
return;
|
||||
}
|
||||
if (m_GLprogram == NULL) {
|
||||
APPL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_DFFont->getId());
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z,unused*/, &m_coord[0], 4*sizeof(btScalar));
|
||||
// Texture :
|
||||
m_GLprogram->sendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
|
||||
m_GLprogram->unUse();
|
||||
|
||||
m_text1.draw();
|
||||
}
|
||||
|
||||
|
||||
@ -111,82 +66,23 @@ void TestDistanceField::onRegenerateDisplay(void) {
|
||||
if (false == needRedraw()) {
|
||||
return;
|
||||
}
|
||||
clear();
|
||||
APPL_WARNING("Regenerate...");
|
||||
//setPos(vec3(-200,-500,0));
|
||||
//print(ivec2(2048,2048));
|
||||
/*
|
||||
m_text1.reset();
|
||||
m_text1.setPos(vec3(50,50,0));
|
||||
m_text1.printDecorated("exemple Text 1");
|
||||
*/
|
||||
m_text2.reset();
|
||||
m_text2.setPos(vec3(100,100,0));
|
||||
m_text2.printDecorated("exemple Text 2");
|
||||
m_text1.clear();
|
||||
m_text1.setPos(vec3(m_size.x()*0.5-20,m_size.y()*0.5+10,0));
|
||||
m_text1.printDecorated("Text To compare ... Avenue AAVVAA ... Normal generic test");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestDistanceField::clear(void) {
|
||||
// reset Buffer :
|
||||
m_coord.clear();
|
||||
m_coordTex.clear();
|
||||
m_coordColor.clear();
|
||||
// reset temporal variables :
|
||||
m_position = vec3(0.0, 0.0, 0.0);
|
||||
m_matrixApply.identity();
|
||||
m_color = etk::Color<>(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void TestDistanceField::print(const ivec2& _size) {
|
||||
vec3 point(0,0,0);
|
||||
vec2 tex(0,1);
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
m_text2.clear();
|
||||
m_text2.setPos(vec3(m_size.x()*0.5-20,m_size.y()*0.5-10,0));
|
||||
m_text2.printDecorated("Text To compare ... Avenue AAVVAA ... Test en distance field Mode");
|
||||
|
||||
tex.setValue(1,1);
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
|
||||
tex.setValue(1,0);
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
|
||||
tex.setValue(0,0);
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
|
||||
tex.setValue(0,1);
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.push_back(point);
|
||||
m_coordTex.push_back(tex);
|
||||
m_coordColor.push_back(m_color);
|
||||
}
|
||||
|
||||
bool TestDistanceField::onEventInput(const ewol::event::Input& _event) {
|
||||
|
||||
if (_event.getId() == 4) {
|
||||
setZoom(getZoom() + 0.01f);
|
||||
} else if (_event.getId() == 5) {
|
||||
setZoom(getZoom() - 0.01f);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,32 +29,6 @@ class TestDistanceField : public ewol::Widget {
|
||||
virtual void calculateSize(const vec2& _availlable);
|
||||
virtual void onRegenerateDisplay(void);
|
||||
virtual bool onEventInput(const ewol::event::Input& _event);
|
||||
void clear(void);
|
||||
void print(const ivec2& _size);
|
||||
private:
|
||||
vec3 m_position; //!< The current position to draw
|
||||
etk::Color<> m_color; //!< The text foreground color
|
||||
private:
|
||||
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
|
||||
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
|
||||
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
|
||||
int32_t m_GLColor; //!< openGL id on the element (color buffer)
|
||||
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
|
||||
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
|
||||
private:
|
||||
ewol::resource::DistanceFieldFont* m_DFFont; //!< texture resources
|
||||
std::vector<vec3 > m_coord; //!< internal coord of the object
|
||||
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
|
||||
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
|
||||
protected:
|
||||
mat4 m_matrixApply;
|
||||
/**
|
||||
* @brief set position for the next text writen
|
||||
* @param[in] _pos Position of the text (in 3D)
|
||||
*/
|
||||
void setPos(const vec3& _pos) {
|
||||
m_position = _pos;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user