Exemplo n.º 1
0
void csGLRender2TextureFramebuf::SetClipRect (const csRect& clipRect)
{
  GLRENDER3D_OUTPUT_LOCATION_MARKER;
  GLint vp[4];
  glGetIntegerv (GL_VIEWPORT, vp);
  glScissor (vp[0] + clipRect.xmin, vp[1] + txt_h - clipRect.ymax, clipRect.Width(),
    clipRect.Height());
}
Exemplo n.º 2
0
void pawsProgressBar::DrawProgressBar(
    const csRect &rect, iGraphics3D* graphics3D, float percent,
    int start_r, int start_g, int start_b,
    int diff_r,  int diff_g,  int diff_b, int alpha)
{
    csSimpleRenderMesh mesh;
    static uint indices[4] = {0, 1, 2, 3};
    csVector3 verts[4];
    csVector4 colors[4];
    float fr1 = start_r / 255.0f;
    float fg1 = start_g / 255.0f;
    float fb1 = start_b / 255.0f;
    float fr2 = fr1 + percent * (diff_r / 255.0f);
    float fg2 = fg1 + percent * (diff_g / 255.0f);
    float fb2 = fb1 + percent * (diff_b / 255.0f);
    float fa = alpha / 255.0f;

    mesh.meshtype = CS_MESHTYPE_QUADS;
    mesh.indexCount = 4;
    mesh.indices = indices;
    mesh.vertexCount = 4;
    mesh.vertices = verts;
    mesh.colors = colors;
    mesh.mixmode = CS_FX_COPY;
    mesh.alphaType.autoAlphaMode = false;
    mesh.alphaType.alphaType = csAlphaMode::alphaSmooth;

    verts[0].Set(rect.xmin, rect.ymin, 0);
    colors[0].Set(fr1, fg1, fb1, fa);

    verts[1].Set(rect.xmin + (rect.Width() * percent), rect.ymin, 0);
    colors[1].Set(fr2, fg2, fb2, fa);

    verts[2].Set(rect.xmin + (rect.Width() * percent), rect.ymax, 0);
    colors[2].Set(fr2, fg2, fb2, fa);

    verts[3].Set(rect.xmin, rect.ymax, 0);
    colors[3].Set(fr1, fg1, fb1, fa);

    graphics3D->DrawSimpleMesh(mesh, csSimpleMeshScreenspace);
}
Exemplo n.º 3
0
csLockedMaterialMap csTerrainCell::LockMaterialMap (const csRect& rectangle)
{
  csLockedMaterialMap data;
  
  if (!materialMapPersistent)
  {
    materialmap.SetSize (rectangle.Width () * rectangle.Height ());

    data.data = materialmap.GetArray ();
    data.pitch = rectangle.Width ();
  }
  else
  {
    data.data = materialmap.GetArray () + materialMapWidth * rectangle.ymin +
      rectangle.xmin;
    data.pitch = materialMapWidth;
  }

  lockedMaterialMapRect = rectangle;

  return data;
}
Exemplo n.º 4
0
void pawsTitle::SetWindowRect(const csRect & windowRect)
{
	size_t a;
	int winWidth = windowRect.Width();
	int w = (int)width;
	if (scaleWidth)
		w = (int)(winWidth * width);

	int deltaX = screenFrame.xmin;
	int deltaY = screenFrame.ymin;
	screenFrame.xmin = windowRect.xmin + (winWidth - w) / 2;
	screenFrame.ymin = windowRect.ymin - height / 2;
	screenFrame.SetSize(w, height);
	deltaX = screenFrame.xmin - deltaX;
	deltaY = screenFrame.ymin - deltaY;

	for (a=0; a<children.GetSize(); ++a)
		children[a]->Resize();

	for (a=0; a<titleButtons.GetSize(); ++a)
	{
		switch (titleButtons[a].align)
		{
		case PTA_LEFT:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmin + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
		case PTA_CENTER:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmin + (screenFrame.Width() - titleButtons[a].buttonWidget->ScreenFrame().Width())/2 + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
		case PTA_RIGHT:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmax - titleButtons[a].buttonWidget->ScreenFrame().Width() + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
        case PTA_COUNT:
            break;
		}
	}
}
Exemplo n.º 5
0
void ProctexPDLight::PDMap::ComputeValueBounds (const csRect& area, 
                                                csRGBcolor& maxValue, 
                                                csRect& nonNullArea)
{
  const int width = imageW;
  maxValue.Set (0, 0, 0);
  nonNullArea.Set (INT_MAX, INT_MAX, INT_MIN, INT_MIN);
  
  int mapPitch = width - area.Width ();
  if (imageData->IsGray())
  {
    const uint8* map = 
      static_cast<LumelBufferGray*> ((LumelBufferBase*)imageData)->GetData() 
      + area.ymin * width + area.xmin;
    for (int y = area.ymin; y < area.ymax; y++)
    {
      for (int x = area.xmin; x < area.xmax; x++)
      {
	uint8 v = *map++;
  
	if (v > maxValue.red)
          maxValue.Set (v, v, v);
  
	if (v > 0)
	{
	  nonNullArea.Extend (x, y);
	}
      }
      map += mapPitch;
    }
  }
  else
  {
    const Lumel* map = 
      static_cast<LumelBufferRGB*> ((LumelBufferBase*)imageData)->GetData() 
      + area.ymin * width + area.xmin;
    for (int y = area.ymin; y < area.ymax; y++)
    {
      for (int x = area.xmin; x < area.xmax; x++)
      {
	const Lumel& p = *map++;
  
	if (p.c.red > maxValue.red)
	  maxValue.red = p.c.red;
	if (p.c.green > maxValue.green)
	  maxValue.green = p.c.green;
	if (p.c.blue > maxValue.blue)
	  maxValue.blue = p.c.blue;
  
	if (p.c.red + p.c.green + p.c.blue > 0)
	{
	  nonNullArea.Extend (x, y);
	}
      }
      map += mapPitch;
    }
  }

  // Align line start+end on 2-pixel-boundary (for MMX)
  nonNullArea.xmin &= ~1;
  nonNullArea.xmax = (nonNullArea.xmax+1) & ~1;
}
Exemplo n.º 6
0
void pawsImageDrawable::Draw(csRect rect, int alpha)
{
    Draw(rect.xmin, rect.ymin, rect.Width(), rect.Height(), alpha);
}