[DEV] butter interface on the texture push
This commit is contained in:
parent
f471429ac3
commit
be029b9103
@ -51,5 +51,5 @@ void main(void) {
|
||||
specularLight = EW_directionalLight.specularColor * EW_material.specularFactor;
|
||||
}
|
||||
vec4 light = ambientLight + diffuseLight + specularLight;
|
||||
gl_FragColor = tmpElementColor * light;
|
||||
gl_FragColor = tmpElementColor;// * light;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
// Input :
|
||||
// Input:
|
||||
uniform sampler2D EW_texID;
|
||||
|
||||
varying vec2 f_texcoord;
|
||||
|
@ -2,17 +2,17 @@
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
// Input :
|
||||
// Input:
|
||||
attribute vec3 EW_coord3d;
|
||||
attribute vec2 EW_texture2d;
|
||||
uniform mat4 EW_MatrixTransformation;
|
||||
uniform mat4 EW_MatrixPosition;
|
||||
|
||||
// output :
|
||||
// output:
|
||||
varying vec2 f_texcoord;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = EW_MatrixTransformation * EW_MatrixPosition * vec4(EW_coord3d, 1.0);
|
||||
// set texture output coord
|
||||
f_texcoord = EW_texture2d;
|
||||
gl_Position = EW_MatrixTransformation * EW_MatrixPosition * vec4(EW_coord3d, 1.0);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ ewol::resource::Texture::~Texture() {
|
||||
removeContext();
|
||||
}
|
||||
|
||||
//#include <egami/wrapperBMP.h>
|
||||
#include <egami/egami.h>
|
||||
|
||||
bool ewol::resource::Texture::updateContext() {
|
||||
EWOL_INFO("updateContext [START]");
|
||||
@ -57,7 +57,7 @@ bool ewol::resource::Texture::updateContext() {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
if (false == m_loaded) {
|
||||
if (m_loaded == false) {
|
||||
// Request a new texture at openGl :
|
||||
glGenTextures(1, &m_texId);
|
||||
}
|
||||
@ -74,16 +74,42 @@ bool ewol::resource::Texture::updateContext() {
|
||||
//--- Mode linear
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
int32_t typeObject = GL_RGBA;
|
||||
int32_t sizeObject = GL_UNSIGNED_BYTE;
|
||||
switch (m_data.getType()) {
|
||||
case egami::colorType::RGBA8:
|
||||
typeObject = GL_RGBA;
|
||||
sizeObject = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case egami::colorType::RGB8:
|
||||
typeObject = GL_RGB;
|
||||
sizeObject = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case egami::colorType::RGBAf:
|
||||
typeObject = GL_RGBA;
|
||||
sizeObject = GL_FLOAT;
|
||||
break;
|
||||
case egami::colorType::RGBf:
|
||||
typeObject = GL_RGBA;
|
||||
sizeObject = GL_FLOAT;
|
||||
break;
|
||||
case egami::colorType::unsignedInt16:
|
||||
case egami::colorType::unsignedInt32:
|
||||
case egami::colorType::float32:
|
||||
case egami::colorType::float64:
|
||||
EWOL_ERROR("Not manage the type " << m_data.getType() << " for texture");
|
||||
break;
|
||||
}
|
||||
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType());
|
||||
//egami::storeBMP("~/bbb_image.bmp", m_data);
|
||||
egami::store(m_data, std::string("~/texture_") + etk::to_string(getId()) + ".bmp");
|
||||
glTexImage2D(GL_TEXTURE_2D, // Target
|
||||
0, // Level
|
||||
GL_RGBA, // Format internal
|
||||
typeObject, // Format internal
|
||||
m_data.getWidth(),
|
||||
m_data.getHeight(),
|
||||
0, // Border
|
||||
GL_RGBA, // format
|
||||
GL_UNSIGNED_BYTE, // type
|
||||
typeObject, // format
|
||||
sizeObject, // type
|
||||
m_data.getTextureDataPointer() );
|
||||
// now the data is loaded
|
||||
m_loaded = true;
|
||||
@ -93,7 +119,7 @@ bool ewol::resource::Texture::updateContext() {
|
||||
|
||||
void ewol::resource::Texture::removeContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
if (true == m_loaded) {
|
||||
if (m_loaded == true) {
|
||||
// Request remove texture ...
|
||||
EWOL_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
|
||||
glDeleteTextures(1, &m_texId);
|
||||
|
@ -22,6 +22,7 @@ ewol::widget::Image::Image() :
|
||||
propertyPosStop(this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image", &ewol::widget::Image::onChangePropertyGlobalSize),
|
||||
propertyDistanceFieldMode(this, "distance-field", false, "Distance field mode", &ewol::widget::Image::onChangePropertyDistanceFieldMode),
|
||||
propertySmooth(this, "smooth", true, "Smooth display of the image", &ewol::widget::Image::onChangePropertySmooth),
|
||||
propertyUseThemeColor(this, "use-theme-color", false, "use the theme color to display images", &ewol::widget::Image::onChangePropertyUseThemeColor),
|
||||
m_colorProperty(nullptr),
|
||||
m_colorId(-1) {
|
||||
addObjectType("ewol::widget::Image");
|
||||
@ -52,8 +53,10 @@ void ewol::widget::Image::onRegenerateDisplay() {
|
||||
}
|
||||
// remove data of the previous composition :
|
||||
m_compositing.clear();
|
||||
if (m_colorProperty != nullptr) {
|
||||
m_compositing.setColor(m_colorProperty->get(m_colorId));
|
||||
if (*propertyUseThemeColor == true) {
|
||||
if (m_colorProperty != nullptr) {
|
||||
m_compositing.setColor(m_colorProperty->get(m_colorId));
|
||||
}
|
||||
}
|
||||
// calculate the new position and size :
|
||||
vec2 imageBoder = propertyBorder->getPixel();
|
||||
@ -213,3 +216,7 @@ void ewol::widget::Image::onChangePropertyDistanceFieldMode() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Image::onChangePropertyUseThemeColor() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ namespace ewol {
|
||||
eproperty::Range<vec2> propertyPosStop; //!< position in the image to start the sisplay (when we want not to display all the image)
|
||||
eproperty::Value<bool> propertyDistanceFieldMode; //!< to have a parameter
|
||||
eproperty::Value<bool> propertySmooth; //!< display is done in the pixed approximation if false
|
||||
eproperty::Value<bool> propertyUseThemeColor; //!< Use the themo color management ("{ewol}THEME:COLOR:Image.json") default false
|
||||
protected:
|
||||
ewol::compositing::Image m_compositing; //!< compositing element of the image.
|
||||
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
|
||||
@ -71,6 +72,7 @@ namespace ewol {
|
||||
virtual void onChangePropertyGlobalSize();
|
||||
virtual void onChangePropertySmooth();
|
||||
virtual void onChangePropertyDistanceFieldMode();
|
||||
virtual void onChangePropertyUseThemeColor();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user