[DEV] add test widget for distance field
This commit is contained in:
parent
ea5d5b8638
commit
cb5c59a079
@ -1,24 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
# name of the librairy
|
||||
LOCAL_MODULE := human
|
||||
|
||||
# name of the dependency
|
||||
LOCAL_LIBRARIES := ewol freetype libpng parsersvg tinyxml lua etk libzip
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST)
|
||||
|
||||
|
||||
LOCAL_LDLIBS := -llog -landroid
|
||||
|
||||
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\""
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -1,24 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
# name of the librairy
|
||||
LOCAL_MODULE := human
|
||||
|
||||
# name of the dependency
|
||||
LOCAL_STATIC_LIBRARIES := ewol
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST)
|
||||
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
|
||||
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\""
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
@ -1,23 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
# name of the librairy
|
||||
LOCAL_MODULE := human
|
||||
|
||||
# name of the dependency
|
||||
LOCAL_STATIC_LIBRARIES := ewol
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST)
|
||||
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
|
||||
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\""
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
@ -28,7 +28,8 @@
|
||||
#include <appl/TestButtonColor.h>
|
||||
#include <appl/TestLabel.h>
|
||||
#include <appl/TestImage.h>
|
||||
//#include <appl/TestScene.h>
|
||||
#include <appl/TestDistanceField.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
|
||||
static const char * l_eventChangeTheme = "event-change-theme";
|
||||
@ -135,16 +136,6 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
default:
|
||||
m_idWidget = 0;
|
||||
case 0:
|
||||
m_subWidget = (ewol::Widget*)new ewol::widget::Label("Test software for EWOL");
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->setExpand(bvec2(true,true));
|
||||
m_sizerVert->subWidgetAdd(m_subWidget);
|
||||
}
|
||||
if (m_testName!=NULL) {
|
||||
m_testName->setLabel("Label");
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
m_subWidget = (ewol::Widget*)new TestButton();
|
||||
if (NULL != m_subWidget) {
|
||||
m_sizerVert->subWidgetAdd(m_subWidget);
|
||||
@ -153,6 +144,15 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
m_testName->setLabel("TestButton");
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
m_subWidget = (ewol::Widget*)new TestDistanceField();
|
||||
if (NULL != m_subWidget) {
|
||||
m_sizerVert->subWidgetAdd(m_subWidget);
|
||||
}
|
||||
if (m_testName!=NULL) {
|
||||
m_testName->setLabel("Test Distance Field");
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
m_subWidget = (ewol::Widget*)new TestButtonColor();
|
||||
if (NULL != m_subWidget) {
|
||||
@ -180,6 +180,16 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
m_testName->setLabel("TestImage");
|
||||
};
|
||||
break;
|
||||
case 5:
|
||||
m_subWidget = (ewol::Widget*)new ewol::widget::Label("Test software for EWOL");
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->setExpand(bvec2(true,true));
|
||||
m_sizerVert->subWidgetAdd(m_subWidget);
|
||||
}
|
||||
if (m_testName!=NULL) {
|
||||
m_testName->setLabel("Label");
|
||||
};
|
||||
break;
|
||||
/*case 5:
|
||||
m_subWidget = (ewol::Widget*)new TestScene();
|
||||
if (NULL != m_subWidget) {
|
||||
|
@ -23,9 +23,6 @@ class TestButton : public ewol::widget::Sizer {
|
||||
TestButton(void);
|
||||
virtual ~TestButton(void);
|
||||
public: // Derived function
|
||||
virtual const char * const getObjectType(void) {
|
||||
return "TestButton";
|
||||
};
|
||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
||||
virtual void onObjectRemove(ewol::Object* _removeObject);
|
||||
};
|
||||
|
164
sources/appl/TestDistanceField.cpp
Normal file
164
sources/appl/TestDistanceField.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/TestDistanceField.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/Sizer.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
#include <ewol/widget/Composer.h>
|
||||
#include <ewol/widget/Menu.h>
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <ewol/widget/meta/Parameter.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TestDistanceField"
|
||||
|
||||
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");
|
||||
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();
|
||||
APPL_INFO("Create " __class__ " (end)");
|
||||
}
|
||||
|
||||
|
||||
TestDistanceField::~TestDistanceField(void) {
|
||||
APPL_INFO("Remove " __class__ " ...");
|
||||
ewol::resource::DistanceFieldFont::release(m_DFFont);
|
||||
ewol::resource::Program::release(m_GLprogram);
|
||||
}
|
||||
|
||||
|
||||
void TestDistanceField::calculateSize(const vec2& _availlable) {
|
||||
// set minimal size
|
||||
m_size = _availlable;
|
||||
}
|
||||
|
||||
|
||||
void TestDistanceField::calculateMinMaxSize(void) {
|
||||
m_minSize = vec2(256,256);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void TestDistanceField::onDraw(void) {
|
||||
|
||||
if (m_coord.size() <= 0) {
|
||||
//EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
if (m_DFFont == NULL) {
|
||||
// this is a normale case ... the user can choice to have no image ...
|
||||
return;
|
||||
}
|
||||
if (m_GLprogram == NULL) {
|
||||
EWOL_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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TestDistanceField::onRegenerateDisplay(void) {
|
||||
if (false == needRedraw()) {
|
||||
return;
|
||||
}
|
||||
setPos(vec3(200,200,0));
|
||||
print(ivec2(256,256));
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
56
sources/appl/TestDistanceField.h
Normal file
56
sources/appl/TestDistanceField.h
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __TEST_DISTANCE_FIELD_H__
|
||||
#define __TEST_DISTANCE_FIELD_H__
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/compositing/Compositing.h>
|
||||
#include <ewol/resource/Program.h>
|
||||
#include <ewol/resource/DistanceFieldFont.h>
|
||||
|
||||
class TestDistanceField : public ewol::Widget {
|
||||
public:
|
||||
// Constructeur
|
||||
TestDistanceField(void);
|
||||
virtual ~TestDistanceField(void);
|
||||
public: // Derived function
|
||||
virtual void onDraw(void);
|
||||
virtual void calculateMinMaxSize(void);
|
||||
virtual void calculateSize(const vec2& _availlable);
|
||||
virtual void onRegenerateDisplay(void);
|
||||
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
|
@ -1,26 +0,0 @@
|
||||
|
||||
|
||||
###############################################################################
|
||||
### Files Listes ###
|
||||
###############################################################################
|
||||
|
||||
# Globals debug tool:
|
||||
FILE_LIST:= appl/Debug.cpp \
|
||||
appl/init.cpp \
|
||||
appl/MainWindows.cpp \
|
||||
appl/TestButton.cpp \
|
||||
appl/TestImage.cpp \
|
||||
appl/TestButtonColor.cpp \
|
||||
appl/TestLabel.cpp \
|
||||
appl/TestScene.cpp
|
||||
|
||||
LOCAL_COPY_FOLDERS := ../data/icon.*: \
|
||||
../data/cube.*: \
|
||||
../data/grass.*: \
|
||||
../data/stone*: \
|
||||
../data/sphere.png: \
|
||||
../data/sphere.obj:
|
||||
|
||||
ifneq ($(__EWOL_INTEGRATED_FONT__),$(empty))
|
||||
LOCAL_COPY_FILES := ../data/FreeSerif*:fonts/FreeSerif.ttf
|
||||
endif
|
@ -18,7 +18,8 @@ def create(target):
|
||||
'appl/TestButton.cpp',
|
||||
'appl/TestImage.cpp',
|
||||
'appl/TestButtonColor.cpp',
|
||||
'appl/TestLabel.cpp'])
|
||||
'appl/TestLabel.cpp',
|
||||
'appl/TestDistanceField.cpp'])
|
||||
# 'appl/TestScene.cpp'
|
||||
|
||||
myModule.add_module_depend(['ewol'])
|
||||
|
Loading…
Reference in New Issue
Block a user