Hi,
I'm currently working at porting my software from the eval version of GapiDraw to the eval version of Edgelib and I am not getting good results. Startup time has gone from "instantaneous" to ~5 seconds or so and in game performance is sluggish at best.
My background:
-Programmed in managed and scripting languages for a number of years now
-C++ learned after the fact for the past year on and off.
-I state this because I might have some c++ stuff wrong but I'm not a complete newbie
My setup:
-I am basing this port on the helloworld example. (I have not changed any configuration options)
-I'm using vs2005 on vista deploying to an Axim 51v.
Extra Diffs between ports:
-I got rid of using CAtlString and replaced with std::wstring covered in a typedef.
-The Gapidraw version runs in a Windowed mode. Not sure exactly what technical context it is, but it has menus and handles window messages.
My Code:
Each surface (about 10 of them) are created at startup but only 5 are displayed. These are the steps that each goes through. (not exact code)
To help complete the context I will tell you that each surface is wrapped in a custom "UIControl" object. That object was developed based on my Gapidraw needs and the code shown below is the current state of it as I port to Edgelib. The basic api differences between Gapidraw and Edgelib seem pretty minimal so I'm pretty sure that there MUST be something wrong with my setup. Hopefully it is obvious to someone.
Thanks and please excuse the seemingly amateur nature of my incomplete code.
(although any general pointers ARE appreciated)
I'm currently working at porting my software from the eval version of GapiDraw to the eval version of Edgelib and I am not getting good results. Startup time has gone from "instantaneous" to ~5 seconds or so and in game performance is sluggish at best.
My background:
-Programmed in managed and scripting languages for a number of years now
-C++ learned after the fact for the past year on and off.
-I state this because I might have some c++ stuff wrong but I'm not a complete newbie
My setup:
-I am basing this port on the helloworld example. (I have not changed any configuration options)
-I'm using vs2005 on vista deploying to an Axim 51v.
Extra Diffs between ports:
-I got rid of using CAtlString and replaced with std::wstring covered in a typedef.
-The Gapidraw version runs in a Windowed mode. Not sure exactly what technical context it is, but it has menus and handles window messages.
My Code:
Each surface (about 10 of them) are created at startup but only 5 are displayed. These are the steps that each goes through. (not exact code)
- Code:
//Instantiate:
SurfacePtr sur(new NamSurface()); //typedef'd E2DSurface with boost shared_ptr
//Create:
UI::DIS->CreateSurface(this->surface.get(), this->width, this->height); //ClassEDisplay object referenced in static object
//Resize:
this->surface->Resize(width, height); //resize as part of greater sizing operation.
//paint:
surface->FillRect(NULL, this->backGroundClr, 0, NULL);
//some controls are slightly different but nothing extreme or taxing going on. It's REALLY basic! ;)
To help complete the context I will tell you that each surface is wrapped in a custom "UIControl" object. That object was developed based on my Gapidraw needs and the code shown below is the current state of it as I port to Edgelib. The basic api differences between Gapidraw and Edgelib seem pretty minimal so I'm pretty sure that there MUST be something wrong with my setup. Hopefully it is obvious to someone.
Thanks and please excuse the seemingly amateur nature of my incomplete code.
- Code:
UIControl::UIControl(UIControl * parent): children(0) {
this->parent = parent;
this->refresh = true;
this->responsive = true;
this->autofresh = false;
this->visible = true;
this->deepFresh = false;
this->backGroundClr = RGB(255,255,255);
this->width = 10;
this->height = 10;
SurfacePtr sur(new NamSurface());
this->surface = sur;
long x = UI::DIS->CreateSurface(this->surface.get(), this->width, this->height);
if (x != E_OK) {
switch (x) {
case E_INVALIDPARAM:
hitlog(_T("invalid param"));
break;
case E_UNSUPPORTED:
hitlog(_T("unsupported"));
break;
case E_NOMEMORY:
hitlog(_T("no mem"));
break;
case E_ERROR:
hitlog(_T("other error"));
break;
}
hitlog(_T("ERROR CREATING SURFACE: ")+stringify(x));
}
if (this->parent != 0) {
this->setSize(this->parent->width, this->parent->height);
}
else {
this->setSize(UI::GetWidth(),UI::GetHeight());
}
this->setLocation(0,0);
}
LPRECT UIControl::getRect() {
this->setLocation(this->x, this->y);
return &m_rect;
}
void UIControl::setLocation(int x, int y) {
this->x = x;
this->y = y;
int xo = 0, yo = 0;
UIControl * parenter = this;
while (parenter != NULL) {
xo += parenter->x;
yo += parenter->y;
parenter = parenter->parent;
}
::SetRect(&this->m_rect, xo, yo, xo+width, yo+height);
this->moved = true;
}
void UIControl::setSize(int width, int height) {
this->width = width;
this->height = height;
this->surface->Resize(width, height);
int l = m_rect.left;
int t = m_rect.top;
::SetRect(&this->m_rect,l, t, l + width, t+height);
this->refresh = true;
}
UIControlPtr UIControl::checkPoint(UIControlPtr thiz, POINT p) {
UIControlPtr control;
if (::PtInRect(&this->m_rect, p)) {
for (unsigned int i = 0; i < this->children.size(); i++) {
if (this->children[i]->responsive) {
control = this->children[i]->checkPoint(this->children[i],p);
}
if (control.get() != NULL) {
break;
}
}
if (control.get() == NULL) {
control = thiz;
}
}
return control;
}
void UIControl::Render(NamSurface* pBackBuffer) {
if (refresh) {
if (this->visible) {
this->Paint();
}
}
//then check children and paint them on top
for (int i = 0; i < this->children.size();i++) {
if (this->deepFresh) this->children[i]->refresh=true;
this->children[i]->Render(pBackBuffer);
}
NamSurface * back = this->parent != NULL ? this->parent->surface.get() : pBackBuffer;
back->BltFast(this->x, this->y, this->surface.get(), NULL,NULL,NULL);
if (!autofresh) this->refresh = false;
if (this->deepFresh) this->deepFresh = false;
if (this->moved) this->moved = false;
}
void UIControl::DrawString(NamString s, int x, int y, int size, int alignment,COLORREF fontColor) {
this->surface->DrawFont(x, y, &UI::DIS->fontinternal, (char *)Utf::ToUtf8(s).c_str(), 0, 0);
}
void UIControl::Paint() {
surface->FillRect(NULL, this->backGroundClr, 0, NULL);
}
void UIControl::AddChild(UIControlPtr child) {
UIControlPtr a(child);
this->children.push_back(a);
child->parent = this;
}