Beispiel #1
0
void Font::BitmapCharacter(float x, float y, float w, float h, int character)
{
	WorldRect dstRect(x, y, w, h);
	ScreenRect* psrcRect;
	psrcRect = &atlas->sourceRectangles[character];
	glBegin(GL_QUADS);
	{
		glTexCoord2d(psrcRect->fLeft(), psrcRect->fTop());	glVertex2f(dstRect.iLeft(), dstRect.iBottom());
		glTexCoord2d(psrcRect->fRight(), psrcRect->fTop());	glVertex2f(dstRect.iRight(), dstRect.iBottom());
		glTexCoord2d(psrcRect->fRight(), psrcRect->fBottom());	glVertex2f(dstRect.iRight(),  dstRect.iTop());
		glTexCoord2d(psrcRect->fLeft(), psrcRect->fBottom());	glVertex2f(dstRect.iLeft(),  dstRect.iTop());
	}
	glEnd();
}
Beispiel #2
0
void DrawLeftPanel()
{
	float x,y,w,h;
	float border = 2.0f;
	x = lmenuRect.x + border;
	y = lmenuRect.y + border - 1;
	w = lmenuRect.w - 2*border;
	h = lmenuRect.h - 2*border + 1;
	glDisable(GL_TEXTURE_2D);
	glColor4f(0.5882f, 0.5882f, 0.5882f, 1.0f);
	glBegin(GL_QUADS);
	{
		glVertex2f(x, y);
		glVertex2f(x + w, y);
		glVertex2f(x + w, y + h);
		glVertex2f(x, y + h);		
	}
	glEnd();

	glEnable(GL_TEXTURE_2D);

	ScreenRect srcRect,dstRect;
	float top = 210;
	float dx = 32;
	float dw = 120;
	float dh = 128;

	w = tilethumbsize.x*2;
	h = tilethumbsize.y*2;	
	x = lmenuRect.x + border + dx;
	y = lmenuRect.y + border - 1 + top;
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glBindTexture(GL_TEXTURE_2D, *(atlas_tile.texture));
	glBegin(GL_QUADS);
	{
		//brush
		srcRect = atlas_tile.sourceRectangles[selectedBrush];
		dstRect = ScreenRect(x,y,w,h);
		glTexCoord2d(srcRect.fLeft(), srcRect.fTop());	glVertex2f(dstRect.fLeft(), dstRect.fTop());
		glTexCoord2d(srcRect.fRight(), srcRect.fTop());	glVertex2f(dstRect.fRight(), dstRect.fTop());
		glTexCoord2d(srcRect.fRight(), srcRect.fBottom());	glVertex2f(dstRect.fRight(),  dstRect.fBottom());
		glTexCoord2d(srcRect.fLeft(), srcRect.fBottom());	glVertex2f(dstRect.fLeft(),  dstRect.fBottom());
	}
	glEnd();
	//cbrush
	glBindTexture(GL_TEXTURE_2D, *(atlas_collision.texture));
	glBegin(GL_QUADS);
	{
		srcRect = atlas_collision.sourceRectangles[selectedCBrush];
		dstRect = ScreenRect(x + dw, y ,w,h);
		glTexCoord2d(srcRect.fLeft(), srcRect.fTop());	glVertex2f(dstRect.fLeft(), dstRect.fTop());
		glTexCoord2d(srcRect.fRight(), srcRect.fTop());	glVertex2f(dstRect.fRight(), dstRect.fTop());
		glTexCoord2d(srcRect.fRight(), srcRect.fBottom());	glVertex2f(dstRect.fRight(),  dstRect.fBottom());
		glTexCoord2d(srcRect.fLeft(), srcRect.fBottom());	glVertex2f(dstRect.fLeft(),  dstRect.fBottom());
	}
	glEnd();

	float lw = 4.0f;
	glDisable(GL_TEXTURE_2D);
	x += -8.0f;
	w += 16.0f;
	y += -8.0f;
	h += 16.0f;
	//tile outline
	glColor4f(0.0f, 0.4f, 0.9f, 1.0f);
	R_DrawHorizontalLine(x - lw, y, w + 2*lw,lw);
	R_DrawVerticalLine(x, y , h, lw);
	R_DrawHorizontalLine(x - lw, y + h, w + 2*lw, lw);
	R_DrawVerticalLine(x + w, y + h, -h, lw);
	//brush outline
	glColor4f(0.0f, 0.9f, 0.4f, 1.0f);
	x += dw;
	R_DrawHorizontalLine(x - lw, y, w + 2*lw,lw);
	R_DrawVerticalLine(x, y , h, lw);
	R_DrawHorizontalLine(x - lw, y + h, w + 2*lw, lw);
	R_DrawVerticalLine(x + w, y + h, -h, lw);
	x -= dw;
	glEnable(GL_TEXTURE_2D);

	char buffer[128];
	Vector4 color;
	int ty = lmenuRect.y + border - 1 + top - 32; int dy = smallfont.charsXYWH.h * smallfont.scaleValue;
	color = Vector4(0.0f,0.0f,0.0f,1.0f);
	sprintf (buffer, "%s", "Image Brush");
	smallfont.displayScreenTextSpacing(x - 16,ty,color.x,color.y,color.z,buffer);
	sprintf (buffer, "index = %d", selectedBrush);
	smallfont.displayScreenTextSpacing(x - 16,ty +dy,color.x,color.y,color.z,buffer);
	sprintf (buffer, "%s", "Collision Brush");
	smallfont.displayScreenTextSpacing(x - 16 + dw, ty,color.x,color.y,color.z,buffer);
	sprintf (buffer, "index = %d", selectedCBrush);
	smallfont.displayScreenTextSpacing(x - 16 + dw, ty + dy,color.x,color.y,color.z,buffer);

	//CBrush icons
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glBindTexture(GL_TEXTURE_2D, *(atlas_collision.texture));

	w = 48.0f;
	h = 48.0f;
	x = lmenuRect.x + border + 8.0f;
	y = lmenuRect.y + border - 1 + top + dh;

	ScreenRect hl_dstRect,sel_dstRect;

	for(int i=0;i<atlas_collision.totalFrames;)
	{
		glBegin(GL_QUADS);
		{
			srcRect = atlas_collision.sourceRectangles[i];
			dstRect = ScreenRect(x,y,w,h);
			glTexCoord2d(srcRect.fLeft(), srcRect.fTop());	glVertex2f(dstRect.fLeft(), dstRect.fTop());
			glTexCoord2d(srcRect.fRight(), srcRect.fTop());	glVertex2f(dstRect.fRight(), dstRect.fTop());
			glTexCoord2d(srcRect.fRight(), srcRect.fBottom());	glVertex2f(dstRect.fRight(),  dstRect.fBottom());
			glTexCoord2d(srcRect.fLeft(), srcRect.fBottom());	glVertex2f(dstRect.fLeft(),  dstRect.fBottom());

		}
		glEnd();
		if(i == highlightedCBrush)
			hl_dstRect = dstRect;
		if(i == selectedCBrush)
			sel_dstRect = dstRect;
		x += w + 8.0f;
		i++;
		if(!fmod(i,4))
		{
			x = lmenuRect.x + border + 8.0f;
			y += h + 8.0f;
		}		
	}

	//highlightedCBrush
	lw = 1.0f;
	glDisable(GL_TEXTURE_2D);
	//selected
	glColor4f(0.5f, 1.0f, 0.5f, 1.0f);
	R_DrawHorizontalLine(sel_dstRect.x - lw, sel_dstRect.y, sel_dstRect.w + 2*lw, lw);
	R_DrawVerticalLine(sel_dstRect.x, sel_dstRect.y , sel_dstRect.h, lw);
	R_DrawHorizontalLine(sel_dstRect.x - lw, sel_dstRect.y + sel_dstRect.h, sel_dstRect.w + 2*lw, lw);
	R_DrawVerticalLine(sel_dstRect.x + sel_dstRect.w, sel_dstRect.y + sel_dstRect.h, -sel_dstRect.h, lw);
	if(PointinRect(Point(input.mouse.lX,input.mouse.lY),lmenuRect))
	{
		x = lmenuRect.x + border + 8.0f;
		y = lmenuRect.y + border - 1 + top + dh;
		Point cursor(CLAMP(input.mouse.lX,0,lmenuRect.fRight()),input.mouse.lY);
		cursor.x -= x;
		cursor.y -= y;
		highlightedCBrush = ((int)(cursor.x/(w + 8.0f)) + 4*((int)((cursor.y)/(h + 8.0f))));
		highlightedCBrush = CLAMP(highlightedCBrush,0,atlas_collision.totalFrames-1);

		glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
		R_DrawHorizontalLine(hl_dstRect.x - lw, hl_dstRect.y, hl_dstRect.w + 2*lw, lw);
		R_DrawVerticalLine(hl_dstRect.x, hl_dstRect.y , hl_dstRect.h, lw);
		R_DrawHorizontalLine(hl_dstRect.x - lw, hl_dstRect.y + hl_dstRect.h, hl_dstRect.w + 2*lw, lw);
		R_DrawVerticalLine(hl_dstRect.x + hl_dstRect.w, hl_dstRect.y + hl_dstRect.h, -hl_dstRect.h, lw);
	}

	glEnable(GL_TEXTURE_2D);
	R_drawScreenDebug();
}
Beispiel #3
0
bool PointinRect(Point p, ScreenRect r)
{
	return p.x >= r.fLeft() && p.x <= r.fRight() && p.y<=r.fBottom() && p.y >= r.fTop();
}