Convert crlf->lf line endings.
[mesa.git] / src / mesa / drivers / allegro / generic.h
index cbdf5ff2b3ad18e41917ed8e4efdd28accfa2a1b..4c8af9b95cfd64d8879bc4eadeba251589f4d1b2 100644 (file)
-/*\r
- * Mesa 3-D graphics library\r
- * Version:  3.0\r
- * Copyright (C) 1995-1998  Brian Paul\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Library General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
- * Library General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Library General Public\r
- * License along with this library; if not, write to the Free\r
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- */\r
-\r
-static void clear_color_generic(GLcontext *ctx, const GLfloat color[4])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    GLubyte r, g, b;\r
-    CLAMPED_FLOAT_TO_UBYTE(r, color[0]);\r
-    CLAMPED_FLOAT_TO_UBYTE(g, color[1]);\r
-    CLAMPED_FLOAT_TO_UBYTE(b, color[2]);\r
-    context->ClearColor = makecol(r, g, b);\r
-    }\r
-\r
-\r
-static void set_color_generic(GLcontext *ctx,\r
-                              GLubyte red,  GLubyte green,\r
-                              GLubyte blue, GLubyte alpha)\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-\r
-    context->CurrentColor = makecol(red, green, blue);\r
-    }\r
-\r
-\r
-static GLbitfield clear_generic(GLcontext *ctx,\r
-                                GLbitfield mask, GLboolean all,\r
-                                GLint x, GLint y,\r
-                                GLint width, GLint height)\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-\r
-    if (mask & GL_COLOR_BUFFER_BIT)\r
-        {\r
-        if (all)\r
-            clear_to_color(context->Buffer->Active, context->ClearColor);\r
-        else\r
-            rect(context->Buffer->Active,\r
-                 x, y, x+width-1, y+height-1,\r
-                 context->ClearColor);\r
-        }\r
-\r
-    return mask & (~GL_COLOR_BUFFER_BIT);\r
-    }\r
-\r
-\r
-static void write_rgba_span_generic(const GLcontext *ctx,\r
-                                    GLuint n, GLint x, GLint y,\r
-                                    const GLubyte rgba[][4],\r
-                                    const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-\r
-    y = FLIP(context, y);\r
-\r
-    if (mask)\r
-        {\r
-        while (n--)\r
-            {\r
-            if (mask[0]) putpixel(bmp, x, y, makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));\r
-            x++; mask++; rgba++;\r
-            }\r
-        }\r
-    else\r
-        {\r
-        while (n--)\r
-            {\r
-            putpixel(bmp, x, y, makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));\r
-            x++; rgba++;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-static void write_rgb_span_generic(const GLcontext *ctx,\r
-                                   GLuint n, GLint x, GLint y,\r
-                                   const GLubyte rgb[][3],\r
-                                   const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-\r
-    y = FLIP(context, y);\r
-\r
-    if (mask)\r
-        {\r
-        while(n--)\r
-            {\r
-            if (mask[0]) putpixel(bmp, x, y, makecol(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]));\r
-            x++; mask++; rgb++;\r
-            }\r
-        }\r
-    else\r
-        {\r
-        while (n--)\r
-            {\r
-            putpixel(bmp, x, y, makecol(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]));\r
-            x++; rgb++;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-static void write_mono_rgba_span_generic(const GLcontext *ctx,\r
-                                         GLuint n, GLint x, GLint y,\r
-                                         const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-    int            color = context->CurrentColor;\r
-\r
-    y = FLIP(context, y);\r
-\r
-    if (mask)\r
-        {\r
-        while(n--)\r
-            {\r
-            if (mask[0]) putpixel(bmp, x, y, color);\r
-            x++; mask++;\r
-            }\r
-        }\r
-    else\r
-        {\r
-        while(n--)\r
-            {\r
-            putpixel(bmp, x, y, color);\r
-            x++;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-static void read_rgba_span_generic(const GLcontext *ctx,\r
-                                   GLuint n, GLint x, GLint y,\r
-                                   GLubyte rgba[][4])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-\r
-    y = FLIP(context, y);\r
-\r
-    while (n--)\r
-        {\r
-        int color = getpixel(bmp, x, y);\r
-\r
-        rgba[0][RCOMP] = getr(color);\r
-        rgba[0][GCOMP] = getg(color);\r
-        rgba[0][BCOMP] = getb(color);\r
-        rgba[0][ACOMP] = 255;\r
-\r
-        x++; rgba++;\r
-        }\r
-    }\r
-\r
-\r
-static void write_rgba_pixels_generic(const GLcontext *ctx,\r
-                                      GLuint n,\r
-                                      const GLint x[],\r
-                                      const GLint y[],\r
-                                      const GLubyte rgba[][4],\r
-                                      const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-\r
-    while (n--)\r
-        {\r
-        if (mask[0]) putpixel(bmp, x[0], FLIP(context, y[0]), makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));\r
-        x++; y++; mask++;\r
-        }\r
-    }\r
-\r
-\r
-static void write_mono_rgba_pixels_generic(const GLcontext *ctx,\r
-                                           GLuint n,\r
-                                           const GLint x[],\r
-                                           const GLint y[],\r
-                                           const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-    int            color = context->CurrentColor;\r
-\r
-    while (n--)\r
-        {\r
-        if (mask[0]) putpixel(bmp, x[0], FLIP(context, y[0]), color);\r
-        x++; y++; mask++;\r
-        }\r
-    }\r
-\r
-\r
-static void read_rgba_pixels_generic(const GLcontext *ctx,\r
-                                     GLuint n,\r
-                                     const GLint x[],\r
-                                     const GLint y[],\r
-                                     GLubyte rgba[][4],\r
-                                     const GLubyte mask[])\r
-    {\r
-    AMesaContext context = (AMesaContext)(ctx->DriverCtx);\r
-    BITMAP          *bmp = context->Buffer->Active;\r
-\r
-    while (n--)\r
-        {\r
-        if (mask[0])\r
-            {\r
-            int color = getpixel(bmp, x[0], FLIP(context, y[0]));\r
-\r
-            rgba[0][RCOMP] = getr(color);\r
-            rgba[0][GCOMP] = getg(color);\r
-            rgba[0][BCOMP] = getb(color);\r
-            rgba[0][ACOMP] = 255;\r
-            }\r
-\r
-        x++; y++; mask++; rgba++;\r
-        }\r
-    }\r
-\r
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.0
+ * Copyright (C) 1995-1998  Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+static void clear_color_generic(GLcontext *ctx, const GLfloat color[4])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    GLubyte r, g, b;
+    CLAMPED_FLOAT_TO_UBYTE(r, color[0]);
+    CLAMPED_FLOAT_TO_UBYTE(g, color[1]);
+    CLAMPED_FLOAT_TO_UBYTE(b, color[2]);
+    context->ClearColor = makecol(r, g, b);
+    }
+
+
+static void set_color_generic(GLcontext *ctx,
+                              GLubyte red,  GLubyte green,
+                              GLubyte blue, GLubyte alpha)
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+
+    context->CurrentColor = makecol(red, green, blue);
+    }
+
+
+static GLbitfield clear_generic(GLcontext *ctx,
+                                GLbitfield mask, GLboolean all,
+                                GLint x, GLint y,
+                                GLint width, GLint height)
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+
+    if (mask & GL_COLOR_BUFFER_BIT)
+        {
+        if (all)
+            clear_to_color(context->Buffer->Active, context->ClearColor);
+        else
+            rect(context->Buffer->Active,
+                 x, y, x+width-1, y+height-1,
+                 context->ClearColor);
+        }
+
+    return mask & (~GL_COLOR_BUFFER_BIT);
+    }
+
+
+static void write_rgba_span_generic(const GLcontext *ctx,
+                                    GLuint n, GLint x, GLint y,
+                                    const GLubyte rgba[][4],
+                                    const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+
+    y = FLIP(context, y);
+
+    if (mask)
+        {
+        while (n--)
+            {
+            if (mask[0]) putpixel(bmp, x, y, makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));
+            x++; mask++; rgba++;
+            }
+        }
+    else
+        {
+        while (n--)
+            {
+            putpixel(bmp, x, y, makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));
+            x++; rgba++;
+            }
+        }
+    }
+
+
+static void write_rgb_span_generic(const GLcontext *ctx,
+                                   GLuint n, GLint x, GLint y,
+                                   const GLubyte rgb[][3],
+                                   const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+
+    y = FLIP(context, y);
+
+    if (mask)
+        {
+        while(n--)
+            {
+            if (mask[0]) putpixel(bmp, x, y, makecol(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]));
+            x++; mask++; rgb++;
+            }
+        }
+    else
+        {
+        while (n--)
+            {
+            putpixel(bmp, x, y, makecol(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]));
+            x++; rgb++;
+            }
+        }
+    }
+
+
+static void write_mono_rgba_span_generic(const GLcontext *ctx,
+                                         GLuint n, GLint x, GLint y,
+                                         const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+    int            color = context->CurrentColor;
+
+    y = FLIP(context, y);
+
+    if (mask)
+        {
+        while(n--)
+            {
+            if (mask[0]) putpixel(bmp, x, y, color);
+            x++; mask++;
+            }
+        }
+    else
+        {
+        while(n--)
+            {
+            putpixel(bmp, x, y, color);
+            x++;
+            }
+        }
+    }
+
+
+static void read_rgba_span_generic(const GLcontext *ctx,
+                                   GLuint n, GLint x, GLint y,
+                                   GLubyte rgba[][4])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+
+    y = FLIP(context, y);
+
+    while (n--)
+        {
+        int color = getpixel(bmp, x, y);
+
+        rgba[0][RCOMP] = getr(color);
+        rgba[0][GCOMP] = getg(color);
+        rgba[0][BCOMP] = getb(color);
+        rgba[0][ACOMP] = 255;
+
+        x++; rgba++;
+        }
+    }
+
+
+static void write_rgba_pixels_generic(const GLcontext *ctx,
+                                      GLuint n,
+                                      const GLint x[],
+                                      const GLint y[],
+                                      const GLubyte rgba[][4],
+                                      const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+
+    while (n--)
+        {
+        if (mask[0]) putpixel(bmp, x[0], FLIP(context, y[0]), makecol(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]));
+        x++; y++; mask++;
+        }
+    }
+
+
+static void write_mono_rgba_pixels_generic(const GLcontext *ctx,
+                                           GLuint n,
+                                           const GLint x[],
+                                           const GLint y[],
+                                           const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+    int            color = context->CurrentColor;
+
+    while (n--)
+        {
+        if (mask[0]) putpixel(bmp, x[0], FLIP(context, y[0]), color);
+        x++; y++; mask++;
+        }
+    }
+
+
+static void read_rgba_pixels_generic(const GLcontext *ctx,
+                                     GLuint n,
+                                     const GLint x[],
+                                     const GLint y[],
+                                     GLubyte rgba[][4],
+                                     const GLubyte mask[])
+    {
+    AMesaContext context = (AMesaContext)(ctx->DriverCtx);
+    BITMAP          *bmp = context->Buffer->Active;
+
+    while (n--)
+        {
+        if (mask[0])
+            {
+            int color = getpixel(bmp, x[0], FLIP(context, y[0]));
+
+            rgba[0][RCOMP] = getr(color);
+            rgba[0][GCOMP] = getg(color);
+            rgba[0][BCOMP] = getb(color);
+            rgba[0][ACOMP] = 255;
+            }
+
+        x++; y++; mask++; rgba++;
+        }
+    }
+