index d76f493e3ed590f9ec3122b60b90731271ba5a14..e836b30d1190e7923f536587de66c616106fd3e0 100644 (file)
r_textures
;
r_textures
;
- procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean);
- procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean);
+ procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
+ procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
+ procedure r_Draw_TextureRepeatRotate (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
- procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const a: TAnimState; x, y, w, h: Integer; flip: Boolean);
+ procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
+ procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
g_game // gScreenWidth, gScreenHeight
;
g_game // gScreenWidth, gScreenHeight
;
+ const
+ NTR = $FF;
+ NTG = $00;
+ NTB = $00;
+ NTA = $FF;
+
procedure SetupMatrix;
begin
glScissor(0, 0, gScreenWidth, gScreenHeight);
procedure SetupMatrix;
begin
glScissor(0, 0, gScreenWidth, gScreenHeight);
glEnd();
end;
glEnd();
end;
- procedure DrawTile (tile: TGLAtlasNode; x, y, w, h: Integer; flip: Boolean);
+ procedure DrawTile (tile: TGLAtlasNode; x, y, w, h: Integer; flip: Boolean; rr, gg, bb, aa: Byte; blend: Boolean);
var nw, nh, ax, bx, ay, by: GLfloat; l, t, r, b: Integer;
begin
if tile = nil then
begin
var nw, nh, ax, bx, ay, by: GLfloat; l, t, r, b: Integer;
begin
if tile = nil then
begin
- glColor3ub(255, 0, 0);
- glDisable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4ub(rr, gg, bb, aa);
+ if blend then glBlendFunc(GL_SRC_ALPHA, GL_ONE) else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
DrawQuad(x, y, w, h);
end
else
DrawQuad(x, y, w, h);
end
else
ay := (tile.t) / nw;
by := (tile.b + 1) / nh;
l := x; t := y; r := x + w; b := y + h;
ay := (tile.t) / nw;
by := (tile.b + 1) / nh;
l := x; t := y; r := x + w; b := y + h;
- glColor3ub(255, 255, 255);
glBindTexture(GL_TEXTURE_2D, tile.id);
glBindTexture(GL_TEXTURE_2D, tile.id);
+ glColor4ub(rr, gg, bb, aa);
+ if blend then glBlendFunc(GL_SRC_ALPHA, GL_ONE) else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_QUADS);
glTexCoord2f(ax, ay); glVertex2i(r, t);
glTexCoord2f(bx, ay); glVertex2i(l, t);
glBegin(GL_QUADS);
glTexCoord2f(ax, ay); glVertex2i(r, t);
glTexCoord2f(bx, ay); glVertex2i(l, t);
end
end;
end
end;
-(*
- procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean);
- var i, j, offx, offy, nw, nh: Integer; n: TGLAtlasNode;
- begin
- ASSERT(w >= 0);
- ASSERT(h >= 0);
- if img = nil then
- DrawTile(nil, x, y, w, h, flip)
- else
- begin
- offx := 0;
- offy := 0;
- nw := w div img.cols;
- nh := h div img.lines;
- for j := 0 to img.lines - 1 do
- begin
- for i := 0 to img.cols - 1 do
- begin
- n := img.GetTile(i, j);
- ASSERT(n <> nil);
- DrawTile(n, x + offx, y + offy, nw, nh, flip);
- offx := offx + nw;
- end;
- offx := 0;
- offy := offy + nh;
- end
- end
- end;
-*)
-
- procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean);
+ procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
var i, j, offx, offy: Integer; n: TGLAtlasNode;
begin
ASSERT(w >= 0);
ASSERT(h >= 0);
if img = nil then
var i, j, offx, offy: Integer; n: TGLAtlasNode;
begin
ASSERT(w >= 0);
ASSERT(h >= 0);
if img = nil then
- DrawTile(nil, x, y, w, h, flip)
+ DrawTile(nil, x, y, w, h, flip, NTR, NTB, NTG, NTA, blend)
else
begin
glPushMatrix;
else
begin
glPushMatrix;
begin
n := img.GetTile(i, j);
ASSERT(n <> nil);
begin
n := img.GetTile(i, j);
ASSERT(n <> nil);
- DrawTile(n, x + offx, y + offy, n.width, n.height, flip);
+ DrawTile(n, x + offx, y + offy, n.width, n.height, flip, r, g, b, a, blend);
offx := offx + n.width;
end;
offx := 0;
offx := offx + n.width;
end;
offx := 0;
end
end;
end
end;
- procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean);
+ procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
var i, j: Integer;
begin
ASSERT(w >= 0);
ASSERT(h >= 0);
if img = nil then
var i, j: Integer;
begin
ASSERT(w >= 0);
ASSERT(h >= 0);
if img = nil then
- r_Draw_Texture(nil, x, y, w, h, flip)
+ r_Draw_Texture(nil, x, y, w, h, flip, NTR, NTG, NTB, NTB, blend)
else
for j := 0 to h div img.height - 1 do
for i := 0 to w div img.width - 1 do
else
for j := 0 to h div img.height - 1 do
for i := 0 to w div img.width - 1 do
- r_Draw_Texture(img, x + i * img.width, y + j * img.height, img.width, img.height, flip);
+ r_Draw_Texture(img, x + i * img.width, y + j * img.height, img.width, img.height, flip, r, g, b, a, blend);
+ end;
+
+ procedure r_Draw_TextureRepeatRotate (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
+ begin
+ ASSERT(w >= 0);
+ ASSERT(h >= 0);
+ if a <> 0 then
+ begin
+ glPushMatrix;
+ glTranslatef(x + rx, y + ry, 0);
+ glRotatef(angle, 0, 0, 1);
+ glTranslatef(-(x + rx), -(y + ry), 0);
+ r_Draw_TextureRepeat(img, x, y, w, h, flip, r, g, b, a, blend);
+ glPopMatrix;
+ end
+ else
+ r_Draw_TextureRepeat(img, x, y, w, h, flip, r, g, b, a, blend);
end;
end;
- procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const a: TAnimState; x, y, w, h: Integer; flip: Boolean);
+ procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
var img: TGLTexture; cur, total, i: Integer;
begin
var img: TGLTexture; cur, total, i: Integer;
begin
- ASSERT(a.IsValid());
+ ASSERT(anim.IsValid());
if m = nil then
if m = nil then
- r_Draw_TextureRepeat(nil, x, y, w, h, flip)
+ r_Draw_TextureRepeat(nil, x, y, w, h, flip, NTR, NTG, NTB, NTB, blend)
else
begin
if m.BackAnim then
begin
total := m.count * 2 - 1;
else
begin
if m.BackAnim then
begin
total := m.count * 2 - 1;
- cur := a.CurrentFrame mod total;
+ cur := anim.CurrentFrame mod total;
if cur < m.count then i := cur else i := total - cur - 1;
end
else
if cur < m.count then i := cur else i := total - cur - 1;
end
else
- i := a.CurrentFrame mod m.count;
+ i := anim.CurrentFrame mod m.count;
img := m.GetTexture(i);
img := m.GetTexture(i);
- r_Draw_TextureRepeat(img, x, y, w, h, flip)
+ r_Draw_TextureRepeat(img, x, y, w, h, flip, r, g, b, a, blend);
end
end;
end
end;
+ procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
+ begin
+ ASSERT(w >= 0);
+ ASSERT(h >= 0);
+ if a <> 0 then
+ begin
+ glPushMatrix;
+ glTranslatef(x + rx, y + ry, 0);
+ glRotatef(angle, 0, 0, 1);
+ glTranslatef(-(x + rx), -(y + ry), 0);
+ r_Draw_MultiTextureRepeat(m, anim, x, y, w, h, flip, r, g, b, a, blend);
+ glPopMatrix;
+ end
+ else
+ r_Draw_MultiTextureRepeat(m, anim, x, y, w, h, flip, r, g, b, a, blend);
+ end;
+
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
begin
ASSERT(r >= l);
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
begin
ASSERT(r >= l);