Begining of GLES3 renderer:
-Most 2D drawing is implemented -Missing shaders -Missing all 3D -Editor needs to be set on update always to be used, otherwise it does not refresh -Large parts of editor not working
This commit is contained in:
@ -59,6 +59,10 @@ void ColorPicker::_notification(int p_what) {
|
||||
w_material->set_shader(get_shader("w_editor"));
|
||||
update_material(uv_material,color,h,s,v);
|
||||
update_material(w_material,color,h,s,v);
|
||||
uv_edit->set_texture(get_icon("color_main"));
|
||||
w_edit->set_texture(get_icon("color_hue"));
|
||||
sample->set_texture(get_icon("color_sample"));
|
||||
|
||||
_update_controls();
|
||||
} break;
|
||||
|
||||
@ -192,10 +196,24 @@ void ColorPicker::_update_presets()
|
||||
{
|
||||
Size2 size=bt_add_preset->get_size();
|
||||
preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height));
|
||||
Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB);
|
||||
for (int y=0;y<size.y;y++)
|
||||
for (int x=0;x<size.x*presets.size();x++)
|
||||
i.put_pixel(x,y,presets[(int)x/size.x]);
|
||||
|
||||
DVector<uint8_t> img;
|
||||
img.resize(size.x*presets.size()*size.y*3);
|
||||
|
||||
{
|
||||
DVector<uint8_t>::Write w=img.write();
|
||||
for (int y=0;y<size.y;y++) {
|
||||
for (int x=0;x<size.x*presets.size();x++) {
|
||||
int ofs = (y*(size.x*presets.size())+x)*3;
|
||||
w[ofs+0]=uint8_t(CLAMP(presets[(int)x/size.x].r*255.0,0,255));
|
||||
w[ofs+1]=uint8_t(CLAMP(presets[(int)x/size.x].g*255.0,0,255));
|
||||
w[ofs+2]=uint8_t(CLAMP(presets[(int)x/size.x].b*255.0,0,255));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB8,img);
|
||||
|
||||
Ref<ImageTexture> t;
|
||||
t.instance();
|
||||
t->create_from_image(i);
|
||||
@ -394,15 +412,23 @@ void ColorPicker::_screen_input(const InputEvent &ev)
|
||||
} else if (ev.type==InputEvent::MOUSE_MOTION) {
|
||||
const InputEventMouse &mev = ev.mouse_motion;
|
||||
Viewport *r=get_tree()->get_root();
|
||||
if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y)))
|
||||
if (!r->get_visible_rect().has_point(Point2(mev.global_x,mev.global_y)))
|
||||
return;
|
||||
Image img =r->get_screen_capture();
|
||||
if (!img.empty()) {
|
||||
last_capture=img;
|
||||
r->queue_screen_capture();
|
||||
}
|
||||
if (!last_capture.empty())
|
||||
set_color(last_capture.get_pixel(mev.global_x,mev.global_y));
|
||||
if (!last_capture.empty()) {
|
||||
int pw = last_capture.get_format()==Image::FORMAT_RGBA8?4:3;
|
||||
int ofs = (mev.global_y*last_capture.get_width()+mev.global_x)*pw;
|
||||
|
||||
DVector<uint8_t>::Read r = last_capture.get_data().read();
|
||||
|
||||
Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 );
|
||||
|
||||
set_color(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,16 +500,10 @@ ColorPicker::ColorPicker() :
|
||||
HBoxContainer *hb_edit = memnew( HBoxContainer );
|
||||
|
||||
uv_edit= memnew ( TextureFrame );
|
||||
Image i(256, 256, false, Image::FORMAT_RGB);
|
||||
for (int y=0;y<256;y++)
|
||||
for (int x=0;x<256;x++)
|
||||
i.put_pixel(x,y,Color());
|
||||
Ref<ImageTexture> t;
|
||||
t.instance();
|
||||
t->create_from_image(i);
|
||||
uv_edit->set_texture(t);
|
||||
|
||||
|
||||
|
||||
uv_edit->set_ignore_mouse(false);
|
||||
uv_edit->set_custom_minimum_size(Size2(256,256));
|
||||
uv_edit->connect("input_event", this, "_uv_input");
|
||||
Control *c= memnew( Control );
|
||||
uv_edit->add_child(c);
|
||||
@ -497,16 +517,9 @@ ColorPicker::ColorPicker() :
|
||||
|
||||
add_child(hb_edit);
|
||||
w_edit= memnew( TextureFrame );
|
||||
i = Image(15, 256, false, Image::FORMAT_RGB);
|
||||
for (int y=0;y<256;y++)
|
||||
for (int x=0;x<15;x++)
|
||||
i.put_pixel(x,y,Color());
|
||||
Ref<ImageTexture> tw;
|
||||
tw.instance();
|
||||
tw->create_from_image(i);
|
||||
w_edit->set_texture(tw);
|
||||
w_edit->set_ignore_mouse(false);
|
||||
w_edit->set_custom_minimum_size(Size2(15,256));
|
||||
|
||||
|
||||
w_edit->set_ignore_mouse(false);
|
||||
w_edit->connect("input_event", this, "_w_input");
|
||||
c= memnew( Control );
|
||||
w_edit->add_child(c);
|
||||
@ -594,17 +607,6 @@ ColorPicker::ColorPicker() :
|
||||
|
||||
set_color(Color(1,1,1));
|
||||
|
||||
i.create(256,20,false,Image::FORMAT_RGB);
|
||||
for (int y=0;y<20;y++)
|
||||
for(int x=0;x<256;x++)
|
||||
if ((x/4+y/4)%2)
|
||||
i.put_pixel(x,y,Color(1,1,1));
|
||||
else
|
||||
i.put_pixel(x,y,Color(0.6,0.6,0.6));
|
||||
Ref<ImageTexture> t_smpl;
|
||||
t_smpl.instance();
|
||||
t_smpl->create_from_image(i);
|
||||
sample->set_texture(t_smpl);
|
||||
|
||||
HBoxContainer *bbc = memnew( HBoxContainer );
|
||||
add_child(bbc);
|
||||
|
||||
Reference in New Issue
Block a user