vita_de Posted April 17, 2013 Posted April 17, 2013 Hi. Tell me, how can I show image to the canvas? Gui gui = engine.getGui(); WidgetCanvas canvas = new WidgetCanvas(gui); gui.addChild(canvas); canvas.setWidth(512); canvas.setHeight(512); canvas.setTexture("D:/Textures/sprite.png"); // I do not see Image im = new Image("D:/Textures/sprite.png"); // I do not see canvas.setImage(im);
binstream Posted April 19, 2013 Posted April 19, 2013 Please refer to the textures from "data" directory only.
vita_de Posted April 22, 2013 Author Posted April 22, 2013 Thank you. In the project I have taken from the texture folder data. Here, I have simplified the example to make it easier to read. But this is still not the solution = (
silent Posted April 22, 2013 Posted April 22, 2013 vita_de, Please, use the WidgetSprite if you want to draw 2D image on screen. WidgetCanvas is designed to draw polygons, lines and text. But, if you still want to draw 2D image in WidgetCanvas, here is the example code: class Canvas { Gui gui; WidgetCanvas canvas; Canvas() { gui = engine.getGui(); // canvas canvas = new WidgetCanvas(gui); canvas.setHeight(512); canvas.setWidth(512); canvas.setTexture("sprite_01.png"); create_quad(0,vec3(512.0f,0.0f,0.0f),vec3(0.0f,0.0f,0.0f),vec3(0.0f,512.0f,10.0f),vec3(512.0f,512.0f,10.0f),vec3(1.0f,0.0f,1.0f),vec3(0.0f,0.0f,1.0f),vec3(0.0f,1.0f,1.0f),vec3(1.0f,1.0f,1.0f)); gui.addChild(canvas); } ~Canvas() { delete canvas; } // int create_quad(int order,vec3 p1,vec3 p2,vec3 p3,vec3 p4,vec3 tex_p1,vec3 tex_p2,vec3 tex_p3,vec3 tex_p4) { int polygon = canvas.addPolygon(order); canvas.addPolygonPoint(polygon,p1); canvas.setPolygonTexCoord(polygon,tex_p1); canvas.addPolygonPoint(polygon,p2); canvas.setPolygonTexCoord(polygon,tex_p2); canvas.addPolygonPoint(polygon,p3); canvas.setPolygonTexCoord(polygon,tex_p3); canvas.addPolygonPoint(polygon,p4); canvas.setPolygonTexCoord(polygon,tex_p4); return polygon; } }; Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
vita_de Posted April 23, 2013 Author Posted April 23, 2013 Helped. Thank You! One more question on canvas. I can take the result creation on canvas? canvas.getImage() does not give any result.
frustum Posted June 12, 2013 Posted June 12, 2013 Canvas.getImage() function return assigned Canvas texture. Use ObjectGui inside WidgetSpriteNode to render interface into Image. render_00.zip
Recommended Posts