159 int w_orig = 0, h_orig = 0, w2 = 0, h2 = 0;
160 bool background =
false;
162 std::string material =
"";
163 std::string Filename = filename;
172 Ogre::TextureManager::getSingleton().setVerbose(
false);
173 Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(Filename);
184 for (
int i = 0; i < count; i++)
189 Filename = filename_selected;
191 Filename = filename_pressed;
194 Ogre::MaterialPtr mat;
197 mat = Ogre::MaterialManager::getSingleton().create(Filename,
"General");
199 catch (Ogre::Exception& e)
201 return vm->
GetHAL()->
ReportFatalError(
"Error creating material for texture " + Filename +
"\n" + e.getDescription(),
"");
208 img.load(Filename,
"General");
210 catch (Ogre::Exception &e)
215 w_orig = img.getWidth();
216 h_orig = img.getHeight();
219 w2 = powf(2, ceilf(
Log2((
Real)w_orig)));
220 h2 = powf(2, ceilf(
Log2((
Real)h_orig)));
223 tex = Ogre::TextureManager::getSingleton().createManual(Filename,
"General", Ogre::TEX_TYPE_2D, w2, h2, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC);
224 tex->getBuffer(0, 0)->blitFromMemory(img.getPixelBox(0, 0), Ogre::Box(0, 0, 0, w_orig, h_orig, img.getDepth()));
227 Ogre::TextureUnitState *state = mat->getTechnique(0)->getPass(0)->createTextureUnitState(Filename);
228 Ogre::Pass *pass = mat->getTechnique(0)->getPass(0);
229 pass->setDepthCheckEnabled(
false);
230 pass->setDepthWriteEnabled(
false);
231 pass->setLightingEnabled(
false);
232 pass->setTextureFiltering(Ogre::TFO_NONE);
236 state->setTextureScroll(-(
Real(w2 - w_orig) / (
Real)w2) / 2.0, -(
Real(h2 - h_orig) / (
Real)h2) / 2.0);
238 if (tex->hasAlpha() ==
true && button)
240 mat->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
241 mat->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 128);
281 material = filename_selected;
292 material = filename_pressed;
307#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
319 button->
node->detachAllObjects();
335 button->
x = x - (w / 2);
336 button->
y = y - (h / 2);
364 Ogre::Rectangle2D* rect =
new Ogre::Rectangle2D(
true);
365 rect->setCorners(x, -y, x + w, -(y + h));
366 Ogre::MaterialPtr materialptr = Ogre::MaterialManager::getSingleton().getByName(material);
367 rect->setMaterial(materialptr);
368 if (background ==
true)
369 rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
372 Ogre::AxisAlignedBox aabInf;
373 aabInf.setInfinite();
374 rect->setBoundingBox(aabInf);
378 node->attachObject(rect);
405 int mouse_x = window->ScreenToClient(wxGetMousePosition()).x;
406 int mouse_y = window->ScreenToClient(wxGetMousePosition()).y;
413 if (window->Active !=
false)
417 Real w = mx / window->GetClientSize().
x;
418 Real h = my / window->GetClientSize().y;
419 Real mouse_x_rel = (w * 2) - 1;
420 Real mouse_y_rel = (h * 2) - 1;
423 if (mouse_x_rel > button->
x && mouse_x_rel < button->x + button->
size_x && mouse_y_rel > button->
y && mouse_y_rel < button->y + button->
size_y)
425 if (button->
drawn_selected ==
false && wxGetMouseState().LeftIsDown() ==
false)
436 if (button->
drawn_pressed ==
false && wxGetMouseState().LeftIsDown() ==
true)
bool Load(const std::string &filename, EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
bool DrawImage(const std::string &filename, buttondata *button, Real x, Real y, bool center, const std::string &filename_selected="", const std::string &filename_pressed="")