summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/windows
diff options
context:
space:
mode:
authorKarl Schultz <kschultz@freedesktop.org>2005-05-24 21:12:43 +0000
committerKarl Schultz <kschultz@freedesktop.org>2005-05-24 21:12:43 +0000
commit45ab8cb08aaf641a397c1a30ac19f0942498430b (patch)
tree0cdf31ef792e82336c68da9a0375d9e8e5cb5798 /src/mesa/drivers/windows
parentb31b1f44f15f385f61e4cd42c10bb967cd2e5b91 (diff)
Major code cleanup and begin using new render buffer interface.
Diffstat (limited to 'src/mesa/drivers/windows')
-rw-r--r--src/mesa/drivers/windows/gdi/colors.h536
-rw-r--r--src/mesa/drivers/windows/gdi/mesa.def21
-rw-r--r--src/mesa/drivers/windows/gdi/wgl.c1001
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c4047
-rw-r--r--src/mesa/drivers/windows/gdi/wmesadef.h179
5 files changed, 1500 insertions, 4284 deletions
diff --git a/src/mesa/drivers/windows/gdi/colors.h b/src/mesa/drivers/windows/gdi/colors.h
index 5ee66e829d..03e512c1fa 100644
--- a/src/mesa/drivers/windows/gdi/colors.h
+++ b/src/mesa/drivers/windows/gdi/colors.h
@@ -1,110 +1,3 @@
-/* File name : colors.h
- * Version : 2.3
- *
- * Header file for display driver for Mesa 2.3 under
- * Windows95 and WindowsNT
- * This file defines macros and global variables needed
- * for converting color format
- *
- * Copyright (C) 1996- Li Wei
- * Address : Institute of Artificial Intelligence
- * : & Robotics
- * : Xi'an Jiaotong University
- * Email : liwei@aiar.xjtu.edu.cn
- * Web page : http://sun.aiar.xjtu.edu.cn
- *
- * This file and its associations are partially based on the
- * Windows NT driver for Mesa, written by Mark Leaming
- * (mark@rsinc.com).
- */
-
-/* $Log: ddcolors.h 1997/6/14 by Li Wei(liwei@aiar.xjtu.edu.cn)
- * Macros for pixel format defined
- */
-
-/*
- * $Log: colors.h,v $
- * Revision 1.2 2004/08/25 15:59:48 brianp
- * Silence gcc 3.4 warnings on ReactOS. Mostly unused var warnings. (patch 1015696)
- *
- * Revision 1.1 2003/07/24 03:47:46 kschultz
- * Source code for GDI driver.
- *
- * Revision 1.3 2002/01/15 18:14:34 kschultz
- * Fixed pixel color component problem and clear code for 24-bit Windows
- * devices. (Jeff Lewis)
- *
- * Revision 1.2 2002/01/15 18:11:36 kschultz
- * Remove trailing CR's. No logical changes.
- *
- * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
- * Imported sources
- *
- * Revision 1.2 1999/01/03 03:08:57 brianp
- * Ted Jump's changes
- *
- * Revision 1.1 1999/01/03 03:08:12 brianp
- * Initial revision
- *
- * Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- * Add LUTs need for dithering
- */
-
-/*
- * $Log: colors.h,v $
- * Revision 1.2 2004/08/25 15:59:48 brianp
- * Silence gcc 3.4 warnings on ReactOS. Mostly unused var warnings. (patch 1015696)
- *
- * Revision 1.1 2003/07/24 03:47:46 kschultz
- * Source code for GDI driver.
- *
- * Revision 1.3 2002/01/15 18:14:34 kschultz
- * Fixed pixel color component problem and clear code for 24-bit Windows
- * devices. (Jeff Lewis)
- *
- * Revision 1.2 2002/01/15 18:11:36 kschultz
- * Remove trailing CR's. No logical changes.
- *
- * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
- * Imported sources
- *
- * Revision 1.2 1999/01/03 03:08:57 brianp
- * Ted Jump's changes
- *
- * Revision 1.1 1999/01/03 03:08:12 brianp
- * Initial revision
- *
- * Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- * Add BGR8 Macro
- */
-
-/*
- * $Log: colors.h,v $
- * Revision 1.2 2004/08/25 15:59:48 brianp
- * Silence gcc 3.4 warnings on ReactOS. Mostly unused var warnings. (patch 1015696)
- *
- * Revision 1.1 2003/07/24 03:47:46 kschultz
- * Source code for GDI driver.
- *
- * Revision 1.3 2002/01/15 18:14:34 kschultz
- * Fixed pixel color component problem and clear code for 24-bit Windows
- * devices. (Jeff Lewis)
- *
- * Revision 1.2 2002/01/15 18:11:36 kschultz
- * Remove trailing CR's. No logical changes.
- *
- * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
- * Imported sources
- *
- * Revision 1.2 1999/01/03 03:08:57 brianp
- * Ted Jump's changes
- *
- * Revision 1.1 1999/01/03 03:08:12 brianp
- * Initial revision
- *
- * Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- * Initial revision
- */
/* Values for wmesa->pixelformat: */
#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
@@ -114,426 +7,23 @@
#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
#define PF_BADFORMAT 11
-#define PF_INDEX8 12
-
-char ColorMap16[] = {
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
-0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
-0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
-0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
-0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
-0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
-0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
-0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
-0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
-0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
-0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
-0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
-0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
-0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
-0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
-0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
-0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
-0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
-0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
-0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
-0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
-0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
-0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
-0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
-0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
-0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
-0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
-
-#define BGR8(r,g,b) (unsigned)(((BYTE)((b & 0xc0) | ((g & 0xe0)>>2) | ((r & 0xe0)>>5))))
-#ifdef DDRAW
-#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
-#else
-#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
-#endif
-#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
-
-#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
-
-
-
-/*
- * If pixelformat==PF_8A8B8G8R:
- */
-#define PACK_8A8B8G8R( R, G, B, A ) \
- ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
-
-
-/*
- * If pixelformat==PF_8R8G8B:
- */
-#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
-
-
-/*
- * If pixelformat==PF_5R6G5B:
- */
-
-
-#ifdef DDRAW
-#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
-#else
-#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
-#endif
-/*----------------------------------------------------------------------------
-
-Division lookup tables. These tables compute 0-255 divided by 51 and
-modulo 51. These tables could approximate gamma correction.
-
-*/
-
-char unsigned const aDividedBy51Rounded[256] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-
-char unsigned const aDividedBy51[256] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
-};
-
-char unsigned const aModulo51[256] =
-{
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
-};
-
-/*----------------------------------------------------------------------------
-
-Multiplication LUTs. These compute 0-5 times 6 and 36.
-
-*/
-
-char unsigned const aTimes6[6] =
-{
- 0, 6, 12, 18, 24, 30
-};
-
-char unsigned const aTimes36[6] =
-{
- 0, 36, 72, 108, 144, 180
-};
-
-
-/*----------------------------------------------------------------------------
-
-Dither matrices for 8 bit to 2.6 bit halftones.
-
-*/
+#define PF_INDEX8 12
-char unsigned const aHalftone16x16[256] =
-{
- 0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
- 34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
- 38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
- 22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
- 2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
- 37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
- 40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
- 24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
- 2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
- 37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
- 40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
- 24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
- 1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
- 36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
- 39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
- 23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
-};
-char unsigned const aHalftone8x8[64] =
-{
- 0, 38, 9, 47, 2, 40, 11, 50,
- 25, 12, 35, 22, 27, 15, 37, 24,
- 6, 44, 3, 41, 8, 47, 5, 43,
- 31, 19, 28, 15, 34, 21, 31, 18,
- 1, 39, 11, 49, 0, 39, 10, 48,
- 27, 14, 36, 23, 26, 13, 35, 23,
- 7, 46, 4, 43, 7, 45, 3, 42,
- 33, 20, 30, 17, 32, 19, 29, 16,
-};
+#define BGR8(r,g,b) (unsigned)(((BYTE)((b & 0xc0) | ((g & 0xe0)>>2) | \
+ ((r & 0xe0)>>5))))
-char unsigned const aHalftone4x4_1[16] =
-{
- 0, 25, 6, 31,
- 38, 12, 44, 19,
- 9, 35, 3, 28,
- 47, 22, 41, 15
-};
+/* Windows uses 5,5,5 for 16-bit */
+#define BGR16(r,g,b) ( (((unsigned short)b ) >> 3) | \
+ (((unsigned short)g & 0xf8) << 2) | \
+ (((unsigned short)r & 0xf8) << 7) )
-char unsigned const aHalftone4x4_2[16] =
-{
- 41, 3, 9, 28,
- 35, 15, 22, 47,
- 6, 25, 38, 0,
- 19, 44, 31, 12
-};
+#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \
+ ((WORD)((BYTE)(g))<<8))| \
+ (((DWORD)(BYTE)(r))<<16)))
-/***************************************************************************
- aWinGHalftoneTranslation
+#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \
+ ((WORD)((BYTE)(g))<<8))| \
+ (((DWORD)(BYTE)(r))<<16)))
- Translates a 2.6 bit-per-pixel halftoned representation into the
- slightly rearranged WinG Halftone Palette.
-*/
-char unsigned const aWinGHalftoneTranslation[216] =
-{
- 0,
- 29,
- 30,
- 31,
- 32,
- 249,
- 33,
- 34,
- 35,
- 36,
- 37,
- 38,
- 39,
- 40,
- 41,
- 42,
- 43,
- 44,
- 45,
- 46,
- 47,
- 48,
- 49,
- 50,
- 51,
- 52,
- 53,
- 54,
- 55,
- 56,
- 250,
- 250,
- 57,
- 58,
- 59,
- 251,
- 60,
- 61,
- 62,
- 63,
- 64,
- 65,
- 66,
- 67,
- 68,
- 69,
- 70,
- 71,
- 72,
- 73,
- 74,
- 75,
- 76,
- 77,
- 78,
- 79,
- 80,
- 81,
- 82,
- 83,
- 84,
- 85,
- 86,
- 87,
- 88,
- 89,
- 250,
- 90,
- 91,
- 92,
- 93,
- 94,
- 95,
- 96,
- 97,
- 98,
- 99,
- 100,
- 101,
- 102,
- 103,
- 104,
- 105,
- 106,
- 107,
- 108,
- 109,
- 110,
- 111,
- 227,
- 112,
- 113,
- 114,
- 115,
- 116,
- 117,
- 118,
- 119,
- 151,
- 120,
- 121,
- 122,
- 123,
- 124,
- 228,
- 125,
- 126,
- 229,
- 133,
- 162,
- 135,
- 131,
- 132,
- 137,
- 166,
- 134,
- 140,
- 130,
- 136,
- 143,
- 138,
- 139,
- 174,
- 141,
- 142,
- 177,
- 129,
- 144,
- 145,
- 146,
- 147,
- 148,
- 149,
- 150,
- 157,
- 152,
- 153,
- 154,
- 155,
- 156,
- 192,
- 158,
- 159,
- 160,
- 161,
- 196,
- 163,
- 164,
- 165,
- 127,
- 199,
- 167,
- 168,
- 169,
- 170,
- 171,
- 172,
- 173,
- 207,
- 175,
- 176,
- 210,
- 178,
- 179,
- 180,
- 181,
- 182,
- 183,
- 184,
- 185,
- 186,
- 187,
- 188,
- 189,
- 190,
- 191,
- 224,
- 193,
- 194,
- 195,
- 252,
- 252,
- 197,
- 198,
- 128,
- 253,
- 252,
- 200,
- 201,
- 202,
- 203,
- 204,
- 205,
- 206,
- 230,
- 208,
- 209,
- 231,
- 211,
- 212,
- 213,
- 214,
- 215,
- 216,
- 217,
- 218,
- 219,
- 220,
- 221,
- 222,
- 254,
- 223,
- 232,
- 225,
- 226,
- 255,
-};
diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def
index a393149b0a..7b67c5ccb9 100644
--- a/src/mesa/drivers/windows/gdi/mesa.def
+++ b/src/mesa/drivers/windows/gdi/mesa.def
@@ -976,9 +976,13 @@ EXPORTS
_ac_InvalidateState
_glapi_get_context
_glapi_get_proc_address
+ _mesa_add_soft_renderbuffers
+ _mesa_add_renderbuffer
_mesa_buffer_data
+ _mesa_buffer_get_subdata
_mesa_buffer_map
_mesa_buffer_subdata
+ _mesa_buffer_unmap
_mesa_bzero
_mesa_calloc
_mesa_choose_tex_format
@@ -986,6 +990,7 @@ EXPORTS
_mesa_create_framebuffer
_mesa_create_visual
_mesa_delete_buffer_object
+ _mesa_delete_program
_mesa_delete_texture_object
_mesa_destroy_framebuffer
_mesa_destroy_visual
@@ -994,19 +999,31 @@ EXPORTS
_mesa_enable_1_5_extensions
_mesa_enable_sw_extensions
_mesa_error
+ _mesa_framebuffer_renderbuffer
_mesa_free
_mesa_free_context_data
+ _mesa_free_texture_image_data
+ _mesa_get_compressed_teximage
_mesa_get_current_context
+ _mesa_get_teximage
_mesa_init_default_imports
_mesa_init_driver_functions
+ _mesa_init_renderbuffer
_mesa_initialize_context
_mesa_make_current
_mesa_memcpy
_mesa_memset
_mesa_new_buffer_object
+ _mesa_new_framebuffer
+ _mesa_new_program
+ _mesa_new_soft_renderbuffer
+ _mesa_new_texture_image
_mesa_new_texture_object
_mesa_problem
+ _mesa_renderbuffer_texture
_mesa_ResizeBuffersMESA
+ _mesa_resize_framebuffer
+; _mesa_resize_renderbuffer
_mesa_store_compressed_teximage1d
_mesa_store_compressed_teximage2d
_mesa_store_compressed_teximage3d
@@ -1023,7 +1040,7 @@ EXPORTS
_mesa_test_proxy_teximage
_mesa_Viewport
_swrast_Accum
- _swrast_alloc_buffers
+; _swrast_alloc_buffers
_swrast_Bitmap
_swrast_CopyPixels
_swrast_DrawBuffer
@@ -1045,7 +1062,7 @@ EXPORTS
_swrast_DestroyContext
_swrast_InvalidateState
_swrast_ReadPixels
- _swrast_zbuffer_address
+; _swrast_zbuffer_address
_swsetup_Wakeup
_swsetup_CreateContext
_swsetup_DestroyContext
diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c
index 920929c42e..7f7937c77d 100644
--- a/src/mesa/drivers/windows/gdi/wgl.c
+++ b/src/mesa/drivers/windows/gdi/wgl.c
@@ -1,96 +1,143 @@
-/* $Id: wgl.c,v 1.6 2004/08/30 08:37:57 dborca Exp $ */
+/* $Id: wgl.c,v 1.7 2005/05/24 21:12:43 kschultz Exp $ */
/*
-* 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.
-*
-*/
+ * 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.
+ *
+ */
/*
-* File name : wgl.c
-* WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru
-* Some things originated from the 3Dfx WGL functions
-*/
+ * File name : wgl.c
+ * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru
+ * Some things originated from the 3Dfx WGL functions
+ */
-#ifdef WIN32
+/*
+ * This file contains the implementation of the wgl* functions for
+ * Mesa on Windows. Since these functions are provided by Windows in
+ * GDI/OpenGL, we must supply our versions that work with Mesa here.
+ */
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* We're essentially building part of GDI here, so define this so that
+ * we get the right export linkage. */
+#define _GDI32_
#include <windows.h>
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
-//#include <GL/glu.h>
-
-#ifdef __cplusplus
-}
-#endif
-#include <stdio.h>
-#include <tchar.h>
-#include "wmesadef.h"
-#include "GL/wmesa.h"
-#include "mtypes.h"
-#include "glapi.h"
+#include "wmesadef.h" /* headers for Mesa Windows driver source code */
+#include "GL/wmesa.h" /* protos for wmesa* functions */
-#define MAX_MESA_ATTRS 20
+/*
+ * Pixel Format Descriptors
+ */
+/* Extend the PFD to include DB flag */
struct __pixelformat__
{
- PIXELFORMATDESCRIPTOR pfd;
+ PIXELFORMATDESCRIPTOR pfd;
GLboolean doubleBuffered;
};
-struct __pixelformat__ pix[] =
+/* These are the PFD's supported by this driver. */
+struct __pixelformat__ pfd[] =
{
+#if 0
/* Double Buffer, alpha */
- { { sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 24, 8, 0, 8, 8, 8, 16, 8, 24,
- 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ {
+ {
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
+ PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 24,
+ 8, 0,
+ 8, 8,
+ 8, 16,
+ 8, 24,
+ 0, 0, 0, 0, 0,
+ 16, 8,
+ 0, 0, 0,
+ 0, 0, 0
+ },
GL_TRUE
},
/* Single Buffer, alpha */
- { { sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
- PFD_TYPE_RGBA,
- 24, 8, 0, 8, 8, 8, 16, 8, 24,
- 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ {
+ {
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
+ PFD_GENERIC_FORMAT,
+ PFD_TYPE_RGBA,
+ 24,
+ 8, 0,
+ 8, 8,
+ 8, 16,
+ 8, 24,
+ 0, 0, 0, 0, 0,
+ 16, 8,
+ 0, 0, 0,
+ 0, 0, 0
+ },
GL_FALSE
},
+#endif
/* Double Buffer, no alpha */
- { { sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 24, 8, 0, 8, 8, 8, 16, 0, 0,
- 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ {
+ {
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
+ PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 24,
+ 8, 0,
+ 8, 8,
+ 8, 16,
+ 0, 0,
+ 0, 0, 0, 0, 0,
+ 16, 8,
+ 0, 0, 0,
+ 0, 0, 0
+ },
GL_TRUE
},
/* Single Buffer, no alpha */
- { { sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
- PFD_TYPE_RGBA,
- 24, 8, 0, 8, 8, 8, 16, 0, 0,
- 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ {
+ {
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
+ PFD_GENERIC_FORMAT,
+ PFD_TYPE_RGBA,
+ 24,
+ 8, 0,
+ 8, 8,
+ 8, 16,
+ 0, 0,
+ 0, 0, 0, 0, 0,
+ 16, 8,
+ 0, 0, 0,
+ 0, 0, 0
+ },
GL_FALSE
},
};
-int qt_pix = sizeof(pix) / sizeof(pix[0]);
+int npfd = sizeof(pfd) / sizeof(pfd[0]);
+
+
+/*
+ * Contexts
+ */
typedef struct {
WMesaContext ctx;
@@ -105,36 +152,27 @@ static unsigned ctx_count = 0;
static int ctx_current = -1;
static unsigned curPFD = 0;
-WGLAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,HGLRC hglrcDst,UINT mask)
-{
- (void) hglrcSrc; (void) hglrcDst; (void) mask;
- return(FALSE);
-}
-
-WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
+WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
{
- HWND hWnd;
+ HWND hWnd;
int i = 0;
- if(!(hWnd = WindowFromDC(hdc)))
- {
- SetLastError(0);
- return(NULL);
+ if(!(hWnd = WindowFromDC(hdc))) {
+ SetLastError(0);
+ return(NULL);
}
- if (!ctx_count)
- {
- for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++)
- {
- wgl_ctx[i].ctx = NULL;
- wgl_ctx[i].hdc = NULL;
- }
+ if (!ctx_count) {
+ for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) {
+ wgl_ctx[i].ctx = NULL;
+ wgl_ctx[i].hdc = NULL;
+ }
}
- for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
- {
- if ( wgl_ctx[i].ctx == NULL )
- {
- wgl_ctx[i].ctx = WMesaCreateContext( hWnd, NULL, GL_TRUE,
- pix[curPFD-1].doubleBuffered,
- pix[curPFD-1].pfd.cAlphaBits ? GL_TRUE : GL_FALSE);
+ for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
+ if ( wgl_ctx[i].ctx == NULL ) {
+ wgl_ctx[i].ctx =
+ WMesaCreateContext(hWnd, NULL, GL_TRUE,
+ pfd[curPFD-1].doubleBuffered,
+ pfd[curPFD-1].pfd.cAlphaBits ?
+ GL_TRUE : GL_FALSE);
if (wgl_ctx[i].ctx == NULL)
break;
wgl_ctx[i].hdc = hdc;
@@ -146,13 +184,11 @@ WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
return(NULL);
}
-WGLAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
+WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
{
int i;
- for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
- {
- if ( wgl_ctx[i].ctx == (PWMC) hglrc )
- {
+ for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
+ if ( wgl_ctx[i].ctx == (PWMC) hglrc ){
WMesaMakeCurrent((PWMC) hglrc);
WMesaDestroyContext();
wgl_ctx[i].ctx = NULL;
@@ -165,59 +201,171 @@ WGLAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
return(FALSE);
}
-WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,int iLayerPlane)
+WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
{
- (void) hdc; (void) iLayerPlane;
- SetLastError(0);
- return(NULL);
+ if (ctx_current < 0)
+ return 0;
+ else
+ return (HGLRC) wgl_ctx[ctx_current].ctx;
}
-WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
+WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID)
{
- if (ctx_current < 0)
- return 0;
- else
- return (HGLRC) wgl_ctx[ctx_current].ctx;
+ if (ctx_current < 0)
+ return 0;
+ else
+ return wgl_ctx[ctx_current].hdc;
}
-WGLAPI HDC GLAPIENTRY wglGetCurrentDC(VOID)
+WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
{
- if (ctx_current < 0)
- return 0;
- else
- return wgl_ctx[ctx_current].hdc;
+ int i;
+
+ if (!hdc || !hglrc) {
+ WMesaMakeCurrent(NULL);
+ ctx_current = -1;
+ return TRUE;
+ }
+
+ for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
+ if ( wgl_ctx[i].ctx == (PWMC) hglrc ) {
+ wgl_ctx[i].hdc = hdc;
+ WMesaMakeCurrent( (WMesaContext) hglrc );
+ ctx_current = i;
+ return TRUE;
+ }
+ }
+ return FALSE;
}
-WGLAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
+
+WINGDIAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
+ CONST
+ PIXELFORMATDESCRIPTOR *ppfd)
{
- int i;
+ int i,best = -1,bestdelta = 0x7FFFFFFF,delta;
+ (void) hdc;
+
+ if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1)
+ {
+ SetLastError(0);
+ return(0);
+ }
+ for(i = 0; i < npfd;i++)
+ {
+ delta = 0;
+ if(
+ (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) &&
+ !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
+ continue;
+ if(
+ (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) &&
+ !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
+ continue;
+ if(
+ (ppfd->dwFlags & PFD_SUPPORT_GDI) &&
+ !(pfd[i].pfd.dwFlags & PFD_SUPPORT_GDI))
+ continue;
+ if(
+ (ppfd->dwFlags & PFD_SUPPORT_OPENGL) &&
+ !(pfd[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ continue;
+ if(
+ !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
+ ((ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
+ (pfd[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
+ continue;
+ if(
+ !(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
+ ((ppfd->dwFlags & PFD_STEREO) !=
+ (pfd[i].pfd.dwFlags & PFD_STEREO)))
+ continue;
+ if(ppfd->iPixelType != pfd[i].pfd.iPixelType)
+ delta++;
+ if(ppfd->cAlphaBits != pfd[i].pfd.cAlphaBits)
+ delta++;
+ if(delta < bestdelta)
+ {
+ best = i + 1;
+ bestdelta = delta;
+ if(bestdelta == 0)
+ break;
+ }
+ }
+ if(best == -1)
+ {
+ SetLastError(0);
+ return(0);
+ }
+ return(best);
+}
- /* new code suggested by Andy Sy */
- if (!hdc || !hglrc) {
- WMesaMakeCurrent(NULL);
- ctx_current = -1;
- return TRUE;
- }
+WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd)
+{
+ (void) hdc;
+
+ if(ppfd == NULL)
+ return(npfd);
+ if(iPixelFormat < 1 || iPixelFormat > npfd ||
+ nBytes != sizeof(PIXELFORMATDESCRIPTOR))
+ {
+ SetLastError(0);
+ return(0);
+ }
+ *ppfd = pfd[iPixelFormat - 1].pfd;
+ return(npfd);
+}
- for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
- {
- if ( wgl_ctx[i].ctx == (PWMC) hglrc )
- {
- wgl_ctx[i].hdc = hdc;
- WMesaMakeCurrent( (WMesaContext) hglrc );
- ctx_current = i;
- return TRUE;
- }
+WINGDIAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc)
+{
+ PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc);
+ if (p)
+ return p;
+
+ SetLastError(0);
+ return(NULL);
+}
+
+WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc)
+{
+ (void) hdc;
+ if(curPFD == 0) {
+ SetLastError(0);
+ return(0);
}
- return FALSE;
+ return(curPFD);
}
-WGLAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,HGLRC hglrc2)
+WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
+ PIXELFORMATDESCRIPTOR *ppfd)
{
- (void) hglrc1; (void) hglrc2;
+ (void) hdc;
+
+ if(iPixelFormat < 1 || iPixelFormat > npfd ||
+ ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
+ SetLastError(0);
+ return(FALSE);
+ }
+ curPFD = iPixelFormat;
return(TRUE);
}
+WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
+{
+ (void) hdc;
+ if (ctx_current < 0)
+ return FALSE;
+
+ if(wgl_ctx[ctx_current].ctx == NULL) {
+ SetLastError(0);
+ return(FALSE);
+ }
+ WMesaSwapBuffers();
+ return(TRUE);
+}
static FIXED FixedFromDouble(double d)
{
@@ -236,209 +384,238 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
DWORD numChars, DWORD listBase)
{
#define VERIFY(a) a
-
- TEXTMETRIC metric;
- BITMAPINFO *dibInfo;
- HDC bitDevice;
- COLORREF tempColor;
- int i;
-
- VERIFY(GetTextMetrics(fontDevice, &metric));
-
- dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
- dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibInfo->bmiHeader.biPlanes = 1;
- dibInfo->bmiHeader.biBitCount = 1;
- dibInfo->bmiHeader.biCompression = BI_RGB;
-
- bitDevice = CreateCompatibleDC(fontDevice);
- // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
- // VERIFY(bitDevice);
-
- // Swap fore and back colors so the bitmap has the right polarity
- tempColor = GetBkColor(bitDevice);
- SetBkColor(bitDevice, GetTextColor(bitDevice));
- SetTextColor(bitDevice, tempColor);
-
- // Place chars based on base line
- VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0);
-
- for(i = 0; i < (int)numChars; i++) {
- SIZE size;
- char curChar;
- int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res;
- HBITMAP bitObject;
- HGDIOBJ origBmap;
- unsigned char *bmap;
-
- curChar = i + firstChar;
-
- // Find how high/wide this character is
- VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
-
- // Create the output bitmap
- charWidth = size.cx;
- charHeight = size.cy;
- bmapWidth = ((charWidth + 31) / 32) * 32; // Round up to the next multiple of 32 bits
- bmapHeight = charHeight;
- bitObject = CreateCompatibleBitmap(bitDevice,
- bmapWidth,
- bmapHeight);
- //VERIFY(bitObject);
-
- // Assign the output bitmap to the device
- origBmap = SelectObject(bitDevice, bitObject);
- (void) VERIFY(origBmap);
-
- VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
-
- // Use our source font on the device
- VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
-
- // Draw the character
- VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
-
- // Unselect our bmap object
- VERIFY(SelectObject(bitDevice, origBmap));
-
- // Convert the display dependant representation to a 1 bit deep DIB
- numBytes = (bmapWidth * bmapHeight) / 8;
- bmap = malloc(numBytes);
- dibInfo->bmiHeader.biWidth = bmapWidth;
- dibInfo->bmiHeader.biHeight = bmapHeight;
- res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
- dibInfo,
- DIB_RGB_COLORS);
- //VERIFY(res);
-
- // Create the GL object
- glNewList(i + listBase, GL_COMPILE);
- glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
- charWidth, 0.0,
- bmap);
- glEndList();
- // CheckGL();
-
- // Destroy the bmap object
- DeleteObject(bitObject);
-
- // Deallocate the bitmap data
- free(bmap);
- }
-
- // Destroy the DC
- VERIFY(DeleteDC(bitDevice));
-
- free(dibInfo);
-
- return TRUE;
+
+ TEXTMETRIC metric;
+ BITMAPINFO *dibInfo;
+ HDC bitDevice;
+ COLORREF tempColor;
+ int i;
+
+ VERIFY(GetTextMetrics(fontDevice, &metric));
+
+ dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
+ dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ dibInfo->bmiHeader.biPlanes = 1;
+ dibInfo->bmiHeader.biBitCount = 1;
+ dibInfo->bmiHeader.biCompression = BI_RGB;
+
+ bitDevice = CreateCompatibleDC(fontDevice);
+
+ // Swap fore and back colors so the bitmap has the right polarity
+ tempColor = GetBkColor(bitDevice);
+ SetBkColor(bitDevice, GetTextColor(bitDevice));
+ SetTextColor(bitDevice, tempColor);
+
+ // Place chars based on base line
+ VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0);
+
+ for(i = 0; i < (int)numChars; i++) {
+ SIZE size;
+ char curChar;
+ int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res;
+ HBITMAP bitObject;
+ HGDIOBJ origBmap;
+ unsigned char *bmap;
+
+ curChar = i + firstChar;
+
+ // Find how high/wide this character is
+ VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
+
+ // Create the output bitmap
+ charWidth = size.cx;
+ charHeight = size.cy;
+ // Round up to the next multiple of 32 bits
+ bmapWidth = ((charWidth + 31) / 32) * 32;
+ bmapHeight = charHeight;
+ bitObject = CreateCompatibleBitmap(bitDevice,
+ bmapWidth,
+ bmapHeight);
+ //VERIFY(bitObject);
+
+ // Assign the output bitmap to the device
+ origBmap = SelectObject(bitDevice, bitObject);
+ (void) VERIFY(origBmap);
+
+ VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
+
+ // Use our source font on the device
+ VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
+
+ // Draw the character
+ VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
+
+ // Unselect our bmap object
+ VERIFY(SelectObject(bitDevice, origBmap));
+
+ // Convert the display dependant representation to a 1 bit deep DIB
+ numBytes = (bmapWidth * bmapHeight) / 8;
+ bmap = malloc(numBytes);
+ dibInfo->bmiHeader.biWidth = bmapWidth;
+ dibInfo->bmiHeader.biHeight = bmapHeight;
+ res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
+ dibInfo,
+ DIB_RGB_COLORS);
+ //VERIFY(res);
+
+ // Create the GL object
+ glNewList(i + listBase, GL_COMPILE);
+ glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
+ charWidth, 0.0,
+ bmap);
+ glEndList();
+ // CheckGL();
+
+ // Destroy the bmap object
+ DeleteObject(bitObject);
+
+ // Deallocate the bitmap data
+ free(bmap);
+ }
+
+ // Destroy the DC
+ VERIFY(DeleteDC(bitDevice));
+
+ free(dibInfo);
+
+ return TRUE;
#undef VERIFY
}
-WGLAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,
- DWORD count, DWORD listBase)
+WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,
+ DWORD count, DWORD listBase)
{
- int i;
- GLuint font_list;
- DWORD size;
- GLYPHMETRICS gm;
- HANDLE hBits;
- LPSTR lpBits;
- MAT2 mat;
- int success = TRUE;
-
- if (count == 0)
- return FALSE;
-
- font_list = listBase;
-
- mat.eM11 = FixedFromDouble(1);
- mat.eM12 = FixedFromDouble(0);
- mat.eM21 = FixedFromDouble(0);
- mat.eM22 = FixedFromDouble(-1);
-
- memset(&gm,0,sizeof(gm));
-
- /*
- ** If we can't get the glyph outline, it may be because this is a fixed
- ** font. Try processing it that way.
- */
- if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat)
- == GDI_ERROR )
- {
- return wglUseFontBitmaps_FX( hdc, first, count, listBase );
- }
-
- /*
- ** Otherwise process all desired characters.
- */
- for (i = 0; i < (int)count; i++)
- {
- DWORD err;
-
- glNewList( font_list+i, GL_COMPILE );
-
- /* allocate space for the bitmap/outline */
- size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, 0, NULL, &mat);
- if (size == GDI_ERROR)
- {
- glEndList( );
- err = GetLastError();
- success = FALSE;
- continue;
- }
-
- hBits = GlobalAlloc(GHND, size+1);
- lpBits = GlobalLock(hBits);
-
- err =
- GetGlyphOutline(hdc, /* handle to device context */
- first + i, /* character to query */
- GGO_BITMAP, /* format of data to return */
- &gm, /* pointer to structure for metrics*/
- size, /* size of buffer for data */
- lpBits, /* pointer to buffer for data */
- &mat /* pointer to transformation */
- /* matrix structure */
- );
-
- if (err == GDI_ERROR)
- {
- GlobalUnlock(hBits);
- GlobalFree(hBits);
-
- glEndList( );
- err = GetLastError();
- success = FALSE;
- continue;
- }
-
- glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY,
- -gm.gmptGlyphOrigin.x,
- gm.gmptGlyphOrigin.y,
- gm.gmCellIncX,gm.gmCellIncY,
- (const GLubyte * )lpBits);
-
- GlobalUnlock(hBits);
- GlobalFree(hBits);
-
- glEndList( );
- }
-
- return success;
+ int i;
+ GLuint font_list;
+ DWORD size;
+ GLYPHMETRICS gm;
+ HANDLE hBits;
+ LPSTR lpBits;
+ MAT2 mat;
+ int success = TRUE;
+
+ if (count == 0)
+ return FALSE;
+
+ font_list = listBase;
+
+ mat.eM11 = FixedFromDouble(1);
+ mat.eM12 = FixedFromDouble(0);
+ mat.eM21 = FixedFromDouble(0);
+ mat.eM22 = FixedFromDouble(-1);
+
+ memset(&gm,0,sizeof(gm));
+
+ /*
+ ** If we can't get the glyph outline, it may be because this is a fixed
+ ** font. Try processing it that way.
+ */
+ if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat)
+ == GDI_ERROR ) {
+ return wglUseFontBitmaps_FX( hdc, first, count, listBase );
+ }
+
+ /*
+ ** Otherwise process all desired characters.
+ */
+ for (i = 0; i < (int)count; i++) {
+ DWORD err;
+
+ glNewList( font_list+i, GL_COMPILE );
+
+ /* allocate space for the bitmap/outline */
+ size = GetGlyphOutline(hdc, first + i, GGO_BITMAP,
+ &gm, 0, NULL, &mat);
+ if (size == GDI_ERROR) {
+ glEndList( );
+ err = GetLastError();
+ success = FALSE;
+ continue;
+ }
+
+ hBits = GlobalAlloc(GHND, size+1);
+ lpBits = GlobalLock(hBits);
+
+ err =
+ GetGlyphOutline(hdc, /* handle to device context */
+ first + i, /* character to query */
+ GGO_BITMAP, /* format of data to return */
+ &gm, /* ptr to structure for metrics*/
+ size, /* size of buffer for data */
+ lpBits, /* pointer to buffer for data */
+ &mat /* pointer to transformation */
+ /* matrix structure */
+ );
+
+ if (err == GDI_ERROR) {
+ GlobalUnlock(hBits);
+ GlobalFree(hBits);
+
+ glEndList( );
+ err = GetLastError();
+ success = FALSE;
+ continue;
+ }
+
+ glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY,
+ -gm.gmptGlyphOrigin.x,
+ gm.gmptGlyphOrigin.y,
+ gm.gmCellIncX,gm.gmCellIncY,
+ (const GLubyte * )lpBits);
+
+ GlobalUnlock(hBits);
+ GlobalFree(hBits);
+
+ glEndList( );
+ }
+
+ return success;
}
-WGLAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,DWORD first,DWORD count,DWORD listBase)
+
+/* NOT IMPLEMENTED YET */
+WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,
+ HGLRC hglrcDst,
+ UINT mask)
+{
+ (void) hglrcSrc; (void) hglrcDst; (void) mask;
+ return(FALSE);
+}
+
+WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,
+ int iLayerPlane)
+{
+ (void) hdc; (void) iLayerPlane;
+ SetLastError(0);
+ return(NULL);
+}
+
+WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,
+ HGLRC hglrc2)
+{
+ (void) hglrc1; (void) hglrc2;
+ return(TRUE);
+}
+
+
+WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase)
{
(void) hdc; (void) first; (void) count; (void) listBase;
return FALSE;
}
-WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
+WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase,
+ FLOAT deviation,
+ FLOAT extrusion,
+ int format,
+ LPGLYPHMETRICSFLOAT lpgmf)
{
(void) hdc; (void) first; (void) count;
(void) listBase; (void) deviation; (void) extrusion; (void) format;
@@ -447,10 +624,14 @@ WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
return(FALSE);
}
-WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
+WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase,
+ FLOAT deviation,
+ FLOAT extrusion,
+ int format,
+ LPGLYPHMETRICSFLOAT lpgmf)
{
(void) hdc; (void) first; (void) count;
(void) listBase; (void) deviation; (void) extrusion; (void) format;
@@ -459,181 +640,55 @@ WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
return(FALSE);
}
-WGLAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
- int iLayerPlane,UINT nBytes,
- LPLAYERPLANEDESCRIPTOR plpd)
+WINGDIAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nBytes,
+ LPLAYERPLANEDESCRIPTOR plpd)
{
- (void) hdc; (void) iPixelFormat; (void) iLayerPlane; (void) nBytes; (void) plpd;
+ (void) hdc; (void) iPixelFormat; (void) iLayerPlane;
+ (void) nBytes; (void) plpd;
SetLastError(0);
return(FALSE);
}
-WGLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc,int iLayerPlane,
- int iStart,int cEntries,
- CONST COLORREF *pcr)
+WINGDIAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc,
+ int iLayerPlane,
+ int iStart,
+ int cEntries,
+ CONST COLORREF *pcr)
{
- (void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr;
+ (void) hdc; (void) iLayerPlane; (void) iStart;
+ (void) cEntries; (void) pcr;
SetLastError(0);
return(0);
}
-WGLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc,int iLayerPlane,
- int iStart,int cEntries,
- COLORREF *pcr)
+WINGDIAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc,
+ int iLayerPlane,
+ int iStart,
+ int cEntries,
+ COLORREF *pcr)
{
(void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr;
SetLastError(0);
return(0);
}
-WGLAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc,int iLayerPlane,BOOL bRealize)
+WINGDIAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc,
+ int iLayerPlane,
+ BOOL bRealize)
{
(void) hdc; (void) iLayerPlane; (void) bRealize;
SetLastError(0);
return(FALSE);
}
-WGLAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,UINT fuPlanes)
+WINGDIAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,
+ UINT fuPlanes)
{
- (void) fuPlanes;
- if( !hdc )
- {
- WMesaSwapBuffers();
- return(TRUE);
- }
+ (void) hdc; (void) fuPlanes;
SetLastError(0);
return(FALSE);
}
-WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
-{
- int i,best = -1,bestdelta = 0x7FFFFFFF,delta,qt_valid_pix;
- (void) hdc;
-
- qt_valid_pix = qt_pix;
- if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1)
- {
- SetLastError(0);
- return(0);
- }
- for(i = 0;i < qt_valid_pix;i++)
- {
- delta = 0;
- if(
- (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) &&
- !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
- continue;
- if(
- (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) &&
- !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
- continue;
- if(
- (ppfd->dwFlags & PFD_SUPPORT_GDI) &&
- !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI))
- continue;
- if(
- (ppfd->dwFlags & PFD_SUPPORT_OPENGL) &&
- !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
- continue;
- if(
- !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
- ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
- continue;
- if(
- !(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
- ((ppfd->dwFlags & PFD_STEREO) != (pix[i].pfd.dwFlags & PFD_STEREO)))
- continue;
- if(ppfd->iPixelType != pix[i].pfd.iPixelType)
- delta++;
- if(ppfd->cAlphaBits != pix[i].pfd.cAlphaBits)
- delta++;
- if(delta < bestdelta)
- {
- best = i + 1;
- bestdelta = delta;
- if(bestdelta == 0)
- break;
- }
- }
- if(best == -1)
- {
- SetLastError(0);
- return(0);
- }
- return(best);
-}
-
-WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd)
-{
- int qt_valid_pix;
- (void) hdc;
-
- qt_valid_pix = qt_pix;
- if(ppfd == NULL)
- return(qt_valid_pix);
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || nBytes != sizeof(PIXELFORMATDESCRIPTOR))
- {
- SetLastError(0);
- return(0);
- }
- *ppfd = pix[iPixelFormat - 1].pfd;
- return(qt_valid_pix);
-}
-
-/*
-* GetProcAddress - return the address of an appropriate extension
-*/
-WGLAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc)
-{
- PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc);
- if (p)
- return p;
-
- SetLastError(0);
- return(NULL);
-}
-
-WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc)
-{
- (void) hdc;
- if(curPFD == 0)
- {
- SetLastError(0);
- return(0);
- }
- return(curPFD);
-}
-
-WGLAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
- PIXELFORMATDESCRIPTOR *ppfd)
-{
- int qt_valid_pix;
- (void) hdc;
-
- qt_valid_pix = qt_pix;
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR))
- {
- SetLastError(0);
- return(FALSE);
- }
- curPFD = iPixelFormat;
- return(TRUE);
-}
-
-WGLAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
-{
- (void) hdc;
- if (ctx_current < 0)
- return FALSE;
-
- if(wgl_ctx[ctx_current].ctx == NULL) {
- SetLastError(0);
- return(FALSE);
- }
- WMesaSwapBuffers();
- return(TRUE);
-}
-
-#endif /* WIN32 */
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index 5d7e260c4b..d32822e65d 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -1,403 +1,173 @@
-
/*
- * Windows (Win32) device driver for Mesa 3.4
- *
- * Original author:
- *
- * Copyright (C) 1996- Li Wei
- * Address : Institute of Artificial Intelligence
- * : & Robotics
- * : Xi'an Jiaotong University
- * Email : liwei@aiar.xjtu.edu.cn
- * Web page : http://sun.aiar.xjtu.edu.cn
+ * Windows (Win32) device driver for Mesa
*
- * This file and its associations are partially borrowed from the
- * Windows NT driver for Mesa 1.8 , written by Mark Leaming
- * (mark@rsinc.com).
- *
- * Updated for Mesa 4.0 by Karl Schultz (kschultz@sourceforge.net)
*/
-#if defined(NDEBUG) && defined(_MSC_VER)
-#pragma auto_inline(on)
-#pragma inline_depth(255)
-#pragma inline_recursion(on)
-#endif
-
#include "wmesadef.h"
-#include <GL/wmesa.h>
-//#include "mesa_extend.h"
-
-#include "glheader.h"
-#include "buffers.h"
#include "colors.h"
-#include "context.h"
-#include "colormac.h"
-#include "dd.h"
-#include "depth.h"
+#include <GL/wmesa.h>
#include "extensions.h"
-#include "imports.h"
-#include "macros.h"
-#include "matrix.h"
-#include "mtypes.h"
-#include "texformat.h"
-#include "teximage.h"
-#include "texstore.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "drivers/common/driverfuncs.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
-#include "swrast/s_alphabuf.h"
-#include "swrast/s_context.h"
-#include "swrast/s_depth.h"
-#include "swrast/s_lines.h"
-#include "swrast/s_triangle.h"
-#include "swrast/s_trispan.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
-#include "drivers/common/driverfuncs.h"
-
-#define SWTC 0 /* SW texture compression */
-
-/* Dither not tested for Mesa 4.0 */
-#ifdef DITHER
-#ifdef USE_WING
-#include <wing.h>
-#endif // USE_WING
-#endif
-
-#ifdef __CYGWIN32__
-#include "macros.h"
-#include <string.h>
-#define CopyMemory memcpy
-#endif
-
-/* Stereo and parallel not tested for Mesa 4.0. */
-#define NO_STEREO
-#if !defined(NO_STEREO)
-#include "GL/glu.h"
-#include "stereo.h"
-#endif
-
-#define NO_PARALLEL
-#if !defined(NO_PARALLEL)
-#include "parallel.h"
-#endif
-
-
-/* File global varaibles */
-struct DISPLAY_OPTIONS {
- int stereo;
- int fullScreen;
- int mode;
- int bpp;
-};
-
-struct DISPLAY_OPTIONS displayOptions =
-{
- 0, // stereo
- 0, // fullScreen
- 0, // full screen mode (1,2,3,4)
- 0 // bpp (8,16,24,32)
-};
-GLenum stereoCompile = GL_FALSE ;
-GLenum stereoShowing = GL_FALSE ;
-GLenum stereoBuffer = GL_FALSE;
-#if !defined(NO_STEREO)
-GLint displayList = MAXIMUM_DISPLAY_LIST ;
-#endif
-GLint stereo_flag = 0 ;
-
-static PWMC Current = NULL;
-WMesaContext WC = NULL;
-
-#ifdef COMPILE_SETPIXEL
-
-#if defined(_MSC_VER) && _MSC_VER >= 1200
-#define FORCEINLINE __forceinline
-#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#define FORCEINLINE __attribute__((always_inline))
-#else
-#define FORCEINLINE __inline
-#endif
-
-FORCEINLINE void wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- pwc->wmSetPixel(pwc,iScanLine,iPixel,r,g,b);
-}
-
-void ChooseSetPixel(PWMC pwc);
-
-#endif // COMPILE_SETPIXEL
-
-/* If we are double-buffering, we want to get the DC for the
- * off-screen DIB, otherwise the DC for the window.
- */
-#define DD_GETDC ((Current->db_flag) ? Current->dib.hDC : Current->hDC )
-#define DD_RELEASEDC
#define FLIP(Y) (Current->height-(Y)-1)
-#define DITHER_RGB_TO_8BIT_SETUP \
-GLubyte pixelDithered;
-
-#define DITHER_RGB_TO_8BIT(red, green, blue, pixel, scanline) \
-{ \
- char unsigned redtemp, greentemp, bluetemp, paletteindex; \
- redtemp = aDividedBy51[red] \
- + (aModulo51[red] > aHalftone8x8[(pixel%8)*8 \
- + scanline%8]); \
- greentemp = aDividedBy51[(char unsigned)green] \
- + (aModulo51[green] > aHalftone8x8[ \
- (pixel%8)*8 + scanline%8]); \
- bluetemp = aDividedBy51[(char unsigned)blue] \
- + (aModulo51[blue] > aHalftone8x8[ \
- (pixel%8)*8 +scanline%8]); \
- paletteindex = redtemp + aTimes6[greentemp] + aTimes36[bluetemp];\
- pixelDithered = aWinGHalftoneTranslation[paletteindex]; \
-}
-
-#ifdef DDRAW
-static BOOL DDInit( WMesaContext wc, HWND hwnd);
-static void DDFree( WMesaContext wc);
-static HRESULT DDRestoreAll( WMesaContext wc );
-static void DDDeleteOffScreen(WMesaContext wc);
-static BOOL DDCreateOffScreen(WMesaContext wc);
-
-// define this to use the GDI Rectangle call to
-// clear the back buffer. Otherwise will manually
-// set the pixels. On an NVidia GEForce 2MX under Windows XP
-// and DirectX 8 , defining this makes apps run much much faster
-#define USE_GDI_TO_CLEAR 1
-#endif
-
-BOOL wmCreateBackingStore(PWMC pwc, long lxSize, long lySize);
-BOOL wmDeleteBackingStore(PWMC pwc);
-void wmCreatePalette( PWMC pwdc );
-BOOL wmSetDibColors(PWMC pwc);
-void wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b);
-BOOL wmFlush(PWMC pwc);
-void wmCreateDIBSection(
- HDC hDC,
- PWMC pwc, // handle of device context
- CONST BITMAPINFO *pbmi, // bitmap size, format, and color data
- UINT iUsage // color data type indicator: RGB values or palette indices
- );
-void WMesaViewport( GLcontext *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height );
-
-
-static void wmSetPixelFormat( PWMC wc, HDC hDC)
-{
- if(wc->rgb_flag)
- wc->cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
- else
- wc->cColorBits = 8;
- switch(wc->cColorBits){
- case 8:
- if(wc->dither_flag != GL_TRUE)
- wc->pixelformat = PF_INDEX8;
- else
- wc->pixelformat = PF_DITHER8;
- break;
- case 16:
- wc->pixelformat = PF_5R6G5B;
- break;
- case 32:
- wc->pixelformat = PF_8R8G8B;
- break;
- default:
- wc->pixelformat = PF_BADFORMAT;
- }
-}
+/* Static Data */
+static PWMC Current = NULL;
-/* This function sets the color table of a DIB section
- * to match that of the destination DC
+/*
+ * Every driver should implement a GetString function in order to
+ * return a meaningful GL_RENDERER string.
*/
-BOOL wmSetDibColors(PWMC pwc)
+static const GLubyte *wmesa_get_string(GLcontext *ctx, GLenum name)
{
- RGBQUAD *pColTab, *pRGB;
- PALETTEENTRY *pPal, *pPE;
- int i, nColors;
- BOOL bRet=TRUE;
- DWORD dwErr=0;
-
- /* Build a color table in the DIB that maps to the
- * selected palette in the DC.
- */
- nColors = 1 << pwc->cColorBits;
- pPal = (PALETTEENTRY *)malloc( nColors * sizeof(PALETTEENTRY));
- memset( pPal, 0, nColors * sizeof(PALETTEENTRY) );
- GetPaletteEntries( pwc->hGLPalette, 0, nColors, pPal );
- pColTab = (RGBQUAD *)malloc( nColors * sizeof(RGBQUAD));
- for (i = 0, pRGB = pColTab, pPE = pPal; i < nColors; i++, pRGB++, pPE++) {
- pRGB->rgbRed = pPE->peRed;
- pRGB->rgbGreen = pPE->peGreen;
- pRGB->rgbBlue = pPE->peBlue;
- }
- if(pwc->db_flag)
- bRet = SetDIBColorTable(pwc->dib.hDC, 0, nColors, pColTab );
-
- if(!bRet)
- dwErr = GetLastError();
-
- free( pColTab );
- free( pPal );
-
- return bRet;
+ return (name == GL_RENDERER) ?
+ (GLubyte *) "Mesa Windows GDI Driver" : NULL;
}
-
/*
- * Free up the dib section that was created
+ * Determine the pixel format based on the pixel size.
*/
-BOOL wmDeleteBackingStore(PWMC pwc)
-{
- SelectObject(pwc->dib.hDC, pwc->hOldBitmap);
- DeleteDC(pwc->dib.hDC);
- DeleteObject(pwc->hbmDIB);
-#ifdef USE_MAPPED_FILE
- UnmapViewOfFile(pwc->dib.base);
- CloseHandle(pwc->dib.hFileMap);
-#endif
- return TRUE;
+static void wmSetPixelFormat(PWMC pwc, HDC hDC)
+{
+ pwc->cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
+
+ // TEMP - only 16 and 32 bit targets are supported now
+ assert(pwc->cColorBits == 16 ||
+ pwc->cColorBits == 32);
+
+ switch(pwc->cColorBits){
+ case 8:
+ pwc->pixelformat = PF_INDEX8;
+ break;
+ case 16:
+ pwc->pixelformat = PF_5R6G5B;
+ break;
+ case 32:
+ pwc->pixelformat = PF_8R8G8B;
+ break;
+ default:
+ pwc->pixelformat = PF_BADFORMAT;
+ }
}
-
/*
- * This function creates the DIB section that is used for combined
- * GL and GDI calls
+ * Create DIB for back buffer.
+ * We write into this memory with the span routines and then blit it
+ * to the window on a buffer swap.
*/
+
BOOL wmCreateBackingStore(PWMC pwc, long lxSize, long lySize)
{
- HDC hdc = pwc->hDC;
- LPBITMAPINFO pbmi = &(pwc->bmi);
- int iUsage;
-
- pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pbmi->bmiHeader.biWidth = lxSize;
- pbmi->bmiHeader.biHeight= -lySize;
- pbmi->bmiHeader.biPlanes = 1;
- if(pwc->rgb_flag)
+ HDC hdc = pwc->hDC;
+ LPBITMAPINFO pbmi = &(pwc->bmi);
+ HDC hic;
+
+ assert(pwc->db_flag == GL_TRUE);
+
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biWidth = lxSize;
+ pbmi->bmiHeader.biHeight= -lySize;
+ pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = GetDeviceCaps(pwc->hDC, BITSPIXEL);
- else
- pbmi->bmiHeader.biBitCount = 8;
- pbmi->bmiHeader.biCompression = BI_RGB;
- pbmi->bmiHeader.biSizeImage = 0;
- pbmi->bmiHeader.biXPelsPerMeter = 0;
- pbmi->bmiHeader.biYPelsPerMeter = 0;
- pbmi->bmiHeader.biClrUsed = 0;
- pbmi->bmiHeader.biClrImportant = 0;
-
- iUsage = (pbmi->bmiHeader.biBitCount <= 8) ? DIB_PAL_COLORS : DIB_RGB_COLORS;
+ pbmi->bmiHeader.biCompression = BI_RGB;
+ pbmi->bmiHeader.biSizeImage = 0;
+ pbmi->bmiHeader.biXPelsPerMeter = 0;
+ pbmi->bmiHeader.biYPelsPerMeter = 0;
+ pbmi->bmiHeader.biClrUsed = 0;
+ pbmi->bmiHeader.biClrImportant = 0;
+
+ pwc->cColorBits = pbmi->bmiHeader.biBitCount;
+ pwc->ScanWidth = (lxSize * (pwc->cColorBits / 8) + 3) & ~3;
+
+ hic = CreateIC("display", NULL, NULL, NULL);
+ pwc->dib.hDC = CreateCompatibleDC(hic);
+
+ pwc->hbmDIB = CreateDIBSection(hic,
+ &pwc->bmi,
+ DIB_RGB_COLORS,
+ (void **)&(pwc->pbPixels),
+ 0,
+ 0);
+ pwc->hOldBitmap = SelectObject(pwc->dib.hDC, pwc->hbmDIB);
+
+ DeleteDC(hic);
- pwc->cColorBits = pbmi->bmiHeader.biBitCount;
- pwc->ScanWidth = pwc->pitch = lxSize;
-
- wmCreateDIBSection(hdc, pwc, pbmi, iUsage);
-
- if ((iUsage == DIB_PAL_COLORS) && !(pwc->hGLPalette)) {
- wmCreatePalette( pwc );
- wmSetDibColors( pwc );
- }
- wmSetPixelFormat(pwc, pwc->hDC);
- return TRUE;
+ wmSetPixelFormat(pwc, pwc->hDC);
+ return TRUE;
}
-#if 0
-// D.R.S. 10/30/01 - this function is never referenced
-/*
- * This function copies one scan line in a DIB section to another
- */
-BOOL wmSetDIBits(PWMC pwc, UINT uiScanWidth, UINT uiNumScans,
- UINT nBypp, UINT uiNewWidth, LPBYTE pBits)
+static wmDeleteBackingStore(PWMC pwc)
{
- UINT uiScans = 0;
- LPBYTE pDest = pwc->pbPixels;
- DWORD dwNextScan = uiScanWidth;
- DWORD dwNewScan = uiNewWidth;
- DWORD dwScanWidth = (uiScanWidth * nBypp);
-
- /*
- * We need to round up to the nearest DWORD
- * and multiply by the number of bytes per
- * pixel
- */
- dwNextScan = (((dwNextScan * nBypp)+ 3) & ~3);
- dwNewScan = (((dwNewScan * nBypp)+ 3) & ~3);
-
- for(uiScans = 0; uiScans < uiNumScans; uiScans++){
- CopyMemory(pDest, pBits, dwScanWidth);
- pBits += dwNextScan;
- pDest += dwNewScan;
- }
- return TRUE;
+ if (pwc->hbmDIB) {
+ SelectObject(pwc->dib.hDC, pwc->hOldBitmap);
+ DeleteDC(pwc->dib.hDC);
+ DeleteObject(pwc->hbmDIB);
+ }
}
-#endif // 0
-
-#if defined(FAST_RASTERIZERS)
-#define PIXELADDR(X,Y) \
- ((GLubyte *)Current->pbPixels + (Current->height-Y-1)* \
- Current->ScanWidth + (X)*nBypp)
-#define PIXELADDR1( X, Y ) \
-((GLubyte *)wmesa->pbPixels + (wmesa->height-Y-1)* wmesa->ScanWidth + (X))
-#define PIXELADDR2( X, Y ) \
-((GLubyte *)wmesa->pbPixels + (wmesa->height-Y-1)* wmesa->ScanWidth + (X)*2)
-#define PIXELADDR4( X, Y ) \
-((GLubyte *)wmesa->pbPixels + (wmesa->height-Y-1)* wmesa->ScanWidth + (X)*4)
-
-#endif // 0
-
-BYTE DITHER_RGB_2_8BIT( int r, int g, int b, int x, int y);
-
-#if 0 /* unused */
-
-/* Finish all pending operations and synchronize. */
-static void finish(GLcontext* ctx)
+static void wmesa_get_buffer_size(GLframebuffer *buffer,
+ GLuint *width,
+ GLuint *height )
{
- /* No op */
- (void) ctx;
+ *width = Current->width;
+ *height = Current->height;
}
-#endif /* unused */
-static void flush(GLcontext* ctx)
+static void wmesa_flush(GLcontext* ctx)
{
- (void) ctx;
- if((Current->rgb_flag &&!(Current->db_flag))
- ||(!Current->rgb_flag))
- {
- wmFlush(Current);
+ if (Current->db_flag) {
+ BitBlt(Current->hDC, 0, 0, Current->width, Current->height,
+ Current->dib.hDC, 0, 0, SRCCOPY);
+ }
+ else {
+ /* Do nothing for single buffer */
}
-
}
+/**********************************************************************/
+/***** CLEAR Functions *****/
+/**********************************************************************/
+
+/* If we do not implement these, Mesa clears the buffers via the pixel
+ * span writing interface, which is very slow for a clear operation.
+ */
/*
* Set the color index used to clear the color buffer.
*/
static void clear_index(GLcontext* ctx, GLuint index)
{
- (void) ctx;
- Current->clearpixel = index;
+ /* Note that indexed mode is not supported yet */
+ Current->clearColorRef = RGB(0,0,0);
}
-
-
/*
* Set the color used to clear the color buffer.
*/
-static void clear_color( GLcontext* ctx, const GLfloat color[4] )
+static void clear_color(GLcontext* ctx, const GLfloat color[4])
{
- GLubyte col[4];
- (void) ctx;
- CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
- CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
- CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
- Current->clearpixel = RGB(col[0], col[1], col[2]);
+ GLubyte col[3];
+ UINT bytesPerPixel = Current->cColorBits / 8;
+
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ Current->clearColorRef = RGB(col[0], col[1], col[2]);
+ DeleteObject(Current->clearPen);
+ DeleteObject(Current->clearBrush);
+ Current->clearPen = CreatePen(PS_SOLID, 1, Current->clearColorRef);
+ Current->clearBrush = CreateSolidBrush(Current->clearColorRef);
}
@@ -408,550 +178,270 @@ static void clear_color( GLcontext* ctx, const GLfloat color[4] )
* This procedure clears either the front and/or the back COLOR buffers.
* Only the "left" buffer is cleared since we are not stereo.
* Clearing of the other non-color buffers is left to the swrast.
- * We also only clear the color buffers if the color masks are all 1's.
- * Otherwise, we let swrast do it.
*/
-static void clear(GLcontext* ctx, GLbitfield mask,
- GLboolean all, GLint x, GLint y, GLint width, GLint height)
-{
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
-
- if (all){
- x=y=0;
- width=Current->width;
- height=Current->height;
- }
-
-
- /* sanity check - can't have right(stereo) buffers */
- assert((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT)) == 0);
-
- /* clear alpha */
- if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) &&
- ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
- ctx->Color.ColorMask[ACOMP]) {
- _swrast_clear_alpha_buffers( ctx );
- }
-
- if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
- if (mask & DD_BACK_LEFT_BIT) {
-#if defined(USE_GDI_TO_CLEAR)
-#if defined(DDRAW)
- // D.R.S. 10/29/01 on my system (Pentium 4 with nvidia GeForce2 MX card,
- // this is almose 100 times faster that the code below
- HDC DC=NULL;
- HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
- HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
- HPEN Old_Pen=NULL;
- HBRUSH Old_Brush=NULL;
- Current->lpDDSOffScreen->lpVtbl->Unlock(Current->lpDDSOffScreen,NULL);
- Current->lpDDSOffScreen->lpVtbl->GetDC(Current->lpDDSOffScreen,&DC);
- Old_Pen=SelectObject(DC,Pen);
- Old_Brush=SelectObject(DC,Brush);
- Rectangle(DC,x,y,x+width,y+height);
- SelectObject(DC,Old_Pen);
- SelectObject(DC,Old_Brush);
- DeleteObject(Pen);
- DeleteObject(Brush);
- Current->lpDDSOffScreen->lpVtbl->ReleaseDC(Current->lpDDSOffScreen,DC);
- while (Current->lpDDSOffScreen->lpVtbl->Lock(Current->lpDDSOffScreen,NULL, &(Current->ddsd), 0, NULL) == DDERR_WASSTILLDRAWING);
-
- mask &= ~DD_BACK_LEFT_BIT;
-#else
- /* single-buffer */
- HDC DC=DD_GETDC;
- HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
- HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
- HPEN Old_Pen=SelectObject(DC,Pen);
- HBRUSH Old_Brush=SelectObject(DC,Brush);
- Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
-
- SelectObject(DC,Old_Pen);
- SelectObject(DC,Old_Brush);
- DeleteObject(Pen);
- DeleteObject(Brush);
- DD_RELEASEDC;
- mask &= ~DD_BACK_LEFT_BIT;
-#endif // DDRAW
-#else
- DWORD dwColor;
- WORD wColor;
- BYTE bColor;
- LPDWORD lpdw = (LPDWORD)Current->pbPixels;
- /*LPWORD lpw = (LPWORD)Current->pbPixels; */
- LPBYTE lpb = Current->pbPixels;
- int lines;
- /* Double-buffering - clear back buffer */
- UINT nBypp = Current->cColorBits / 8;
- int i = 0;
- int iSize = 0;
- int mult = 4;
-
-
- assert(Current->db_flag==GL_TRUE); /* we'd better be double buffer */
- if(nBypp ==1 ){
- iSize = Current->width/4;
- bColor = BGR8(GetRValue(Current->clearpixel),
- GetGValue(Current->clearpixel),
- GetBValue(Current->clearpixel));
- wColor = MAKEWORD(bColor,bColor);
- dwColor = MAKELONG(wColor, wColor);
- }
- else if(nBypp == 2){
- iSize = Current->width / 2;
- wColor = BGR16(GetRValue(Current->clearpixel),
- GetGValue(Current->clearpixel),
- GetBValue(Current->clearpixel));
- dwColor = MAKELONG(wColor, wColor);
- }
- else if(nBypp == 3){
- BYTE r, g, b;
- r = GetRValue(Current->clearpixel);
- g = GetGValue(Current->clearpixel);
- b = GetBValue(Current->clearpixel);
- iSize = Current->width;
- while (i < iSize) {
- *lpb++ = b;
- *lpb++ = g;
- *lpb++ = r;
- i++;
- }
- lpb = Current->pbPixels + Current->ScanWidth;
- mult = 3;
- }
- else if(nBypp == 4){
- iSize = Current->width;
- dwColor = BGR32(GetRValue(Current->clearpixel),
- GetGValue(Current->clearpixel),
- GetBValue(Current->clearpixel));
- }
- else
- dwColor = 0;
-
- if (nBypp != 3)
- {
- /* clear a line */
- while(i < iSize){
- *lpdw = dwColor;
- lpdw++;
- i++;
- }
- }
-
- i = 0;
- if (stereo_flag)
- lines = height /2;
- else
- lines = height;
- /* copy cleared line to other lines in buffer */
- do {
- memcpy(lpb, Current->pbPixels, iSize*mult);
- lpb += Current->ScanWidth;
- i++;
- }
- while (i<lines-1);
- mask &= ~DD_BACK_LEFT_BIT;
-#endif // defined(USE_GDI_TO_CLEAR)
- } /* double-buffer */
-
- if (mask & DD_FRONT_LEFT_BIT) {
- /* single-buffer */
- HDC DC=DD_GETDC;
- HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
- HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
- HPEN Old_Pen=SelectObject(DC,Pen);
- HBRUSH Old_Brush=SelectObject(DC,Brush);
- Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
-
- SelectObject(DC,Old_Pen);
- SelectObject(DC,Old_Brush);
- DeleteObject(Pen);
- DeleteObject(Brush);
- DD_RELEASEDC;
- mask &= ~DD_FRONT_LEFT_BIT;
- } /* single-buffer */
- } /* if masks are all 1's */
-
- /* Call swrast if there is anything left to clear (like DEPTH) */
- if (mask)
- _swrast_Clear( ctx, mask, all, x, y, width, height );
-}
-
-
-static void enable( GLcontext* ctx, GLenum pname, GLboolean enable )
-{
- (void) ctx;
- if (!Current)
- return;
-
- if (pname == GL_DITHER) {
- if(enable == GL_FALSE){
- Current->dither_flag = GL_FALSE;
- if(Current->cColorBits == 8)
- Current->pixelformat = PF_INDEX8;
+static void clear(GLcontext* ctx,
+ GLbitfield mask,
+ GLboolean all,
+ GLint x, GLint y,
+ GLint width, GLint height)
+{
+ int done = 0;
+
+ /* Let swrast do all the work if the masks are not set to
+ * clear all channels. */
+ if (ctx->Color.ColorMask[0] != 0xff ||
+ ctx->Color.ColorMask[1] != 0xff ||
+ ctx->Color.ColorMask[2] != 0xff ||
+ ctx->Color.ColorMask[3] != 0xff) {
+ _swrast_Clear(ctx, mask, all, x, y, width, height);
+ return;
}
- else{
- if (Current->rgb_flag && Current->cColorBits == 8){
- Current->pixelformat = PF_DITHER8;
- Current->dither_flag = GL_TRUE;
- }
- else
- Current->dither_flag = GL_FALSE;
- }
- }
-}
-
-
-
-static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
- GLuint bufferBit )
-{
- (void) ctx; (void) colorBuffer; (void) bufferBit;
- /* XXX todo - examine bufferBit and set read/write pointers */
- return;
-}
-
+ /* 'all' means clear the entire window */
+ if (all) {
+ x = y = 0;
+ width = Current->width;
+ height = Current->height;
+ }
-/* Return characteristics of the output buffer. */
-static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
-{
- /*GET_CURRENT_CONTEXT(ctx);*/
- int New_Size;
- RECT CR;
- (void) buffer;
-
- GetClientRect(Current->Window,&CR);
+ /* Back buffer */
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+
+ int i, rowSize;
+ UINT bytesPerPixel = Current->cColorBits / 8;
+ LPBYTE lpb, clearRow;
+ LPWORD lpw;
+ BYTE bColor;
+ WORD wColor;
+ BYTE r, g, b;
+ DWORD dwColor;
+ LPDWORD lpdw;
+
+ /* Try for a fast clear - clearing entire buffer with a single
+ * byte value. */
+ if (all) { /* entire buffer */
+ /* Now check for an easy clear value */
+ switch (bytesPerPixel) {
+ case 1:
+ bColor = BGR8(GetRValue(Current->clearColorRef),
+ GetGValue(Current->clearColorRef),
+ GetBValue(Current->clearColorRef));
+ memset(Current->pbPixels, bColor,
+ Current->ScanWidth * height);
+ done = 1;
+ break;
+ case 2:
+ wColor = BGR16(GetRValue(Current->clearColorRef),
+ GetGValue(Current->clearColorRef),
+ GetBValue(Current->clearColorRef));
+ if (((wColor >> 8) & 0xff) == (wColor & 0xff)) {
+ memset(Current->pbPixels, wColor & 0xff,
+ Current->ScanWidth * height);
+ done = 1;
+ }
+ break;
+ case 3:
+ /* fall through */
+ case 4:
+ if (GetRValue(Current->clearColorRef) ==
+ GetGValue(Current->clearColorRef) &&
+ GetRValue(Current->clearColorRef) ==
+ GetBValue(Current->clearColorRef)) {
+ memset(Current->pbPixels,
+ GetRValue(Current->clearColorRef),
+ Current->ScanWidth * height);
+ done = 1;
+ }
+ break;
+ default:
+ break;
+ }
+ } /* all */
+
+ if (!done) {
+ /* Need to clear a row at a time. Begin by setting the first
+ * row in the area to be cleared to the clear color. */
+
+ clearRow = Current->pbPixels +
+ Current->ScanWidth * FLIP(y) +
+ bytesPerPixel * x;
+ switch (bytesPerPixel) {
+ case 1:
+ lpb = clearRow;
+ bColor = BGR8(GetRValue(Current->clearColorRef),
+ GetGValue(Current->clearColorRef),
+ GetBValue(Current->clearColorRef));
+ memset(lpb, bColor, width);
+ break;
+ case 2:
+ lpw = (LPWORD)clearRow;
+ wColor = BGR16(GetRValue(Current->clearColorRef),
+ GetGValue(Current->clearColorRef),
+ GetBValue(Current->clearColorRef));
+ for (i=0; i<width; i++)
+ *lpw++ = wColor;
+ break;
+ case 3:
+ lpb = clearRow;
+ r = GetRValue(Current->clearColorRef);
+ g = GetGValue(Current->clearColorRef);
+ b = GetBValue(Current->clearColorRef);
+ for (i=0; i<width; i++) {
+ *lpb++ = b;
+ *lpb++ = g;
+ *lpb++ = r;
+ }
+ break;
+ case 4:
+ lpdw = (LPDWORD)clearRow;
+ dwColor = BGR32(GetRValue(Current->clearColorRef),
+ GetGValue(Current->clearColorRef),
+ GetBValue(Current->clearColorRef));
+ for (i=0; i<width; i++)
+ *lpdw++ = dwColor;
+ break;
+ default:
+ break;
+ } /* switch */
+
+ /* copy cleared row to other rows in buffer */
+ lpb = clearRow - Current->ScanWidth;
+ rowSize = width * bytesPerPixel;
+ for (i=1; i<height; i++) {
+ memcpy(lpb, clearRow, rowSize);
+ lpb -= Current->ScanWidth;
+ }
+ } /* not done */
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ } /* back buffer */
+
+ /* front buffer */
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ HDC DC = Current->hDC;
+ HPEN Old_Pen = SelectObject(DC, Current->clearPen);
+ HBRUSH Old_Brush = SelectObject(DC, Current->clearBrush);
+ Rectangle(DC,
+ x,
+ FLIP(y),
+ x + width + 1,
+ FLIP(y) - height + 1);
+ SelectObject(DC, Old_Pen);
+ SelectObject(DC, Old_Brush);
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ } /* front buffer */
+
+ /* Call swrast if there is anything left to clear (like DEPTH) */
+ if (mask)
+ _swrast_Clear(ctx, mask, all, x, y, width, height);
- *width=CR.right;
- *height=CR.bottom;
-
- New_Size=((*width)!=Current->width) || ((*height)!=Current->height);
-
- if (New_Size){
- Current->width=*width;
- Current->height=*height;
- Current->ScanWidth=Current->width;
- if ((Current->ScanWidth%sizeof(long))!=0)
- Current->ScanWidth+=(sizeof(long)-(Current->ScanWidth%sizeof(long)));
-
- if (Current->db_flag){
-#ifdef DDRAW
- DDDeleteOffScreen(Current);
- DDCreateOffScreen(Current);
-#else
- if (Current->rgb_flag==GL_TRUE && Current->dither_flag!=GL_TRUE){
- wmDeleteBackingStore(Current);
- wmCreateBackingStore(Current, Current->width, Current->height);
- }
-#endif
- }
-
- /* Resize OsmesaBuffer if in Parallel mode */
-#if !defined(NO_PARALLEL)
- if(parallelFlag)
- PRSizeRenderBuffer(Current->width, Current->height,Current->ScanWidth,
- Current->rgb_flag == GL_TRUE ? Current->pbPixels:
- Current->ScreenMem);
-#endif
- }
-}
-
-
-static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
- /* poll for window size change and realloc software Z/stencil/etc if needed */
- _mesa_ResizeBuffersMESA();
-}
+}
/**********************************************************************/
-/***** Accelerated point, line, polygon rendering *****/
+/***** PIXEL Functions *****/
/**********************************************************************/
-/* Accelerated routines are not implemented in 4.0. See OSMesa for ideas. */
-
-#if 0 /* unused */
-
-static void fast_rgb_points( GLcontext* ctx, GLuint first, GLuint last )
-{
- (void) ctx; (void) first; (void) last;
-}
-
-#endif /* unused */
+/* SINGLE BUFFER */
-/* Return pointer to accelerated points function */
-extern tnl_points_func choose_points_function( GLcontext* ctx )
-{
- (void) ctx;
- return NULL;
-}
-
-#if 0 /* unused */
-
-static void fast_flat_rgb_line( GLcontext* ctx, GLuint v0,
- GLuint v1, GLuint pv )
-{
- (void) ctx; (void) v0; (void) v1; (void) pv;
-}
-
-static tnl_line_func choose_line_function( GLcontext* ctx )
-{
- (void) ctx;
-}
-
-#endif /* unused */
-
-/**********************************************************************/
-/***** Span-based pixel drawing *****/
-/**********************************************************************/
-
-
-/* Write a horizontal span of 32-bit color-index pixels with a boolean mask. */
-static void write_ci32_span( const GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLuint index[],
- const GLubyte mask[] )
-{
- GLuint i;
- PBYTE Mem=Current->ScreenMem+FLIP(y)*Current->ScanWidth+x;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++)
- if (mask[i])
- Mem[i]=index[i];
-}
-
-
-/* Write a horizontal span of 8-bit color-index pixels with a boolean mask. */
-static void write_ci8_span( const GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte index[],
- const GLubyte mask[] )
-{
- GLuint i;
- PBYTE Mem=Current->ScreenMem+FLIP(y)*Current->ScanWidth+x;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++)
- if (mask[i])
- Mem[i]=index[i];
-}
-
-
-
-/*
- * Write a horizontal span of pixels with a boolean mask. The current
- * color index is used for all pixels.
- */
-static void write_mono_ci_span(const GLcontext* ctx,
- GLuint n,GLint x,GLint y,
- GLuint colorIndex, const GLubyte mask[])
-{
- GLuint i;
- BYTE *Mem=Current->ScreenMem+FLIP(y)*Current->ScanWidth+x;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++)
- if (mask[i])
- Mem[i]=colorIndex;
-}
-
-/*
- * To improve the performance of this routine, frob the data into an actual
- * scanline and call bitblt on the complete scan line instead of SetPixel.
- */
+/* These are slow, but work with all non-indexed visual types */
/* Write a horizontal span of RGBA color pixels with a boolean mask. */
-static void write_rgba_span( const GLcontext* ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[] )
-{
- PWMC pwc = Current;
- (void) ctx;
-
- if (pwc->rgb_flag==GL_TRUE)
- {
- GLuint i;
- /*HDC DC=DD_GETDC;*/
- y=FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- wmSetPixel(pwc, y, x + i,
- rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- }
- else {
+static void write_rgba_span_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
+{
+ PWMC pwc = Current;
+ GLuint i;
+
+ (void) ctx;
+ y=FLIP(y);
+ if (mask) {
for (i=0; i<n; i++)
- wmSetPixel(pwc, y, x + i,
- rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- DD_RELEASEDC;
+ if (mask[i])
+ SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]));
}
- else
- {
- GLuint i;
- BYTE *Mem=Current->ScreenMem+y*Current->ScanWidth+x;
- y = FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- Mem[i] = GetNearestPaletteIndex(Current->hPal,
- RGB(rgba[i][RCOMP],
- rgba[i][GCOMP],
- rgba[i][BCOMP]));
- }
- else {
+ else {
for (i=0; i<n; i++)
- Mem[i] = GetNearestPaletteIndex(Current->hPal,
- RGB(rgba[i][RCOMP],
- rgba[i][GCOMP],
- rgba[i][BCOMP]));
- }
+ SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]));
}
+
}
/* Write a horizontal span of RGB color pixels with a boolean mask. */
-static void write_rgb_span( const GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[] )
-{
- PWMC pwc = Current;
- (void) ctx;
-
- if (pwc->rgb_flag==GL_TRUE)
- {
- GLuint i;
- /*HDC DC=DD_GETDC;*/
- y=FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- wmSetPixel(pwc, y, x + i,
- rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
- }
- else {
+static void write_rgb_span_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3],
+ const GLubyte mask[] )
+{
+ PWMC pwc = Current;
+ GLuint i;
+
+ (void) ctx;
+ y=FLIP(y);
+ if (mask) {
for (i=0; i<n; i++)
- wmSetPixel(pwc, y, x + i,
- rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
- }
- DD_RELEASEDC;
+ if (mask[i])
+ SetPixel(pwc->hDC, x+i, y, RGB(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]));
}
- else
- {
- GLuint i;
- BYTE *Mem=Current->ScreenMem+y*Current->ScanWidth+x;
- y = FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- Mem[i] = GetNearestPaletteIndex(Current->hPal,
- RGB(rgb[i][RCOMP],
- rgb[i][GCOMP],
- rgb[i][BCOMP]));
- }
- else {
+ else {
for (i=0; i<n; i++)
- Mem[i] = GetNearestPaletteIndex(Current->hPal,
- RGB(rgb[i][RCOMP],
- rgb[i][GCOMP],
- rgb[i][BCOMP]));
- }
+ SetPixel(pwc->hDC, x+i, y, RGB(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]));
}
+
}
/*
* Write a horizontal span of pixels with a boolean mask. The current color
* is used for all pixels.
*/
-static void write_mono_rgba_span( const GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLchan color[4], const GLubyte mask[])
+static void write_mono_rgba_span_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4],
+ const GLubyte mask[])
{
- GLuint i;
- PWMC pwc = Current;
- (void) ctx;
- assert(Current->rgb_flag==GL_TRUE);
- y=FLIP(y);
- if(Current->rgb_flag==GL_TRUE)
- {
- for (i=0; i<n; i++)
- if (mask[i])
- wmSetPixel(pwc,y,x+i,color[RCOMP], color[GCOMP], color[BCOMP]);
- }
- else
- {
- HDC DC=DD_GETDC;
- ULONG pixel = RGB( color[RCOMP], color[GCOMP], color[BCOMP] );
- for (i=0; i<n; i++)
- if (mask[i])
- SetPixel(DC, y, x+i, pixel);
- DD_RELEASEDC;
- }
-}
-
-
-
-/**********************************************************************/
-/***** Array-based pixel drawing *****/
-/**********************************************************************/
+ GLuint i;
+ PWMC pwc = Current;
+ COLORREF colorref;
-
-/* Write an array of 32-bit index pixels with a boolean mask. */
-static void write_ci32_pixels( const GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLuint index[], const GLubyte mask[] )
-{
- GLuint i;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++) {
- if (mask[i]) {
- BYTE *Mem=Current->ScreenMem+FLIP(y[i])*Current->ScanWidth+x[i];
- *Mem = index[i];
+ (void) ctx;
+ colorref = RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
+ y=FLIP(y);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ SetPixel(pwc->hDC, x+i, y, colorref);
}
- }
-}
-
-
+ else
+ for (i=0; i<n; i++)
+ SetPixel(pwc->hDC, x+i, y, colorref);
-/*
- * Write an array of pixels with a boolean mask. The current color
- * index is used for all pixels.
- */
-static void write_mono_ci_pixels( const GLcontext* ctx,
- GLuint n,
- const GLint x[], const GLint y[],
- GLuint colorIndex, const GLubyte mask[] )
-{
- GLuint i;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++) {
- if (mask[i]) {
- BYTE *Mem=Current->ScreenMem+FLIP(y[i])*Current->ScanWidth+x[i];
- *Mem = colorIndex;
- }
- }
}
-
-
/* Write an array of RGBA pixels with a boolean mask. */
-static void write_rgba_pixels( const GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte rgba[][4], const GLubyte mask[] )
-{
- GLuint i;
- PWMC pwc = Current;
- /*HDC DC=DD_GETDC;*/
- (void) ctx;
- assert(Current->rgb_flag==GL_TRUE);
- for (i=0; i<n; i++)
- if (mask[i])
- wmSetPixel(pwc, FLIP(y[i]), x[i],
- rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- DD_RELEASEDC;
+static void write_rgba_pixels_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
+{
+ GLuint i;
+ PWMC pwc = Current;
+ (void) ctx;
+ for (i=0; i<n; i++)
+ if (mask[i])
+ SetPixel(pwc->hDC, x[i], FLIP(y[i]),
+ RGB(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]));
}
@@ -960,2428 +450,733 @@ static void write_rgba_pixels( const GLcontext* ctx,
* Write an array of pixels with a boolean mask. The current color
* is used for all pixels.
*/
-static void write_mono_rgba_pixels( const GLcontext* ctx,
- GLuint n,
- const GLint x[], const GLint y[],
- const GLchan color[4],
- const GLubyte mask[] )
-{
- GLuint i;
- PWMC pwc = Current;
- /*HDC DC=DD_GETDC;*/
- (void) ctx;
- assert(Current->rgb_flag==GL_TRUE);
- for (i=0; i<n; i++)
- if (mask[i])
- wmSetPixel(pwc, FLIP(y[i]),x[i],color[RCOMP],
- color[GCOMP], color[BCOMP]);
- DD_RELEASEDC;
-}
-
-
-
-/**********************************************************************/
-/***** Read spans/arrays of pixels *****/
-/**********************************************************************/
-
-
-/* Read a horizontal span of color-index pixels. */
-static void read_ci32_span( const GLcontext* ctx, GLuint n, GLint x, GLint y,
- GLuint index[])
-{
- GLuint i;
- BYTE *Mem=Current->ScreenMem+FLIP(y)*Current->ScanWidth+x;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++)
- index[i]=Mem[i];
-}
-
-
-
-
-/* Read an array of color index pixels. */
-static void read_ci32_pixels( const GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLuint indx[], const GLubyte mask[] )
-{
- GLuint i;
- (void) ctx;
- assert(Current->rgb_flag==GL_FALSE);
- for (i=0; i<n; i++) {
- if (mask[i]) {
- indx[i]=*(Current->ScreenMem+FLIP(y[i])*Current->ScanWidth+x[i]);
- }
- }
+static void write_mono_rgba_pixels_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLchan color[4],
+ const GLubyte mask[] )
+{
+ GLuint i;
+ PWMC pwc = Current;
+ COLORREF colorref;
+ (void) ctx;
+ colorref = RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
+ for (i=0; i<n; i++)
+ if (mask[i])
+ SetPixel(pwc->hDC, x[i], FLIP(y[i]), colorref);
}
-
-
/* Read a horizontal span of color pixels. */
-static void read_rgba_span( const GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4] )
-{
- UINT i;
- COLORREF Color;
- HDC DC=DD_GETDC;
- (void) ctx;
- assert(Current->rgb_flag==GL_TRUE);
- y = Current->height - y - 1;
- for (i=0; i<n; i++) {
- Color=GetPixel(DC,x+i,y);
- rgba[i][RCOMP] = GetRValue(Color);
- rgba[i][GCOMP] = GetGValue(Color);
- rgba[i][BCOMP] = GetBValue(Color);
- rgba[i][ACOMP] = 255;
- }
- DD_RELEASEDC;
+static void read_rgba_span_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4] )
+{
+ GLuint i;
+ COLORREF Color;
+ y = FLIP(y);
+ for (i=0; i<n; i++) {
+ Color = GetPixel(Current->hDC, x+i, y);
+ rgba[i][RCOMP] = GetRValue(Color);
+ rgba[i][GCOMP] = GetGValue(Color);
+ rgba[i][BCOMP] = GetBValue(Color);
+ rgba[i][ACOMP] = 255;
+ }
}
/* Read an array of color pixels. */
-static void read_rgba_pixels( const GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
+static void read_rgba_pixels_single(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4])
{
GLuint i;
COLORREF Color;
- HDC DC=DD_GETDC;
- (void) ctx;
- assert(Current->rgb_flag==GL_TRUE);
for (i=0; i<n; i++) {
- if (mask[i]) {
- GLint y2 = Current->height - y[i] - 1;
- Color=GetPixel(DC,x[i],y2);
+ GLint y2 = FLIP(y[i]);
+ Color = GetPixel(Current->hDC, x[i], y2);
rgba[i][RCOMP] = GetRValue(Color);
rgba[i][GCOMP] = GetGValue(Color);
rgba[i][BCOMP] = GetBValue(Color);
rgba[i][ACOMP] = 255;
- }
}
- DD_RELEASEDC;
}
+/*********************************************************************/
+/* DOUBLE BUFFER 32-bit */
-/**********************************************************************/
-/**********************************************************************/
-
+#define WMSETPIXEL32(pwc, y, x, r, g, b) { \
+LPDWORD lpdw = ((LPDWORD)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (x)); \
+*lpdw = BGR32((r),(g),(b)); }
-static const struct gl_texture_format *
-choose_tex_format( GLcontext *ctx, GLint internalFormat,
- GLenum format, GLenum type )
-{
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_ARB:
- return &_mesa_texformat_rgb;
- case GL_COMPRESSED_RGBA_ARB:
- return &_mesa_texformat_rgba;
- default:
- return _mesa_choose_tex_format(ctx, internalFormat, format, type);
- }
-}
-static const GLubyte *get_string(GLcontext *ctx, GLenum name)
+/* Write a horizontal span of RGBA color pixels with a boolean mask. */
+static void write_rgba_span_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
{
- (void) ctx;
- if (name == GL_RENDERER) {
- return (GLubyte *) "Mesa Windows";
- }
- else {
- return NULL;
- }
-}
-
-static void wmesa_update_state( GLcontext *ctx, GLuint new_state );
+ PWMC pwc = Current;
+ GLuint i;
+ LPDWORD lpdw;
-static void SetFunctionPointers( struct dd_function_table *functions )
-{
- functions->GetString = get_string;
- functions->UpdateState = wmesa_update_state;
- functions->ResizeBuffers = _swrast_alloc_buffers;
- functions->GetBufferSize = get_buffer_size;
- functions->Viewport = viewport;
-
- functions->Clear = clear;
-
- functions->Flush = flush;
- functions->ClearIndex = clear_index;
- functions->ClearColor = clear_color;
- functions->Enable = enable;
-
-#if SWTC
- functions->ChooseTextureFormat = choose_tex_format;
-#endif
+ (void) ctx;
+
+ y=FLIP(y);
+ lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpdw[i] = BGR32(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]);
+ }
+ else {
+ for (i=0; i<n; i++)
+ *lpdw++ = BGR32(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]);
+ }
}
-static void SetSWrastPointers(GLcontext *ctx)
-{
- struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
- swdd->SetBuffer = set_buffer;
-
- /* Pixel/span writing functions: */
- swdd->WriteRGBASpan = write_rgba_span;
- swdd->WriteRGBSpan = write_rgb_span;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span;
- swdd->WriteRGBAPixels = write_rgba_pixels;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels;
- swdd->WriteCI32Span = write_ci32_span;
- swdd->WriteCI8Span = write_ci8_span;
- swdd->WriteMonoCISpan = write_mono_ci_span;
- swdd->WriteCI32Pixels = write_ci32_pixels;
- swdd->WriteMonoCIPixels = write_mono_ci_pixels;
-
- swdd->ReadCI32Span = read_ci32_span;
- swdd->ReadRGBASpan = read_rgba_span;
- swdd->ReadCI32Pixels = read_ci32_pixels;
- swdd->ReadRGBAPixels = read_rgba_pixels;
-}
-
-
-static void wmesa_update_state( GLcontext *ctx, GLuint new_state )
+/* Write a horizontal span of RGB color pixels with a boolean mask. */
+static void write_rgb_span_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][4],
+ const GLubyte mask[] )
{
- /*struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );*/
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /*
- * XXX these function pointers could be initialized just once during
- * context creation since they don't depend on any state changes.
- * kws - This is true - this function gets called a lot and it
- * would be good to minimize setting all this when not needed.
- */
-#ifndef SET_FPOINTERS_ONCE
- SetFunctionPointers(&ctx->Driver);
- SetSWrastPointers(ctx);
-#if 0
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = wmesa_update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = clear;
-
- ctx->Driver.Flush = flush;
- ctx->Driver.ClearIndex = clear_index;
- ctx->Driver.ClearColor = clear_color;
- ctx->Driver.Enable = enable;
-
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
-
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
-
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
-
- swdd->SetBuffer = set_buffer;
-
- /* Pixel/span writing functions: */
- swdd->WriteRGBASpan = write_rgba_span;
- swdd->WriteRGBSpan = write_rgb_span;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span;
- swdd->WriteRGBAPixels = write_rgba_pixels;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels;
- swdd->WriteCI32Span = write_ci32_span;
- swdd->WriteCI8Span = write_ci8_span;
- swdd->WriteMonoCISpan = write_mono_ci_span;
- swdd->WriteCI32Pixels = write_ci32_pixels;
- swdd->WriteMonoCIPixels = write_mono_ci_pixels;
-
- swdd->ReadCI32Span = read_ci32_span;
- swdd->ReadRGBASpan = read_rgba_span;
- swdd->ReadCI32Pixels = read_ci32_pixels;
- swdd->ReadRGBAPixels = read_rgba_pixels;
-#endif // 0
-#endif // !SET_FPOINTERS_ONCE
- tnl->Driver.RunPipeline = _tnl_run_pipeline;
-
- _swrast_InvalidateState( ctx, new_state );
- _swsetup_InvalidateState( ctx, new_state );
- _ac_InvalidateState( ctx, new_state );
- _tnl_InvalidateState( ctx, new_state );
-}
-
-
-
-
-/**********************************************************************/
-/***** WMesa API Functions *****/
-/**********************************************************************/
-
-#if 0 /* unused */
+ PWMC pwc = Current;
+ GLuint i;
+ LPDWORD lpdw;
-#define PAL_SIZE 256
-static void GetPalette(HPALETTE Pal,RGBQUAD *aRGB)
-{
- int i;
- HDC hdc;
- struct
- {
- WORD Version;
- WORD NumberOfEntries;
- PALETTEENTRY aEntries[PAL_SIZE];
- } Palette;
- Palette.Version = 0x300;
- Palette.NumberOfEntries = PAL_SIZE;
- hdc=GetDC(NULL);
- if (Pal!=NULL)
- GetPaletteEntries(Pal,0,PAL_SIZE,Palette.aEntries);
- else
- GetSystemPaletteEntries(hdc,0,PAL_SIZE,Palette.aEntries);
- if (GetSystemPaletteUse(hdc) == SYSPAL_NOSTATIC)
- {
- for(i = 0; i <PAL_SIZE; i++)
- Palette.aEntries[i].peFlags = PC_RESERVED;
- Palette.aEntries[255].peRed = 255;
- Palette.aEntries[255].peGreen = 255;
- Palette.aEntries[255].peBlue = 255;
- Palette.aEntries[255].peFlags = 0;
- Palette.aEntries[0].peRed = 0;
- Palette.aEntries[0].peGreen = 0;
- Palette.aEntries[0].peBlue = 0;
- Palette.aEntries[0].peFlags = 0;
- }
- else
- {
- int nStaticColors;
- int nUsableColors;
- nStaticColors = GetDeviceCaps(hdc, NUMCOLORS)/2;
- for (i=0; i<nStaticColors; i++)
- Palette.aEntries[i].peFlags = 0;
- nUsableColors = PAL_SIZE-nStaticColors;
- for (; i<nUsableColors; i++)
- Palette.aEntries[i].peFlags = PC_RESERVED;
- for (; i<PAL_SIZE-nStaticColors; i++)
- Palette.aEntries[i].peFlags = PC_RESERVED;
- for (i=PAL_SIZE-nStaticColors; i<PAL_SIZE; i++)
- Palette.aEntries[i].peFlags = 0;
+ (void) ctx;
+
+ y=FLIP(y);
+ lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpdw[i] = BGR32(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]);
}
- ReleaseDC(NULL,hdc);
- for (i=0; i<PAL_SIZE; i++)
- {
- aRGB[i].rgbRed=Palette.aEntries[i].peRed;
- aRGB[i].rgbGreen=Palette.aEntries[i].peGreen;
- aRGB[i].rgbBlue=Palette.aEntries[i].peBlue;
- aRGB[i].rgbReserved=Palette.aEntries[i].peFlags;
+ else {
+ for (i=0; i<n; i++)
+ *lpdw++ = BGR32(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]);
}
}
-#endif /* unused */
-
-WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
- GLboolean rgb_flag,
- GLboolean db_flag,
- GLboolean alpha_flag )
-{
- RECT CR;
- WMesaContext c;
- GLboolean true_color_flag;
- struct dd_function_table functions;
- (void) Pal;
-
- c = (struct wmesa_context * ) calloc(1,sizeof(struct wmesa_context));
- if (!c)
- return NULL;
-
- c->Window=hWnd;
- c->hDC = GetDC(hWnd);
- true_color_flag = GetDeviceCaps(c->hDC, BITSPIXEL) > 8;
-#ifdef DDRAW
- if(true_color_flag) c->rgb_flag = rgb_flag = GL_TRUE;
-#endif
-
-
-#ifdef DITHER
- if ((true_color_flag==GL_FALSE) && (rgb_flag == GL_TRUE)){
- c->dither_flag = GL_TRUE;
-#ifdef USE_WING
- c->hPalHalfTone = WinGCreateHalftonePalette();
-#else
- c->hPalHalfTone = CreateHalftonePalette(c->hDC);
-#endif
- }
- else
- c->dither_flag = GL_FALSE;
-#else
- c->dither_flag = GL_FALSE;
-#endif
-
-
- if (rgb_flag==GL_FALSE)
- {
- c->rgb_flag = GL_FALSE;
-#if 0
- /* Old WinG stuff???? */
- c->db_flag = db_flag =GL_TRUE; /* WinG requires double buffering */
- printf("Single buffer is not supported in color index mode, ",
- "setting to double buffer.\n");
-#endif
- }
- else
- {
- c->rgb_flag = GL_TRUE;
- }
- GetClientRect(c->Window,&CR);
- c->width=CR.right;
- c->height=CR.bottom;
- if (db_flag)
- {
- c->db_flag = 1;
- /* Double buffered */
-#ifndef DDRAW
- {
- wmCreateBackingStore(c, c->width, c->height);
-
- }
-#endif
- }
- else
- {
- /* Single Buffered */
- if (c->rgb_flag)
- c->db_flag = 0;
+/*
+ * Write a horizontal span of pixels with a boolean mask. The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_span_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ LPDWORD lpdw;
+ DWORD pixel;
+ GLuint i;
+ PWMC pwc = Current;
+ lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ y=FLIP(y);
+ pixel = BGR32(color[RCOMP], color[GCOMP], color[BCOMP]);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpdw[i] = pixel;
}
-#ifdef DDRAW
- if (DDInit(c,hWnd) == GL_FALSE) {
- free( (void *) c );
- exit(1);
- }
-#endif
-
-
- c->gl_visual = _mesa_create_visual(rgb_flag,
- db_flag, /* db_flag */
- GL_FALSE, /* stereo */
- 8,8,8, /* r, g, b bits */
- alpha_flag ? 8 : 0, /* alpha bits */
- 0, /* index bits */
- 16, /* depth_bits */
- 8, /* stencil_bits */
- 16,16,16,/* accum_bits */
- alpha_flag ? 16 : 0, /* alpha accum */
- 1);
-
- if (!c->gl_visual) {
- return NULL;
- }
+ else
+ for (i=0; i<n; i++)
+ *lpdw++ = pixel;
- _mesa_init_driver_functions(&functions);
- SetFunctionPointers(&functions);
-
- /* allocate a new Mesa context */
- c->gl_ctx = _mesa_create_context( c->gl_visual, NULL,
- &functions, (void *) c );
-
- if (!c->gl_ctx) {
- _mesa_destroy_visual( c->gl_visual );
- free(c);
- return NULL;
- }
-
- _mesa_enable_sw_extensions(c->gl_ctx);
- _mesa_enable_1_3_extensions(c->gl_ctx);
- _mesa_enable_1_4_extensions(c->gl_ctx);
- _mesa_enable_1_5_extensions(c->gl_ctx);
- _mesa_enable_2_0_extensions(c->gl_ctx);
-#if SWTC
- if (c->gl_ctx->Mesa_DXTn) {
- _mesa_enable_extension(c->gl_ctx, "GL_EXT_texture_compression_s3tc");
- _mesa_enable_extension(c->gl_ctx, "GL_S3_s3tc");
- }
- _mesa_enable_extension(c->gl_ctx, "GL_3DFX_texture_compression_FXT1");
-#endif
-
- c->gl_buffer = _mesa_create_framebuffer( c->gl_visual,
- c->gl_visual->depthBits > 0,
- c->gl_visual->stencilBits > 0,
- c->gl_visual->accumRedBits > 0,
- alpha_flag /* s/w alpha */ );
- if (!c->gl_buffer) {
- _mesa_destroy_visual( c->gl_visual );
- _mesa_free_context_data( c->gl_ctx );
- free(c);
- return NULL;
- }
-
- /* Initialize the software rasterizer and helper modules.
- */
- {
- GLcontext *ctx = c->gl_ctx;
- _swrast_CreateContext( ctx );
- _ac_CreateContext( ctx );
- _tnl_CreateContext( ctx );
- _swsetup_CreateContext( ctx );
-
-#ifdef SET_FPOINTERS_ONCE
- /*SetFunctionPointers(ctx);*/
- SetSWrastPointers(ctx);
-#endif // SET_FPOINTERS_ONCE
- _swsetup_Wakeup( ctx );
- }
-#ifdef COMPILE_SETPIXEL
- ChooseSetPixel(c);
-#endif
- return c;
}
-void WMesaDestroyContext( void )
-{
- WMesaContext c = Current;
- ReleaseDC(c->Window,c->hDC);
- WC = c;
- if(c->hPalHalfTone != NULL)
- DeleteObject(c->hPalHalfTone);
-
- _swsetup_DestroyContext( c->gl_ctx );
- _tnl_DestroyContext( c->gl_ctx );
- _ac_DestroyContext( c->gl_ctx );
- _swrast_DestroyContext( c->gl_ctx );
-
- _mesa_destroy_visual( c->gl_visual );
- _mesa_destroy_framebuffer( c->gl_buffer );
- _mesa_free_context_data( c->gl_ctx );
- free( (void *) c->gl_ctx);
-
- if (c->db_flag)
-#ifdef DDRAW
- DDFree(c);
-#else
- wmDeleteBackingStore(c);
-#endif
- free( (void *) c );
-#if !defined(NO_PARALLEL)
- if(parallelMachine)
- PRDestroyRenderBuffer();
-#endif
-
- // Destroyed context no longer valid
- WMesaMakeCurrent( NULL );
+/* Write an array of RGBA pixels with a boolean mask. */
+static void write_rgba_pixels_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ PWMC pwc = Current;
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL32(pwc, FLIP(y[i]), x[i],
+ rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
-
-void WMesaMakeCurrent( WMesaContext c )
-{
- if(!c){
- Current = c;
- return;
- }
-
- if(Current == c)
- return;
-
- Current = c;
- wmesa_update_state(c->gl_ctx, 0);
- _mesa_make_current(c->gl_ctx, c->gl_buffer);
- if ((c->cColorBits <= 8 ) && (c->rgb_flag == GL_TRUE)){
- WMesaPaletteChange(c->hPalHalfTone);
- }
+/*
+ * Write an array of pixels with a boolean mask. The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_pixels_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ PWMC pwc = Current;
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL32(pwc, FLIP(y[i]),x[i],color[RCOMP],
+ color[GCOMP], color[BCOMP]);
}
-
-
-void WMesaSwapBuffers( void )
-{
-/* HDC DC = Current->hDC;*/
- GET_CURRENT_CONTEXT(ctx);
-
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- if (Current && Current->gl_ctx == ctx)
- _mesa_notifySwapBuffers(ctx);
-
- if (Current->db_flag)
- wmFlush(Current);
+/* Read a horizontal span of color pixels. */
+static void read_rgba_span_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4] )
+{
+ GLuint i;
+ DWORD pixel;
+ LPDWORD lpdw;
+ PWMC pwc = Current;
+
+ y = FLIP(y);
+ lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ for (i=0; i<n; i++) {
+ pixel = lpdw[i];
+ rgba[i][RCOMP] = (pixel & 0x00ff0000) >> 16;
+ rgba[i][GCOMP] = (pixel & 0x0000ff00) >> 8;
+ rgba[i][BCOMP] = (pixel & 0x000000ff);
+ rgba[i][ACOMP] = 255;
+ }
}
-
-void WMesaPaletteChange(HPALETTE Pal)
-{
-#ifndef DDRAW
- int vRet;
-#endif
- LPPALETTEENTRY pPal;
- if (Current && (Current->rgb_flag==GL_FALSE ||
- Current->dither_flag == GL_TRUE))
- {
- pPal = (PALETTEENTRY *)malloc( 256 * sizeof(PALETTEENTRY));
- Current->hPal=Pal;
- GetPaletteEntries( Pal, 0, 256, pPal );
-#ifdef DDRAW
- Current->lpDD->lpVtbl->CreatePalette(Current->lpDD,DDPCAPS_8BIT,
- pPal, &(Current->lpDDPal), NULL);
- if (Current->lpDDPal)
- Current->lpDDSPrimary->lpVtbl->SetPalette(Current->lpDDSPrimary,
- Current->lpDDPal);
-#else
- vRet = SetDIBColorTable(Current->dib.hDC, 0, 256, (RGBQUAD*)pPal);
-#endif
- free( pPal );
- }
+/* Read an array of color pixels. */
+static void read_rgba_pixels_32(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4])
+{
+ GLuint i;
+ DWORD pixel;
+ LPDWORD lpdw;
+ PWMC pwc = Current;
+
+ for (i=0; i<n; i++) {
+ GLint y2 = FLIP(y[i]);
+ lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * y2)) + x[i];
+ pixel = lpdw[i];
+ rgba[i][RCOMP] = (pixel & 0x00ff0000) >> 16;
+ rgba[i][GCOMP] = (pixel & 0x0000ff00) >> 8;
+ rgba[i][BCOMP] = (pixel & 0x000000ff);
+ rgba[i][ACOMP] = 255;
+ }
}
+/*********************************************************************/
+/* DOUBLE BUFFER 16-bit */
-static unsigned char threeto8[8] = {
- 0, 0111>>1, 0222>>1, 0333>>1, 0444>>1, 0555>>1, 0666>>1, 0377
-};
+#define WMSETPIXEL16(pwc, y, x, r, g, b) { \
+LPWORD lpw = ((LPWORD)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (x)); \
+*lpw = BGR16((r),(g),(b)); }
-static unsigned char twoto8[4] = {
- 0, 0x55, 0xaa, 0xff
-};
-static unsigned char oneto8[2] = {
- 0, 255
-};
-static unsigned char componentFromIndex(UCHAR i, UINT nbits, UINT shift)
+/* Write a horizontal span of RGBA color pixels with a boolean mask. */
+static void write_rgba_span_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
{
- unsigned char val;
-
- val = i >> shift;
- switch (nbits) {
-
- case 1:
- val &= 0x1;
- return oneto8[val];
-
- case 2:
- val &= 0x3;
- return twoto8[val];
-
- case 3:
- val &= 0x7;
- return threeto8[val];
-
- default:
- return 0;
- }
-}
+ PWMC pwc = Current;
+ GLuint i;
+ LPWORD lpw;
-void wmCreatePalette( PWMC pwdc )
-{
- /* Create a compressed and re-expanded 3:3:2 palette */
- int i;
- LOGPALETTE *pPal;
- BYTE rb, rs, gb, gs, bb, bs;
-
- pwdc->nColors = 0x100;
-
- pPal = (PLOGPALETTE)malloc(sizeof(LOGPALETTE) +
- pwdc->nColors * sizeof(PALETTEENTRY));
- memset( pPal, 0, sizeof(LOGPALETTE) + pwdc->nColors * sizeof(PALETTEENTRY) );
-
- pPal->palVersion = 0x300;
-
- rb = REDBITS;
- rs = REDSHIFT;
- gb = GREENBITS;
- gs = GREENSHIFT;
- bb = BLUEBITS;
- bs = BLUESHIFT;
-
- if (pwdc->db_flag) {
+ (void) ctx;
- /* Need to make two palettes: one for the screen DC and one for the DIB. */
- pPal->palNumEntries = pwdc->nColors;
- for (i = 0; i < pwdc->nColors; i++) {
- pPal->palPalEntry[i].peRed = componentFromIndex( i, rb, rs );
- pPal->palPalEntry[i].peGreen = componentFromIndex( i, gb, gs );
- pPal->palPalEntry[i].peBlue = componentFromIndex( i, bb, bs );
- pPal->palPalEntry[i].peFlags = 0;
+ y=FLIP(y);
+ lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpw[i] = BGR16(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]);
}
- pwdc->hGLPalette = CreatePalette( pPal );
- pwdc->hPalette = CreatePalette( pPal );
- }
-
- else {
- pPal->palNumEntries = pwdc->nColors;
- for (i = 0; i < pwdc->nColors; i++) {
- pPal->palPalEntry[i].peRed = componentFromIndex( i, rb, rs );
- pPal->palPalEntry[i].peGreen = componentFromIndex( i, gb, gs );
- pPal->palPalEntry[i].peBlue = componentFromIndex( i, bb, bs );
- pPal->palPalEntry[i].peFlags = 0;
+ else {
+ for (i=0; i<n; i++)
+ *lpw++ = BGR16(rgba[i][RCOMP], rgba[i][GCOMP],
+ rgba[i][BCOMP]);
}
- pwdc->hGLPalette = CreatePalette( pPal );
- }
-
- free(pPal);
-
-}
-
-
-void
-#ifdef COMPILE_SETPIXEL
-
-wmSetPixelDefault(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- if (Current->db_flag)
- {
-#ifdef DDRAW
- HDC hdc = NULL;
- Current->lpDDSOffScreen->lpVtbl->Unlock(Current->lpDDSOffScreen,NULL);
- Current->lpDDSOffScreen->lpVtbl->GetDC(Current->lpDDSOffScreen,&hdc);
- SetPixelV(hdc,iPixel, iScanLine, RGB(r,g,b));
- Current->lpDDSOffScreen->lpVtbl->ReleaseDC(Current->lpDDSOffScreen,hdc);
- while (Current->lpDDSOffScreen->lpVtbl->Lock(Current->lpDDSOffScreen,NULL, &(Current->ddsd), 0, NULL) == DDERR_WASSTILLDRAWING);
-#else
- SetPixelV(Current->hDC, iPixel, iScanLine, RGB(r,g,b));
-#endif
- }
- else
- {
- SetPixelV(Current->hDC, iPixel+pwc->rectSurface.left, pwc->rectSurface.top+iScanLine, RGB(r,g,b));
- }
-}
-#else
-wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- if (Current->db_flag)
- {
- LPBYTE lpb = pwc->pbPixels;
- UINT nBypp = pwc->cColorBits >> 3;
-
- lpb += pwc->ScanWidth * iScanLine;
- lpb += iPixel * nBypp;
-
- if(nBypp == 1)
- {
- if(pwc->dither_flag)
- *lpb = DITHER_RGB_2_8BIT(r,g,b,iScanLine,iPixel);
- else
- *lpb = BGR8(r,g,b);
- }
- else if(nBypp == 2)
- *((LPWORD)lpb) = BGR16(r,g,b);
- else if (nBypp == 3)
- {
- *lpb++ = b;
- *lpb++ = g;
- *lpb = r;
- }
- else if (nBypp == 4)
- *((LPDWORD)lpb) = BGR32(r,g,b);
- }
- else
- {
- SetPixel(Current->hDC, iPixel, iScanLine, RGB(r,g,b));
- }
-}
-#endif
-#ifdef COMPILE_SETPIXEL
-void wmSetPixel4(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- LPDWORD lpdw = ((LPDWORD)(pwc->pbPixels + pwc->ScanWidth * iScanLine)) + iPixel;
- *lpdw = BGR32(r,g,b);
-// LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel + iPixel + iPixel + iPixel;
-// *((LPDWORD)lpb) = BGR32(r,g,b);
}
-void wmSetPixel3(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel + iPixel + iPixel;
- *lpb++ = b;
- *lpb++ = g;
- *lpb = r;
-}
-
-void wmSetPixel2(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- LPWORD lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * iScanLine)) + iPixel;
- *lpw = BGR16(r,g,b);
-// LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel + iPixel;
-// *((LPWORD)lpb) = BGR16(r,g,b);
-}
-void wmSetPixel1(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel;
- *lpb = BGR8(r,g,b);
-}
-
-void wmSetPixel1Dither(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
-{
- LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel;
- *lpb = DITHER_RGB_2_8BIT(r,g,b,iScanLine,iPixel);
-}
-
-
-void ChooseSetPixel(PWMC pwc)
+/* Write a horizontal span of RGB color pixels with a boolean mask. */
+static void write_rgb_span_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][4],
+ const GLubyte mask[] )
{
- UINT nBypp = (pwc ) ? pwc->cColorBits >> 3 : 0;
- switch(nBypp)
- {
- case 1:
- pwc->wmSetPixel = pwc->dither_flag ? &wmSetPixel1Dither : &wmSetPixel1;
- break;
- case 2:
- pwc->wmSetPixel = &wmSetPixel2;
- break;
- case 3:
- pwc->wmSetPixel = &wmSetPixel3;
- break;
- case 4:
- pwc->wmSetPixel = &wmSetPixel4;
- break;
- default:
- pwc->wmSetPixel = &wmSetPixelDefault;
- break;
- }
-}
+ PWMC pwc = Current;
+ GLuint i;
+ LPWORD lpw;
-#endif
-
-void wmCreateDIBSection(
- HDC hDC,
- PWMC pwc, // handle of device context
- CONST BITMAPINFO *pbmi, // bitmap size, format, and color data
- UINT iUsage // color data type indicator: RGB values or palette indices
- )
-{
- DWORD dwSize = 0;
- DWORD dwScanWidth;
- UINT nBypp = pwc->cColorBits / 8;
- HDC hic;
- (void) hDC;
- (void) pbmi;
-
- dwScanWidth = (((pwc->ScanWidth * nBypp)+ 3) & ~3);
-
- pwc->ScanWidth =pwc->pitch = dwScanWidth;
-
- if (stereo_flag)
- pwc->ScanWidth = 2* pwc->pitch;
-
- dwSize = sizeof(BITMAPINFO) + (dwScanWidth * pwc->height);
-#ifdef USE_MAPPED_FILE
- pwc->dib.hFileMap = CreateFileMapping((HANDLE)PAGE_FILE,
- NULL,
- PAGE_READWRITE | SEC_COMMIT,
- 0,
- dwSize,
- NULL);
-
- if (!pwc->dib.hFileMap)
- return;
-
- pwc->dib.base = MapViewOfFile(pwc->dib.hFileMap,
- FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- 0);
-
- if(!pwc->dib.base){
- CloseHandle(pwc->dib.hFileMap);
- return;
- }
-
-
- CopyMemory(pwc->dib.base, pbmi, sizeof(BITMAPINFO));
-#endif // USE_MAPPED_FILE
-
- hic = CreateIC("display", NULL, NULL, NULL);
- pwc->dib.hDC = CreateCompatibleDC(hic);
-
-#ifdef USE_MAPPED_FILE
-
- pwc->hbmDIB = CreateDIBSection(hic,
- &(pwc->bmi),
- (iUsage ? DIB_PAL_COLORS : DIB_RGB_COLORS),
- (void **)&(pwc->pbPixels),
- pwc->dib.hFileMap,
- 0);
-#else
- pwc->hbmDIB = CreateDIBSection(hic,
- &(pwc->bmi),
- (iUsage ? DIB_PAL_COLORS : DIB_RGB_COLORS),
- (void **)&(pwc->pbPixels),
- 0,
- 0);
-#endif // USE_MAPPED_FILE
- pwc->ScreenMem = pwc->addrOffScreen = pwc->pbPixels;
- pwc->hOldBitmap = SelectObject(pwc->dib.hDC, pwc->hbmDIB);
-
- DeleteDC(hic);
-
- return;
-
+ (void) ctx;
+
+ y=FLIP(y);
+ lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpw[i] = BGR16(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]);
+ }
+ else {
+ for (i=0; i<n; i++)
+ *lpw++ = BGR16(rgb[i][RCOMP], rgb[i][GCOMP],
+ rgb[i][BCOMP]);
+ }
}
/*
- * Blit memory DC to screen DC
+ * Write a horizontal span of pixels with a boolean mask. The current color
+ * is used for all pixels.
*/
-BOOL wmFlush(PWMC pwc)
-{
- BOOL bRet = 0;
-/* DWORD dwErr = 0;*/
-#ifdef DDRAW
- HRESULT ddrval;
-#endif
-
- if(pwc->db_flag){
-#ifdef DDRAW
- if (pwc->lpDDSOffScreen == NULL)
- if(DDCreateOffScreen(pwc) == GL_FALSE)
- return FALSE;
-
- pwc->lpDDSOffScreen->lpVtbl->Unlock(pwc->lpDDSOffScreen, NULL);
-
- while( 1 )
- {
- ddrval = pwc->lpDDSPrimary->lpVtbl->Blt( pwc->lpDDSPrimary,
- &(pwc->rectSurface),
- pwc->lpDDSOffScreen,
- &(pwc->rectOffScreen),
- 0, NULL );
-
- if( ddrval == DD_OK )
- {
- break;
- }
- if( ddrval == DDERR_SURFACELOST )
- {
- if(!DDRestoreAll(pwc))
- {
- break;
- }
- }
- if( ddrval != DDERR_WASSTILLDRAWING )
- {
- break;
- }
- }
-
- while (pwc->lpDDSOffScreen->lpVtbl->Lock(pwc->lpDDSOffScreen,
- NULL, &(pwc->ddsd), 0, NULL) ==
- DDERR_WASSTILLDRAWING)
- ;
-
- if(ddrval != DD_OK)
- dwErr = GetLastError();
-#else
- bRet = BitBlt(pwc->hDC, 0, 0, pwc->width, pwc->height,
- pwc->dib.hDC, 0, 0, SRCCOPY);
-#endif
- }
-
- return(TRUE);
-
-}
-
-
-/* The following code is added by Li Wei to enable stereo display */
-
-#if !defined(NO_STEREO)
-
-static void __gluMakeIdentityf(GLfloat m[16])
-{
- m[0+4*0] = 1; m[0+4*1] = 0; m[0+4*2] = 0; m[0+4*3] = 0;
- m[1+4*0] = 0; m[1+4*1] = 1; m[1+4*2] = 0; m[1+4*3] = 0;
- m[2+4*0] = 0; m[2+4*1] = 0; m[2+4*2] = 1; m[2+4*3] = 0;
- m[3+4*0] = 0; m[3+4*1] = 0; m[3+4*2] = 0; m[3+4*3] = 1;
-}
-
-static void normalize(float v[3])
-{
- float r;
-
- r = sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
- if (r == 0.0) return;
-
- v[0] /= r;
- v[1] /= r;
- v[2] /= r;
-}
-
-static void cross(float v1[3], float v2[3], float result[3])
-{
- result[0] = v1[1]*v2[2] - v1[2]*v2[1];
- result[1] = v1[2]*v2[0] - v1[0]*v2[2];
- result[2] = v1[0]*v2[1] - v1[1]*v2[0];
-}
-
-
-static void
-__gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
- GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
- GLdouble upz)
-{
- int i;
- float forward[3], side[3], up[3];
- GLfloat m[4][4];
-
- forward[0] = centerx - eyex;
- forward[1] = centery - eyey;
- forward[2] = centerz - eyez;
-
- up[0] = upx;
- up[1] = upy;
- up[2] = upz;
-
- normalize(forward);
-
- /* Side = forward x up */
- cross(forward, up, side);
- normalize(side);
-
- /* Recompute up as: up = side x forward */
- cross(side, forward, up);
-
- __gluMakeIdentityf(&m[0][0]);
- m[0][0] = side[0];
- m[1][0] = side[1];
- m[2][0] = side[2];
-
- m[0][1] = up[0];
- m[1][1] = up[1];
- m[2][1] = up[2];
-
- m[0][2] = -forward[0];
- m[1][2] = -forward[1];
- m[2][2] = -forward[2];
+static void write_mono_rgba_span_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ LPWORD lpw;
+ WORD pixel;
+ GLuint i;
+ PWMC pwc = Current;
+ (void) ctx;
+ lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ y=FLIP(y);
+ pixel = BGR16(color[RCOMP], color[GCOMP], color[BCOMP]);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ lpw[i] = pixel;
+ }
+ else
+ for (i=0; i<n; i++)
+ *lpw++ = pixel;
- glMultMatrixf(&m[0][0]);
- glTranslated(-eyex, -eyey, -eyez);
}
-GLfloat viewDistance = 1.0;
-
-void WMesaShowStereo(GLuint list)
-{
-
- GLbitfield mask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
- GLfloat cm[16];
- GLint matrix_mode;
- /* Must use double Buffer */
- if( ! Current-> db_flag )
- return;
-
-
- glGetIntegerv(GL_MATRIX_MODE,&matrix_mode);
-
- WMesaViewport(Current->gl_ctx,0,Current->height/2,
- Current->width,Current->height/2);
- if(matrix_mode!=GL_MODELVIEW)
- glMatrixMode(GL_MODELVIEW);
-
- glGetFloatv(GL_MODELVIEW_MATRIX,cm);
- glLoadIdentity();
- __gluLookAt(viewDistance/2,0.0,0.0 ,
- viewDistance/2,0.0,-1.0,
- 0.0,1.0,0.0 );
- glMultMatrixf( cm );
-
- Current->ScreenMem = Current->pbPixels = Current->addrOffScreen;
- glCallList( list );
-
- glGetFloatv(GL_MODELVIEW_MATRIX,cm);
- glLoadIdentity();
- __gluLookAt(-viewDistance/2,0.0,0.0 ,
- -viewDistance/2,0.0,-1.0,
- 0.0,1.0,0.0 );
- glMultMatrixf(cm);
-
- Current->ScreenMem = Current->pbPixels = Current->addrOffScreen + Current->pitch;
- glCallList(list);
- if(matrix_mode!=GL_MODELVIEW)
- glMatrixMode(matrix_mode);
-
- glFlush();
-
- WMesaViewport(Current->gl_ctx,0,0,Current->width,Current->height);
- WMesaSwapBuffers();
+/* Write an array of RGBA pixels with a boolean mask. */
+static void write_rgba_pixels_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ PWMC pwc = Current;
+ (void) ctx;
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL16(pwc, FLIP(y[i]), x[i],
+ rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
-void toggleStereoMode()
-{
- if(!Current->db_flag)
- return;
- if(!stereo_flag){
- stereo_flag = 1;
- if(stereoBuffer==GL_FALSE)
-#if !defined(NO_PARALLEL)
- if(!parallelFlag)
-#endif
- {
- Current->ScanWidth = Current->pitch*2;
- }
- }
- else {
- stereo_flag = 0;
-#if !defined(NO_PARALLEL)
- if(!parallelFlag)
-#endif
- Current->ScanWidth = Current->pitch;
- Current->pbPixels = Current->addrOffScreen;
- }
+/*
+ * Write an array of pixels with a boolean mask. The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_pixels_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ PWMC pwc = Current;
+ (void) ctx;
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL16(pwc, FLIP(y[i]),x[i],color[RCOMP],
+ color[GCOMP], color[BCOMP]);
}
-/* if in stereo mode, the following function is called */
-void glShowStereo(GLuint list)
-{
- WMesaShowStereo(list);
+/* Read a horizontal span of color pixels. */
+static void read_rgba_span_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4] )
+{
+ GLuint i, pixel;
+ LPWORD lpw;
+ PWMC pwc = Current;
+
+ y = FLIP(y);
+ lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * y)) + x;
+ for (i=0; i<n; i++) {
+ pixel = lpw[i];
+ /* Windows uses 5,5,5 for 16-bit */
+ rgba[i][RCOMP] = (pixel & 0x7c00) >> 7;
+ rgba[i][GCOMP] = (pixel & 0x03e0) >> 2;
+ rgba[i][BCOMP] = (pixel & 0x001f) << 3;
+ rgba[i][ACOMP] = 255;
+ }
}
-#endif /* NO_STEREO */
-
-#if !defined(NO_PARALLEL)
-void toggleParallelMode(void)
-{
- if(!parallelFlag){
- parallelFlag = GL_TRUE;
- if(parallelMachine==GL_FALSE){
- PRCreateRenderBuffer( Current->rgb_flag? GL_RGBA :GL_COLOR_INDEX,
- Current->cColorBits/8,
- Current->width ,Current->height,
- Current->ScanWidth,
- Current->rgb_flag? Current->pbPixels:
- Current->ScreenMem);
- parallelMachine = GL_TRUE;
- }
- }
- else {
- parallelFlag = GL_FALSE;
- if(parallelMachine==GL_TRUE){
- PRDestroyRenderBuffer();
- parallelMachine=GL_FALSE;
- ReadyForNextFrame = GL_TRUE;
- }
-
- /***********************************************
- * Seems something wrong!!!!
- ************************************************/
-
- WMesaMakeCurrent(Current);
-#if !defined(NO_STEREO)
- stereo_flag = GL_FALSE ;
-#endif
+/* Read an array of color pixels. */
+static void read_rgba_pixels_16(const GLcontext* ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4])
+{
+ GLuint i, pixel;
+ LPWORD lpw;
+ PWMC pwc = Current;
+
+ for (i=0; i<n; i++) {
+ GLint y2 = FLIP(y[i]);
+ lpw = ((LPWORD)(pwc->pbPixels + pwc->ScanWidth * y2)) + x[i];
+ pixel = lpw[i];
+ /* Windows uses 5,5,5 for 16-bit */
+ rgba[i][RCOMP] = (pixel & 0x7c00) >> 7;
+ rgba[i][GCOMP] = (pixel & 0x03e0) >> 2;
+ rgba[i][BCOMP] = (pixel & 0x001f) << 3;
+ rgba[i][ACOMP] = 255;
}
}
-void PRShowRenderResult(void)
-{
- int flag = 0;
- if(!glImageRendered())
- return;
-
- if (parallelFlag)
- {
- WMesaSwapBuffers();
- }
-
-}
-#endif /* NO_PARALLEL */
-BYTE DITHER_RGB_2_8BIT( int red, int green, int blue, int pixel, int scanline)
-{
- char unsigned redtemp, greentemp, bluetemp, paletteindex;
-
- //*** now, look up each value in the halftone matrix
- //*** using an 8x8 ordered dither.
- redtemp = aDividedBy51[red]
- + (aModulo51[red] > aHalftone8x8[(pixel%8)*8
- + scanline%8]);
- greentemp = aDividedBy51[(char unsigned)green]
- + (aModulo51[green] > aHalftone8x8[
- (pixel%8)*8 + scanline%8]);
- bluetemp = aDividedBy51[(char unsigned)blue]
- + (aModulo51[blue] > aHalftone8x8[
- (pixel%8)*8 +scanline%8]);
-
- //*** recombine the halftoned rgb values into a palette index
- paletteindex =
- redtemp + aTimes6[greentemp] + aTimes36[bluetemp];
-
- //*** and translate through the wing halftone palette
- //*** translation vector to give the correct value.
- return aWinGHalftoneTranslation[paletteindex];
-}
-#ifdef DDRAW
-/*
- * restoreAll
- *
- * restore all lost objects
- */
-HRESULT DDRestoreAll( WMesaContext wc )
-{
- HRESULT ddrval;
-
- ddrval = wc->lpDDSPrimary->lpVtbl->Restore(wc->lpDDSPrimary);
- if( ddrval == DD_OK )
- {
- ddrval = wc->lpDDSOffScreen->lpVtbl->Restore(wc->lpDDSOffScreen);
- }
- return ddrval;
-
-} /* restoreAll */
+/**********************************************************************/
+/***** BUFFER Functions *****/
+/**********************************************************************/
-/*
- * This function is called if the initialization function fails
- */
-BOOL initFail( HWND hwnd, WMesaContext wc )
-{
- DDFree(wc);
- MessageBox( hwnd, "DirectDraw Init FAILED", "", MB_OK );
- return FALSE;
-
-} /* initFail */
-static void DDDeleteOffScreen(WMesaContext wc)
-{
- if( wc->lpDDSOffScreen != NULL )
- {
- wc->lpDDSOffScreen->lpVtbl->Unlock(wc->lpDDSOffScreen,NULL);
- wc->lpDDSOffScreen->lpVtbl->Release(wc->lpDDSOffScreen);
- wc->lpDDSOffScreen = NULL;
- }
-
-}
-static void DDFreePrimarySurface(WMesaContext wc)
+static void
+wmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
{
- if( wc->lpDDSPrimary != NULL )
- {
- if(wc->db_flag == GL_FALSE)
- wc->lpDDSPrimary->lpVtbl->ReleaseDC(wc->lpDDSPrimary, wc->hDC);
- wc->lpDDSPrimary->lpVtbl->Release(wc->lpDDSPrimary);
- wc->lpDDSPrimary = NULL;
- }
+ _mesa_free(rb);
}
-static BOOL DDCreatePrimarySurface(WMesaContext wc)
+static GLboolean
+wmesa_renderbuffer_storage(GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width,
+ GLuint height)
{
- HRESULT ddrval;
-// DDSCAPS ddscaps;
- wc->ddsd.dwSize = sizeof( wc->ddsd );
- wc->ddsd.dwFlags = DDSD_CAPS;
- wc->ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- ddrval = wc->lpDD->lpVtbl->CreateSurface( wc->lpDD,&(wc->ddsd),
- &(wc->lpDDSPrimary), NULL );
- if( ddrval != DD_OK )
- {
- return initFail(wc->hwnd , wc);
- }
- if(wc->db_flag == GL_FALSE)
- wc->lpDDSPrimary->lpVtbl->GetDC(wc->lpDDSPrimary, &(wc->hDC));
- return TRUE;
+ return GL_TRUE;
}
-static BOOL DDCreateOffScreen(WMesaContext wc)
-{
- POINT pt;
- HRESULT ddrval;
- if(wc->lpDD == NULL)
- return FALSE;
- GetClientRect( wc->hwnd, &(wc->rectOffScreen) );
- wc->ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- wc->ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- wc->ddsd.dwHeight = wc->rectOffScreen.bottom - wc->rectOffScreen.top;
- wc->ddsd.dwWidth = wc->rectOffScreen.right - wc->rectOffScreen.left;
-
- ddrval = wc->lpDD->lpVtbl->CreateSurface( wc->lpDD, &(wc->ddsd),
- &(wc->lpDDSOffScreen), NULL );
- if( ddrval != DD_OK )
- {
- return FALSE;
+/**
+ * Called by ctx->Driver.ResizeBuffers()
+ * Resize the front/back colorbuffers to match the latest window size.
+ */
+static void
+wmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height)
+{
+ RECT CR;
+ if (Current->width != width || Current->height != height) {
+ Current->width = width;
+ Current->height = height;
+ /* Realloc back buffer */
+ if (Current->db_flag) {
+ wmDeleteBackingStore(Current);
+ wmCreateBackingStore(Current, width, height);
+ }
+ GetClientRect(Current->Window, &CR);
+ Current->width = CR.right;
+ Current->height = CR.bottom;
}
-
- while (wc->lpDDSOffScreen->lpVtbl->Lock(wc->lpDDSOffScreen,NULL,
- &(wc->ddsd), 0, NULL) ==
- DDERR_WASSTILLDRAWING)
- ;
-
- if(wc->ddsd.lpSurface==NULL)
- return initFail(wc->hwnd, wc);
-
- wc->ScreenMem = wc->pbPixels = wc->addrOffScreen =
- (PBYTE)(wc->ddsd.lpSurface);
- wc->ScanWidth = wc->pitch = wc->ddsd.lPitch;
- if (stereo_flag)
- wc->ScanWidth = wc->ddsd.lPitch*2;
-
- GetClientRect( wc->hwnd, &(wc->rectSurface) );
- pt.x = pt.y = 0;
- ClientToScreen( wc->hwnd, &pt );
- OffsetRect(&(wc->rectSurface), pt.x, pt.y);
- wmSetPixelFormat(wc, wc->hDC);
- return TRUE;
+ _mesa_resize_framebuffer(ctx, buffer, width, height);
}
-typedef
-struct tagWMesaContextList
-{
- WMesaContext wc;
- struct tagWMesaContextList *next;
-}WMesaContextList;
-
-WMesaContextList *head = 0;
-void AddContext(WMesaContext wc)
+/**
+ * Called by glViewport.
+ * This is a good time for us to poll the current window size and adjust
+ * our renderbuffers to match the current window size.
+ * Remember, we have no opportunity to respond to conventional
+ * resize events since the driver has no event loop.
+ * Thus, we poll.
+ * Note that this trick isn't fool-proof. If the application never calls
+ * glViewport, our notion of the current window size may be incorrect.
+ */
+static void wmesa_viewport(GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
{
- WMesaContextList *lst = (WMesaContextList *)malloc(sizeof(WMesaContextList));
- lst->wc = wc;
- if( head )
- lst->next = head;
- head = lst;
+ if (Current->width != width || Current->height != height) {
+ wmesa_resize_buffers(ctx, ctx->WinSysDrawBuffer, width, height);
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ }
}
-WMesaContext FindContext(HWND hWnd)
-{
- WMesaContextList *tmp = head;
- while(tmp)
- {
- if( tmp->wc->hwnd == hWnd )
- return tmp->wc;
- tmp = tmp->next;
- }
- return NULL;
-}
-void RemoveContext(HWND hWnd)
-{
- WMesaContextList *tmp = head;
- if(tmp )
- {
- if( tmp->wc->hwnd == hWnd )
- {
- WMesaContextList *lst = tmp;
-
- head = tmp->next;
- free((void *)lst);
- }
- else
- while(tmp->next)
- {
- if( tmp->next->wc->hwnd == hWnd )
- {
- WMesaContextList *lst = tmp->next;
- tmp->next = tmp->next->next;
- free((void *)lst);
- }
- tmp = tmp->next;
- }
- }
-}
-static LRESULT CALLBACK MyWndProc(HWND hwnd,UINT message,WPARAM wParam, LPARAM lParam)
-{
- WMesaContext wc;
-
- if (Current==0 || Current->hwnd != hwnd)
- wc=FindContext(hwnd);
- else
- wc=Current;
-
-
- if( wc )
- {
- LRESULT lret = CallWindowProc((WNDPROC)(wc->oldWndProc),hwnd,message,wParam,lParam);
- if( message = WM_MOVE )
- {
- POINT pt = {0};
- GetClientRect( wc->hwnd, &(wc->rectSurface) );
- ClientToScreen( hwnd, &pt );
- OffsetRect(&(wc->rectSurface), pt.x, pt.y);
- }
- return lret;
- }
- return 0L;
-}
-/*
- * doInit - do work required for every instance of the application:
- * create the window, initialize data
+/**
+ * Called when the driver should update it's state, based on the new_state
+ * flags.
*/
-static BOOL DDInit( WMesaContext wc, HWND hwnd)
+static void wmesa_update_state(GLcontext *ctx, GLuint new_state)
{
- HRESULT ddrval;
-// DWORD dwFrequency;
-
-// LPDIRECTDRAW lpDD; // DirectDraw object
-// LPDIRECTDRAW2 lpDD2;
- LPDIRECTDRAWCLIPPER pcClipper = NULL;
-
- wc->fullScreen = displayOptions.fullScreen;
- wc->gMode = displayOptions.mode;
- wc->hwnd = hwnd;
- stereo_flag = displayOptions.stereo;
- if(wc->db_flag!= GL_TRUE)
- stereo_flag = GL_FALSE;
- /*
- * create the main DirectDraw object
- */
- ddrval = DirectDrawCreate( NULL, &(wc->lpDD), NULL );
- if( ddrval != DD_OK )
- {
- return initFail(hwnd,wc);
- }
-
- // Get exclusive mode if requested
- if(wc->fullScreen)
- {
- ddrval = wc->lpDD->lpVtbl->SetCooperativeLevel( wc->lpDD, hwnd,
- DDSCL_EXCLUSIVE |
- DDSCL_FULLSCREEN );
- }
- else
- {
- ddrval = wc->lpDD->lpVtbl->SetCooperativeLevel( wc->lpDD, hwnd,
- DDSCL_NORMAL );
- }
- if( ddrval != DD_OK )
- {
- return initFail(hwnd , wc);
- }
-
-
- if(ddrval != DD_OK)
- return initFail(hwnd , wc);
-
-
- switch( wc->gMode )
- {
- case 1:
- ddrval = wc->lpDD->lpVtbl->SetDisplayMode( wc->lpDD, 640, 480,
- displayOptions.bpp);
- break;
- case 2:
- ddrval = wc->lpDD->lpVtbl->SetDisplayMode( wc->lpDD, 800, 600,
- displayOptions.bpp);
- break;
- case 3:
- ddrval = wc->lpDD->lpVtbl->SetDisplayMode( wc->lpDD, 1024, 768,
- displayOptions.bpp);
- break;
- case 4:
- ddrval = wc->lpDD->lpVtbl->SetDisplayMode( wc->lpDD, 1152, 864,
- displayOptions.bpp);
- break;
- case 5:
- ddrval = wc->lpDD->lpVtbl->SetDisplayMode( wc->lpDD, 1280, 1024,
- displayOptions.bpp);
- break;
- }
-
- if( ddrval != DD_OK )
- {
- printf("Can't modify display mode, current mode used\n");
- }
- switch(ddrval){
- case DDERR_INVALIDOBJECT:
- break;
- case DDERR_INVALIDPARAMS:
- break;
- case DDERR_UNSUPPORTEDMODE:
- ;
- }
-
- if(DDCreatePrimarySurface(wc) == GL_FALSE)
- return initFail(hwnd, wc);
-
- if(wc->db_flag)
- DDCreateOffScreen(wc);
-
- if( FAILED( ddrval = wc->lpDD->lpVtbl->CreateClipper(wc->lpDD, 0, &pcClipper, NULL ) ) )
- return E_FAIL;
+ _swrast_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
+ _ac_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
- if( FAILED( ddrval = pcClipper->lpVtbl->SetHWnd(pcClipper, 0, wc->hwnd ) ) )
- {
- pcClipper->lpVtbl->Release(pcClipper);
- return E_FAIL;
- }
-
- if( FAILED( ddrval = wc->lpDDSPrimary->lpVtbl->SetClipper(wc->lpDDSPrimary, pcClipper ) ) )
- {
- pcClipper->lpVtbl->Release(pcClipper);
- return E_FAIL;
- }
-
- // Done with clipper
- pcClipper->lpVtbl->Release(pcClipper);
- AddContext(wc);
- // Hook the window so we can update the drawing rectangle when the window moves
- wc->oldWndProc = SetWindowLong(wc->hwnd,GWL_WNDPROC,(LONG)MyWndProc);
-
- return TRUE;
-
-} /* DDInit */
-
-static void DDFree( WMesaContext wc)
-{
- RemoveContext(wc->hwnd);
- SetWindowLong(wc->hwnd,GWL_WNDPROC,(LONG)(wc->oldWndProc));
- wc->oldWndProc = 0;
- if( wc->lpDD != NULL )
- {
- DDFreePrimarySurface(wc);
- DDDeleteOffScreen(wc);
- wc->lpDD->lpVtbl->Release(wc->lpDD);
- wc->lpDD = NULL;
- }
- // Clean up the screen on exit
- RedrawWindow( NULL, NULL, NULL, RDW_INVALIDATE | RDW_ERASE |
- RDW_ALLCHILDREN );
-
+ /* TODO - need code to update the span functions in case the
+ * renderer changes the target buffer (like a DB app writing to
+ * the front buffer). */
}
-#endif
-void WMesaMove(void)
-{
- WMesaContext wc = Current;
- POINT pt;
- if (Current != NULL){
- GetClientRect( wc->hwnd, &(wc->rectSurface) );
- pt.x = pt.y = 0;
- ClientToScreen( wc->hwnd, &pt );
- OffsetRect(&(wc->rectSurface), pt.x, pt.y);
- }
-}
-
-
-/************************************************
- * Mesa 4.0 - These triangle rasterizers are not
- * implemented in this version of the Windows
- * driver. They could be implemented for a
- * potential performance improvement.
- * See OSMesa for an example of the approach
- * to use.
- * This old code is left in this file in case
- * it is useful. However, it may end up looking
- * a lot more like the OSMesa code.
- ************************************************/
-#if defined(FAST_RASTERIZERS)
-/*
- * Like PACK_8A8B8G8R() but don't use alpha. This is usually an acceptable
- * shortcut.
- */
-#define PACK_8B8G8R( R, G, B ) ( ((B) << 16) | ((G) << 8) | (R) )
-
/**********************************************************************/
-/*** Triangle rendering ***/
+/***** WMESA Functions *****/
/**********************************************************************/
-/*
- * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
- */
-static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
- }
-
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, smooth, depth-buffered, PF_8R8G8B triangle.
-*/
-static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-
-/*
-* XImage, smooth, depth-buffered, PF_5R6G5B triangle.
-*/
-static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
+WMesaContext WMesaCreateContext(HWND hWnd,
+ HPALETTE* Pal,
+ GLboolean rgb_flag,
+ GLboolean db_flag,
+ GLboolean alpha_flag)
{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(X,Y)
-#define PIXEL_TYPE GLushort
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-/*
-* XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
-*/
-static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, flat, depth-buffered, PF_8R8G8B triangle.
-*/
-static void flat_8R8G8B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
+ RECT CR;
+ WMesaContext c;
+ struct dd_function_table functions;
+ struct gl_renderbuffer *rb;
+ (void) Pal;
+
+ /* Indexed mode not supported */
+ if (!rgb_flag)
+ return NULL;
-/*
-* XImage, flat, depth-buffered, PF_5R6G5B triangle.
-*/
-static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(X,Y)
-#define PIXEL_TYPE GLushort
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
+ c = CALLOC_STRUCT(wmesa_context);
+ if (!c)
+ return NULL;
+
+ c->Window = hWnd;
+ c->hDC = GetDC(hWnd);
+ GetClientRect(c->Window, &CR);
+ c->width = CR.right;
+ c->height = CR.bottom;
+
+ c->clearPen = CreatePen(PS_SOLID, 1, 0);
+ c->clearBrush = CreateSolidBrush(0);
+
+ /* Create back buffer if double buffered */
+ if (db_flag) {
+ c->db_flag = 1;
+ wmCreateBackingStore(c, c->width, c->height);
+
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
-*/
-static void smooth_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
+
+ c->gl_visual = _mesa_create_visual(rgb_flag,
+ db_flag, /* db_flag */
+ GL_FALSE, /* stereo */
+ 8,8,8, /* color RGB */
+ alpha_flag ? 8 : 0, /* color A */
+ 0, /* index bits */
+ 16, /* depth_bits */
+ 8, /* stencil_bits */
+ 16,16,16, /* accum RGB */
+ alpha_flag ? 16 : 0, /* accum A */
+ 1);
+
+ if (!c->gl_visual) {
+ free(c);
+ return NULL;
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-/*
-* XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
-*/
-static void smooth_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
+ /* Set up driver functions */
+ _mesa_init_driver_functions(&functions);
+ /* Fill in required functions */
+ functions.GetString = wmesa_get_string;
+ functions.UpdateState = wmesa_update_state;
+ functions.GetBufferSize = wmesa_get_buffer_size;
+ functions.Flush = wmesa_flush;
+
+ functions.Clear = clear;
+ functions.ClearIndex = clear_index;
+ functions.ClearColor = clear_color;
+
+ functions.ResizeBuffers = wmesa_resize_buffers;
+ functions.Viewport = wmesa_viewport;
+
+ /* allocate a new Mesa context */
+ c->gl_ctx = _mesa_create_context(c->gl_visual, NULL,
+ &functions, (void *)c);
+ if (!c->gl_ctx) {
+ _mesa_destroy_visual( c->gl_visual );
+ free(c);
+ return NULL;
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
-*/
-static void smooth_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(X,Y)
-#define PIXEL_TYPE GLushort
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
+
+ _mesa_enable_sw_extensions(c->gl_ctx);
+ _mesa_enable_1_3_extensions(c->gl_ctx);
+ _mesa_enable_1_4_extensions(c->gl_ctx);
+ _mesa_enable_1_5_extensions(c->gl_ctx);
+ _mesa_enable_2_0_extensions(c->gl_ctx);
+
+ c->gl_buffer = _mesa_create_framebuffer(c->gl_visual);
+ if (!c->gl_buffer) {
+ _mesa_destroy_visual(c->gl_visual);
+ _mesa_free_context_data(c->gl_ctx);
+ free(c);
+ return NULL;
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
+
+ rb = CALLOC_STRUCT(gl_renderbuffer);
-/*
-* XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
-*/
-static void flat_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = p; \
- } \
+ if (!rb) {
+ _mesa_destroy_visual(c->gl_visual);
+ _mesa_destroy_framebuffer(c->gl_buffer);
+ _mesa_free_context_data(c->gl_ctx);
+ free(c);
+ return NULL;
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
-*/
-static void flat_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(X,Y)
-#define PIXEL_TYPE GLuint
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = p; \
- } \
+ _mesa_init_renderbuffer(rb, (GLuint)0);
+
+ rb->_BaseFormat = GL_RGBA;
+ rb->InternalFormat = GL_RGBA;
+ rb->DataType = CHAN_TYPE;
+ rb->Delete = wmesa_delete_renderbuffer;
+ rb->AllocStorage = wmesa_renderbuffer_storage;
+
+ if (db_flag) {
+ switch(c->cColorBits) {
+ case 16:
+ rb->PutRow = write_rgba_span_16;
+ rb->PutRowRGB = write_rgb_span_16;
+ rb->PutMonoRow = write_mono_rgba_span_16;
+ rb->PutValues = write_rgba_pixels_16;
+ rb->PutMonoValues = write_mono_rgba_pixels_16;
+ rb->GetRow = read_rgba_span_16;
+ rb->GetValues = read_rgba_pixels_16;
+ break;
+ case 32:
+ rb->PutRow = write_rgba_span_32;
+ rb->PutRowRGB = write_rgb_span_32;
+ rb->PutMonoRow = write_mono_rgba_span_32;
+ rb->PutValues = write_rgba_pixels_32;
+ rb->PutMonoValues = write_mono_rgba_pixels_32;
+ rb->GetRow = read_rgba_span_32;
+ rb->GetValues = read_rgba_pixels_32;
+ break;
+ default:
+ break;
+ }
+ _mesa_add_renderbuffer(c->gl_buffer, BUFFER_BACK_LEFT, rb);
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
-*/
-static void flat_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(X,Y)
-#define PIXEL_TYPE GLushort
- //#define BYTES_PER_ROW (wmesa->xm_buffer->backimage->bytes_per_line)
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = p; \
- } \
+ else { /* single buffer */
+ rb->PutRow = write_rgba_span_single;
+ rb->PutRowRGB = write_rgb_span_single;
+ rb->PutMonoRow = write_mono_rgba_span_single;
+ rb->PutValues = write_rgba_pixels_single;
+ rb->PutMonoValues = write_mono_rgba_pixels_single;
+ rb->GetRow = read_rgba_span_single;
+ rb->GetValues = read_rgba_pixels_single;
+ _mesa_add_renderbuffer(c->gl_buffer, BUFFER_FRONT_LEFT, rb);
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-/*
-* XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
-*/
-
-static void smooth_ci_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define INTERP_INDEX 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = FixedToInt(ffi); \
- zRow[i] = z; \
- } \
- ffi += fdidx; \
- ffz += fdzdx; \
- } \
+ _mesa_add_soft_renderbuffers(c->gl_buffer,
+ GL_FALSE, /* color */
+ c->gl_visual->depthBits > 0,
+ c->gl_visual->stencilBits > 0,
+ c->gl_visual->accumRedBits > 0,
+ alpha_flag,
+ GL_FALSE);
+
+ /* Initialize the software rasterizer and helper modules. */
+ if (!_swrast_CreateContext(c->gl_ctx) ||
+ !_ac_CreateContext(c->gl_ctx) ||
+ !_tnl_CreateContext(c->gl_ctx) ||
+ !_swsetup_CreateContext(c->gl_ctx)) {
+ _mesa_destroy_visual(c->gl_visual);
+ _mesa_destroy_framebuffer(c->gl_buffer);
+ _mesa_free_context_data(c->gl_ctx);
+ free(c);
+ return NULL;
}
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-/*
-* XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
-*/
-
-static void flat_ci_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- GLuint index = VB->IndexPtr->data[pv]; \
- (*ctx->Driver.Index)( ctx, index );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = index; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
-
-
-
-/*
-* XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
-*/
+
+ _swsetup_Wakeup(c->gl_ctx);
+
+ TNL_CONTEXT(c->gl_ctx)->Driver.RunPipeline = _tnl_run_pipeline;
-static void smooth_ci_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define INTERP_INDEX 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = FixedToInt(ffi); \
- ffi += fdidx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
+ return c;
}
-
-/*
-* XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
-*/
-static void flat_ci_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+void WMesaDestroyContext( void )
{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define SETUP_CODE \
- GLuint index = VB->IndexPtr->data[pv]; \
- (*ctx->Driver.Index)( ctx, index );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = index; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
+ WMesaContext c = Current;
-/*
-* XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
-*/
-static void smooth_DITHER8_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
- DITHER_RGB_TO_8BIT_SETUP
-#define INTERP_Z 1
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, xx = LEFT, yy = FLIP(Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- DITHER_RGB_TO_8BIT( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb), xx, yy); \
- pRow[i] = pixelDithered; \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
+ WMesaMakeCurrent(NULL);
-/*
-* XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
-*/
-static void flat_DITHER8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
- DITHER_RGB_TO_8BIT_SETUP
-#define INTERP_Z 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint i, xx = LEFT, yy = FLIP(Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- DITHER_RGB_TO_8BIT( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], xx, yy); \
- pRow[i] = pixelDithered; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
-}
+ ReleaseDC(c->Window, c->hDC);
+ DeleteObject(c->clearPen);
+ DeleteObject(c->clearBrush);
+
+ if (c->db_flag)
+ wmDeleteBackingStore(c);
-/*
-* XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
-*/
-static void smooth_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
- DITHER_RGB_TO_8BIT_SETUP
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx, yy = FLIP(Y); \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- DITHER_RGB_TO_8BIT( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], xx, yy);\
- *pixel = pixelDithered; \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
+ _swsetup_DestroyContext(c->gl_ctx);
+ _tnl_DestroyContext(c->gl_ctx);
+ _ac_DestroyContext(c->gl_ctx);
+ _swrast_DestroyContext(c->gl_ctx);
+
+ _mesa_destroy_visual(c->gl_visual);
+ _mesa_destroy_framebuffer(c->gl_buffer);
+ _mesa_free_context_data(c->gl_ctx);
+ free(c);
}
-/*
-* XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
-*/
-static void flat_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+void WMesaMakeCurrent(WMesaContext c)
{
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
- DITHER_RGB_TO_8BIT_SETUP
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (wmesa->ScanWidth)
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
- { \
- GLint xx, yy = FLIP(Y); \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- DITHER_RGB_TO_8BIT( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], xx, yy); \
- *pixel = pixelDithered; \
- } \
- }
-#ifdef __MINGW32__
- #include "tritemp.h"
-#else
-
- #ifdef WIN32
-// #include "..\tritemp.h"
- #else
- #include "tritemp.h"
- #endif
-#endif
+ /* return if already current */
+ if (Current == c)
+ return;
+
+ if (Current = c)
+ _mesa_make_current(c->gl_ctx, c->gl_buffer, c->gl_buffer);
}
-#endif
-/************** END DEAD TRIANGLE CODE ***********************/
-#if 0 /* unused */
-
-static tnl_triangle_func choose_triangle_function( GLcontext *ctx )
+void WMesaSwapBuffers( void )
{
- (void) ctx;
-#if 0
- WMesaContext wmesa = (WMesaContext) ctx->DriverCtx;
- int depth = wmesa->cColorBits;
-
- if (ctx->Polygon.SmoothFlag) return NULL;
- if (ctx->Texture._EnabledUnits) return NULL;
- if (!wmesa->db_flag) return NULL;
- if (ctx->swrast->_RasterMask & MULTI_DRAW_BIT) return NULL;
-
- /*if (wmesa->xm_buffer->buffer==XIMAGE)*/ {
- if ( ctx->Light.ShadeModel==GL_SMOOTH
- && ctx->_RasterMask==DEPTH_BIT
- && ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (wmesa->pixelformat) {
- case PF_8A8B8G8R:
- return smooth_8A8B8G8R_z_triangle;
- case PF_8R8G8B:
- return smooth_8R8G8B_z_triangle;
- case PF_5R6G5B:
- return smooth_5R6G5B_z_triangle;
- case PF_DITHER8:
- return smooth_DITHER8_z_triangle;
- case PF_INDEX8:
- return smooth_ci_z_triangle;
- default:
- return NULL;
- }
- }
- if ( ctx->Light.ShadeModel==GL_FLAT
- && ctx->_RasterMask==DEPTH_BIT
- && ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (wmesa->pixelformat) {
- case PF_8A8B8G8R:
- return flat_8A8B8G8R_z_triangle;
- case PF_8R8G8B:
- return flat_8R8G8B_z_triangle;
- case PF_5R6G5B:
- return flat_5R6G5B_z_triangle;
- case PF_DITHER8:
- return flat_DITHER8_z_triangle;
- case PF_INDEX8:
- return flat_ci_z_triangle;
- default:
- return NULL;
- }
- }
- if ( ctx->_RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_SMOOTH
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (wmesa->pixelformat) {
- case PF_8A8B8G8R:
- return smooth_8A8B8G8R_triangle;
- case PF_8R8G8B:
- return smooth_8R8G8B_triangle;
- case PF_5R6G5B:
- return smooth_5R6G5B_triangle;
- case PF_DITHER8:
- return smooth_DITHER8_triangle;
- case PF_INDEX8:
- return smooth_ci_triangle;
- default:
- return NULL;
- }
- }
-
- if ( ctx->_RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_FLAT
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (wmesa->pixelformat) {
- case PF_8A8B8G8R:
- return flat_8A8B8G8R_triangle;
- case PF_8R8G8B:
- return flat_8R8G8B_triangle;
- case PF_5R6G5B:
- return flat_5R6G5B_triangle;
- case PF_DITHER8:
- return flat_DITHER8_triangle;
- case PF_INDEX8:
- return flat_ci_triangle;
- default:
- return NULL;
- }
- }
-
- return NULL;
- }
-#endif
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ if (Current && Current->gl_ctx == ctx)
+ _mesa_notifySwapBuffers(ctx);
+
+ if (Current->db_flag)
+ wmesa_flush(ctx);
}
-#endif /* unused */
-
-/*
- * Define a new viewport and reallocate auxillary buffers if the size of
- * the window (color buffer) has changed.
- */
-void WMesaViewport( GLcontext *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height )
-{
- (void) ctx; (void) x; (void) y; (void) width; (void) height;
- assert(0); /* I don't think that this is being used. */
-#if 0
- /* Save viewport */
- ctx->Viewport.X = x;
- ctx->Viewport.Width = width;
- ctx->Viewport.Y = y;
- ctx->Viewport.Height = height;
-
- /* compute scale and bias values */
-/* Pre-Keith 3.1 changes
- ctx->Viewport.Map.m[Sx] = (GLfloat) width / 2.0F;
- ctx->Viewport.Map.m[Tx] = ctx->Viewport.Sx + x;
- ctx->Viewport.Map.m[Sy] = (GLfloat) height / 2.0F;
- ctx->Viewport.Map.m[Ty] = ctx->Viewport.Sy + y;
-*/
- ctx->Viewport.WindowMap.m[MAT_SX] = (GLfloat) width / 2.0F;
- ctx->Viewport.WindowMap.m[MAT_TX] = ctx->Viewport.WindowMap.m[MAT_SX] + x;
- ctx->Viewport.WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F;
- ctx->Viewport.WindowMap.m[MAT_TY] = ctx->Viewport.WindowMap.m[MAT_SY] + y;
-#endif
-}
+/**********************************************************************/
+/***** END *****/
+/**********************************************************************/
diff --git a/src/mesa/drivers/windows/gdi/wmesadef.h b/src/mesa/drivers/windows/gdi/wmesadef.h
index d43e990ed3..9aa0ab20b7 100644
--- a/src/mesa/drivers/windows/gdi/wmesadef.h
+++ b/src/mesa/drivers/windows/gdi/wmesadef.h
@@ -1,175 +1,34 @@
-/* File name : wmesadef.h
- * Version : 2.3
- *
- * Header file for display driver for Mesa 2.3 under
- * Windows95, WindowsNT and Win32
- *
- * Copyright (C) 1996- Li Wei
- * Address : Institute of Artificial Intelligence
- * : & Robotics
- * : Xi'an Jiaotong University
- * Email : liwei@aiar.xjtu.edu.cn
- * Web page : http://sun.aiar.xjtu.edu.cn
- *
- * This file and its associations are partially based on the
- * Windows NT driver for Mesa, written by Mark Leaming
- * (mark@rsinc.com).
- */
-/*
- * $Log: wmesadef.h,v
- * Revision 1.1.1.1 1999/08/19 00:55:42 jt
- * Imported source
-
- * Revision 1.3 1999/01/03 03:08:57 brian
- * Ted Jump's change
- *
- * Initial version 1997/6/14 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- */
-
-/*
- * $Log: wmesadef.h,v
- * Revision 1.1.1.1 1999/08/19 00:55:42 jt
- * Imported source
-
- * Revision 1.3 1999/01/03 03:08:57 brian
- * Ted Jump's change
- *
- * Revision 2.1 1996/11/15 10:54:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- * a new element added to wmesa_context :
- * dither_flag
- */
-
-/*
- * $Log: wmesadef.h,v
- * Revision 1.1.1.1 1999/08/19 00:55:42 jt
- * Imported source
-
- * Revision 1.3 1999/01/03 03:08:57 brian
- * Ted Jump's change
- *
- * Revision 2.0 1996/11/15 10:54:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
- * Initial revision
- */
-
-
-
-#ifndef DDMESADEF_H
-#define DDMESADEF_H
-
-// uncomment this to use DirectDraw driver
-//#define DDRAW 1
-// uncomment this to use a pointer to a function for setting the pixels
-// in the buffer
-#define COMPILE_SETPIXEL 1
-// uncomment this to enable the fast win32 rasterizers ( commented out for MesaGL 4.0 )
-// #define FAST_RASTERIZERS 1
-// uncomment this to enable setting function pointers once inside of
-// WMesaCreateContext instead of on every call to wmesa_update_state()
-#define SET_FPOINTERS_ONCE 1
-
-
-#include <windows.h>
-#include <GL/gl.h>
#include "context.h"
-#ifdef DDRAW
-#define DIRECTDRAW_VERSION 0x0100
- #include <ddraw.h>
-#endif
-//#include "profile.h"
-
-#define REDBITS 0x03
-#define REDSHIFT 0x00
-#define GREENBITS 0x03
-#define GREENSHIFT 0x03
-#define BLUEBITS 0x02
-#define BLUESHIFT 0x06
typedef struct _dibSection{
- HDC hDC;
- HANDLE hFileMap;
- BOOL fFlushed;
- LPVOID base;
+ HDC hDC;
+ HANDLE hFileMap;
+ BOOL fFlushed;
+ LPVOID base;
}WMDIBSECTION, *PWMDIBSECTION;
-#ifdef COMPILE_SETPIXEL
-struct wmesa_context;
-typedef void (*SETPIXELTYPE)(struct wmesa_context *pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b);
-#endif
-
typedef struct wmesa_context{
- GLcontext *gl_ctx; /* The core GL/Mesa context */
- GLvisual *gl_visual; /* Describes the buffers */
- GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers */
-
-
- HWND Window;
+ GLcontext *gl_ctx; /* The core GL/Mesa context */
+ GLvisual *gl_visual; /* Describes the buffers */
+ GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers*/
+
+ HWND Window;
HDC hDC;
- HPALETTE hPalette;
- HPALETTE hOldPalette;
- HPEN hPen;
- HPEN hOldPen;
- HCURSOR hOldCursor;
- COLORREF crColor;
- // 3D projection stuff
- RECT drawRect;
- UINT uiDIBoffset;
- // OpenGL stuff
- HPALETTE hGLPalette;
- GLuint width;
- GLuint height;
- GLuint ScanWidth;
- GLboolean db_flag; //* double buffered?
- GLboolean rgb_flag; //* RGB mode?
- GLboolean dither_flag; //* use dither when 256 color mode for RGB?
- GLuint depth; //* bits per pixel (1, 8, 24, etc)
- ULONG pixel; // current color index or RGBA pixel value
- ULONG clearpixel; //* pixel for clearing the color buffers
- PBYTE ScreenMem; // WinG memory
- BITMAPINFO *IndexFormat;
- HPALETTE hPal; // Current Palette
- HPALETTE hPalHalfTone;
-
-
- WMDIBSECTION dib;
+ COLORREF clearColorRef;
+ HPEN clearPen;
+ HBRUSH clearBrush;
+ GLuint width;
+ GLuint height;
+ GLuint ScanWidth;
+ GLboolean db_flag;
+ WMDIBSECTION dib;
BITMAPINFO bmi;
HBITMAP hbmDIB;
HBITMAP hOldBitmap;
- HBITMAP Old_Compat_BM;
- HBITMAP Compat_BM; // Bitmap for double buffering
PBYTE pbPixels;
- int nColors;
- BYTE cColorBits;
- int pixelformat;
-
-#ifdef DDRAW
- LPDIRECTDRAW lpDD; // DirectDraw object
-// LPDIRECTDRAW2 lpDD2; // DirectDraw object
- LPDIRECTDRAWSURFACE lpDDSPrimary; // DirectDraw primary surface
- LPDIRECTDRAWSURFACE lpDDSOffScreen; // DirectDraw off screen surface
- LPDIRECTDRAWPALETTE lpDDPal; // DirectDraw palette
- BOOL bActive; // is application active?
- DDSURFACEDESC ddsd; // surface description
- int fullScreen; // fullscreen ?
- int gMode ; // fullscreen mode
- LONG oldWndProc; // old Window proc. we need to hook WM_MOVE message to update the drawing rectangle
-#endif
- RECT rectOffScreen;
- RECT rectSurface;
- HWND hwnd;
- DWORD pitch;
- PBYTE addrOffScreen;
-#ifdef COMPILE_SETPIXEL
- SETPIXELTYPE wmSetPixel;
-#endif // COMPILE_SETPIXEL
-//#ifdef PROFILE
-// MESAPROF profile;
-//#endif
+ BYTE cColorBits;
+ int pixelformat;
} *PWMC;
-#define PAGE_FILE 0xffffffff
-
-
-
-#endif