Пример #1
0
PolygonInfo AutoPolygon::generateTriangles(const Rect& rect, const float& epsilon, const float& threshold)
{
    Rect realRect = getRealRect(rect);
    auto p = trace(realRect, threshold);
    p = reduce(p, realRect, epsilon);
    p = expand(p, realRect, epsilon);
    auto tri = triangulate(p);
    calculateUV(realRect, tri.verts, tri.vertCount);
    PolygonInfo ret;
    ret.triangles = tri;
    ret.filename = _filename;
    ret.rect = realRect;
    return ret;
}
Пример #2
0
  void create(HINSTANCE hInstance, int buffer, bool fullscreen, bool border, std::string title, int &x, int &y, unsigned int &w, unsigned int &h) {
    DWORD dwExStyle;
    DWORD style;

    if (fullscreen){
        DEVMODE dmScreenSettings;								// Device Mode

        if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmScreenSettings)){
            ::error("GEM: couldn't get screen capabilities!");
        } else {
        w = dmScreenSettings.dmPelsWidth;
        h = dmScreenSettings.dmPelsHeight;
        }

        x=y=0;

        memset(&dmScreenSettings,0,sizeof(dmScreenSettings));	// Makes Sure Memory's Cleared
        dmScreenSettings.dmSize=sizeof(dmScreenSettings);		// Size Of The Devmode Structure
        dmScreenSettings.dmPelsWidth	= w;			// Selected Screen Width
        dmScreenSettings.dmPelsHeight	= h;			// Selected Screen Height
        dmScreenSettings.dmBitsPerPel	= 32;					// Selected Bits Per Pixel
        dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
        // Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
        if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) {
          dmScreenSettings.dmPelsWidth	= w;
          dmScreenSettings.dmPelsHeight	= h;
          if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) {
              ::error("couldn't switch to fullscreen");
            fullscreen=false;
          }
        }
      }

      // Since Windows uses some of the window for the border, etc,
      //		we have to ask how big the window should really be
      RECT newSize = getRealRect(x, y, w, h,
                          border, fullscreen,
                          style, dwExStyle);
      // Create the window
      win = CreateWindowEx (
                            dwExStyle,
                            "GEM",
                            title.c_str(),
                            style,
                            newSize.left,
                            newSize.top,
                            newSize.right - newSize.left,
                            newSize.bottom - newSize.top,
                            NULL,
                            NULL,
                            hInstance,
                            NULL);
      if (!win)  {
        throw(GemException("Unable to create window"));
      }
      // create the device context
      dc = GetDC(win);
      if (!dc)  {
        throw(GemException("GEM: Unable to create device context"));
      }

      // set the pixel format for the window
      if (!bSetupPixelFormat(dc, buffer))  {
        throw(GemException("Unable to set window pixel format"));
      }

      // create the OpenGL context
      context = wglCreateContext(dc);
      if (!context)  {
        throw(GemException("Unable to create OpenGL context"));
      }

      // do we share display lists?
      if (sharedContext) wglShareLists(sharedContext, context);

      // make the context the current rendering context
      if (!wglMakeCurrent(dc, context))   {
        throw(GemException("Unable to make OpenGL context current"));
      }
    }
Пример #3
0
sf::FloatRect Entity::getInteriorRect()
{
	return getWorldTransform().transformRect(getRealRect());
}