mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 23:20:08 +01:00
Removing from this directory. Will be added to new gdi driver directory.
This commit is contained in:
parent
6ff00f91c8
commit
f78311ed64
4 changed files with 0 additions and 4630 deletions
|
|
@ -1,521 +0,0 @@
|
|||
/* 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.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.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.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 */
|
||||
#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
|
||||
#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
|
||||
#define PF_DITHER8 6 /* Dithered RGB using a lookup table */
|
||||
#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.
|
||||
|
||||
*/
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
char unsigned const aHalftone4x4_1[16] =
|
||||
{
|
||||
0, 25, 6, 31,
|
||||
38, 12, 44, 19,
|
||||
9, 35, 3, 28,
|
||||
47, 22, 41, 15
|
||||
};
|
||||
|
||||
char unsigned const aHalftone4x4_2[16] =
|
||||
{
|
||||
41, 3, 9, 28,
|
||||
35, 15, 22, 47,
|
||||
6, 25, 38, 0,
|
||||
19, 44, 31, 12
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
aWinGHalftoneTranslation
|
||||
|
||||
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,
|
||||
};
|
||||
|
|
@ -1,623 +0,0 @@
|
|||
/* $Id: wgl.c,v 1.12 2003/01/15 00:34:16 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* File name : wgl.c
|
||||
* WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru
|
||||
* Some things originated from the 3Dfx WGL functions
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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"
|
||||
|
||||
#define MAX_MESA_ATTRS 20
|
||||
|
||||
struct __pixelformat__
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
GLboolean doubleBuffered;
|
||||
};
|
||||
|
||||
struct __pixelformat__ pix[] =
|
||||
{
|
||||
/* 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 },
|
||||
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 },
|
||||
GL_FALSE
|
||||
},
|
||||
/* 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 },
|
||||
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 },
|
||||
GL_FALSE
|
||||
},
|
||||
};
|
||||
|
||||
int qt_pix = sizeof(pix) / sizeof(pix[0]);
|
||||
|
||||
typedef struct {
|
||||
WMesaContext ctx;
|
||||
HDC hdc;
|
||||
} MesaWglCtx;
|
||||
|
||||
#define MESAWGL_CTX_MAX_COUNT 20
|
||||
|
||||
static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT];
|
||||
|
||||
static unsigned ctx_count = 0;
|
||||
static unsigned ctx_current = -1;
|
||||
static unsigned curPFD = 0;
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,HGLRC hglrcDst,UINT mask)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
|
||||
{
|
||||
HWND hWnd;
|
||||
int i = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (wgl_ctx[i].ctx == NULL)
|
||||
break;
|
||||
wgl_ctx[i].hdc = hdc;
|
||||
ctx_count++;
|
||||
return ((HGLRC)wgl_ctx[i].ctx);
|
||||
}
|
||||
}
|
||||
SetLastError(0);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
|
||||
{
|
||||
int i;
|
||||
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;
|
||||
wgl_ctx[i].hdc = NULL;
|
||||
ctx_count--;
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,int iLayerPlane)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
|
||||
{
|
||||
if (ctx_current < 0)
|
||||
return 0;
|
||||
else
|
||||
return (HGLRC) wgl_ctx[ctx_current].ctx;
|
||||
}
|
||||
|
||||
WGLAPI HDC GLAPIENTRY wglGetCurrentDC(VOID)
|
||||
{
|
||||
if (ctx_current < 0)
|
||||
return 0;
|
||||
else
|
||||
return wgl_ctx[ctx_current].hdc;
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* new code suggested by Andy Sy */
|
||||
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 wglShareLists(HGLRC hglrc1,HGLRC hglrc2)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
static FIXED FixedFromDouble(double d)
|
||||
{
|
||||
long l = (long) (d * 65536L);
|
||||
return *(FIXED *)&l;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** This is cribbed from FX/fxwgl.c, and seems to implement support
|
||||
** for bitmap fonts where the wglUseFontBitmapsA() code implements
|
||||
** support for outline fonts. In combination they hopefully give
|
||||
** fairly generic support for fonts.
|
||||
*/
|
||||
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) >= 0 ? 1 : 0);
|
||||
|
||||
for(i = 0; i < 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);
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
GLuint font_list;
|
||||
DWORD size;
|
||||
GLYPHMETRICS gm;
|
||||
HANDLE hBits;
|
||||
LPSTR lpBits;
|
||||
MAT2 mat;
|
||||
int success = TRUE;
|
||||
|
||||
if (first<0)
|
||||
return FALSE;
|
||||
if (count<0)
|
||||
return FALSE;
|
||||
if (listBase<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 < 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;
|
||||
}
|
||||
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,DWORD first,DWORD count,DWORD listBase)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
|
||||
DWORD listBase,FLOAT deviation,
|
||||
FLOAT extrusion,int format,
|
||||
LPGLYPHMETRICSFLOAT lpgmf)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
|
||||
DWORD listBase,FLOAT deviation,
|
||||
FLOAT extrusion,int format,
|
||||
LPGLYPHMETRICSFLOAT lpgmf)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
|
||||
int iLayerPlane,UINT nBytes,
|
||||
LPLAYERPLANEDESCRIPTOR plpd)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc,int iLayerPlane,
|
||||
int iStart,int cEntries,
|
||||
CONST COLORREF *pcr)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
WGLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc,int iLayerPlane,
|
||||
int iStart,int cEntries,
|
||||
COLORREF *pcr)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc,int iLayerPlane,BOOL bRealize)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,UINT fuPlanes)
|
||||
{
|
||||
if( !hdc )
|
||||
{
|
||||
WMesaSwapBuffers();
|
||||
return(TRUE);
|
||||
}
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
|
||||
CONST PIXELFORMATDESCRIPTOR *ppfd)
|
||||
{
|
||||
int i,best = -1,bestdelta = 0x7FFFFFFF,delta,qt_valid_pix;
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
if(curPFD == 0)
|
||||
{
|
||||
SetLastError(0);
|
||||
return(0);
|
||||
}
|
||||
return(curPFD);
|
||||
}
|
||||
|
||||
WGLAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
|
||||
PIXELFORMATDESCRIPTOR *ppfd)
|
||||
{
|
||||
int qt_valid_pix;
|
||||
|
||||
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)
|
||||
{
|
||||
if (ctx_current < 0)
|
||||
return FALSE;
|
||||
|
||||
if(wgl_ctx[ctx_current].ctx == NULL) {
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
WMesaSwapBuffers();
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,174 +0,0 @@
|
|||
/* 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;
|
||||
}WMDIBSECTION, *PWMDIBSECTION;
|
||||
|
||||
#ifdef COMPILE_SETPIXEL
|
||||
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;
|
||||
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;
|
||||
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
|
||||
} *PWMC;
|
||||
|
||||
|
||||
#define PAGE_FILE 0xffffffff
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue