c++ - Rendering to a CCRenderTexture not working -
i'm trying use ccrendertexture create heightmap use terrain class. don't know if best way it, i'm newb both opengl , cocos2d-x, please bear me.
auto* rendertexheightmap = ccrendertexture::create(width, height); rendertexheightmap->begin(); glrasterpos2i(0, 0); gldrawpixels(width, height, gl_rgb, gl_float, pixelbuffer); rendertexheightmap->end(); rendertexheightmap->savetofile("heightmap.jpg", false);
i know pixelbuffer contains data want (greyscale pixel data), whenever call ccrendertexture::savetofile black picture. missing?
rendertexture delay 1 frame render ,so need savetofile @ next frame,my english not ,do anderstand? can use delaytime or way way: code type lua
local function save() rendertexture:savetofile("heightmap.jpg",false) end local callfunc = cc.callfunc:create(save) local dela = cc.delaytime:create(0.01) local seq = cc.sequence:create(dela,callfunc) node:runaction(seq)
Comments
Post a Comment