mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 19:30:12 +01:00
Fix CRLF line endings.
This commit is contained in:
parent
9286a14fbe
commit
ae18cbcfc5
8 changed files with 4675 additions and 4675 deletions
|
|
@ -1,420 +1,420 @@
|
|||
/* WarpWin.c */
|
||||
/* glut for Warp */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "WarpWin.h"
|
||||
#include "WarpGL.h"
|
||||
|
||||
#define POKA 0
|
||||
|
||||
/* global variables that must be set for some functions to operate
|
||||
correctly. */
|
||||
HDC XHDC;
|
||||
HWND XHWND;
|
||||
|
||||
|
||||
void
|
||||
XStoreColor(Display* display, Colormap colormap, XColor* color)
|
||||
{
|
||||
/* KLUDGE: set XHDC to 0 if the palette should NOT be realized after
|
||||
setting the color. set XHDC to the correct HDC if it should. */
|
||||
|
||||
LONG pe;
|
||||
ULONG cclr;
|
||||
int r,g,b;
|
||||
/* X11 stores color from 0-65535, Win32 expects them to be 0-256, so
|
||||
twiddle the bits ( / 256). */
|
||||
r = color->red / 256;
|
||||
g = color->green / 256;
|
||||
b = color->blue / 256;
|
||||
pe = LONGFromRGB(r,g,b);
|
||||
/* make sure we use this flag, otherwise the colors might get mapped
|
||||
to another place in the colormap, and when we glIndex() that
|
||||
color, it may have moved (argh!!) */
|
||||
pe |= (PC_NOCOLLAPSE<<24);
|
||||
/* This function changes the entries in a palette. */
|
||||
#if POKA
|
||||
OS2:
|
||||
rc = GpiSetPaletteEntries(colormap,LCOLF_CONSECRGB, color->pixel, 1, &pe);
|
||||
GpiSelectPalette(hps,colormap);
|
||||
WinRealizePalette(hwnd,hps,&cclr);
|
||||
source Win:
|
||||
if (XHDC) {
|
||||
UnrealizeObject(colormap);
|
||||
SelectPalette(XHDC, colormap, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
XSetWindowColormap(Display* display, Window window, Colormap colormap)
|
||||
{
|
||||
#if POKA
|
||||
HDC hdc = GetDC(window);
|
||||
|
||||
/* if the third parameter is FALSE, the logical colormap is copied
|
||||
into the device palette when the application is in the
|
||||
foreground, if it is TRUE, the colors are mapped into the current
|
||||
palette in the best possible way. */
|
||||
SelectPalette(hdc, colormap, FALSE);
|
||||
RealizePalette(hdc);
|
||||
|
||||
/* note that we don't have to release the DC, since our window class
|
||||
uses the WC_OWNDC flag! */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* display, root and visual - don't used at all */
|
||||
Colormap
|
||||
XCreateColormap(Display* display, Window root, Visual* visual, int alloc)
|
||||
{
|
||||
/* KLUDGE: this function needs XHDC to be set to the HDC currently
|
||||
being operated on before it is invoked! */
|
||||
|
||||
HPAL palette;
|
||||
int n;
|
||||
#if POKA
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
LOGPALETTE *logical;
|
||||
|
||||
/* grab the pixel format */
|
||||
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
|
||||
DescribePixelFormat(XHDC, GetPixelFormat(XHDC),
|
||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
if (!(pfd.dwFlags & PFD_NEED_PALETTE ||
|
||||
pfd.iPixelType == PFD_TYPE_COLORINDEX))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = 1 << pfd.cColorBits;
|
||||
|
||||
/* allocate a bunch of memory for the logical palette (assume 256
|
||||
colors in a Win32 palette */
|
||||
logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
|
||||
sizeof(PALETTEENTRY) * n);
|
||||
memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
|
||||
|
||||
/* set the entries in the logical palette */
|
||||
logical->palVersion = 0x300;
|
||||
logical->palNumEntries = n;
|
||||
|
||||
/* start with a copy of the current system palette */
|
||||
GetSystemPaletteEntries(XHDC, 0, 256, &logical->palPalEntry[0]);
|
||||
|
||||
if (pfd.iPixelType == PFD_TYPE_RGBA) {
|
||||
int redMask = (1 << pfd.cRedBits) - 1;
|
||||
int greenMask = (1 << pfd.cGreenBits) - 1;
|
||||
int blueMask = (1 << pfd.cBlueBits) - 1;
|
||||
int i;
|
||||
|
||||
/* fill in an RGBA color palette */
|
||||
for (i = 0; i < n; ++i) {
|
||||
logical->palPalEntry[i].peRed =
|
||||
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
|
||||
logical->palPalEntry[i].peGreen =
|
||||
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
|
||||
logical->palPalEntry[i].peBlue =
|
||||
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
|
||||
logical->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
palette = CreatePalette(logical);
|
||||
free(logical);
|
||||
|
||||
SelectPalette(XHDC, palette, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
#endif /* POKA */
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int GetSystemMetrics( int mode)
|
||||
{ RECTL rect;
|
||||
|
||||
switch(mode)
|
||||
{ case SM_CXSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.xRight-rect.xLeft);
|
||||
break;
|
||||
case SM_CYSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.yTop-rect.yBottom);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* XParseGeometry parses strings of the form
|
||||
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
|
||||
* width, height, xoffset, and yoffset are unsigned integers.
|
||||
* Example: "=80x24+300-49"
|
||||
* The equal sign is optional.
|
||||
* It returns a bitmask that indicates which of the four values
|
||||
* were actually found in the string. For each value found,
|
||||
* the corresponding argument is updated; for each value
|
||||
* not found, the corresponding argument is left unchanged.
|
||||
*/
|
||||
|
||||
static int
|
||||
ReadInteger(char *string, char **NextString)
|
||||
{
|
||||
register int Result = 0;
|
||||
int Sign = 1;
|
||||
|
||||
if (*string == '+')
|
||||
string++;
|
||||
else if (*string == '-')
|
||||
{
|
||||
string++;
|
||||
Sign = -1;
|
||||
}
|
||||
for (; (*string >= '0') && (*string <= '9'); string++)
|
||||
{
|
||||
Result = (Result * 10) + (*string - '0');
|
||||
}
|
||||
*NextString = string;
|
||||
if (Sign >= 0)
|
||||
return (Result);
|
||||
else
|
||||
return (-Result);
|
||||
}
|
||||
|
||||
int XParseGeometry(char *string, int *x, int *y, unsigned int *width, unsigned int *height)
|
||||
{
|
||||
int mask = NoValue;
|
||||
register char *strind;
|
||||
unsigned int tempWidth, tempHeight;
|
||||
int tempX, tempY;
|
||||
char *nextCharacter;
|
||||
|
||||
if ( (string == NULL) || (*string == '\0')) return(mask);
|
||||
if (*string == '=')
|
||||
string++; /* ignore possible '=' at beg of geometry spec */
|
||||
|
||||
strind = (char *)string;
|
||||
if (*strind != '+' && *strind != '-' && *strind != 'x') {
|
||||
tempWidth = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= WidthValue;
|
||||
}
|
||||
|
||||
if (*strind == 'x' || *strind == 'X') {
|
||||
strind++;
|
||||
tempHeight = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= HeightValue;
|
||||
}
|
||||
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempX = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= XNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{ strind++;
|
||||
tempX = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= XValue;
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempY = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
mask |= YNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempY = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= YValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* If strind isn't at the end of the string the it's an invalid
|
||||
geometry specification. */
|
||||
|
||||
if (*strind != '\0') return (0);
|
||||
|
||||
if (mask & XValue)
|
||||
*x = tempX;
|
||||
if (mask & YValue)
|
||||
*y = tempY;
|
||||
if (mask & WidthValue)
|
||||
*width = tempWidth;
|
||||
if (mask & HeightValue)
|
||||
*height = tempHeight;
|
||||
return (mask);
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval* tp, void* tzp)
|
||||
{
|
||||
DATETIME DateTime;
|
||||
APIRET ulrc; /* Return Code. */
|
||||
|
||||
ulrc = DosGetDateTime(&DateTime);
|
||||
tp->tv_sec = 60 * (60*DateTime.hours + DateTime.minutes) + DateTime.seconds;
|
||||
tp->tv_usec = DateTime.hundredths * 10000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
XPending(Display* display)
|
||||
{
|
||||
/* similar functionality...I don't think that it is exact, but this
|
||||
will have to do. */
|
||||
QMSG msg;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
//?? WinPeekMsg(hab
|
||||
return WinPeekMsg(hab, &msg, NULLHANDLE, 0, 0, PM_NOREMOVE);
|
||||
}
|
||||
|
||||
void
|
||||
__glutAdjustCoords(Window parent, int* x, int* y, int* width, int* height)
|
||||
{
|
||||
RECTL rect;
|
||||
|
||||
/* adjust the window rectangle because Win32 thinks that the x, y,
|
||||
width & height are the WHOLE window (including decorations),
|
||||
whereas GLUT treats the x, y, width & height as only the CLIENT
|
||||
area of the window. */
|
||||
rect.xLeft = *x; rect.yTop = *y;
|
||||
rect.xRight = *x + *width; rect.yBottom = *y + *height;
|
||||
|
||||
/* must adjust the coordinates according to the correct style
|
||||
because depending on the style, there may or may not be
|
||||
borders. */
|
||||
//?? AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||
//?? (parent ? WS_CHILD : WS_OVERLAPPEDWINDOW),
|
||||
//?? FALSE);
|
||||
/* FALSE in the third parameter = window has no menu bar */
|
||||
|
||||
/* readjust if the x and y are offscreen */
|
||||
if(rect.xLeft < 0) {
|
||||
*x = 0;
|
||||
} else {
|
||||
*x = rect.xLeft;
|
||||
}
|
||||
|
||||
if(rect.yTop < 0) {
|
||||
*y = 0;
|
||||
} else {
|
||||
*y = rect.yTop;
|
||||
}
|
||||
|
||||
*width = rect.xRight - rect.xLeft; /* adjusted width */
|
||||
*height = -(rect.yBottom - rect.yTop); /* adjusted height */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
|
||||
{
|
||||
/* the transparent pixel on Win32 is always index number 0. So if
|
||||
we put this routine in this file, we can avoid compiling the
|
||||
whole of layerutil.c which is where this routine normally comes
|
||||
from. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Translate point coordinates src_x and src_y from src to dst */
|
||||
|
||||
Bool
|
||||
XTranslateCoordinates(Display *display, Window src, Window dst,
|
||||
int src_x, int src_y,
|
||||
int* dest_x_return, int* dest_y_return,
|
||||
Window* child_return)
|
||||
{
|
||||
SWP swp_src,swp_dst;
|
||||
|
||||
WinQueryWindowPos(src,&swp_src);
|
||||
WinQueryWindowPos(dst,&swp_dst);
|
||||
|
||||
*dest_x_return = src_x + swp_src.x - swp_dst.x;
|
||||
*dest_y_return = src_y + swp_src.y - swp_dst.y;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return True;
|
||||
}
|
||||
|
||||
Status
|
||||
XGetGeometry(Display* display, Window window, Window* root_return,
|
||||
int* x_return, int* y_return,
|
||||
unsigned int* width_return, unsigned int* height_return,
|
||||
unsigned int *border_width_return, unsigned int* depth_return)
|
||||
{
|
||||
/* KLUDGE: doesn't return the border_width or depth or root, x & y
|
||||
are in screen coordinates. */
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(window,&swp_src);
|
||||
|
||||
*x_return = swp_src.x;
|
||||
*y_return = swp_src.y;
|
||||
*width_return = swp_src.cx;
|
||||
*height_return = swp_src.cy;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get Display Width in millimeters */
|
||||
int
|
||||
DisplayWidthMM(Display* display, int screen)
|
||||
{
|
||||
int width;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
width = (int)( 0.001 * pVC_Caps[CAPS_WIDTH] / pVC_Caps[CAPS_HORIZONTAL_RESOLUTION]);/* mm */
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Get Display Height in millimeters */
|
||||
int
|
||||
DisplayHeightMM(Display* display, int screen)
|
||||
{
|
||||
int height;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
height = (int)( 0.001 * pVC_Caps[CAPS_HEIGHT] / pVC_Caps[CAPS_VERTICAL_RESOLUTION]); /* mm */
|
||||
return height;
|
||||
}
|
||||
|
||||
void ScreenToClient( HWND hwnd, POINTL *point)
|
||||
{
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(hwnd,&swp_src);
|
||||
point->x -= swp_src.x;
|
||||
point->y -= swp_src.y;
|
||||
}
|
||||
|
||||
/* WarpWin.c */
|
||||
/* glut for Warp */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "WarpWin.h"
|
||||
#include "WarpGL.h"
|
||||
|
||||
#define POKA 0
|
||||
|
||||
/* global variables that must be set for some functions to operate
|
||||
correctly. */
|
||||
HDC XHDC;
|
||||
HWND XHWND;
|
||||
|
||||
|
||||
void
|
||||
XStoreColor(Display* display, Colormap colormap, XColor* color)
|
||||
{
|
||||
/* KLUDGE: set XHDC to 0 if the palette should NOT be realized after
|
||||
setting the color. set XHDC to the correct HDC if it should. */
|
||||
|
||||
LONG pe;
|
||||
ULONG cclr;
|
||||
int r,g,b;
|
||||
/* X11 stores color from 0-65535, Win32 expects them to be 0-256, so
|
||||
twiddle the bits ( / 256). */
|
||||
r = color->red / 256;
|
||||
g = color->green / 256;
|
||||
b = color->blue / 256;
|
||||
pe = LONGFromRGB(r,g,b);
|
||||
/* make sure we use this flag, otherwise the colors might get mapped
|
||||
to another place in the colormap, and when we glIndex() that
|
||||
color, it may have moved (argh!!) */
|
||||
pe |= (PC_NOCOLLAPSE<<24);
|
||||
/* This function changes the entries in a palette. */
|
||||
#if POKA
|
||||
OS2:
|
||||
rc = GpiSetPaletteEntries(colormap,LCOLF_CONSECRGB, color->pixel, 1, &pe);
|
||||
GpiSelectPalette(hps,colormap);
|
||||
WinRealizePalette(hwnd,hps,&cclr);
|
||||
source Win:
|
||||
if (XHDC) {
|
||||
UnrealizeObject(colormap);
|
||||
SelectPalette(XHDC, colormap, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
XSetWindowColormap(Display* display, Window window, Colormap colormap)
|
||||
{
|
||||
#if POKA
|
||||
HDC hdc = GetDC(window);
|
||||
|
||||
/* if the third parameter is FALSE, the logical colormap is copied
|
||||
into the device palette when the application is in the
|
||||
foreground, if it is TRUE, the colors are mapped into the current
|
||||
palette in the best possible way. */
|
||||
SelectPalette(hdc, colormap, FALSE);
|
||||
RealizePalette(hdc);
|
||||
|
||||
/* note that we don't have to release the DC, since our window class
|
||||
uses the WC_OWNDC flag! */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* display, root and visual - don't used at all */
|
||||
Colormap
|
||||
XCreateColormap(Display* display, Window root, Visual* visual, int alloc)
|
||||
{
|
||||
/* KLUDGE: this function needs XHDC to be set to the HDC currently
|
||||
being operated on before it is invoked! */
|
||||
|
||||
HPAL palette;
|
||||
int n;
|
||||
#if POKA
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
LOGPALETTE *logical;
|
||||
|
||||
/* grab the pixel format */
|
||||
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
|
||||
DescribePixelFormat(XHDC, GetPixelFormat(XHDC),
|
||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
if (!(pfd.dwFlags & PFD_NEED_PALETTE ||
|
||||
pfd.iPixelType == PFD_TYPE_COLORINDEX))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = 1 << pfd.cColorBits;
|
||||
|
||||
/* allocate a bunch of memory for the logical palette (assume 256
|
||||
colors in a Win32 palette */
|
||||
logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
|
||||
sizeof(PALETTEENTRY) * n);
|
||||
memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
|
||||
|
||||
/* set the entries in the logical palette */
|
||||
logical->palVersion = 0x300;
|
||||
logical->palNumEntries = n;
|
||||
|
||||
/* start with a copy of the current system palette */
|
||||
GetSystemPaletteEntries(XHDC, 0, 256, &logical->palPalEntry[0]);
|
||||
|
||||
if (pfd.iPixelType == PFD_TYPE_RGBA) {
|
||||
int redMask = (1 << pfd.cRedBits) - 1;
|
||||
int greenMask = (1 << pfd.cGreenBits) - 1;
|
||||
int blueMask = (1 << pfd.cBlueBits) - 1;
|
||||
int i;
|
||||
|
||||
/* fill in an RGBA color palette */
|
||||
for (i = 0; i < n; ++i) {
|
||||
logical->palPalEntry[i].peRed =
|
||||
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
|
||||
logical->palPalEntry[i].peGreen =
|
||||
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
|
||||
logical->palPalEntry[i].peBlue =
|
||||
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
|
||||
logical->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
palette = CreatePalette(logical);
|
||||
free(logical);
|
||||
|
||||
SelectPalette(XHDC, palette, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
#endif /* POKA */
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int GetSystemMetrics( int mode)
|
||||
{ RECTL rect;
|
||||
|
||||
switch(mode)
|
||||
{ case SM_CXSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.xRight-rect.xLeft);
|
||||
break;
|
||||
case SM_CYSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.yTop-rect.yBottom);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* XParseGeometry parses strings of the form
|
||||
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
|
||||
* width, height, xoffset, and yoffset are unsigned integers.
|
||||
* Example: "=80x24+300-49"
|
||||
* The equal sign is optional.
|
||||
* It returns a bitmask that indicates which of the four values
|
||||
* were actually found in the string. For each value found,
|
||||
* the corresponding argument is updated; for each value
|
||||
* not found, the corresponding argument is left unchanged.
|
||||
*/
|
||||
|
||||
static int
|
||||
ReadInteger(char *string, char **NextString)
|
||||
{
|
||||
register int Result = 0;
|
||||
int Sign = 1;
|
||||
|
||||
if (*string == '+')
|
||||
string++;
|
||||
else if (*string == '-')
|
||||
{
|
||||
string++;
|
||||
Sign = -1;
|
||||
}
|
||||
for (; (*string >= '0') && (*string <= '9'); string++)
|
||||
{
|
||||
Result = (Result * 10) + (*string - '0');
|
||||
}
|
||||
*NextString = string;
|
||||
if (Sign >= 0)
|
||||
return (Result);
|
||||
else
|
||||
return (-Result);
|
||||
}
|
||||
|
||||
int XParseGeometry(char *string, int *x, int *y, unsigned int *width, unsigned int *height)
|
||||
{
|
||||
int mask = NoValue;
|
||||
register char *strind;
|
||||
unsigned int tempWidth, tempHeight;
|
||||
int tempX, tempY;
|
||||
char *nextCharacter;
|
||||
|
||||
if ( (string == NULL) || (*string == '\0')) return(mask);
|
||||
if (*string == '=')
|
||||
string++; /* ignore possible '=' at beg of geometry spec */
|
||||
|
||||
strind = (char *)string;
|
||||
if (*strind != '+' && *strind != '-' && *strind != 'x') {
|
||||
tempWidth = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= WidthValue;
|
||||
}
|
||||
|
||||
if (*strind == 'x' || *strind == 'X') {
|
||||
strind++;
|
||||
tempHeight = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= HeightValue;
|
||||
}
|
||||
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempX = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= XNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{ strind++;
|
||||
tempX = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= XValue;
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempY = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
mask |= YNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempY = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= YValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* If strind isn't at the end of the string the it's an invalid
|
||||
geometry specification. */
|
||||
|
||||
if (*strind != '\0') return (0);
|
||||
|
||||
if (mask & XValue)
|
||||
*x = tempX;
|
||||
if (mask & YValue)
|
||||
*y = tempY;
|
||||
if (mask & WidthValue)
|
||||
*width = tempWidth;
|
||||
if (mask & HeightValue)
|
||||
*height = tempHeight;
|
||||
return (mask);
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval* tp, void* tzp)
|
||||
{
|
||||
DATETIME DateTime;
|
||||
APIRET ulrc; /* Return Code. */
|
||||
|
||||
ulrc = DosGetDateTime(&DateTime);
|
||||
tp->tv_sec = 60 * (60*DateTime.hours + DateTime.minutes) + DateTime.seconds;
|
||||
tp->tv_usec = DateTime.hundredths * 10000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
XPending(Display* display)
|
||||
{
|
||||
/* similar functionality...I don't think that it is exact, but this
|
||||
will have to do. */
|
||||
QMSG msg;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
//?? WinPeekMsg(hab
|
||||
return WinPeekMsg(hab, &msg, NULLHANDLE, 0, 0, PM_NOREMOVE);
|
||||
}
|
||||
|
||||
void
|
||||
__glutAdjustCoords(Window parent, int* x, int* y, int* width, int* height)
|
||||
{
|
||||
RECTL rect;
|
||||
|
||||
/* adjust the window rectangle because Win32 thinks that the x, y,
|
||||
width & height are the WHOLE window (including decorations),
|
||||
whereas GLUT treats the x, y, width & height as only the CLIENT
|
||||
area of the window. */
|
||||
rect.xLeft = *x; rect.yTop = *y;
|
||||
rect.xRight = *x + *width; rect.yBottom = *y + *height;
|
||||
|
||||
/* must adjust the coordinates according to the correct style
|
||||
because depending on the style, there may or may not be
|
||||
borders. */
|
||||
//?? AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||
//?? (parent ? WS_CHILD : WS_OVERLAPPEDWINDOW),
|
||||
//?? FALSE);
|
||||
/* FALSE in the third parameter = window has no menu bar */
|
||||
|
||||
/* readjust if the x and y are offscreen */
|
||||
if(rect.xLeft < 0) {
|
||||
*x = 0;
|
||||
} else {
|
||||
*x = rect.xLeft;
|
||||
}
|
||||
|
||||
if(rect.yTop < 0) {
|
||||
*y = 0;
|
||||
} else {
|
||||
*y = rect.yTop;
|
||||
}
|
||||
|
||||
*width = rect.xRight - rect.xLeft; /* adjusted width */
|
||||
*height = -(rect.yBottom - rect.yTop); /* adjusted height */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
|
||||
{
|
||||
/* the transparent pixel on Win32 is always index number 0. So if
|
||||
we put this routine in this file, we can avoid compiling the
|
||||
whole of layerutil.c which is where this routine normally comes
|
||||
from. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Translate point coordinates src_x and src_y from src to dst */
|
||||
|
||||
Bool
|
||||
XTranslateCoordinates(Display *display, Window src, Window dst,
|
||||
int src_x, int src_y,
|
||||
int* dest_x_return, int* dest_y_return,
|
||||
Window* child_return)
|
||||
{
|
||||
SWP swp_src,swp_dst;
|
||||
|
||||
WinQueryWindowPos(src,&swp_src);
|
||||
WinQueryWindowPos(dst,&swp_dst);
|
||||
|
||||
*dest_x_return = src_x + swp_src.x - swp_dst.x;
|
||||
*dest_y_return = src_y + swp_src.y - swp_dst.y;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return True;
|
||||
}
|
||||
|
||||
Status
|
||||
XGetGeometry(Display* display, Window window, Window* root_return,
|
||||
int* x_return, int* y_return,
|
||||
unsigned int* width_return, unsigned int* height_return,
|
||||
unsigned int *border_width_return, unsigned int* depth_return)
|
||||
{
|
||||
/* KLUDGE: doesn't return the border_width or depth or root, x & y
|
||||
are in screen coordinates. */
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(window,&swp_src);
|
||||
|
||||
*x_return = swp_src.x;
|
||||
*y_return = swp_src.y;
|
||||
*width_return = swp_src.cx;
|
||||
*height_return = swp_src.cy;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get Display Width in millimeters */
|
||||
int
|
||||
DisplayWidthMM(Display* display, int screen)
|
||||
{
|
||||
int width;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
width = (int)( 0.001 * pVC_Caps[CAPS_WIDTH] / pVC_Caps[CAPS_HORIZONTAL_RESOLUTION]);/* mm */
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Get Display Height in millimeters */
|
||||
int
|
||||
DisplayHeightMM(Display* display, int screen)
|
||||
{
|
||||
int height;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
height = (int)( 0.001 * pVC_Caps[CAPS_HEIGHT] / pVC_Caps[CAPS_VERTICAL_RESOLUTION]); /* mm */
|
||||
return height;
|
||||
}
|
||||
|
||||
void ScreenToClient( HWND hwnd, POINTL *point)
|
||||
{
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(hwnd,&swp_src);
|
||||
point->x -= swp_src.x;
|
||||
point->y -= swp_src.y;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,259 +1,259 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "glutint.h"
|
||||
|
||||
#if defined(__OS2PM__)
|
||||
#define IsWindowVisible WinIsWindowVisible
|
||||
#endif
|
||||
|
||||
#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue)
|
||||
{
|
||||
GLUTcolormap *cmap, *newcmap;
|
||||
XVisualInfo *vis;
|
||||
XColor color;
|
||||
int i;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
cmap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
cmap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning(
|
||||
"glutSetColor: cannot set color of overlay transparent index %d\n",
|
||||
ndx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmap) {
|
||||
__glutWarning("glutSetColor: current window is RGBA");
|
||||
return;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (ndx >= 256 || /* always assume 256 colors on Win32 */
|
||||
#else
|
||||
if (ndx >= vis->visual->map_entries ||
|
||||
#endif
|
||||
ndx < 0) {
|
||||
__glutWarning("glutSetColor: index %d out of range", ndx);
|
||||
return;
|
||||
}
|
||||
if (cmap->refcnt > 1) {
|
||||
newcmap = __glutAssociateNewColormap(vis);
|
||||
cmap->refcnt--;
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
for (i = cmap->size - 1; i >= 0; i--) {
|
||||
if (i == ndx) {
|
||||
/* We are going to set this cell shortly! */
|
||||
continue;
|
||||
}
|
||||
if (cmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
newcmap->cells[i].component[GLUT_RED] =
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
newcmap->cells[i].component[GLUT_GREEN] =
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
newcmap->cells[i].component[GLUT_BLUE] =
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, newcmap->cmap, &color);
|
||||
} else {
|
||||
/* Leave unallocated entries unallocated. */
|
||||
}
|
||||
}
|
||||
cmap = newcmap;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = cmap;
|
||||
__glutCurrentWindow->cmap = cmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = cmap;
|
||||
__glutCurrentWindow->overlay->cmap = cmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay,
|
||||
__glutCurrentWindow->renderWin, cmap->cmap);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
{
|
||||
GLUTwindow *toplevel;
|
||||
|
||||
toplevel = __glutToplevelOf(__glutCurrentWindow);
|
||||
if (toplevel->cmap != cmap->cmap) {
|
||||
__glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
color.pixel = ndx;
|
||||
red = CLAMP(red);
|
||||
cmap->cells[ndx].component[GLUT_RED] = red;
|
||||
color.red = (GLfloat) 0xffff *red;
|
||||
green = CLAMP(green);
|
||||
cmap->cells[ndx].component[GLUT_GREEN] = green;
|
||||
color.green = (GLfloat) 0xffff *green;
|
||||
blue = CLAMP(blue);
|
||||
cmap->cells[ndx].component[GLUT_BLUE] = blue;
|
||||
color.blue = (GLfloat) 0xffff *blue;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, cmap->cmap, &color);
|
||||
}
|
||||
|
||||
GLfloat GLUTAPIENTRY
|
||||
glutGetColor(int ndx, int comp)
|
||||
{
|
||||
GLUTcolormap *colormap;
|
||||
XVisualInfo *vis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
colormap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
colormap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning("glutGetColor: requesting overlay transparent index %d\n",
|
||||
ndx);
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colormap) {
|
||||
__glutWarning("glutGetColor: current window is RGBA");
|
||||
return -1.0;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= 256 || ndx < 0)
|
||||
#else
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= vis->visual->map_entries || ndx < 0)
|
||||
#endif
|
||||
if (OUT_OF_RANGE_NDX(ndx)) {
|
||||
__glutWarning("glutGetColor: index %d out of range", ndx);
|
||||
return -1.0;
|
||||
}
|
||||
return colormap->cells[ndx].component[comp];
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutCopyColormap(int winnum)
|
||||
{
|
||||
GLUTwindow *window = __glutWindowList[winnum - 1];
|
||||
GLUTcolormap *oldcmap, *newcmap;
|
||||
XVisualInfo *dstvis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
oldcmap = __glutCurrentWindow->colormap;
|
||||
dstvis = __glutCurrentWindow->vis;
|
||||
newcmap = window->colormap;
|
||||
} else {
|
||||
oldcmap = __glutCurrentWindow->overlay->colormap;
|
||||
dstvis = __glutCurrentWindow->overlay->vis;
|
||||
if (!window->overlay) {
|
||||
__glutWarning("glutCopyColormap: window %d has no overlay", winnum);
|
||||
return;
|
||||
}
|
||||
newcmap = window->overlay->colormap;
|
||||
}
|
||||
|
||||
if (!oldcmap) {
|
||||
__glutWarning("glutCopyColormap: destination colormap must be color index");
|
||||
return;
|
||||
}
|
||||
if (!newcmap) {
|
||||
__glutWarning(
|
||||
"glutCopyColormap: source colormap of window %d must be color index",
|
||||
winnum);
|
||||
return;
|
||||
}
|
||||
if (newcmap == oldcmap) {
|
||||
/* Source and destination are the same; now copy needed. */
|
||||
return;
|
||||
}
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
/* Play safe: compare visual IDs, not Visual*'s. */
|
||||
if (newcmap->visual->visualid == oldcmap->visual->visualid) {
|
||||
#endif
|
||||
/* Visuals match! "Copy" by reference... */
|
||||
__glutFreeColormap(oldcmap);
|
||||
newcmap->refcnt++;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = newcmap;
|
||||
__glutCurrentWindow->cmap = newcmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = newcmap;
|
||||
__glutCurrentWindow->overlay->cmap = newcmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay, __glutCurrentWindow->renderWin,
|
||||
newcmap->cmap);
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
__glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
|
||||
bla bla bla
|
||||
|
||||
} else {
|
||||
GLUTcolormap *copycmap;
|
||||
XColor color;
|
||||
int i, last;
|
||||
|
||||
/* Visuals different - need a distinct X colormap! */
|
||||
copycmap = __glutAssociateNewColormap(dstvis);
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
last = newcmap->size;
|
||||
if (last > copycmap->size) {
|
||||
last = copycmap->size;
|
||||
}
|
||||
for (i = last - 1; i >= 0; i--) {
|
||||
if (newcmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
copycmap->cells[i].component[GLUT_RED] =
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
copycmap->cells[i].component[GLUT_GREEN] =
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
copycmap->cells[i].component[GLUT_BLUE] =
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
XStoreColor(__glutDisplay, copycmap->cmap, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* ENDCENTRY */
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "glutint.h"
|
||||
|
||||
#if defined(__OS2PM__)
|
||||
#define IsWindowVisible WinIsWindowVisible
|
||||
#endif
|
||||
|
||||
#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue)
|
||||
{
|
||||
GLUTcolormap *cmap, *newcmap;
|
||||
XVisualInfo *vis;
|
||||
XColor color;
|
||||
int i;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
cmap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
cmap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning(
|
||||
"glutSetColor: cannot set color of overlay transparent index %d\n",
|
||||
ndx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmap) {
|
||||
__glutWarning("glutSetColor: current window is RGBA");
|
||||
return;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (ndx >= 256 || /* always assume 256 colors on Win32 */
|
||||
#else
|
||||
if (ndx >= vis->visual->map_entries ||
|
||||
#endif
|
||||
ndx < 0) {
|
||||
__glutWarning("glutSetColor: index %d out of range", ndx);
|
||||
return;
|
||||
}
|
||||
if (cmap->refcnt > 1) {
|
||||
newcmap = __glutAssociateNewColormap(vis);
|
||||
cmap->refcnt--;
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
for (i = cmap->size - 1; i >= 0; i--) {
|
||||
if (i == ndx) {
|
||||
/* We are going to set this cell shortly! */
|
||||
continue;
|
||||
}
|
||||
if (cmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
newcmap->cells[i].component[GLUT_RED] =
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
newcmap->cells[i].component[GLUT_GREEN] =
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
newcmap->cells[i].component[GLUT_BLUE] =
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, newcmap->cmap, &color);
|
||||
} else {
|
||||
/* Leave unallocated entries unallocated. */
|
||||
}
|
||||
}
|
||||
cmap = newcmap;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = cmap;
|
||||
__glutCurrentWindow->cmap = cmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = cmap;
|
||||
__glutCurrentWindow->overlay->cmap = cmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay,
|
||||
__glutCurrentWindow->renderWin, cmap->cmap);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
{
|
||||
GLUTwindow *toplevel;
|
||||
|
||||
toplevel = __glutToplevelOf(__glutCurrentWindow);
|
||||
if (toplevel->cmap != cmap->cmap) {
|
||||
__glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
color.pixel = ndx;
|
||||
red = CLAMP(red);
|
||||
cmap->cells[ndx].component[GLUT_RED] = red;
|
||||
color.red = (GLfloat) 0xffff *red;
|
||||
green = CLAMP(green);
|
||||
cmap->cells[ndx].component[GLUT_GREEN] = green;
|
||||
color.green = (GLfloat) 0xffff *green;
|
||||
blue = CLAMP(blue);
|
||||
cmap->cells[ndx].component[GLUT_BLUE] = blue;
|
||||
color.blue = (GLfloat) 0xffff *blue;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, cmap->cmap, &color);
|
||||
}
|
||||
|
||||
GLfloat GLUTAPIENTRY
|
||||
glutGetColor(int ndx, int comp)
|
||||
{
|
||||
GLUTcolormap *colormap;
|
||||
XVisualInfo *vis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
colormap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
colormap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning("glutGetColor: requesting overlay transparent index %d\n",
|
||||
ndx);
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colormap) {
|
||||
__glutWarning("glutGetColor: current window is RGBA");
|
||||
return -1.0;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= 256 || ndx < 0)
|
||||
#else
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= vis->visual->map_entries || ndx < 0)
|
||||
#endif
|
||||
if (OUT_OF_RANGE_NDX(ndx)) {
|
||||
__glutWarning("glutGetColor: index %d out of range", ndx);
|
||||
return -1.0;
|
||||
}
|
||||
return colormap->cells[ndx].component[comp];
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutCopyColormap(int winnum)
|
||||
{
|
||||
GLUTwindow *window = __glutWindowList[winnum - 1];
|
||||
GLUTcolormap *oldcmap, *newcmap;
|
||||
XVisualInfo *dstvis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
oldcmap = __glutCurrentWindow->colormap;
|
||||
dstvis = __glutCurrentWindow->vis;
|
||||
newcmap = window->colormap;
|
||||
} else {
|
||||
oldcmap = __glutCurrentWindow->overlay->colormap;
|
||||
dstvis = __glutCurrentWindow->overlay->vis;
|
||||
if (!window->overlay) {
|
||||
__glutWarning("glutCopyColormap: window %d has no overlay", winnum);
|
||||
return;
|
||||
}
|
||||
newcmap = window->overlay->colormap;
|
||||
}
|
||||
|
||||
if (!oldcmap) {
|
||||
__glutWarning("glutCopyColormap: destination colormap must be color index");
|
||||
return;
|
||||
}
|
||||
if (!newcmap) {
|
||||
__glutWarning(
|
||||
"glutCopyColormap: source colormap of window %d must be color index",
|
||||
winnum);
|
||||
return;
|
||||
}
|
||||
if (newcmap == oldcmap) {
|
||||
/* Source and destination are the same; now copy needed. */
|
||||
return;
|
||||
}
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
/* Play safe: compare visual IDs, not Visual*'s. */
|
||||
if (newcmap->visual->visualid == oldcmap->visual->visualid) {
|
||||
#endif
|
||||
/* Visuals match! "Copy" by reference... */
|
||||
__glutFreeColormap(oldcmap);
|
||||
newcmap->refcnt++;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = newcmap;
|
||||
__glutCurrentWindow->cmap = newcmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = newcmap;
|
||||
__glutCurrentWindow->overlay->cmap = newcmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay, __glutCurrentWindow->renderWin,
|
||||
newcmap->cmap);
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
__glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
|
||||
bla bla bla
|
||||
|
||||
} else {
|
||||
GLUTcolormap *copycmap;
|
||||
XColor color;
|
||||
int i, last;
|
||||
|
||||
/* Visuals different - need a distinct X colormap! */
|
||||
copycmap = __glutAssociateNewColormap(dstvis);
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
last = newcmap->size;
|
||||
if (last > copycmap->size) {
|
||||
last = copycmap->size;
|
||||
}
|
||||
for (i = last - 1; i >= 0; i--) {
|
||||
if (newcmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
copycmap->cells[i].component[GLUT_RED] =
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
copycmap->cells[i].component[GLUT_GREEN] =
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
copycmap->cells[i].component[GLUT_BLUE] =
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
XStoreColor(__glutDisplay, copycmap->cmap, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* ENDCENTRY */
|
||||
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,127 +1,127 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetWindowTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
__glutSetWindowText(__glutCurrentWindow->win, (char *)title);
|
||||
|
||||
#else
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetIconTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
//todo ?
|
||||
#else
|
||||
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMIconName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPositionWindow(int x, int y)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredX = x;
|
||||
__glutCurrentWindow->desiredY = y;
|
||||
__glutCurrentWindow->desiredConfMask |= CWX | CWY;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutReshapeWindow(int w, int h)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
if (w <= 0 || h <= 0)
|
||||
__glutWarning("glutReshapeWindow: non-positive width or height not allowed");
|
||||
|
||||
__glutCurrentWindow->desiredWidth = w;
|
||||
__glutCurrentWindow->desiredHeight = h;
|
||||
__glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPopWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Above;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPushWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Below;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutIconifyWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
__glutCurrentWindow->desiredMapState = IconicState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutShowWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = NormalState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutHideWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = WithdrawnState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetWindowTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
__glutSetWindowText(__glutCurrentWindow->win, (char *)title);
|
||||
|
||||
#else
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetIconTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
//todo ?
|
||||
#else
|
||||
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMIconName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPositionWindow(int x, int y)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredX = x;
|
||||
__glutCurrentWindow->desiredY = y;
|
||||
__glutCurrentWindow->desiredConfMask |= CWX | CWY;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutReshapeWindow(int w, int h)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
if (w <= 0 || h <= 0)
|
||||
__glutWarning("glutReshapeWindow: non-positive width or height not allowed");
|
||||
|
||||
__glutCurrentWindow->desiredWidth = w;
|
||||
__glutCurrentWindow->desiredHeight = h;
|
||||
__glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPopWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Above;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPushWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Below;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutIconifyWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
__glutCurrentWindow->desiredMapState = IconicState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutShowWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = NormalState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutHideWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = WithdrawnState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
|
|
@ -1,146 +1,146 @@
|
|||
/* os2_glx.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "gl/gl.h"
|
||||
#include "WarpGL.h"
|
||||
#include "GL/os2mesa.h"
|
||||
|
||||
#define POKA 0
|
||||
/* global current HDC */
|
||||
|
||||
XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
|
||||
|
||||
extern HDC XHDC;
|
||||
extern HWND XHWND;
|
||||
//extern HPS hpsCurrent;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
GLXContext
|
||||
glXCreateContext(HPS hps, XVisualInfo * visinfo,
|
||||
GLXContext share, Bool direct)
|
||||
{
|
||||
/* KLUDGE: GLX really expects a display pointer to be passed
|
||||
in as the first parameter, but Win32 needs an HDC instead,
|
||||
so BE SURE that the global XHDC is set before calling this
|
||||
routine. */
|
||||
HGLRC context;
|
||||
|
||||
context = wglCreateContext(XHDC,hps,hab);
|
||||
|
||||
|
||||
/* Since direct rendering is implicit, the direct flag is
|
||||
ignored. */
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
glXGetConfig(XVisualInfo * visual, int attrib, int *value)
|
||||
{
|
||||
if (!visual)
|
||||
return GLX_BAD_VISUAL;
|
||||
|
||||
switch (attrib) {
|
||||
case GLX_USE_GL:
|
||||
if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
|
||||
/* XXX Brad's Matrix Millenium II has problems creating
|
||||
color index windows in 24-bit mode (lead to GDI crash)
|
||||
and 32-bit mode (lead to black window). The cColorBits
|
||||
filed of the PIXELFORMATDESCRIPTOR returned claims to
|
||||
have 24 and 32 bits respectively of color indices. 2^24
|
||||
and 2^32 are ridiculously huge writable colormaps.
|
||||
Assume that if we get back a color index
|
||||
PIXELFORMATDESCRIPTOR with 24 or more bits, the
|
||||
PIXELFORMATDESCRIPTOR doesn't really work and skip it.
|
||||
-mjk */
|
||||
if (visual->iPixelType == PFD_TYPE_COLORINDEX
|
||||
&& visual->cColorBits >= 24) {
|
||||
*value = 0;
|
||||
} else {
|
||||
*value = 1;
|
||||
}
|
||||
} else {
|
||||
*value = 0;
|
||||
}
|
||||
break;
|
||||
case GLX_BUFFER_SIZE:
|
||||
/* KLUDGE: if we're RGBA, return the number of bits/pixel,
|
||||
otherwise, return 8 (we guessed at 256 colors in CI
|
||||
mode). */
|
||||
if (visual->iPixelType == PFD_TYPE_RGBA)
|
||||
*value = visual->cColorBits;
|
||||
else
|
||||
*value = 8;
|
||||
break;
|
||||
case GLX_LEVEL:
|
||||
/* The bReserved flag of the pfd contains the
|
||||
overlay/underlay info. */
|
||||
*value = visual->bReserved;
|
||||
break;
|
||||
case GLX_RGBA:
|
||||
*value = visual->iPixelType == PFD_TYPE_RGBA;
|
||||
break;
|
||||
case GLX_DOUBLEBUFFER:
|
||||
*value = visual->dwFlags & PFD_DOUBLEBUFFER;
|
||||
break;
|
||||
case GLX_STEREO:
|
||||
*value = visual->dwFlags & PFD_STEREO;
|
||||
break;
|
||||
case GLX_AUX_BUFFERS:
|
||||
*value = visual->cAuxBuffers;
|
||||
break;
|
||||
case GLX_RED_SIZE:
|
||||
*value = visual->cRedBits;
|
||||
break;
|
||||
case GLX_GREEN_SIZE:
|
||||
*value = visual->cGreenBits;
|
||||
break;
|
||||
case GLX_BLUE_SIZE:
|
||||
*value = visual->cBlueBits;
|
||||
break;
|
||||
case GLX_ALPHA_SIZE:
|
||||
*value = visual->cAlphaBits;
|
||||
break;
|
||||
case GLX_DEPTH_SIZE:
|
||||
*value = visual->cDepthBits;
|
||||
break;
|
||||
case GLX_STENCIL_SIZE:
|
||||
*value = visual->cStencilBits;
|
||||
break;
|
||||
case GLX_ACCUM_RED_SIZE:
|
||||
*value = visual->cAccumRedBits;
|
||||
break;
|
||||
case GLX_ACCUM_GREEN_SIZE:
|
||||
*value = visual->cAccumGreenBits;
|
||||
break;
|
||||
case GLX_ACCUM_BLUE_SIZE:
|
||||
*value = visual->cAccumBlueBits;
|
||||
break;
|
||||
case GLX_ACCUM_ALPHA_SIZE:
|
||||
*value = visual->cAccumAlphaBits;
|
||||
break;
|
||||
#if POKA == 100
|
||||
#endif /* POKA == 100 */
|
||||
default:
|
||||
return GLX_BAD_ATTRIB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
XVisualInfo * glXChooseVisual(int mode)
|
||||
{ int imode = 2;
|
||||
if(mode & GLUT_DOUBLE)
|
||||
imode = 1;
|
||||
return
|
||||
wglDescribePixelFormat(imode);
|
||||
}
|
||||
|
||||
|
||||
#if POKA
|
||||
#endif /* POKA */
|
||||
|
||||
/* os2_glx.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "gl/gl.h"
|
||||
#include "WarpGL.h"
|
||||
#include "GL/os2mesa.h"
|
||||
|
||||
#define POKA 0
|
||||
/* global current HDC */
|
||||
|
||||
XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
|
||||
|
||||
extern HDC XHDC;
|
||||
extern HWND XHWND;
|
||||
//extern HPS hpsCurrent;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
GLXContext
|
||||
glXCreateContext(HPS hps, XVisualInfo * visinfo,
|
||||
GLXContext share, Bool direct)
|
||||
{
|
||||
/* KLUDGE: GLX really expects a display pointer to be passed
|
||||
in as the first parameter, but Win32 needs an HDC instead,
|
||||
so BE SURE that the global XHDC is set before calling this
|
||||
routine. */
|
||||
HGLRC context;
|
||||
|
||||
context = wglCreateContext(XHDC,hps,hab);
|
||||
|
||||
|
||||
/* Since direct rendering is implicit, the direct flag is
|
||||
ignored. */
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
glXGetConfig(XVisualInfo * visual, int attrib, int *value)
|
||||
{
|
||||
if (!visual)
|
||||
return GLX_BAD_VISUAL;
|
||||
|
||||
switch (attrib) {
|
||||
case GLX_USE_GL:
|
||||
if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
|
||||
/* XXX Brad's Matrix Millenium II has problems creating
|
||||
color index windows in 24-bit mode (lead to GDI crash)
|
||||
and 32-bit mode (lead to black window). The cColorBits
|
||||
filed of the PIXELFORMATDESCRIPTOR returned claims to
|
||||
have 24 and 32 bits respectively of color indices. 2^24
|
||||
and 2^32 are ridiculously huge writable colormaps.
|
||||
Assume that if we get back a color index
|
||||
PIXELFORMATDESCRIPTOR with 24 or more bits, the
|
||||
PIXELFORMATDESCRIPTOR doesn't really work and skip it.
|
||||
-mjk */
|
||||
if (visual->iPixelType == PFD_TYPE_COLORINDEX
|
||||
&& visual->cColorBits >= 24) {
|
||||
*value = 0;
|
||||
} else {
|
||||
*value = 1;
|
||||
}
|
||||
} else {
|
||||
*value = 0;
|
||||
}
|
||||
break;
|
||||
case GLX_BUFFER_SIZE:
|
||||
/* KLUDGE: if we're RGBA, return the number of bits/pixel,
|
||||
otherwise, return 8 (we guessed at 256 colors in CI
|
||||
mode). */
|
||||
if (visual->iPixelType == PFD_TYPE_RGBA)
|
||||
*value = visual->cColorBits;
|
||||
else
|
||||
*value = 8;
|
||||
break;
|
||||
case GLX_LEVEL:
|
||||
/* The bReserved flag of the pfd contains the
|
||||
overlay/underlay info. */
|
||||
*value = visual->bReserved;
|
||||
break;
|
||||
case GLX_RGBA:
|
||||
*value = visual->iPixelType == PFD_TYPE_RGBA;
|
||||
break;
|
||||
case GLX_DOUBLEBUFFER:
|
||||
*value = visual->dwFlags & PFD_DOUBLEBUFFER;
|
||||
break;
|
||||
case GLX_STEREO:
|
||||
*value = visual->dwFlags & PFD_STEREO;
|
||||
break;
|
||||
case GLX_AUX_BUFFERS:
|
||||
*value = visual->cAuxBuffers;
|
||||
break;
|
||||
case GLX_RED_SIZE:
|
||||
*value = visual->cRedBits;
|
||||
break;
|
||||
case GLX_GREEN_SIZE:
|
||||
*value = visual->cGreenBits;
|
||||
break;
|
||||
case GLX_BLUE_SIZE:
|
||||
*value = visual->cBlueBits;
|
||||
break;
|
||||
case GLX_ALPHA_SIZE:
|
||||
*value = visual->cAlphaBits;
|
||||
break;
|
||||
case GLX_DEPTH_SIZE:
|
||||
*value = visual->cDepthBits;
|
||||
break;
|
||||
case GLX_STENCIL_SIZE:
|
||||
*value = visual->cStencilBits;
|
||||
break;
|
||||
case GLX_ACCUM_RED_SIZE:
|
||||
*value = visual->cAccumRedBits;
|
||||
break;
|
||||
case GLX_ACCUM_GREEN_SIZE:
|
||||
*value = visual->cAccumGreenBits;
|
||||
break;
|
||||
case GLX_ACCUM_BLUE_SIZE:
|
||||
*value = visual->cAccumBlueBits;
|
||||
break;
|
||||
case GLX_ACCUM_ALPHA_SIZE:
|
||||
*value = visual->cAccumAlphaBits;
|
||||
break;
|
||||
#if POKA == 100
|
||||
#endif /* POKA == 100 */
|
||||
default:
|
||||
return GLX_BAD_ATTRIB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
XVisualInfo * glXChooseVisual(int mode)
|
||||
{ int imode = 2;
|
||||
if(mode & GLUT_DOUBLE)
|
||||
imode = 1;
|
||||
return
|
||||
wglDescribePixelFormat(imode);
|
||||
}
|
||||
|
||||
|
||||
#if POKA
|
||||
#endif /* POKA */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue