[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/video.h video/font.c vide...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/video.h video/font.c vide... |
Date: |
15 Jan 2004 15:20:44 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/15 15:20:43
Modified files:
src/include : video.h
src/video : font.c graphic.c linedraw.c sdl.c sprite.c
Log message:
USE_OPENGL updates
Patches:
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.114 stratagus/src/include/video.h:1.115
--- stratagus/src/include/video.h:1.114 Thu Jan 15 13:05:39 2004
+++ stratagus/src/include/video.h Thu Jan 15 15:20:41 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.h,v 1.114 2004/01/15 02:05:39 jsalmon3 Exp $
+// $Id: video.h,v 1.115 2004/01/15 04:20:41 jsalmon3 Exp $
#ifndef __VIDEO_H__
#define __VIDEO_H__
@@ -323,16 +323,21 @@
extern int ColorBuildingCycleStart; /// color # start for color
cycling
extern int ColorBuildingCycleEnd; /// color # end for color
cycling
-// FIXME: check these out, clean up if we can
-// FIXME: check these out, clean up if we can
-// FIXME: check these out, clean up if we can
-
+#ifndef USE_OPENGL
/// Draw pixel unclipped.
extern void (*VideoDrawPixel)(Uint32 color, int x, int y);
/// Draw translucent pixel unclipped.
extern void (*VideoDrawTransPixel)(Uint32 color, int x, int y,
unsigned char alpha);
+#else
+ /// Draw pixel unclipped.
+extern void VideoDrawPixel(Uint32 color, int x, int y);
+
+ /// Draw translucent pixel unclipped.
+extern void VideoDrawTransPixel(Uint32 color, int x, int y,
+ unsigned char alpha);
+#endif
/// Draw pixel clipped to current clip setting.
extern void VideoDrawPixelClip(Uint32 color, int x, int y);
Index: stratagus/src/video/font.c
diff -u stratagus/src/video/font.c:1.77 stratagus/src/video/font.c:1.78
--- stratagus/src/video/font.c:1.77 Thu Jan 15 13:14:07 2004
+++ stratagus/src/video/font.c Thu Jan 15 15:20:42 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: font.c,v 1.77 2004/01/15 02:14:07 jsalmon3 Exp $
+// $Id: font.c,v 1.78 2004/01/15 04:20:42 jsalmon3 Exp $
//@{
@@ -157,7 +157,7 @@
for (i = 0; i < NumFontColors; ++i) {
c = FontColor->Color + i;
glColor3ub(c->r, c->g, c->b);
- glRasterPos2i(x, VideoHeight - y - h);
+ glRasterPos2i(x, y + h);
glBitmap(FontBitmapWidths[CurrentFont] * 8, h,
0.0f, 0.0f, 0.0f, 0.0f,
FontBitmaps[CurrentFont][i] +
@@ -609,7 +609,7 @@
x = 0;
numfonts = g->Height / Fonts[font].Height;
for (k = 0; k < numfonts; ++k) {
- for (i = 0; i<Fonts[font].Height; ++i) {
+ for (i = 0; i < Fonts[font].Height; ++i) {
c = FontBitmaps[font][n] + k *
Fonts[font].Height * FontBitmapWidths[font] +
(Fonts[font].Height - 1 - i) *
FontBitmapWidths[font];
for (j = 0; j < g->Width; ++j) {
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.63 stratagus/src/video/graphic.c:1.64
--- stratagus/src/video/graphic.c:1.63 Thu Jan 15 13:14:07 2004
+++ stratagus/src/video/graphic.c Thu Jan 15 15:20:42 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.63 2004/01/15 02:14:07 jsalmon3 Exp $
+// $Id: graphic.c,v 1.64 2004/01/15 04:20:42 jsalmon3 Exp $
//@{
@@ -101,8 +101,8 @@
sx = x;
ex = sx + w;
- ey = VideoHeight - y;
- sy = ey - h;
+ sy = y;
+ ey = y + h;
stx = (GLfloat)gx / graphic->Width * graphic->TextureWidth;
etx = (GLfloat)(gx + w) / graphic->Width * graphic->TextureWidth;
@@ -111,13 +111,13 @@
glBindTexture(GL_TEXTURE_2D, graphic->TextureNames[0]);
glBegin(GL_QUADS);
- glTexCoord2f(stx, 1.0f - ety);
+ glTexCoord2f(stx, sty);
glVertex2i(sx, sy);
- glTexCoord2f(stx, 1.0f - sty);
+ glTexCoord2f(stx, ety);
glVertex2i(sx, ey);
- glTexCoord2f(etx, 1.0f - sty);
+ glTexCoord2f(etx, ety);
glVertex2i(ex, ey);
- glTexCoord2f(etx, 1.0f - ety);
+ glTexCoord2f(etx, sty);
glVertex2i(ex, sy);
glEnd();
}
@@ -210,30 +210,6 @@
free(graphic);
}
-#if 0
-local void FreeGraphic8(Graphic* graphic)
-{
-#ifdef DEBUG
- AllocatedGraphicMemory -= graphic->Size;
- AllocatedGraphicMemory -= sizeof(Graphic);
-#endif
-
-#ifdef USE_OPENGL
- if (graphic->NumTextureNames) {
- glDeleteTextures(graphic->NumTextureNames,
graphic->TextureNames);
- free(graphic->TextureNames);
- }
-#endif
-
- VideoFreeSharedPalette(graphic->Pixels);
- if (graphic->Palette) {
- free(graphic->Palette);
- }
- free(graphic->Frames);
- free(graphic);
-}
-#endif
-
/*----------------------------------------------------------------------------
-- Global functions
----------------------------------------------------------------------------*/
@@ -380,7 +356,7 @@
int c;
SDL_Color p;
- c = (h - i - 1) * w * 4 + j * 4;
+ c = i * w * 4 + j * 4;
if (*sp == 255) {
tex[c + 3] = 0;
} else {
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.67 stratagus/src/video/linedraw.c:1.68
--- stratagus/src/video/linedraw.c:1.67 Thu Jan 15 13:14:07 2004
+++ stratagus/src/video/linedraw.c Thu Jan 15 15:20:42 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: linedraw.c,v 1.67 2004/01/15 02:14:07 jsalmon3 Exp $
+// $Id: linedraw.c,v 1.68 2004/01/15 04:20:42 jsalmon3 Exp $
//@{
@@ -65,38 +65,19 @@
-- Variables
----------------------------------------------------------------------------*/
+#ifndef USE_OPENGL
global void (*VideoDrawPixel)(Uint32 color, int x, int y);
local void (*VideoDoDrawPixel)(Uint32 color, int x, int y);
global void (*VideoDrawTransPixel)(Uint32 color, int x, int y, unsigned char
alpha);
local void (*VideoDoDrawTransPixel)(Uint32 color, int x, int y, unsigned char
alpha);
-global void VideoDrawPixelClip(Uint32 color, int x, int y);
-global void VideoDrawTransPixelClip(Uint32 color, int x, int y, unsigned char
alpha);
-global void VideoDrawVLine(Uint32 color, int x, int y, int width);
-global void VideoDrawVLineClip(Uint32 color, int x, int y, int width);
-global void VideoDrawTransVLine(Uint32 color, int x, int y,
- int height, unsigned char alpha);
-global void VideoDrawHLine(Uint32 color, int x, int y, int width);
-global void VideoDrawHLineClip(Uint32 color, int x, int y, int width);
-global void VideoDrawTransHLine(Uint32 color, int x, int y,
- int width, unsigned char alpha);
-global void VideoDrawLine(Uint32 color, int sx, int sy, int dx, int dy);
-global void VideoDrawTransLine(Uint32 color, int sx, int sy,
- int dx, int dy, unsigned char alpha);
-global void VideoDrawRectangle(Uint32 color, int x, int y,
- int w, int h);
-global void VideoDrawRectangleClip(Uint32 color, int x, int y,
- int w, int h);
-global void VideoDrawTransRectangle(Uint32 color, int x, int y,
- int w, int h, unsigned char alpha);
-global void VideoFillRectangle(Uint32 color, int x, int y,
- int w, int h);
-global void VideoFillTransRectangle(Uint32 color, int x, int y,
- int w, int h, unsigned char alpha);
+#endif
// ===========================================================================
// Pixel
// ===========================================================================
+#ifndef USE_OPENGL
+
/**
** FIXME: docu
*/
@@ -1007,7 +988,7 @@
/**
** FIXME: docu
*/
-global void InitLineDraw()
+global void InitLineDraw(void)
{
switch (VideoDepth) {
case 16:
@@ -1024,858 +1005,825 @@
}
}
-#if 0
+#else
/**
-** Draw pixel unclipped.
+** Draw pixel unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
*/
-#ifdef USE_OPENGL
-local void DrawPixelOpenGL(VMemType color, int x, int y)
+global void VideoDrawPixel(Uint32 color, int x, int y)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor3ub(r, g, b);
glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw 25% translucent pixel unclipped.
+** Draw translucent pixel unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param alpha alpha value of pixel.
*/
-#ifdef USE_OPENGL
-local void Draw25TransPixelOpenGL(VMemType color, int x, int y)
+global void VideoDrawTransPixel(Uint32 color, int x, int y,
+ unsigned char alpha)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
+ glColor4ub(r, g, b, 255 - alpha);
glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
-
/**
-** Draw 50% translucent pixel unclipped.
+** Draw pixel clipped to current clip setting.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
*/
-#ifdef USE_OPENGL
-local void Draw50TransPixelOpenGL(VMemType color, int x, int y)
+global void VideoDrawPixelClip(Uint32 color, int x, int y)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ // Clipping:
+ if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
+ return;
+ }
+
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
+ glColor3ub(r, g, b);
glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw 75% translucent pixel unclipped.
+** Draw horizontal line unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void Draw75TransPixelOpenGL(VMemType color, int x, int y)
+global void VideoDrawHLine(Uint32 color, int x, int y, int width)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
+ glColor3ub(r, g, b);
+ glBegin(GL_LINES);
+ glVertex2i(x, y);
+ glVertex2i(x + width, y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
+
+#define CLIP_HLINE(x, y, width) { \
+ if (y < ClipY1 || y > ClipY2) { \
+ return; \
+ } \
+ if (x < ClipX1) { \
+ int f = ClipX1 - x; \
+ if (width <= f) { \
+ return; \
+ } \
+ width -= f; \
+ x = ClipX1; \
+ } \
+ if ((x + width) > ClipX2 + 1) { \
+ if (x > ClipX2) { \
+ return; \
+ } \
+ width = ClipX2 - x + 1; \
+ } \
+}
/**
-** Draw translucent pixel unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
+** Draw horizontal line clipped.
+**
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void DrawTransPixelOpenGL(VMemType color, int x, int y,
- unsigned char alpha)
+global void VideoDrawHLineClip(Uint32 color, int x, int y, int width)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_HLINE(x, y, width);
+ VideoDrawHLine(color, x, y, width);
}
-#endif
/**
-** Draw pixel clipped to current clip setting.
+** Draw translucent horizontal line unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
+** @param alpha alpha value of pixels.
*/
-#ifdef USE_OPENGL
-local void DrawPixelClipOpenGL(VMemType color, int x, int y)
+global void VideoDrawTransHLine(Uint32 color, int x, int y, int width,
+ unsigned char alpha)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
-
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
+ glColor4ub(r, g, b, 255 - alpha);
+ glBegin(GL_LINES);
+ glVertex2i(x, y);
+ glVertex2i(x + width, y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
-
/**
-** Draw horizontal line unclipped.
+** Draw translucent horizontal line clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
+** @param color Color index
+** @param x X pixel coordinate on the screen
+** @param y Y c pixeloordinate on the screen
+** @param width Width of line (0=don't draw)
+** @param alpha Alpha value of pixels
*/
-#ifdef USE_OPENGL
-local void DrawHLineOpenGL(VMemType color, int x, int y, int width)
+global void VideoDrawTransHLineClip(Uint32 color, int x, int y, int width,
+ unsigned char alpha)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_HLINE(x, y, width);
+ VideoDrawTransHLine(color, x, y, width, alpha);
}
-#endif
/**
-** Draw 25% translucent horizontal line unclipped.
+** Draw vertical line unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param height height of line (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void Draw25TransHLineOpenGL(VMemType color, int x, int y, int width)
+global void VideoDrawVLine(Uint32 color, int x, int y, int height)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
+ glColor3ub(r, g, b);
glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
+ glVertex2i(x, y);
+ glVertex2i(x, y + height);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
+
+#define CLIP_VLINE(x, y, width) { \
+ if (x < ClipX1 || x > ClipX2) { \
+ return; \
+ } \
+ if (y < ClipY1) { \
+ int f = ClipY1 - y; \
+ if (height <= f) { \
+ return; \
+ } \
+ height -= f; \
+ y = ClipY1; \
+ } \
+ if ((y + height) > ClipY2 + 1) { \
+ if (y > ClipY2) { \
+ return; \
+ } \
+ height = ClipY2 - y + 1; \
+ } \
+}
/**
-** Draw 50% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
+** Draw vertical line clipped.
+**
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param height height of line (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void Draw50TransHLineOpenGL(VMemType color, int x, int y, int width)
+global void VideoDrawVLineClip(Uint32 color, int x, int y, int height)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_VLINE(x, y, height);
+ VideoDrawVLine(color, x, y, height);
}
-#endif
/**
-** Draw 75% translucent horizontal line unclipped.
+** Draw translucent vertical line unclipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param height height of line (0=don't draw).
+** @param alpha alpha value of pixels.
*/
-#ifdef USE_OPENGL
-local void Draw75TransHLineOpenGL(VMemType color, int x, int y, int width)
+global void VideoDrawTransVLine(Uint32 color, int x, int y, int height,
+ unsigned char alpha)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
+ glColor4ub(r, g, b, 255 - alpha);
glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
+ glVertex2i(x, y);
+ glVertex2i(x, y + height);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw translucent horizontal line unclipped.
+** Draw translucent vertical line clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param height height of line (0=don't draw).
+** @param alpha alpha value of pixels.
*/
-#ifdef USE_OPENGL
-local void DrawTransHLineOpenGL(VMemType color, int x, int y, int width,
- unsigned char alpha)
+global void VideoDrawTransVLineClip(Uint32 color, int x, int y,
+ int height, unsigned char alpha)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_VLINE(x, y, height);
+ VideoDrawTransVLine(color, x, y, height, alpha);
}
-#endif
/**
-** Draw vertical line unclipped.
+** Draw line unclipped into 32bit framebuffer.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
+** @param color color
+** @param x1 Source x coordinate on the screen
+** @param y1 Source y coordinate on the screen
+** @param x2 Destination x coordinate on the screen
+** @param y2 Destination y coordinate on the screen
*/
-#ifdef USE_OPENGL
-local void DrawVLineOpenGL(VMemType color, int x, int y, int height)
+global void VideoDrawLine(Uint32 color, int x1, int y1, int x2, int y2)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor3ub(r, g, b);
glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
+ glVertex2i(x1, y1);
+ glVertex2i(x2, y2);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw 25% translucent vertical line unclipped.
+** Delivers bitmask denoting given point is left/right/above/below
+** clip rectangle, used for faster determinination of clipped position.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
+** @param x pixel's x position (not restricted to screen width)
+** @param y pixel's y position (not restricted to screen height)
*/
-#ifdef USE_OPENGL
-local void Draw25TransVLineOpenGL(VMemType color, int x, int y, int height)
+local ClipCode ClipCodeLine(int x, int y)
{
- VMemType32 c;
- GLubyte r,g,b;
+ ClipCode result;
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ if (y < ClipY1) {
+ result = ClipCodeAbove;
+ } else if (y > ClipY2) {
+ result = ClipCodeBelow;
+ } else {
+ result = ClipCodeInside;
+ }
+
+ if (x < ClipX1) {
+ result |= ClipCodeLeft;
+ } else if (x > ClipX2) {
+ result |= ClipCodeRight;
+ }
+
+ return result;
}
-#endif
/**
-** Draw 50% translucent vertical line unclipped.
+** Denotes entire line located at the same side outside clip rectangle
+** (point 1 and 2 are both as left/right/above/below the clip rectangle)
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
+** @param code1 ClipCode of one point of line
+** @param code2 ClipCode of second point of line
*/
-#ifdef USE_OPENGL
-local void Draw50TransVLineOpenGL(VMemType color, int x, int y, int height)
+local ClipCode LineIsUnclippedOnSameSide(int code1, int code2)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ return code1 & code2;
}
-#endif
/**
-** Draw 75% translucent vertical line unclipped.
+** Denotes part of (or entire) line located outside clip rectangle
+** (point 1 and/or 2 is outside clip rectangle)
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
+** @param code1 ClipCode of one point of line
+** @param code2 ClipCode of second point of line
*/
-#ifdef USE_OPENGL
-local void Draw75TransVLineOpenGL(VMemType color, int x, int y, int height)
+local ClipCode LineIsUnclipped(int code1, int code2)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ return code1 | code2;
}
-#endif
/**
-** Draw translucent vertical line unclipped.
+** Draw line clipped.
+** Based on Sutherland-Cohen clipping technique
+** (Replaces Liang/Barksy clipping algorithm in CVS version 1.18, which
+** might be faster, but that one contained some BUGs)
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
+** @param color color
+** @param x1 Source x coordinate on the screen
+** @param y1 Source y coordinate on the screen
+** @param x2 Destination x coordinate on the screen
+** @param y2 Destination y coordinate on the screen
*/
-#ifdef USE_OPENGL
-local void DrawTransVLineOpenGL(VMemType color, int x, int y, int height,
- unsigned char alpha)
+global void VideoDrawLineClip(Uint32 color, int x1, int y1, int x2, int y2)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
+ ClipCode code1;
+ ClipCode code2;
+ int temp;
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ // Make sure coordinates or on/in clipped rectangle
+ while (code1 = ClipCodeLine(x1, y1), code2 = ClipCodeLine(x2, y2),
+ LineIsUnclipped(code1, code2)) {
+ if (LineIsUnclippedOnSameSide(code1, code2)) {
+ return;
+ }
+
+ if (!code1) {
+ temp = x1; x1 = x2; x2 = temp;
+ temp = y1; y1 = y2; y2 = temp;
+ code1 = code2;
+ }
+
+ if (code1 & ClipCodeAbove) {
+ temp = ClipY1;
+ x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 -
y1));
+ y1 = temp;
+ } else if (code1 & ClipCodeBelow) {
+ temp = ClipY2;
+ x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 -
y1));
+ y1 = temp;
+ } else if (code1 & ClipCodeLeft) {
+ temp = ClipX1;
+ y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 -
x1));
+ x1 = temp;
+ } else { /* code1 & ClipCodeRight */
+ temp = ClipX2;
+ y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 -
x1));
+ x1 = temp;
+ }
+ }
+
+ // Draw line based on clipped coordinates
+ // FIXME: As the clipped coordinates are rounded to integers, the line's
+ // direction vector might be slightly off. Somehow, the sub-pixel
+ // position(s) on the clipped retangle should be denoted to the
line
+ // drawing routine..
+ DebugCheck(x1 < ClipX1 || x2 < ClipX1 || x1 > ClipX2 || x2 > ClipX2 ||
+ y1 < ClipY1 || y2 < ClipY1 || y1 > ClipY2 || y2 > ClipY2);
+ VideoDrawLine(color, x1, y1, x2, y2);
}
-#endif
/**
-** Draw line unclipped into 32bit framebuffer.
+** Draw rectangle.
**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void DrawLineOpenGL(VMemType color, int x1, int y1, int x2, int y2)
+global void VideoDrawRectangle(Uint32 color, int x, int y, int w, int h)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor3ub(r, g, b);
- glBegin(GL_LINES);
- glVertex2i(x1, VideoHeight - y1);
- glVertex2i(x2, VideoHeight - y2);
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(x, y);
+ glVertex2i(x + w, y);
+ glVertex2i(x + w, y + h);
+ glVertex2i(x, y + h);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw rectangle.
+** Draw rectangle clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void DrawRectangleOpenGL(VMemType color, int x, int y, int w, int h)
+global void VideoDrawRectangleClip(Uint32 color, int x, int y,
+ int w, int h)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ #define _x x
+ #define _y y
+ #define _w w
+ #define _h h
+ #define _hline(x, y,w) VideoDrawHLine(color, x, y, w)
+ #define _vline(x, y,h) VideoDrawVLine(color, x, y, h)
+
+ #include "_clip_rectangle"
+
+ #undef _x
+ #undef _y
+ #undef _w
+ #undef _h
+ #undef _hline
+ #undef _vline
}
-#endif
/**
-** Draw 25% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** Draw translucent rectangle.
+**
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
+** @param alpha alpha value of pixel.
*/
-#ifdef USE_OPENGL
-local void Draw25TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoDrawTransRectangle(Uint32 color, int x, int y,
+ int w, int h, unsigned char alpha)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
+ glColor4ub(r, g, b, 255 - alpha);
glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x, y);
+ glVertex2i(x + w, y);
+ glVertex2i(x + w, y + h);
+ glVertex2i(x, y + h);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw 50% translucent rectangle into 32bpp frame buffer.
+** Fill rectangle.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void Draw50TransRectangleOpenGL(VMemType color, int x, int y,
+global void VideoFillRectangle(Uint32 color, int x, int y,
int w, int h)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
+ glColor3ub(r, g, b);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x + w, y);
+ glVertex2i(x, y + h);
+ glVertex2i(x + w, y + h);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Draw 75% translucent rectangle.
+** Fill rectangle clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
*/
-#ifdef USE_OPENGL
-local void Draw75TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoFillRectangleClip(Uint32 color, int x, int y,
+ int w, int h)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoFillRectangle(color, x, y, w, h);
}
-#endif
/**
-** Draw translucent rectangle.
+** Draw translucent rectangle.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
+** @param alpha alpha value of pixel.
*/
-#ifdef USE_OPENGL
-local void DrawTransRectangleOpenGL(VMemType color, int x, int y,
+global void VideoFillTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha)
{
- VMemType32 c;
+ Uint32 c;
GLubyte r;
GLubyte g;
GLubyte b;
- c = color.D32;
+ c = color;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x + w, y);
+ glVertex2i(x, y + h);
+ glVertex2i(x + w, y + h);
glEnd();
glEnable(GL_TEXTURE_2D);
}
-#endif
/**
-** Fill rectangle.
+** Fill rectangle translucent clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+** @param h height of rectangle (0=don't draw).
+** @param w width of rectangle (0=don't draw).
+** @param alpha alpha value of pixels.
*/
-#ifdef USE_OPENGL
-local void DrawFillRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoFillTransRectangleClip(Uint32 color, int x, int y,
+ int w, int h, unsigned char alpha)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoFillTransRectangle(color, x, y, w, h,alpha);
}
-#endif
/**
-** Fill rectangle 25% translucent clipped.
+** Draw circle clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x Center x coordinate on the screen
+** @param y Center y coordinate on the screen
+** @param r radius of circle
*/
-#ifdef USE_OPENGL
-local void DrawFill25TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoDrawCircleClip(Uint32 color, int x, int y, int r)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ int cx;
+ int cy;
+ int df;
+ int d_e;
+ int d_se;
+
+ cx = 0;
+ cy = r;
+ df = 1 - r;
+ d_e = 3;
+ d_se = -2 * r + 5;
+
+ // FIXME: could be much improved :)
+ do {
+ if (cx == 0) {
+ VideoDrawPixelClip(color, x, y + cy);
+ VideoDrawPixelClip(color, x, y - cy);
+ VideoDrawPixelClip(color, x + cy, y);
+ VideoDrawPixelClip(color, x - cy, y);
+ } else if (cx == cy) {
+ DebugCheck(cx == 0 || cy == 0);
+ VideoDrawPixelClip(color, x + cx, y + cy);
+ VideoDrawPixelClip(color, x - cx, y + cy);
+ VideoDrawPixelClip(color, x + cx, y - cy);
+ VideoDrawPixelClip(color, x - cx, y - cy);
+ } else if (cx < cy) {
+ DebugCheck(cx == 0 || cy == 0);
+ VideoDrawPixelClip(color, x + cx, y + cy);
+ VideoDrawPixelClip(color, x + cx, y - cy);
+ VideoDrawPixelClip(color, x + cy, y + cx);
+ VideoDrawPixelClip(color, x + cy, y - cx);
+ VideoDrawPixelClip(color, x - cx, y + cy);
+ VideoDrawPixelClip(color, x - cx, y - cy);
+ VideoDrawPixelClip(color, x - cy, y + cx);
+ VideoDrawPixelClip(color, x - cy, y - cx);
+ }
+ if (df < 0) {
+ df += d_e;
+ d_se += 2;
+ } else {
+ df += d_se;
+ d_se += 4;
+ --cy;
+ }
+ d_e += 2;
+ ++cx;
+ } while (cx <= cy);
}
-#endif
/**
-** Fill rectangle 50% translucent clipped.
+** Fill circle clipped.
**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param color color
+** @param x Center x coordinate on the screen
+** @param y Center y coordinate on the screen
+** @param r radius of circle
*/
-#ifdef USE_OPENGL
-local void DrawFill50TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoFillCircleClip(Uint32 color, int x, int y, int r)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
+ int cx;
+ int cy;
+ int df;
+ int d_e;
+ int d_se;
+
+ cx = 0;
+ cy = r;
+ df = 1 - r;
+ d_e = 3;
+ d_se = -2 * r + 5;
+
+ // FIXME: could be much improved :)
+ do {
+ VideoDrawHLineClip(color, x - cy, y - cx, 1 + cy * 2);
+ if (cx) {
+ VideoDrawHLineClip(color, x - cy, y + cx, 1 + cy * 2);
+ }
+ if (df < 0) {
+ df += d_e;
+ d_se += 2;
+ } else {
+ if (cx != cy) {
+ VideoDrawHLineClip(color, x - cx, y - cy, 1 +
cx * 2);
+ VideoDrawHLineClip(color, x - cx, y + cy, 1 +
cx * 2);
+ }
+ df += d_se;
+ d_se += 4;
+ --cy;
+ }
+ d_e += 2;
+ ++cx;
+ } while (cx <= cy);
+}
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+global void VideoFillTransCircle(Uint32 color, int x, int y,
+ int r, unsigned char alpha)
+{
+ int p;
+ int px;
+ int py;
+
+ p = 1 - r;
+ py = r;
+
+ for (px = 0; px <= py + 1; ++px) {
+
+ // Fill up the middle half of the circle
+ VideoDrawTransVLine(color, x + px, y, py + 1, alpha);
+ VideoDrawTransVLine(color, x + px, y - py, py, alpha);
+ if (px) {
+ VideoDrawTransVLine(color, x - px, y, py + 1, alpha);
+ VideoDrawTransVLine(color, x - px, y - py, py, alpha);
+ }
+
+ if (p < 0) {
+ p += 2 * px + 3;
+ } else {
+ p += 2 * (px - py) + 5;
+ py -= 1;
+
+ // Fill up the left/right half of the circle
+ if (py >= px) {
+ VideoDrawTransVLine(color, x + py + 1, y, px +
1, alpha);
+ VideoDrawTransVLine(color, x + py + 1, y - px,
px, alpha);
+ VideoDrawTransVLine(color, x - py - 1, y, px +
1, alpha);
+ VideoDrawTransVLine(color, x - py - 1, y - px,
px, alpha);
+ }
+ }
+ }
}
-#endif
-/**
-** Fill rectangle 75% translucent clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawFill75TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+global void VideoFillTransCircleClip(Uint32 color, int x, int y,
+ int r, unsigned char alpha)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- Glubyte b;
+ int p;
+ int px;
+ int py;
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
+ p = 1 - r;
+ py = r;
+
+ for (px = 0; px <= py + 1; ++px) {
+
+ // Fill up the middle half of the circle
+ VideoDrawTransVLineClip(color, x + px, y, py + 1, alpha);
+ VideoDrawTransVLineClip(color, x + px, y - py, py, alpha);
+ if (px) {
+ VideoDrawTransVLineClip(color, x - px, y, py + 1,
alpha);
+ VideoDrawTransVLineClip(color, x - px, y - py, py,
alpha);
+ }
+
+ if (p < 0) {
+ p += 2 * px + 3;
+ } else {
+ p += 2 * (px - py) + 5;
+ py -= 1;
+
+ // Fill up the left/right half of the circle
+ if (py >= px) {
+ VideoDrawTransVLineClip(color, x + py + 1, y,
px + 1, alpha);
+ VideoDrawTransVLineClip(color, x + py + 1, y -
px, px, alpha);
+ VideoDrawTransVLineClip(color, x - py - 1, y,
px + 1, alpha);
+ VideoDrawTransVLineClip(color, x - py - 1, y -
px, px, alpha);
+ }
+ }
+ }
}
-#endif
/**
-** Draw translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
+** FIXME: docu
*/
-#ifdef USE_OPENGL
-local void DrawFillTransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
+global void InitLineDraw(void)
{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
}
-#endif
#endif
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.114 stratagus/src/video/sdl.c:1.115
--- stratagus/src/video/sdl.c:1.114 Thu Jan 15 13:14:08 2004
+++ stratagus/src/video/sdl.c Thu Jan 15 15:20:42 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sdl.c,v 1.114 2004/01/15 02:14:08 jsalmon3 Exp $
+// $Id: sdl.c,v 1.115 2004/01/15 04:20:42 jsalmon3 Exp $
//@{
@@ -141,7 +141,7 @@
glViewport(0, 0, (GLsizei)VideoWidth, (GLsizei)VideoHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0, VideoWidth, 0, VideoHeight, -1, 1);
+ glOrtho(0, VideoWidth, VideoHeight, 0, -1, 1);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.62 stratagus/src/video/sprite.c:1.63
--- stratagus/src/video/sprite.c:1.62 Thu Jan 15 13:14:08 2004
+++ stratagus/src/video/sprite.c Thu Jan 15 15:20:43 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sprite.c,v 1.62 2004/01/15 02:14:08 jsalmon3 Exp $
+// $Id: sprite.c,v 1.63 2004/01/15 04:20:43 jsalmon3 Exp $
//@{
@@ -63,6 +63,15 @@
-- RLE Sprites
----------------------------------------------------------------------------*/
+/**
+** Draw graphic object unclipped.
+**
+** @param sprite pointer to object
+** @param frame number of frame (object index)
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+*/
+#ifndef USE_OPENGL
global void VideoDraw(const Graphic* sprite, unsigned frame, int x, int y)
{
SDL_Rect srect;
@@ -78,7 +87,42 @@
SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
}
+#else
+global void VideoDraw(const Graphic* sprite, unsigned frame, int x, int y)
+{
+ GLint sx;
+ GLint ex;
+ GLint sy;
+ GLint ey;
+
+ sx = x;
+ ex = sx + sprite->Width;
+ sy = y;
+ ey = sy + sprite->Height;
+
+ glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex2i(sx, sy);
+ glTexCoord2f(0.0f, sprite->TextureHeight);
+ glVertex2i(sx, ey);
+ glTexCoord2f(sprite->TextureWidth, sprite->TextureHeight);
+ glVertex2i(ex, ey);
+ glTexCoord2f(sprite->TextureWidth, 0.0f);
+ glVertex2i(ex, sy);
+ glEnd();
+}
+#endif
+/**
+** Draw graphic object clipped.
+**
+** @param sprite pointer to object
+** @param frame number of frame (object index)
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+*/
+#ifndef USE_OPENGL
global void VideoDrawClip(const Graphic* sprite, unsigned frame, int x, int y)
{
SDL_Rect srect;
@@ -102,7 +146,60 @@
SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
}
+#else
+global void VideoDrawClip(const Graphic* sprite, unsigned frame, int x, int y)
+{
+ GLint svx;
+ GLint evx;
+ GLint svy;
+ GLint evy;
+ GLfloat stx;
+ GLfloat etx;
+ GLfloat sty;
+ GLfloat ety;
+ int ox;
+ int oy;
+ int ex;
+ int w;
+ int h;
+
+ w = sprite->Width;
+ h = sprite->Height;
+ CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+ svx = x;
+ evx = svx + w;
+ svy = y;
+ evy = svy + h;
+
+ stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
+ etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
+ sty = (GLfloat)oy / sprite->Height * sprite->TextureHeight;
+ ety = (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
+
+ glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(stx, sty);
+ glVertex3f(svx, svy, 0.0f);
+ glTexCoord2f(stx, ety);
+ glVertex3f(svx, evy, 0.0f);
+ glTexCoord2f(etx, ety);
+ glVertex3f(evx, evy, 0.0f);
+ glTexCoord2f(etx, sty);
+ glVertex3f(evx, svy, 0.0f);
+ glEnd();
+}
+#endif
+/**
+** Draw graphic object unclipped and flipped in X direction.
+**
+** @param sprite pointer to object
+** @param frame number of frame (object index)
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+*/
+#ifndef USE_OPENGL
global void VideoDrawX(const Graphic* sprite, unsigned frame, int x, int y)
{
SDL_Rect srect;
@@ -119,7 +216,42 @@
SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
}
+#else
+global void VideoDrawX(const Graphic* sprite, unsigned frame, int x, int y)
+{
+ GLint sx;
+ GLint ex;
+ GLint sy;
+ GLint ey;
+
+ sx = x;
+ ex = sx + sprite->Width;
+ ey = VideoHeight - y;
+ sy = ey - sprite->Height;
+
+ glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0f, 1.0f - sprite->TextureHeight);
+ glVertex2i(sx, sy);
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex2i(sx, ey);
+ glTexCoord2f(sprite->TextureWidth, 1.0f);
+ glVertex2i(ex, ey);
+ glTexCoord2f(sprite->TextureWidth, 1.0f - sprite->TextureHeight);
+ glVertex2i(ex, sy);
+ glEnd();
+}
+#endif
+/**
+** Draw graphic object clipped and flipped in X direction.
+**
+** @param sprite pointer to object
+** @param frame number of frame (object index)
+** @param x x coordinate on the screen
+** @param y y coordinate on the screen
+*/
+#ifndef USE_OPENGL
global void VideoDrawClipX(const Graphic* sprite, unsigned frame, int x, int y)
{
SDL_Rect srect;
@@ -144,10 +276,62 @@
SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
}
-
-global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame,
+#else
+global void VideoDrawClipX(const Graphic* sprite, unsigned frame,
int x, int y)
{
+ GLint svx;
+ GLint evx;
+ GLint svy;
+ GLint evy;
+ GLfloat stx;
+ GLfloat etx;
+ GLfloat sty;
+ GLfloat ety;
+ int ox;
+ int oy;
+ int ex;
+ int w;
+ int h;
+
+ w = sprite->Width;
+ h = sprite->Height;
+ CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
+
+ svx = x;
+ evx = svx + w;
+ evy = VideoHeight - y;
+ svy = evy - h;
+
+ if (w < sprite->Width) {
+ if (ox == 0) {
+ ox += sprite->Width - w;
+ } else {
+ ox = 0;
+ }
+ }
+ stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
+ etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
+ ety = 1.0f - (GLfloat)oy / sprite->Height * sprite->TextureHeight;
+ sty = 1.0f - (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
+
+ glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(stx, sty);
+ glVertex2i(evx, svy);
+ glTexCoord2f(stx, ety);
+ glVertex2i(evx, evy);
+ glTexCoord2f(etx, ety);
+ glVertex2i(svx, evy);
+ glTexCoord2f(etx, sty);
+ glVertex2i(svx, svy);
+ glEnd();
+}
+#endif
+
+#ifndef USE_OPENGL
+global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame, int x,
int y)
+{
SDL_Rect srect;
SDL_Rect drect;
int oldx;
@@ -174,8 +358,7 @@
SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
}
-global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
+global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame, int x,
int y)
{
SDL_Rect srect;
SDL_Rect drect;
@@ -301,188 +484,24 @@
SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
}
-
-/**
-** Draw graphic object unclipped.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void VideoDrawOpenGL(const Graphic* sprite, unsigned frame, int x, int y)
+#else
+global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame, int x,
int y)
{
- GLint sx;
- GLint ex;
- GLint sy;
- GLint ey;
-
- sx = x;
- ex = sx + sprite->Width;
- ey = VideoHeight - y;
- sy = ey - sprite->Height;
-
- glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 1.0f - sprite->TextureHeight);
- glVertex2i(sx, sy);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2i(sx, ey);
- glTexCoord2f(sprite->TextureWidth, 1.0f);
- glVertex2i(ex, ey);
- glTexCoord2f(sprite->TextureWidth, 1.0f - sprite->TextureHeight);
- glVertex2i(ex, sy);
- glEnd();
}
-#endif
-
-/**
-** Draw graphic object unclipped and flipped in X direction.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void VideoDrawXOpenGL(const Graphic* sprite, unsigned frame, int x, int
y)
+global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame, int x,
int y)
{
- GLint sx;
- GLint ex;
- GLint sy;
- GLint ey;
-
- sx = x;
- ex = sx + sprite->Width;
- ey = VideoHeight - y;
- sy = ey - sprite->Height;
-
- glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 1.0f - sprite->TextureHeight);
- glVertex2i(sx, sy);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2i(sx, ey);
- glTexCoord2f(sprite->TextureWidth, 1.0f);
- glVertex2i(ex, ey);
- glTexCoord2f(sprite->TextureWidth, 1.0f - sprite->TextureHeight);
- glVertex2i(ex, sy);
- glEnd();
}
-#endif
-
-/**
-** Draw graphic object clipped.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void VideoDrawClipOpenGL(const Graphic* sprite, unsigned frame, int x,
int y)
+global void VideoDrawTrans(const Graphic* sprite, unsigned frame, int x, int
y, int alpha)
{
- GLint svx;
- GLint evx;
- GLint svy;
- GLint evy;
- GLfloat stx;
- GLfloat etx;
- GLfloat sty;
- GLfloat ety;
- int ox;
- int oy;
- int ex;
- int w;
- int h;
-
- w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- svx = x;
- evx = svx + w;
- evy = VideoHeight - y;
- svy = evy - h;
-
- stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
- etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
- ety = 1.0f - (GLfloat)oy / sprite->Height * sprite->TextureHeight;
- sty = 1.0f - (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
-
- glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
- glBegin(GL_QUADS);
- glTexCoord2f(stx, sty);
- glVertex3f(svx, svy, 0.0f);
- glTexCoord2f(stx, ety);
- glVertex3f(svx, evy, 0.0f);
- glTexCoord2f(etx, ety);
- glVertex3f(evx, evy, 0.0f);
- glTexCoord2f(etx, sty);
- glVertex3f(evx, svy, 0.0f);
- glEnd();
}
-#endif
-
-/**
-** Draw graphic object clipped and flipped in X direction.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void VideoDrawClipXOpenGL(const Graphic* sprite, unsigned frame,
- int x, int y)
+global void VideoDrawClipTrans(const Graphic* sprite, unsigned frame, int x,
int y, int alpha)
+{
+}
+global void VideoDrawTransX(const Graphic* sprite, unsigned frame, int x, int
y, int alpha)
+{
+}
+global void VideoDrawClipTransX(const Graphic* sprite, unsigned frame, int x,
int y, int alpha)
{
- GLint svx;
- GLint evx;
- GLint svy;
- GLint evy;
- GLfloat stx;
- GLfloat etx;
- GLfloat sty;
- GLfloat ety;
- int ox;
- int oy;
- int ex;
- int w;
- int h;
-
- w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- svx = x;
- evx = svx + w;
- evy = VideoHeight - y;
- svy = evy - h;
-
- if (w < sprite->Width) {
- if (ox == 0) {
- ox += sprite->Width - w;
- } else {
- ox = 0;
- }
- }
- stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
- etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
- ety = 1.0f - (GLfloat)oy / sprite->Height * sprite->TextureHeight;
- sty = 1.0f - (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
-
- glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
- glBegin(GL_QUADS);
- glTexCoord2f(stx, sty);
- glVertex2i(evx, svy);
- glTexCoord2f(stx, ety);
- glVertex2i(evx, evy);
- glTexCoord2f(etx, ety);
- glVertex2i(svx, evy);
- glTexCoord2f(etx, sty);
- glVertex2i(svx, svy);
- glEnd();
}
#endif