I want to draw pixel point on irrlicht game screen using 2D APIs. the data source is a vector<Point> contains corrdinates which should be present on screen(800x600).So each time there is a event, i would scan the vector and draw the points.
However, I find in tutorial that APIs supporting 2D line and receangle like driver->draw2DRectangle() is called between beginScene() and endScene(). So when i using the code showing below, no effect...
Code: Select all
else if(event.EventType == EET_USER_EVENT)
{
s32 a = event.UserEvent.UserData1;
//s32 b = event.UserEvent.UserData2;
f32 f = event.UserEvent.UserData3;
// transform int handle into a vector pointer
pactivePoints = static_cast<vector<Point>*>((void*)a);
vector<Point>::iterator i;
if(pactivePoints != NULL)
for(i = pactivePoints->begin(); i != pactivePoints->end(); i++)
{
int x = (*i).x;
int y = (*i).y;
position2d<int> start(x, y);
position2d<int> end(x+1,y+1);
SColor whitecolor(255,255,255,255);
driver->draw2DLine(start, end, whitecolor);
}
if i change the structure to:
Code: Select all
driver->beginScene(true, true, video::SColor(0,200,200,200));
for(...)
driver->draw2DLine(start, end, whitecolor);
driver->endScene();
So, can I call 2D rendering APIs in other part of my program like OnEvent()? You know, if i add a mesh to smgr in other part of the program, it works since i call smgr->drawall() in the main loop.