Selaa lähdekoodia

Drop unused glut subdirectories

tags/7.8-rc1
Kristian Høgsberg 15 vuotta sitten
vanhempi
commit
b15fe60ba5
91 muutettua tiedostoa jossa 0 lisäystä ja 54558 poistoa
  1. 0
    163
      src/glut/dos/PC_HW/pc_hw.c
  2. 0
    229
      src/glut/dos/PC_HW/pc_hw.h
  3. 0
    182
      src/glut/dos/PC_HW/pc_irq.S
  4. 0
    540
      src/glut/dos/PC_HW/pc_keyb.c
  5. 0
    293
      src/glut/dos/PC_HW/pc_mouse.c
  6. 0
    327
      src/glut/dos/PC_HW/pc_timer.c
  7. 0
    115
      src/glut/dos/bitmap.c
  8. 0
    204
      src/glut/dos/callback.c
  9. 0
    53
      src/glut/dos/color.c
  10. 0
    70
      src/glut/dos/extens.c
  11. 0
    1183
      src/glut/dos/f8x13.c
  12. 0
    1407
      src/glut/dos/f9x15.c
  13. 0
    1019
      src/glut/dos/hel10.c
  14. 0
    1029
      src/glut/dos/hel12.c
  15. 0
    1138
      src/glut/dos/hel18.c
  16. 0
    223
      src/glut/dos/init.c
  17. 0
    197
      src/glut/dos/internal.h
  18. 0
    245
      src/glut/dos/loop.c
  19. 0
    130
      src/glut/dos/menu.c
  20. 0
    55
      src/glut/dos/mouse.c
  21. 0
    2779
      src/glut/dos/mroman.c
  22. 0
    93
      src/glut/dos/overlay.c
  23. 0
    2779
      src/glut/dos/roman.c
  24. 0
    1143
      src/glut/dos/shapes.c
  25. 0
    238
      src/glut/dos/state.c
  26. 0
    118
      src/glut/dos/stroke.c
  27. 0
    201
      src/glut/dos/teapot.c
  28. 0
    1018
      src/glut/dos/tr10.c
  29. 0
    1301
      src/glut/dos/tr24.c
  30. 0
    74
      src/glut/dos/util.c
  31. 0
    329
      src/glut/dos/window.c
  32. 0
    94
      src/glut/fbdev/Makefile
  33. 0
    78
      src/glut/fbdev/bitmap.c
  34. 0
    171
      src/glut/fbdev/callback.c
  35. 0
    177
      src/glut/fbdev/colormap.c
  36. 0
    272
      src/glut/fbdev/cursor.c
  37. 0
    7099
      src/glut/fbdev/cursors.h
  38. 0
    154
      src/glut/fbdev/ext.c
  39. 0
    940
      src/glut/fbdev/fbdev.c
  40. 0
    306
      src/glut/fbdev/gamemode.c
  41. 0
    828
      src/glut/fbdev/input.c
  42. 0
    177
      src/glut/fbdev/internal.h
  43. 0
    309
      src/glut/fbdev/menu.c
  44. 0
    57
      src/glut/fbdev/overlay.c
  45. 0
    197
      src/glut/fbdev/state.c
  46. 0
    81
      src/glut/fbdev/stroke.c
  47. 0
    55
      src/glut/fbdev/vidresize.c
  48. 0
    420
      src/glut/os2/Makefile
  49. 0
    419
      src/glut/os2/WarpWin.cpp
  50. 0
    133
      src/glut/os2/glutOverlay.cpp
  51. 0
    2076
      src/glut/os2/glut_8x13.cpp
  52. 0
    2077
      src/glut/os2/glut_9x15.cpp
  53. 0
    57
      src/glut/os2/glut_bitmap.cpp
  54. 0
    258
      src/glut/os2/glut_cindex.cpp
  55. 0
    399
      src/glut/os2/glut_cmap.cpp
  56. 0
    210
      src/glut/os2/glut_cursor.cpp
  57. 0
    1399
      src/glut/os2/glut_event.cpp
  58. 0
    204
      src/glut/os2/glut_ext.cpp
  59. 0
    38
      src/glut/os2/glut_fullscrn.cpp
  60. 0
    679
      src/glut/os2/glut_gamemode.cpp
  61. 0
    232
      src/glut/os2/glut_get.cpp
  62. 0
    1781
      src/glut/os2/glut_hel10.cpp
  63. 0
    1791
      src/glut/os2/glut_hel12.cpp
  64. 0
    1900
      src/glut/os2/glut_hel18.cpp
  65. 0
    451
      src/glut/os2/glut_init.cpp
  66. 0
    628
      src/glut/os2/glut_input.cpp
  67. 0
    29
      src/glut/os2/glut_key.cpp
  68. 0
    29
      src/glut/os2/glut_keyctrl.cpp
  69. 0
    29
      src/glut/os2/glut_keyup.cpp
  70. 0
    57
      src/glut/os2/glut_mesa.cpp
  71. 0
    31
      src/glut/os2/glut_modifier.cpp
  72. 0
    2451
      src/glut/os2/glut_roman.cpp
  73. 0
    595
      src/glut/os2/glut_shapes.cpp
  74. 0
    42
      src/glut/os2/glut_stroke.cpp
  75. 0
    67
      src/glut/os2/glut_swap.cpp
  76. 0
    210
      src/glut/os2/glut_teapot.cpp
  77. 0
    2063
      src/glut/os2/glut_tr24.cpp
  78. 0
    90
      src/glut/os2/glut_util.cpp
  79. 0
    232
      src/glut/os2/glut_vidresize.cpp
  80. 0
    29
      src/glut/os2/glut_warp.cpp
  81. 0
    1220
      src/glut/os2/glut_win.cpp
  82. 0
    126
      src/glut/os2/glut_winmisc.cpp
  83. 0
    32
      src/glut/os2/glutbitmap.h
  84. 0
    36
      src/glut/os2/glutos2.h
  85. 0
    42
      src/glut/os2/glutstroke.h
  86. 0
    59
      src/glut/os2/layerutil.h
  87. 0
    94
      src/glut/os2/libGlut.DEF
  88. 0
    145
      src/glut/os2/os2_glx.cpp
  89. 0
    532
      src/glut/os2/os2_menu.cpp
  90. 0
    1296
      src/glut/os2/os2_winproc.cpp
  91. BIN
      src/glut/os2/src-glut_os2pm.zip

+ 0
- 163
src/glut/dos/PC_HW/pc_hw.c Näytä tiedosto

@@ -1,163 +0,0 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


#include <dpmi.h>
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "pc_hw.h"


/*
* atexit
*/
#define MAX_ATEXIT 32

static volatile int atexitcnt;
static VFUNC atexittbl[MAX_ATEXIT];


static void __attribute__((destructor))
doexit (void)
{
while (atexitcnt) atexittbl[--atexitcnt]();
}


int
pc_clexit (VFUNC f)
{
int i;

for (i = 0; i < atexitcnt; i++) {
if (atexittbl[i] == f) {
for (atexitcnt--; i < atexitcnt; i++) atexittbl[i] = atexittbl[i+1];
atexittbl[i] = 0;
return 0;
}
}
return -1;
}


int
pc_atexit (VFUNC f)
{
pc_clexit(f);
if (atexitcnt < MAX_ATEXIT) {
atexittbl[atexitcnt++] = f;
return 0;
}
return -1;
}


/*
* locked memory allocation
*/
void *
pc_malloc (size_t size)
{
void *p = malloc(size);

if (p) {
if (_go32_dpmi_lock_data(p, size)) {
free(p);
return NULL;
}
}

return p;
}


/*
* standard redirection
*/
static char outname[L_tmpnam];
static int h_out, h_outbak;
static char errname[L_tmpnam];
static int h_err, h_errbak;


int
pc_open_stdout (void)
{
tmpnam(outname);

if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_outbak = dup(STDOUT_FILENO);
fflush(stdout);
dup2(h_out, STDOUT_FILENO);
}

return h_out;
}


void
pc_close_stdout (void)
{
FILE *f;
char *line = alloca(512);

if (h_out > 0) {
dup2(h_outbak, STDOUT_FILENO);
close(h_out);
close(h_outbak);

f = fopen(outname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stdout);
}
fclose(f);

remove(outname);
}
}


int
pc_open_stderr (void)
{
tmpnam(errname);

if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_errbak = dup(STDERR_FILENO);
fflush(stderr);
dup2(h_err, STDERR_FILENO);
}

return h_err;
}


void
pc_close_stderr (void)
{
FILE *f;
char *line = alloca(512);

if (h_err > 0) {
dup2(h_errbak, STDERR_FILENO);
close(h_err);
close(h_errbak);

f = fopen(errname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stderr);
}
fclose(f);

remove(errname);
}
}

+ 0
- 229
src/glut/dos/PC_HW/pc_hw.h Näytä tiedosto

@@ -1,229 +0,0 @@
/*
* PC/HW routine collection v1.4 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


#ifndef PC_HW_H_included
#define PC_HW_H_included

#include <dpmi.h>
#include <stdlib.h>

/*
* misc C definitions
*/
#define FALSE 0
#define TRUE !FALSE

#define SQR(x) ((x) * (x))

#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MID(x,y,z) MAX((x), MIN((y), (z)))

typedef void (*VFUNC) (void);
typedef void (*PFUNC) (void *);
typedef void (*MFUNC) (int x, int y, int z, int b);

/*
* atexit
*/
int pc_atexit (VFUNC f);
int pc_clexit (VFUNC f);

/*
* locked memory
*/
#define ENDOFUNC(x) static void x##_end() { }
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)

void *pc_malloc (size_t size);

/*
* IRQ
*/
#define ENABLE() __asm __volatile ("sti")
#define DISABLE() __asm __volatile ("cli")

extern int pc_install_irq (int i, int (*handler) ());
extern int pc_remove_irq (int i);

/*
* keyboard
*/
#define KB_SHIFT_FLAG 0x0001
#define KB_CTRL_FLAG 0x0002
#define KB_ALT_FLAG 0x0004
#define KB_LWIN_FLAG 0x0008
#define KB_RWIN_FLAG 0x0010
#define KB_MENU_FLAG 0x0020
#define KB_SCROLOCK_FLAG 0x0100
#define KB_NUMLOCK_FLAG 0x0200
#define KB_CAPSLOCK_FLAG 0x0400
#define KB_INALTSEQ_FLAG 0x0800
#define KB_ACCENT1_FLAG 0x1000
#define KB_ACCENT2_FLAG 0x2000
#define KB_ACCENT3_FLAG 0x4000
#define KB_ACCENT4_FLAG 0x8000

#define KEY_A 1
#define KEY_B 2
#define KEY_C 3
#define KEY_D 4
#define KEY_E 5
#define KEY_F 6
#define KEY_G 7
#define KEY_H 8
#define KEY_I 9
#define KEY_J 10
#define KEY_K 11
#define KEY_L 12
#define KEY_M 13
#define KEY_N 14
#define KEY_O 15
#define KEY_P 16
#define KEY_Q 17
#define KEY_R 18
#define KEY_S 19
#define KEY_T 20
#define KEY_U 21
#define KEY_V 22
#define KEY_W 23
#define KEY_X 24
#define KEY_Y 25
#define KEY_Z 26
#define KEY_0 27
#define KEY_1 28
#define KEY_2 29
#define KEY_3 30
#define KEY_4 31
#define KEY_5 32
#define KEY_6 33
#define KEY_7 34
#define KEY_8 35
#define KEY_9 36
#define KEY_0_PAD 37
#define KEY_1_PAD 38
#define KEY_2_PAD 39
#define KEY_3_PAD 40
#define KEY_4_PAD 41
#define KEY_5_PAD 42
#define KEY_6_PAD 43
#define KEY_7_PAD 44
#define KEY_8_PAD 45
#define KEY_9_PAD 46
#define KEY_F1 47
#define KEY_F2 48
#define KEY_F3 49
#define KEY_F4 50
#define KEY_F5 51
#define KEY_F6 52
#define KEY_F7 53
#define KEY_F8 54
#define KEY_F9 55
#define KEY_F10 56
#define KEY_F11 57
#define KEY_F12 58
#define KEY_ESC 59
#define KEY_TILDE 60
#define KEY_MINUS 61
#define KEY_EQUALS 62
#define KEY_BACKSPACE 63
#define KEY_TAB 64
#define KEY_OPENBRACE 65
#define KEY_CLOSEBRACE 66
#define KEY_ENTER 67
#define KEY_COLON 68
#define KEY_QUOTE 69
#define KEY_BACKSLASH 70
#define KEY_BACKSLASH2 71
#define KEY_COMMA 72
#define KEY_STOP 73
#define KEY_SLASH 74
#define KEY_SPACE 75
#define KEY_INSERT 76
#define KEY_DEL 77
#define KEY_HOME 78
#define KEY_END 79
#define KEY_PGUP 80
#define KEY_PGDN 81
#define KEY_LEFT 82
#define KEY_RIGHT 83
#define KEY_UP 84
#define KEY_DOWN 85
#define KEY_SLASH_PAD 86
#define KEY_ASTERISK 87
#define KEY_MINUS_PAD 88
#define KEY_PLUS_PAD 89
#define KEY_DEL_PAD 90
#define KEY_ENTER_PAD 91
#define KEY_PRTSCR 92
#define KEY_PAUSE 93
#define KEY_ABNT_C1 94
#define KEY_YEN 95
#define KEY_KANA 96
#define KEY_CONVERT 97
#define KEY_NOCONVERT 98
#define KEY_AT 99
#define KEY_CIRCUMFLEX 100
#define KEY_COLON2 101
#define KEY_KANJI 102

#define KEY_MODIFIERS 103

#define KEY_LSHIFT 103
#define KEY_RSHIFT 104
#define KEY_LCONTROL 105
#define KEY_RCONTROL 106
#define KEY_ALT 107
#define KEY_ALTGR 108
#define KEY_LWIN 109
#define KEY_RWIN 110
#define KEY_MENU 111
#define KEY_SCRLOCK 112
#define KEY_NUMLOCK 113
#define KEY_CAPSLOCK 114

#define KEY_MAX 115

int pc_install_keyb (void);
void pc_remove_keyb (void);
int pc_keypressed (void);
int pc_readkey (void);
int pc_keydown (int code);
int pc_keyshifts (void);

/*
* timer
*/
int pc_install_int (PFUNC func, void *parm, unsigned int freq);
int pc_remove_int (int fid);
int pc_adjust_int (int fid, unsigned int freq);
void pc_remove_timer (void);

/*
* mouse
*/
int pc_install_mouse (void);
void pc_remove_mouse (void);
MFUNC pc_install_mouse_handler (MFUNC handler);
void pc_mouse_area (int x1, int y1, int x2, int y2);
void pc_mouse_speed (int xspeed, int yspeed);
int pc_query_mouse (int *x, int *y, int *z);
void pc_warp_mouse (int x, int y);

/*
* standard redirection
*/
int pc_open_stdout (void);
int pc_open_stderr (void);
void pc_close_stdout (void);
void pc_close_stderr (void);

#endif

+ 0
- 182
src/glut/dos/PC_HW/pc_irq.S Näytä tiedosto

@@ -1,182 +0,0 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


.file "pc_irq.S"

.text

#define IRQ_STACK_SIZE 16384

#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)

.balign 4
common:
movw $0x0400, %ax
int $0x31

movl %ss:8(%ebp), %ebx
cmpl $15, %ebx
jbe 0f
fail:
orl $-1, %eax
popl %edi
popl %ebx
leave
ret

0:
movl %ebx, %edi
imull $IRQ_WRAPPER_LEN, %edi
addl $__irq_wrapper_0, %edi

cmpb $7, %bl
jbe 1f
movb %dl, %dh
subb $8, %dh
1:
addb %dh, %bl
ret

.balign 4
.global _pc_install_irq
_pc_install_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi

call common

cmpl $0, IRQ_HOOK(%edi)
jne fail

pushl $IRQ_WRAPPER_LEN
pushl %edi
call __go32_dpmi_lock_code
addl $8, %esp
testl %eax, %eax
jnz fail

pushl $IRQ_STACK_SIZE
call _pc_malloc
popl %edx
testl %eax, %eax
jz fail
addl %edx, %eax
movl %eax, IRQ_STACK(%edi)

movl ___djgpp_ds_alias, %eax
movl %eax, IRQ_STACK+4(%edi)

movl %ss:12(%ebp), %eax
movl %eax, IRQ_HOOK(%edi)

movw $0x0204, %ax
int $0x31
movl %edx, IRQ_OLD(%edi)
movw %cx, IRQ_OLD+4(%edi)
movw $0x0205, %ax
movl %edi, %edx
movl %cs, %ecx
int $0x31

done:
xorl %eax, %eax
popl %edi
popl %ebx
leave
ret

.balign 4
.global _pc_remove_irq
_pc_remove_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi

call common

cmpl $0, IRQ_HOOK(%edi)
je fail

movl $0, IRQ_HOOK(%edi)

movw $0x0205, %ax
movl IRQ_OLD(%edi), %edx
movl IRQ_OLD+4(%edi), %ecx
int $0x31

movl IRQ_STACK(%edi), %eax
subl $IRQ_STACK_SIZE, %eax
pushl %eax
call _free
popl %eax

jmp done

#define WRAPPER(x) ; \
.balign 4 ; \
__irq_wrapper_##x: ; \
pushal ; \
pushl %ds ; \
pushl %es ; \
pushl %fs ; \
pushl %gs ; \
movl %ss, %ebx ; \
movl %esp, %esi ; \
lss %cs:__irq_stack_##x, %esp ; \
pushl %ss ; \
pushl %ss ; \
popl %es ; \
popl %ds ; \
movl ___djgpp_dos_sel, %fs ; \
pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
popl %fs ; \
popl %es ; \
popl %ds ; \
popal ; \
jz __irq_ignore_##x ; \
__irq_bypass_##x: ; \
ljmp *%cs:__irq_old_##x ; \
__irq_ignore_##x: ; \
iret ; \
.balign 4 ; \
__irq_old_##x: ; \
.long 0, 0 ; \
__irq_hook_##x: ; \
.long 0 ; \
__irq_stack_##x: ; \
.long 0, 0

WRAPPER(0);
WRAPPER(1);
WRAPPER(2);
WRAPPER(3);
WRAPPER(4);
WRAPPER(5);
WRAPPER(6);
WRAPPER(7);
WRAPPER(8);
WRAPPER(9);
WRAPPER(10);
WRAPPER(11);
WRAPPER(12);
WRAPPER(13);
WRAPPER(14);
WRAPPER(15);

+ 0
- 540
src/glut/dos/PC_HW/pc_keyb.c Näytä tiedosto

@@ -1,540 +0,0 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


#include <pc.h>
#include <sys/exceptn.h>
#include <sys/farptr.h>

#include "pc_hw.h"


#define KEYB_IRQ 1

#define KEY_BUFFER_SIZE 64

#define KB_MODIFIERS (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG | KB_LWIN_FLAG | KB_RWIN_FLAG | KB_MENU_FLAG)
#define KB_LED_FLAGS (KB_SCROLOCK_FLAG | KB_NUMLOCK_FLAG | KB_CAPSLOCK_FLAG)

static int keyboard_installed;

static volatile struct {
volatile int start, end;
volatile int key[KEY_BUFFER_SIZE];
} key_buffer;

static volatile int key_enhanced, key_pause_loop, key_shifts;
static int leds_ok = TRUE;
static int in_a_terrupt = FALSE;
static volatile char pc_key[KEY_MAX];


/* convert Allegro format scancodes into key_shifts flag bits */
static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] = {
KB_SHIFT_FLAG, KB_SHIFT_FLAG, KB_CTRL_FLAG,
KB_CTRL_FLAG, KB_ALT_FLAG, KB_ALT_FLAG,
KB_LWIN_FLAG, KB_RWIN_FLAG, KB_MENU_FLAG,
KB_SCROLOCK_FLAG, KB_NUMLOCK_FLAG, KB_CAPSLOCK_FLAG
};


/* lookup table for converting hardware scancodes into Allegro format */
static unsigned char hw_to_mycode[128] = {
/* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
/* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
/* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
/* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
/* 0x10 */ KEY_Q, KEY_W, KEY_E, KEY_R,
/* 0x14 */ KEY_T, KEY_Y, KEY_U, KEY_I,
/* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
/* 0x1C */ KEY_ENTER, KEY_LCONTROL, KEY_A, KEY_S,
/* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
/* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
/* 0x28 */ KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH,
/* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
/* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
/* 0x34 */ KEY_STOP, KEY_SLASH, KEY_RSHIFT, KEY_ASTERISK,
/* 0x38 */ KEY_ALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
/* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
/* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
/* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_SCRLOCK, KEY_7_PAD,
/* 0x48 */ KEY_8_PAD, KEY_9_PAD, KEY_MINUS_PAD, KEY_4_PAD,
/* 0x4C */ KEY_5_PAD, KEY_6_PAD, KEY_PLUS_PAD, KEY_1_PAD,
/* 0x50 */ KEY_2_PAD, KEY_3_PAD, KEY_0_PAD, KEY_DEL_PAD,
/* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
/* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
/* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
/* 0x60 */ 0, 0, 0, 0,
/* 0x64 */ 0, 0, 0, 0,
/* 0x68 */ 0, 0, 0, 0,
/* 0x6C */ 0, 0, 0, 0,
/* 0x70 */ KEY_KANA, 0, 0, KEY_ABNT_C1,
/* 0x74 */ 0, 0, 0, 0,
/* 0x78 */ 0, KEY_CONVERT, 0, KEY_NOCONVERT,
/* 0x7C */ 0, KEY_YEN, 0, 0
};


/* lookup table for converting extended hardware codes into Allegro format */
static unsigned char hw_to_mycode_ex[128] = {
/* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
/* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
/* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
/* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
/* 0x10 */ KEY_CIRCUMFLEX, KEY_AT, KEY_COLON2, KEY_R,
/* 0x14 */ KEY_KANJI, KEY_Y, KEY_U, KEY_I,
/* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
/* 0x1C */ KEY_ENTER_PAD, KEY_RCONTROL, KEY_A, KEY_S,
/* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
/* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
/* 0x28 */ KEY_QUOTE, KEY_TILDE, 0, KEY_BACKSLASH,
/* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
/* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
/* 0x34 */ KEY_STOP, KEY_SLASH_PAD, 0, KEY_PRTSCR,
/* 0x38 */ KEY_ALTGR, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
/* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
/* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
/* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_PAUSE, KEY_HOME,
/* 0x48 */ KEY_UP, KEY_PGUP, KEY_MINUS_PAD, KEY_LEFT,
/* 0x4C */ KEY_5_PAD, KEY_RIGHT, KEY_PLUS_PAD, KEY_END,
/* 0x50 */ KEY_DOWN, KEY_PGDN, KEY_INSERT, KEY_DEL,
/* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
/* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
/* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
/* 0x60 */ 0, 0, 0, 0,
/* 0x64 */ 0, 0, 0, 0,
/* 0x68 */ 0, 0, 0, 0,
/* 0x6C */ 0, 0, 0, 0,
/* 0x70 */ 0, 0, 0, 0,
/* 0x74 */ 0, 0, 0, 0,
/* 0x78 */ 0, 0, 0, 0,
/* 0x7C */ 0, 0, 0, 0
};


/* default mapping table for the US keyboard layout */
static unsigned short standard_key_ascii_table[KEY_MAX] = {
/* start */ 0,
/* alphabet */ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
/* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


/* capslock mapping table for the US keyboard layout */
static unsigned short standard_key_capslock_table[KEY_MAX] = {
/* start */ 0,
/* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
/* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


/* shifted mapping table for the US keyboard layout */
static unsigned short standard_key_shift_table[KEY_MAX] = {
/* start */ 0,
/* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
/* numbers */ ')', '!', '@', '#', '$', '%', '^', '&', '*', '(',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '~', '_', '+', 8, 9, '{', '}', 13, ':', '"', '|', '|', '<', '>', '?', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


/* ctrl+key mapping table for the US keyboard layout */
static unsigned short standard_key_control_table[KEY_MAX] = {
/* start */ 0,
/* alphabet */ 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,
/* numbers */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, 2, 2, 2, 127, 127, 2, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2,
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ 2, 2, 2, 2, 2, 10,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


/* convert numeric pad scancodes into arrow codes */
static unsigned char numlock_table[10] = {
KEY_INSERT, KEY_END, KEY_DOWN, KEY_PGDN, KEY_LEFT,
KEY_5_PAD, KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PGUP
};


/* kb_wait_for_write_ready:
* Wait for the keyboard controller to set the ready-for-write bit.
*/
static __inline int
kb_wait_for_write_ready (void)
{
int timeout = 4096;

while ((timeout > 0) && (inportb(0x64) & 2)) timeout--;

return (timeout > 0);
}


/* kb_wait_for_read_ready:
* Wait for the keyboard controller to set the ready-for-read bit.
*/
static __inline int
kb_wait_for_read_ready (void)
{
int timeout = 16384;

while ((timeout > 0) && (!(inportb(0x64) & 1))) timeout--;

return (timeout > 0);
}


/* kb_send_data:
* Sends a byte to the keyboard controller. Returns 1 if all OK.
*/
static __inline int
kb_send_data (unsigned char data)
{
int resends = 4;
int timeout, temp;

do {
if (!kb_wait_for_write_ready())
return 0;

outportb(0x60, data);
timeout = 4096;

while (--timeout > 0) {
if (!kb_wait_for_read_ready())
return 0;

temp = inportb(0x60);

if (temp == 0xFA)
return 1;

if (temp == 0xFE)
break;
}
} while ((resends-- > 0) && (timeout > 0));

return 0;
}


static void
update_leds (int leds)
{
if (leds_ok) {
if (!in_a_terrupt)
DISABLE();

if (!kb_send_data(0xED)) {
kb_send_data(0xF4);
leds_ok = FALSE;
} else if (!kb_send_data((leds >> 8) & 7)) {
kb_send_data(0xF4);
leds_ok = FALSE;
}

if (!in_a_terrupt)
ENABLE();
}
} ENDOFUNC(update_leds)


static void
inject_key (int scancode)
{
unsigned short *table;

if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) {
if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) {
scancode = numlock_table[scancode - KEY_0_PAD];
}
table = standard_key_ascii_table;
} else if (key_shifts & KB_CTRL_FLAG) {
table = standard_key_control_table;
} else if (key_shifts & KB_SHIFT_FLAG) {
if (key_shifts & KB_CAPSLOCK_FLAG) {
if (standard_key_ascii_table[scancode] == standard_key_capslock_table[scancode]) {
table = standard_key_shift_table;
} else {
table = standard_key_ascii_table;
}
} else {
table = standard_key_shift_table;
}
} else if (key_shifts & KB_CAPSLOCK_FLAG) {
table = standard_key_capslock_table;
} else {
table = standard_key_ascii_table;
}

key_buffer.key[key_buffer.end++] = (scancode << 16) | table[scancode];

if (key_buffer.end >= KEY_BUFFER_SIZE)
key_buffer.end = 0;
if (key_buffer.end == key_buffer.start) {
key_buffer.start++;
if (key_buffer.start >= KEY_BUFFER_SIZE)
key_buffer.start = 0;
}
} ENDOFUNC(inject_key)


static void
handle_code (int scancode, int keycode)
{
in_a_terrupt++;

if (keycode == 0) { /* pause */
inject_key(scancode);
pc_key[KEY_PAUSE] ^= TRUE;
} else if (scancode) {
int flag;

if (scancode >= KEY_MODIFIERS) {
flag = modifier_table[scancode - KEY_MODIFIERS];
} else {
flag = 0;
}
if ((char)keycode < 0) { /* release */
pc_key[scancode] = FALSE;
if (flag & KB_MODIFIERS) {
key_shifts &= ~flag;
}
} else { /* keypress */
pc_key[scancode] = TRUE;
if (flag & KB_MODIFIERS) {
key_shifts |= flag;
}
if (flag & KB_LED_FLAGS) {
key_shifts ^= flag;
update_leds(key_shifts);
}
if (scancode < KEY_MODIFIERS) {
inject_key(scancode);
}
}
}

in_a_terrupt--;
} ENDOFUNC(handle_code)


static int
keyboard ()
{
unsigned char temp, scancode;

temp = inportb(0x60);

if (temp <= 0xe1) {
if (key_pause_loop) {
if (!--key_pause_loop) handle_code(KEY_PAUSE, 0);
} else
switch (temp) {
case 0xe0:
key_enhanced = TRUE;
break;
case 0xe1:
key_pause_loop = 5;
break;
default:
if (key_enhanced) {
key_enhanced = FALSE;
scancode = hw_to_mycode_ex[temp & 0x7f];
} else {
scancode = hw_to_mycode[temp & 0x7f];
}
handle_code(scancode, temp);
}
}

if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) {
/* Hack alert:
* only SIGINT (but not Ctrl-Break)
* calls the destructors and will safely clean up
*/
__asm("\n\
movb $0x79, %%al \n\
call ___djgpp_hw_exception \n\
":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
}

__asm("\n\
inb $0x61, %%al \n\
movb %%al, %%ah \n\
orb $0x80, %%al \n\
outb %%al, $0x61 \n\
xchgb %%al, %%ah \n\
outb %%al, $0x61 \n\
movb $0x20, %%al \n\
outb %%al, $0x20 \n\
":::"%eax");
return 0;
} ENDOFUNC(keyboard)


int
pc_keypressed (void)
{
return (key_buffer.start!=key_buffer.end);
}


int
pc_readkey (void)
{
if (keyboard_installed) {
int key;

while (key_buffer.start == key_buffer.end) {
__dpmi_yield();
}

DISABLE();
key = key_buffer.key[key_buffer.start++];
if (key_buffer.start >= KEY_BUFFER_SIZE)
key_buffer.start = 0;
ENABLE();

return key;
} else {
return 0;
}
}


int
pc_keydown (int code)
{
return pc_key[code];
}


int
pc_keyshifts (void)
{
return key_shifts;
}


void
pc_remove_keyb (void)
{
if (keyboard_installed) {
int s1, s2, s3;

keyboard_installed = FALSE;
pc_clexit(pc_remove_keyb);

DISABLE();
_farsetsel(__djgpp_dos_sel);
_farnspokew(0x41c, _farnspeekw(0x41a));

s1 = _farnspeekb(0x417) & 0x80;
s2 = _farnspeekb(0x418) & 0xFC;
s3 = _farnspeekb(0x496) & 0xF3;

if (pc_key[KEY_RSHIFT]) { s1 |= 1; }
if (pc_key[KEY_LSHIFT]) { s1 |= 2; }
if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; }
if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; }
if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; }
if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; }

if (key_shifts & KB_SCROLOCK_FLAG) s1 |= 16;
if (key_shifts & KB_NUMLOCK_FLAG) s1 |= 32;
if (key_shifts & KB_CAPSLOCK_FLAG) s1 |= 64;

_farnspokeb(0x417, s1);
_farnspokeb(0x418, s2);
_farnspokeb(0x496, s3);
update_leds(key_shifts);

ENABLE();
pc_remove_irq(KEYB_IRQ);
}
}


int
pc_install_keyb (void)
{
if (keyboard_installed || pc_install_irq(KEYB_IRQ, keyboard)) {
return -1;
} else {
int s1, s2, s3;

LOCKDATA(key_buffer);
LOCKDATA(key_enhanced);
LOCKDATA(key_pause_loop);
LOCKDATA(key_shifts);
LOCKDATA(leds_ok);
LOCKDATA(in_a_terrupt);
LOCKDATA(pc_key);
LOCKDATA(modifier_table);
LOCKDATA(hw_to_mycode);
LOCKDATA(hw_to_mycode_ex);
LOCKDATA(standard_key_ascii_table);
LOCKDATA(standard_key_capslock_table);
LOCKDATA(standard_key_shift_table);
LOCKDATA(standard_key_control_table);
LOCKDATA(numlock_table);
LOCKFUNC(update_leds);
LOCKFUNC(inject_key);
LOCKFUNC(handle_code);
LOCKFUNC(keyboard);

DISABLE();
_farsetsel(__djgpp_dos_sel);
_farnspokew(0x41c, _farnspeekw(0x41a));

key_shifts = 0;
s1 = _farnspeekb(0x417);
s2 = _farnspeekb(0x418);
s3 = _farnspeekb(0x496);

if (s1 & 1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; }
if (s1 & 2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; }
if (s2 & 1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; }
if (s2 & 2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; }
if (s3 & 4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; }
if (s3 & 8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; }

if (s1 & 16) key_shifts |= KB_SCROLOCK_FLAG;
if (s1 & 32) key_shifts |= KB_NUMLOCK_FLAG;
if (s1 & 64) key_shifts |= KB_CAPSLOCK_FLAG;
update_leds(key_shifts);

key_enhanced = key_pause_loop = 0;
key_buffer.start = key_buffer.end = 0;
ENABLE();

pc_atexit(pc_remove_keyb);
keyboard_installed = TRUE;
return 0;
}
}

+ 0
- 293
src/glut/dos/PC_HW/pc_mouse.c Näytä tiedosto

@@ -1,293 +0,0 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


#include <dpmi.h>
#include <sys/exceptn.h>
#include <sys/segments.h>

#include "pc_hw.h"


#define PC_CUTE_WHEEL 1 /* CuteMouse WheelAPI */

#define MOUSE_STACK_SIZE 16384

#define CLEAR_MICKEYS() \
do { \
__asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
ox = oy = 0; \
} while (0)

extern void mouse_wrap (void);
extern int mouse_wrap_end[];

static MFUNC mouse_func;
static long mouse_callback;
static __dpmi_regs mouse_regs;

static volatile struct {
volatile int x, y, z, b;
} pc_mouse;

static int minx = 0;
static int maxx = 319;
static int miny = 0;
static int maxy = 199;
static int minz = 0;
static int maxz = 255;

static int sx = 2;
static int sy = 2;

static int emulat3 = FALSE;

static int ox, oy;


static void
mouse (__dpmi_regs *r)
{
int nx = (signed short)r->x.si / sx;
int ny = (signed short)r->x.di / sy;
int dx = nx - ox;
int dy = ny - oy;
#if PC_CUTE_WHEEL
int dz = (signed char)r->h.bh;
#endif
ox = nx;
oy = ny;

pc_mouse.b = r->h.bl;
pc_mouse.x = MID(minx, pc_mouse.x + dx, maxx);
pc_mouse.y = MID(miny, pc_mouse.y + dy, maxy);
#if PC_CUTE_WHEEL
pc_mouse.z = MID(minz, pc_mouse.z + dz, maxz);
#endif

if (emulat3) {
if ((pc_mouse.b & 3) == 3) {
pc_mouse.b = 4;
}
}

if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
} ENDOFUNC(mouse)


void
pc_remove_mouse (void)
{
if (mouse_callback) {
pc_clexit(pc_remove_mouse);
__asm("\n\
movl %%edx, %%ecx \n\
shrl $16, %%ecx \n\
movw $0x0304, %%ax \n\
int $0x31 \n\
movw $0x000c, %%ax \n\
xorl %%ecx, %%ecx \n\
int $0x33 \n\
"::"d"(mouse_callback):"%eax", "%ecx");

mouse_callback = 0;

free((void *)(mouse_wrap_end[0] - MOUSE_STACK_SIZE));
}
}


int
pc_install_mouse (void)
{
int buttons;

/* fail if already call-backed */
if (mouse_callback) {
return 0;
}

/* reset mouse and get status */
__asm("\n\
xorl %%eax, %%eax \n\
int $0x33 \n\
andl %%ebx, %%eax \n\
movl %%eax, %0 \n\
":"=g" (buttons)::"%eax", "%ebx");
if (!buttons) {
return 0;
}

/* lock wrapper */
LOCKDATA(mouse_func);
LOCKDATA(mouse_callback);
LOCKDATA(mouse_regs);
LOCKDATA(pc_mouse);
LOCKDATA(minx);
LOCKDATA(maxx);
LOCKDATA(miny);
LOCKDATA(maxy);
LOCKDATA(minz);
LOCKDATA(maxz);
LOCKDATA(sx);
LOCKDATA(sy);
LOCKDATA(emulat3);
LOCKDATA(ox);
LOCKDATA(oy);
LOCKFUNC(mouse);
LOCKFUNC(mouse_wrap);

mouse_wrap_end[1] = __djgpp_ds_alias;
/* grab a locked stack */
if ((mouse_wrap_end[0] = (int)pc_malloc(MOUSE_STACK_SIZE)) == NULL) {
return 0;
}

/* try to hook a call-back */
__asm("\n\
pushl %%ds \n\
pushl %%es \n\
movw $0x0303, %%ax \n\
pushl %%ds \n\
pushl %%cs \n\
popl %%ds \n\
popl %%es \n\
int $0x31 \n\
popl %%es \n\
popl %%ds \n\
jc 0f \n\
shll $16, %%ecx \n\
movw %%dx, %%cx \n\
movl %%ecx, %0 \n\
0: \n\
":"=g"(mouse_callback)
:"S" (mouse_wrap), "D"(&mouse_regs)
:"%eax", "%ecx", "%edx");
if (!mouse_callback) {
free((void *)mouse_wrap_end[0]);
return 0;
}

/* adjust stack */
mouse_wrap_end[0] += MOUSE_STACK_SIZE;

/* install the handler */
mouse_regs.x.ax = 0x000c;
#if PC_CUTE_WHEEL
mouse_regs.x.cx = 0x7f | 0x80;
#else
mouse_regs.x.cx = 0x7f;
#endif
mouse_regs.x.dx = mouse_callback & 0xffff;
mouse_regs.x.es = mouse_callback >> 16;
__dpmi_int(0x33, &mouse_regs);

CLEAR_MICKEYS();

emulat3 = (buttons < 3);
pc_atexit(pc_remove_mouse);
return buttons;
}


MFUNC
pc_install_mouse_handler (MFUNC handler)
{
MFUNC old;

if (!mouse_callback && !pc_install_mouse()) {
return NULL;
}

old = mouse_func;
mouse_func = handler;
return old;
}


void
pc_mouse_area (int x1, int y1, int x2, int y2)
{
minx = x1;
maxx = x2;
miny = y1;
maxy = y2;
}


void
pc_mouse_speed (int xspeed, int yspeed)
{
DISABLE();

sx = MAX(1, xspeed);
sy = MAX(1, yspeed);

ENABLE();
}


int
pc_query_mouse (int *x, int *y, int *z)
{
*x = pc_mouse.x;
*y = pc_mouse.y;
*z = pc_mouse.z;
return pc_mouse.b;
}


void
pc_warp_mouse (int x, int y)
{
CLEAR_MICKEYS();

pc_mouse.x = MID(minx, x, maxx);
pc_mouse.y = MID(miny, y, maxy);

if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
}


/* Hack alert:
* `mouse_wrap_end' actually holds the
* address of stack in a safe data selector.
*/
__asm("\n\
.text \n\
.p2align 5,,31 \n\
.global _mouse_wrap \n\
_mouse_wrap: \n\
cld \n\
lodsl \n\
movl %eax, %es:42(%edi) \n\
addw $4, %es:46(%edi) \n\
pushl %es \n\
movl %ss, %ebx \n\
movl %esp, %esi \n\
lss %cs:_mouse_wrap_end, %esp\n\
pushl %ss \n\
pushl %ss \n\
popl %es \n\
popl %ds \n\
movl ___djgpp_dos_sel, %fs \n\
pushl %fs \n\
popl %gs \n\
pushl %edi \n\
call _mouse \n\
popl %edi \n\
movl %ebx, %ss \n\
movl %esi, %esp \n\
popl %es \n\
iret \n\
.global _mouse_wrap_end \n\
_mouse_wrap_end:.long 0, 0");

+ 0
- 327
src/glut/dos/PC_HW/pc_timer.c Näytä tiedosto

@@ -1,327 +0,0 @@
/*
* PC/HW routine collection v1.5 for DOS/DJGPP
*
* Copyright (C) 2002 - Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/


#include <pc.h>
#include <string.h>

#include "pc_hw.h"

#define TIMER_IRQ 0

#define MAX_TIMERS 8

#define PIT_FREQ 0x1234DD

#define ADJUST(timer, basefreq) timer.counter = PIT_FREQ * timer.freq / SQR(basefreq)

#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})

static int timer_installed;

typedef struct {
volatile unsigned int counter, clock_ticks, freq;
volatile PFUNC func;
volatile void *parm;
} TIMER;

static TIMER timer_main, timer_func[MAX_TIMERS];


/* Desc: main timer callback
*
* In : -
* Out : 0 to bypass BIOS, 1 to chain to BIOS
*
* Note: -
*/
static int
timer ()
{
int i;

for (i = 0; i < MAX_TIMERS; i++) {
TIMER *t = &timer_func[i];
if (t->func) {
t->clock_ticks += t->counter;
if (t->clock_ticks >= timer_main.counter) {
t->clock_ticks -= timer_main.counter;
t->func(unvolatile(t->parm, void *));
}
}
}

timer_main.clock_ticks += timer_main.counter;
if (timer_main.clock_ticks >= 0x10000) {
timer_main.clock_ticks -= 0x10000;
return 1;
} else {
outportb(0x20, 0x20);
return 0;
}
} ENDOFUNC(timer)


/* Desc: uninstall timer engine
*
* In : -
* Out : -
*
* Note: -
*/
void
pc_remove_timer (void)
{
if (timer_installed) {
timer_installed = FALSE;
pc_clexit(pc_remove_timer);

DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
ENABLE();

pc_remove_irq(TIMER_IRQ);
}
}


/* Desc: remove timerfunc
*
* In : timerfunc id
* Out : 0 if success
*
* Note: tries to relax the main timer whenever possible
*/
int
pc_remove_int (int fid)
{
int i;
unsigned int freq = 0;

/* are we installed? */
if (!timer_installed) {
return -1;
}

/* sanity check */
if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) {
return -1;
}
timer_func[fid].func = NULL;

/* scan for maximum frequency */
for (i = 0; i < MAX_TIMERS; i++) {
TIMER *t = &timer_func[i];
if (t->func) {
if (freq < t->freq) {
freq = t->freq;
}
}
}

/* if there are no callbacks left, cleanup */
if (!freq) {
pc_remove_timer();
return 0;
}

/* if we just lowered the maximum frequency, try to relax the timer engine */
if (freq < timer_main.freq) {
unsigned int new_counter = PIT_FREQ / freq;

DISABLE();

for (i = 0; i < MAX_TIMERS; i++) {
if (timer_func[i].func) {
ADJUST(timer_func[i], freq);
}
}

outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;

ENABLE();
}
return 0;
} ENDOFUNC(pc_remove_int)


/* Desc: adjust timerfunc
*
* In : timerfunc id, new frequency (Hz)
* Out : 0 if success
*
* Note: might change the main timer frequency
*/
int
pc_adjust_int (int fid, unsigned int freq)
{
int i;

/* are we installed? */
if (!timer_installed) {
return -1;
}

/* sanity check */
if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) {
return -1;
}
timer_func[fid].freq = freq;

/* scan for maximum frequency */
freq = 0;
for (i = 0; i < MAX_TIMERS; i++) {
TIMER *t = &timer_func[i];
if (t->func) {
if (freq < t->freq) {
freq = t->freq;
}
}
}

/* update main timer / sons to match highest frequency */
DISABLE();

/* using '>' is correct still (and avoids updating
* the HW timer too often), but doesn't relax the timer!
*/
if (freq != timer_main.freq) {
unsigned int new_counter = PIT_FREQ / freq;

for (i = 0; i < MAX_TIMERS; i++) {
if (timer_func[i].func) {
ADJUST(timer_func[i], freq);
}
}

outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;
} else {
ADJUST(timer_func[fid], timer_main.freq);
}

ENABLE();

return 0;
} ENDOFUNC(pc_adjust_int)


/* Desc: install timer engine
*
* In : -
* Out : 0 for success
*
* Note: initial frequency is 18.2 Hz
*/
static int
install_timer (void)
{
if (timer_installed || pc_install_irq(TIMER_IRQ, timer)) {
return -1;
} else {
memset(timer_func, 0, sizeof(timer_func));

LOCKDATA(timer_func);
LOCKDATA(timer_main);
LOCKFUNC(timer);
LOCKFUNC(pc_adjust_int);
LOCKFUNC(pc_remove_int);

timer_main.counter = 0x10000;

DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
timer_main.clock_ticks = 0;
ENABLE();

pc_atexit(pc_remove_timer);
timer_installed = TRUE;
return 0;
}
}


/* Desc: install timerfunc
*
* In : callback function, opaque pointer to be passed to callee, freq (Hz)
* Out : timerfunc id (0 .. MAX_TIMERS-1)
*
* Note: returns -1 if error
*/
int
pc_install_int (PFUNC func, void *parm, unsigned int freq)
{
int i;
TIMER *t = NULL;

/* ensure the timer engine is set up */
if (!timer_installed) {
if (install_timer()) {
return -1;
}
}

/* find an empty slot */
for (i = 0; i < MAX_TIMERS; i++) {
if (!timer_func[i].func) {
t = &timer_func[i];
break;
}
}
if (t == NULL) {
return -1;
}

DISABLE();

t->func = func;
t->parm = parm;
t->freq = freq;
t->clock_ticks = 0;

/* update main timer / sons to match highest frequency */
if (freq > timer_main.freq) {
unsigned int new_counter = PIT_FREQ / freq;

for (i = 0; i < MAX_TIMERS; i++) {
if (timer_func[i].func) {
ADJUST(timer_func[i], freq);
}
}

outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;
} else {
/* t == &timer_func[i] */
ADJUST(timer_func[i], timer_main.freq);
}

i = t - timer_func;

ENABLE();

return i;
}

+ 0
- 115
src/glut/dos/bitmap.c Näytä tiedosto

@@ -1,115 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "internal.h"


void APIENTRY
glutBitmapCharacter (void *font, int c)
{
const GLUTBitmapFont *bfp = _glut_font(font);
const GLUTBitmapChar *bcp;

if (c >= bfp->num || !(bcp = bfp->table[c]))
return;

glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBitmap(bcp->width, bcp->height, bcp->xorig, bcp->yorig,
bcp->xmove, 0, bcp->bitmap);

glPopClientAttrib();
}


void APIENTRY
glutBitmapString (void *font, const unsigned char *string)
{
const GLUTBitmapFont *bfp = _glut_font(font);
const GLUTBitmapChar *bcp;
unsigned char c;

glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

while ((c = *(string++))) {
if (c < bfp->num && (bcp = bfp->table[c]))
glBitmap(bcp->width, bcp->height, bcp->xorig,
bcp->yorig, bcp->xmove, 0, bcp->bitmap);
}

glPopClientAttrib();
}


int APIENTRY
glutBitmapWidth (void *font, int c)
{
const GLUTBitmapFont *bfp = _glut_font(font);
const GLUTBitmapChar *bcp;

if (c >= bfp->num || !(bcp = bfp->table[c]))
return 0;

return bcp->xmove;
}


int APIENTRY
glutBitmapLength (void *font, const unsigned char *string)
{
const GLUTBitmapFont *bfp = _glut_font(font);
const GLUTBitmapChar *bcp;
unsigned char c;
int length = 0;

while ((c = *(string++))) {
if (c < bfp->num && (bcp = bfp->table[c]))
length += bcp->xmove;
}

return length;
}


int APIENTRY
glutBitmapHeight (void *font)
{
const GLUTBitmapFont *bfp = _glut_font(font);

return bfp->height;
}

+ 0
- 204
src/glut/dos/callback.c Näytä tiedosto

@@ -1,204 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "internal.h"


GLUTSShotCB _glut_timer_cb[MAX_TIMER_CB];

GLUTidleCB _glut_idle_func = NULL;


void APIENTRY
glutDisplayFunc (GLUTdisplayCB func)
{
_glut_current->display = func;
}


void APIENTRY
glutReshapeFunc (GLUTreshapeCB func)
{
_glut_current->reshape = func;
}


void APIENTRY
glutKeyboardFunc (GLUTkeyboardCB func)
{
_glut_current->keyboard = func;
}


void APIENTRY
glutMouseFunc (GLUTmouseCB func)
{
_glut_current->mouse = func;
}


void APIENTRY
glutMotionFunc (GLUTmotionCB func)
{
_glut_current->motion = func;
}


void APIENTRY
glutPassiveMotionFunc (GLUTpassiveCB func)
{
_glut_current->passive = func;
}


void APIENTRY
glutEntryFunc (GLUTentryCB func)
{
_glut_current->entry = func;
}


void APIENTRY
glutVisibilityFunc (GLUTvisibilityCB func)
{
_glut_current->visibility = func;
}


void APIENTRY
glutWindowStatusFunc (GLUTwindowStatusCB func)
{
_glut_current->windowStatus = func;
}


void APIENTRY
glutIdleFunc (GLUTidleCB func)
{
_glut_idle_func = func;
}


void APIENTRY
glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)
{
int i;

if (millis > 0) {
for (i = 0; i < MAX_TIMER_CB; i++) {
GLUTSShotCB *cb = &_glut_timer_cb[i];
if (cb->func == NULL) {
cb->value = value;
cb->func = func;
cb->time = glutGet(GLUT_ELAPSED_TIME) + millis;
break;
}
}
}
}


void APIENTRY
glutSpecialFunc (GLUTspecialCB func)
{
_glut_current->special = func;
}


void APIENTRY
glutSpaceballMotionFunc (GLUTspaceMotionCB func)
{
_glut_current->spaceMotion = func;
}


void APIENTRY
glutSpaceballRotateFunc (GLUTspaceRotateCB func)
{
_glut_current->spaceRotate = func;
}


void APIENTRY
glutSpaceballButtonFunc (GLUTspaceButtonCB func)
{
_glut_current->spaceButton = func;
}


void APIENTRY
glutDialsFunc (GLUTdialsCB func)
{
_glut_current->dials = func;
}


void APIENTRY
glutButtonBoxFunc (GLUTbuttonBoxCB func)
{
_glut_current->buttonBox = func;
}


void APIENTRY
glutTabletMotionFunc (GLUTtabletMotionCB func)
{
_glut_current->tabletMotion = func;
}


void APIENTRY
glutTabletButtonFunc (GLUTtabletButtonCB func)
{
_glut_current->tabletButton = func;
}


void APIENTRY
glutJoystickFunc (GLUTjoystickCB func, int interval)
{
_glut_current->joystick = func;
}


void APIENTRY
glutKeyboardUpFunc (GLUTkeyboardCB func)
{
_glut_current->keyboardUp = func;
}


void APIENTRY
glutSpecialUpFunc (GLUTspecialCB func)
{
_glut_current->specialUp = func;
}


void APIENTRY
glutMouseWheelFunc (GLUTmouseWheelCB func)
{
_glut_current->mouseWheel = func;
}

+ 0
- 53
src/glut/dos/color.c Näytä tiedosto

@@ -1,53 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "internal.h"


#define CLAMP(i) ((i) > 1.0F ? 1.0F : ((i) < 0.0F ? 0.0F : (i)))


void APIENTRY
glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
if (_glut_default.mode & GLUT_INDEX) {
if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) {
DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));
}
}
}


GLfloat APIENTRY
glutGetColor (int ndx, int component)
{
return 0.0;
}


void APIENTRY
glutCopyColormap (int win)
{
}

+ 0
- 70
src/glut/dos/extens.c Näytä tiedosto

@@ -1,70 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include <string.h>

#include "internal.h"


int APIENTRY
glutExtensionSupported (const char *extension)
{
static const GLubyte *extensions = NULL;
const GLubyte *last, *where;

/* Extension names should not have spaces. */
if (strchr(extension, ' ') || *extension == '\0') {
return GL_FALSE;
}

/* Not my problem if you don't have a valid OpenGL context */
if (!extensions) {
extensions = glGetString(GL_EXTENSIONS);
}
if (!extensions) {
return GL_FALSE;
}

/* Take care of sub-strings etc. */
for (last = extensions;;) {
if ((where = (GLubyte *)strstr((const char *)last, extension)) == NULL) {
return GL_FALSE;
}
last = where + strlen(extension);
if (where == extensions || *(where - 1) == ' ') {
if (*last == ' ' || *last == '\0') {
return GL_TRUE;
}
}
}
}


GLUTproc APIENTRY
glutGetProcAddress (const char *procName)
{
/* TODO - handle glut namespace */
return (GLUTproc)DMesaGetProcAddress(procName);
}

+ 0
- 1183
src/glut/dos/f8x13.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1407
src/glut/dos/f9x15.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1019
src/glut/dos/hel10.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1029
src/glut/dos/hel12.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1138
src/glut/dos/hel18.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 223
src/glut/dos/init.c Näytä tiedosto

@@ -1,223 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "internal.h"


char *__glutProgramName = NULL;

GLUTvisual _glut_visual = {
16, 8, 16, 8, 16, /* bpp, alpha, depth, stencil, accum */

{ 0, 0 }, 0, /* geometry */

0 /* flags */
};

GLUTdefault _glut_default = {
0, 0, /* glutInitWindowPosition */
300, 300, /* glutInitWindowSize */
0 /* glutInitDisplayMode */
};

GLuint _glut_fps = 0;

static char *init_string;


void
_glut_fatal (char *format,...)
{
va_list args;

va_start(args, format);
fprintf(stderr, "GLUT: Fatal Error in %s: ",
__glutProgramName ? __glutProgramName : "(unamed)");
vfprintf(stderr, format, args);
va_end(args);
putc('\n', stderr);
exit(1);
}


/* strdup is actually not a standard ANSI C or POSIX routine
* so implement a private one for GLUT.
*/
static char *
_glut_strdup (const char *string)
{
if (string != NULL) {
int len = strlen(string) + 1;
char *p = malloc(len);
if (p != NULL) {
return strcpy(p, string);
}
}
return NULL;
}


void APIENTRY
glutInit (int *argc, char **argv)
{
char *str;
const char *env;

if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
_glut_visual.bpp = atoi(env);
}
if ((env = getenv("DMESA_GLUT_ALPHA")) != NULL) {
_glut_visual.alpha = atoi(env);
}
if ((env = getenv("DMESA_GLUT_DEPTH")) != NULL) {
_glut_visual.depth = atoi(env);
}
if ((env = getenv("DMESA_GLUT_STENCIL")) != NULL) {
_glut_visual.stencil = atoi(env);
}
if ((env = getenv("DMESA_GLUT_ACCUM")) != NULL) {
_glut_visual.accum = atoi(env);
}
if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
_glut_visual.refresh = atoi(env);
}

/* Determine program name. */
str = strrchr(argv[0], '/');
if (str == NULL) {
str = argv[0];
} else {
str++;
}
__glutProgramName = _glut_strdup(str);

/* check if GLUT_FPS env var is set */
if ((env = getenv("GLUT_FPS")) != NULL) {
if ((_glut_fps = atoi(env)) <= 0) {
_glut_fps = 5000; /* 5000 milliseconds */
}
}

/* Initialize timer */
glutGet(GLUT_ELAPSED_TIME);
}


void APIENTRY
glutInitDisplayMode (unsigned int mode)
{
_glut_default.mode = mode;
}


void APIENTRY
glutInitWindowPosition (int x, int y)
{
_glut_default.x = x;
_glut_default.y = y;
}


void APIENTRY
glutInitWindowSize (int width, int height)
{
_glut_default.width = width;
_glut_default.height = height;
}


void APIENTRY
glutInitDisplayString (const char *string)
{
init_string = _glut_strdup(string);
}


void APIENTRY
glutSetOption (GLenum pname, int value)
{
switch (pname) {
case GLUT_INIT_WINDOW_X:
_glut_default.x = value;
break;
case GLUT_INIT_WINDOW_Y:
_glut_default.y = value;
break;
}
}


void APIENTRY
glutForceJoystickFunc (void)
{
}


void APIENTRY
glutIgnoreKeyRepeat (int ignore)
{
}


void APIENTRY
glutSetKeyRepeat (int repeatMode)
{
}


void APIENTRY
glutVideoPan (int x, int y, int w, int h)
{
}


int APIENTRY
glutVideoResizeGet( GLenum eWhat )
{
return 0;
}


void APIENTRY
glutSetupVideoResizing (void)
{
}


void APIENTRY
glutStopVideoResizing (void)
{
}


void APIENTRY
glutVideoResize (int x, int y, int w, int h)
{
}

+ 0
- 197
src/glut/dos/internal.h Näytä tiedosto

@@ -1,197 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef INTERNAL_H_included
#define INTERNAL_H_included

#include <GL/glut.h>

#include "GL/dmesa.h"


#define MAX_WINDOWS 2
#define MAX_TIMER_CB 8
#define RESERVED_COLORS 0


/* GLUT function types */
typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
typedef void (GLUTCALLBACK *GLUTentryCB) (int);
typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
typedef void (GLUTCALLBACK *GLUTidleCB) (void);
typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int); /* DEPRECATED. */
typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTselectCB) (int);
typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);

typedef void (GLUTCALLBACK *GLUTdestroyCB) (void);
typedef void (GLUTCALLBACK *GLUTmouseWheelCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTmenuDestroyCB) (void);


typedef struct {
GLuint bpp, alpha;
GLuint depth, stencil;
GLuint accum;

GLint geometry[2];
GLuint refresh;

GLint flags;
} GLUTvisual;

typedef struct {
GLint x, y;
GLint width, height;
GLuint mode;
} GLUTdefault;

typedef struct {
void (*func) (int);
int value;
int time;
} GLUTSShotCB;

typedef struct GLUTwindow {
int num; /* window id */

DMesaContext context;
DMesaBuffer buffer;

int show_mouse;
GLboolean redisplay;

/* GLUT settable or visible window state. */
int xpos;
int ypos;
int width; /* window width in pixels */
int height; /* window height in pixels */

/* Per-window callbacks. */
GLUTdisplayCB display; /* redraw */
GLUTreshapeCB reshape; /* resize (width,height) */
GLUTmouseCB mouse; /* mouse (button,state,x,y) */
GLUTmotionCB motion; /* motion (x,y) */
GLUTpassiveCB passive; /* passive motion (x,y) */
GLUTentryCB entry; /* window entry/exit (state) */
GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */
GLUTkeyboardCB keyboardUp; /* keyboard up (ASCII,x,y) */
GLUTwindowStatusCB windowStatus; /* window status */
GLUTvisibilityCB visibility; /* visibility */
GLUTspecialCB special; /* special key */
GLUTspecialCB specialUp; /* special up key */
GLUTbuttonBoxCB buttonBox; /* button box */
GLUTdialsCB dials; /* dials */
GLUTspaceMotionCB spaceMotion; /* Spaceball motion */
GLUTspaceRotateCB spaceRotate; /* Spaceball rotate */
GLUTspaceButtonCB spaceButton; /* Spaceball button */
GLUTtabletMotionCB tabletMotion; /* tablet motion */
GLUTtabletButtonCB tabletButton; /* tablet button */
GLUTjoystickCB joystick; /* joystick */

GLUTdestroyCB destroy; /* destroy */
GLUTmouseWheelCB mouseWheel; /* mouse wheel */

/* specific data */
void *data;
} GLUTwindow;

typedef struct {
int width, height;
int xorig, yorig;
int xmove;
const unsigned char *bitmap;
} GLUTBitmapChar;

typedef struct {
const char *name;
int height;
int num;
const GLUTBitmapChar *const *table;
} GLUTBitmapFont;

typedef struct {
const GLfloat x, y;
} GLUTStrokeVertex;

typedef struct {
const unsigned num;
const GLUTStrokeVertex *vertex;
} GLUTStrokeStrip;

typedef struct {
const GLfloat right;
const unsigned num;
const GLUTStrokeStrip *strip;
} GLUTStrokeChar;

typedef struct {
const char *name;
const unsigned num;
const GLUTStrokeChar *const *table;
const GLfloat height;
const GLfloat descent;
} GLUTStrokeFont;


extern char *__glutProgramName;

extern GLUTvisual _glut_visual;
extern GLUTdefault _glut_default;

extern GLuint _glut_fps;
extern GLUTidleCB _glut_idle_func;
extern GLUTmenuStatusCB _glut_menu_status_func;
extern GLUTSShotCB _glut_timer_cb[];

extern GLUTwindow *_glut_current, *_glut_windows[];

extern int _glut_mouse; /* number of buttons, if mouse installed */
extern int _glut_mouse_x, _glut_mouse_y; /* mouse coords, relative to current win */


extern void _glut_mouse_init (void);
extern void _glut_fatal(char *format,...);
extern void *_glut_font (void *font);


#include "pc_hw/pc_hw.h"

#endif

+ 0
- 245
src/glut/dos/loop.c Näytä tiedosto

@@ -1,245 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include <string.h>

#include <GL/glut.h>
#include "GL/dmesa.h"

#include "PC_HW/pc_hw.h"
#include "internal.h"


static int looping = 0;


#define DO_REDISPLAY(w, ccin, ccout) \
do { \
if (w->redisplay && w->display) { \
int rv = GL_TRUE; \
\
idle = GL_FALSE; \
w->redisplay = GL_FALSE; \
\
/* test IN condition (whether we need to `MakeCurrent') */\
if (ccin) { \
rv = DMesaMakeCurrent(w->context, w->buffer); \
} \
\
/* do the display only if `MakeCurrent' didn't failed */ \
if (rv) { \
if (w->show_mouse && !(_glut_default.mode & GLUT_DOUBLE)) {\
/* XXX scare mouse */ \
w->display(); \
/* XXX unscare mouse */ \
} else { \
w->display(); \
} \
\
/* update OUT condition */ \
ccout; \
} \
} \
} while (0)


void APIENTRY
glutMainLoopEvent (void)
{
int i, n;
GLUTwindow *w;
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
static int old_mouse_b = 0;

static GLboolean virgin = GL_TRUE;
if (virgin) {
pc_install_keyb();
_glut_mouse_init();

for (i = 0; i < MAX_WINDOWS; i++) {
w = _glut_windows[i];
if (w != NULL) {
glutSetWindow(w->num);
glutPostRedisplay();
if (w->reshape) {
w->reshape(w->width, w->height);
}
if (w->visibility) {
w->visibility(GLUT_VISIBLE);
}
}
}
virgin = GL_FALSE;
}

idle = GL_TRUE;

n = 0;
for (i = 0; i < MAX_WINDOWS; i++) {
w = _glut_windows[i];
if ((w != NULL) && (w != _glut_current)) {
/* 1) redisplay `w'
* 2) `MakeCurrent' always
* 3) update number of non-default windows
*/
DO_REDISPLAY(w, GL_TRUE, n++);
}
}
/* 1) redisplay `_glut_current'
* 2) `MakeCurrent' only if we previously did non-default windows
* 3) don't update anything
*/
DO_REDISPLAY(_glut_current, n, n);

if (_glut_mouse) {
int mouse_x;
int mouse_y;
int mouse_z;
int mouse_b;

/* query mouse */
mouse_b = pc_query_mouse(&mouse_x, &mouse_y, &mouse_z);

/* relative to window coordinates */
_glut_mouse_x = mouse_x - _glut_current->xpos;
_glut_mouse_y = mouse_y - _glut_current->ypos;

/* mouse was moved? */
if ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y)) {
idle = GL_FALSE;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;

if (mouse_b) {
/* any button pressed */
if (_glut_current->motion) {
_glut_current->motion(_glut_mouse_x, _glut_mouse_y);
}
} else {
/* no button pressed */
if (_glut_current->passive) {
_glut_current->passive(_glut_mouse_x, _glut_mouse_y);
}
}
}

/* button state changed? */
if (mouse_b != old_mouse_b) {
GLUTmouseCB mouse_func;

if ((mouse_func = _glut_current->mouse)) {
if ((old_mouse_b & 1) && !(mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, _glut_mouse_x, _glut_mouse_y);
else if (!(old_mouse_b & 1) && (mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, _glut_mouse_x, _glut_mouse_y);

if ((old_mouse_b & 2) && !(mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, _glut_mouse_x, _glut_mouse_y);
else if (!(old_mouse_b & 2) && (mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, _glut_mouse_x, _glut_mouse_y);

if ((old_mouse_b & 4) && !(mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, _glut_mouse_x, _glut_mouse_y);
else if (!(old_mouse_b & 3) && (mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, _glut_mouse_x, _glut_mouse_y);
}

idle = GL_FALSE;
old_mouse_b = mouse_b;
}
}

if (pc_keypressed()) {
int key;
int glut_key;

idle = GL_FALSE;
key = pc_readkey();

switch (key>>16) {
case KEY_F1: glut_key = GLUT_KEY_F1; goto special;
case KEY_F2: glut_key = GLUT_KEY_F2; goto special;
case KEY_F3: glut_key = GLUT_KEY_F3; goto special;
case KEY_F4: glut_key = GLUT_KEY_F4; goto special;
case KEY_F5: glut_key = GLUT_KEY_F5; goto special;
case KEY_F6: glut_key = GLUT_KEY_F6; goto special;
case KEY_F7: glut_key = GLUT_KEY_F7; goto special;
case KEY_F8: glut_key = GLUT_KEY_F8; goto special;
case KEY_F9: glut_key = GLUT_KEY_F9; goto special;
case KEY_F10: glut_key = GLUT_KEY_F10; goto special;
case KEY_F11: glut_key = GLUT_KEY_F11; goto special;
case KEY_F12: glut_key = GLUT_KEY_F12; goto special;
case KEY_LEFT: glut_key = GLUT_KEY_LEFT; goto special;
case KEY_UP: glut_key = GLUT_KEY_UP; goto special;
case KEY_RIGHT: glut_key = GLUT_KEY_RIGHT; goto special;
case KEY_DOWN: glut_key = GLUT_KEY_DOWN; goto special;
case KEY_PGUP: glut_key = GLUT_KEY_PAGE_UP; goto special;
case KEY_PGDN: glut_key = GLUT_KEY_PAGE_DOWN; goto special;
case KEY_HOME: glut_key = GLUT_KEY_HOME; goto special;
case KEY_END: glut_key = GLUT_KEY_END; goto special;
case KEY_INSERT: glut_key = GLUT_KEY_INSERT; goto special;
special:
if (_glut_current->special) {
_glut_current->special(glut_key, _glut_mouse_x, _glut_mouse_y);
}
break;
default:
if (_glut_current->keyboard) {
_glut_current->keyboard(key & 0xFF, _glut_mouse_x, _glut_mouse_y);
}
}
}

if (idle && _glut_idle_func)
_glut_idle_func();

for (i = 0; i < MAX_TIMER_CB; i++) {
int time = glutGet(GLUT_ELAPSED_TIME);
GLUTSShotCB *cb = &_glut_timer_cb[i];
if (cb->func && (time >= cb->time)) {
cb->func(cb->value);
cb->func = NULL;
}
}
}


void APIENTRY
glutMainLoop (void)
{
looping++;
while (looping) {
glutMainLoopEvent();
}
}


void APIENTRY
glutLeaveMainLoop (void)
{
looping--;
}

+ 0
- 130
src/glut/dos/menu.c Näytä tiedosto

@@ -1,130 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include "internal.h"


GLUTmenuStatusCB _glut_menu_status_func = NULL;


void APIENTRY
glutMenuStateFunc (GLUTmenuStateCB func)
{
_glut_menu_status_func = (GLUTmenuStatusCB)func;
}


void APIENTRY
glutMenuStatusFunc (GLUTmenuStatusCB func)
{
_glut_menu_status_func = func;
}


int APIENTRY
glutCreateMenu (GLUTselectCB func)
{
return 0;
}


void APIENTRY
glutDestroyMenu (int menu)
{
}


int APIENTRY
glutGetMenu (void)
{
return 0;
}


void APIENTRY
glutSetMenu (int menu)
{
}


void APIENTRY
glutAddMenuEntry (const char *label, int value)
{
}


void APIENTRY
glutAddSubMenu (const char *label, int submenu)
{
}


void APIENTRY
glutChangeToMenuEntry (int item, const char *label, int value)
{
}


void APIENTRY
glutChangeToSubMenu (int item, const char *label, int submenu)
{
}


void APIENTRY
glutRemoveMenuItem (int item)
{
}


void APIENTRY
glutAttachMenu (int button)
{
}


void APIENTRY
glutDetachMenu (int button)
{
}


void APIENTRY
glutMenuDestroyFunc ( void (* callback)( void ) )
{
}


void * APIENTRY
glutGetMenuData (void)
{
return NULL;
}


void APIENTRY
glutSetMenuData (void *data)
{
}

+ 0
- 55
src/glut/dos/mouse.c Näytä tiedosto

@@ -1,55 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include "internal.h"


int _glut_mouse;
int _glut_mouse_x = 0, _glut_mouse_y = 0;


void
_glut_mouse_init (void)
{
if ((_glut_mouse = pc_install_mouse())) {
pc_mouse_area(_glut_current->xpos, _glut_current->ypos, _glut_current->xpos + _glut_current->width - 1, _glut_current->ypos + _glut_current->height - 1);

_glut_current->show_mouse = (_glut_current->mouse || _glut_current->motion || _glut_current->passive);
}
}


void APIENTRY
glutSetCursor (int cursor)
{
/* XXX completely futile until full mouse support (maybe never) */
}


void APIENTRY
glutWarpPointer (int x, int y)
{
pc_warp_mouse(x, y);
}

+ 0
- 2779
src/glut/dos/mroman.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 93
src/glut/dos/overlay.c Näytä tiedosto

@@ -1,93 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include "internal.h"


int APIENTRY
glutLayerGet (GLenum info)
{
switch (info) {
case GLUT_OVERLAY_POSSIBLE:
case GLUT_HAS_OVERLAY:
return GL_FALSE;
case GLUT_LAYER_IN_USE:
return GLUT_NORMAL;
case GLUT_NORMAL_DAMAGED:
return GL_FALSE;
case GLUT_OVERLAY_DAMAGED:
case GLUT_TRANSPARENT_INDEX:
default:
return -1;
}
}


void APIENTRY
glutOverlayDisplayFunc (GLUTdisplayCB func)
{
}


void APIENTRY
glutEstablishOverlay (void)
{
}


void APIENTRY
glutRemoveOverlay (void)
{
}


void APIENTRY
glutUseLayer (GLenum layer)
{
}


void APIENTRY
glutPostOverlayRedisplay (void)
{
}


void APIENTRY
glutShowOverlay (void)
{
}


void APIENTRY
glutHideOverlay (void)
{
}


void APIENTRY
glutPostWindowOverlayRedisplay (int win)
{
}

+ 0
- 2779
src/glut/dos/roman.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1143
src/glut/dos/shapes.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 238
src/glut/dos/state.c Näytä tiedosto

@@ -1,238 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include <stdio.h>

#include "internal.h"


#define FREQUENCY 100 /* set this to zero to use the default timer */


static int timer_installed;
#if FREQUENCY
static volatile int ticks;


static void
ticks_timer (void *p)
{
(void)p;
ticks++;
} ENDOFUNC(ticks_timer)
#else
#include <time.h>

static struct timeval then;
#endif


int APIENTRY
glutGet (GLenum type)
{
switch (type) {
case GLUT_WINDOW_X:
return _glut_current->xpos;
case GLUT_WINDOW_Y:
return _glut_current->ypos;
case GLUT_WINDOW_WIDTH:
return _glut_current->width;
case GLUT_WINDOW_HEIGHT:
return _glut_current->height;
case GLUT_WINDOW_STENCIL_SIZE:
return _glut_visual.stencil;
case GLUT_WINDOW_DEPTH_SIZE:
return _glut_visual.depth;
case GLUT_WINDOW_RGBA:
return !(_glut_default.mode & GLUT_INDEX);
case GLUT_WINDOW_COLORMAP_SIZE:
return (_glut_default.mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0;
case GLUT_SCREEN_WIDTH:
return _glut_visual.geometry[0];
case GLUT_SCREEN_HEIGHT:
return _glut_visual.geometry[1];
case GLUT_INIT_WINDOW_X:
return _glut_default.x;
case GLUT_INIT_WINDOW_Y:
return _glut_default.y;
case GLUT_INIT_WINDOW_WIDTH:
return _glut_default.width;
case GLUT_INIT_WINDOW_HEIGHT:
return _glut_default.height;
case GLUT_INIT_DISPLAY_MODE:
return _glut_default.mode;
case GLUT_ELAPSED_TIME:
#if FREQUENCY
if (!timer_installed) {
timer_installed = GL_TRUE;
LOCKDATA(ticks);
LOCKFUNC(ticks_timer);
pc_install_int(ticks_timer, NULL, FREQUENCY);
}
return ticks * 1000 / FREQUENCY;
#else
if (!timer_installed) {
timer_installed = GL_TRUE;
gettimeofday(&then, NULL);
return 0;
} else {
struct timeval now;
gettimeofday(&now, NULL);
return (now.tv_usec - then.tv_usec) / 1000 +
(now.tv_sec - then.tv_sec) * 1000;
}
#endif
default:
return -1;
}
}


int APIENTRY
glutDeviceGet (GLenum type)
{
switch (type) {
case GLUT_HAS_KEYBOARD:
return GL_TRUE;
case GLUT_HAS_MOUSE:
return (_glut_mouse != 0);
case GLUT_NUM_MOUSE_BUTTONS:
return _glut_mouse;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return GL_FALSE;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;
default:
return -1;
}
}


int APIENTRY
glutGetModifiers (void)
{
int mod = 0;
int shifts = pc_keyshifts();

if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {
mod |= GLUT_ACTIVE_SHIFT;
}

if (shifts & KB_ALT_FLAG) {
mod |= GLUT_ACTIVE_ALT;
}

if (shifts & KB_CTRL_FLAG) {
mod |= GLUT_ACTIVE_CTRL;
}

return mod;
}


void APIENTRY
glutReportErrors (void)
{
/* reports all the OpenGL errors that happened till now */
}


/* GAME MODE
* Hack alert: incomplete... what is GameMode, anyway?
*/
static GLint game;
static GLboolean game_possible;
static GLboolean game_active;
static GLuint game_width;
static GLuint game_height;
static GLuint game_bpp;
static GLuint game_refresh;


void APIENTRY
glutGameModeString (const char *string)
{
if (sscanf(string, "%ux%u:%u@%u", &game_width, &game_height, &game_bpp, &game_refresh) == 4) {
game_possible = GL_TRUE;
}
}


int APIENTRY
glutGameModeGet (GLenum mode)
{
switch (mode) {
case GLUT_GAME_MODE_ACTIVE:
return game_active;
case GLUT_GAME_MODE_POSSIBLE:
return game_possible && !_glut_current;
case GLUT_GAME_MODE_WIDTH:
return game_active ? (int)game_width : -1;
case GLUT_GAME_MODE_HEIGHT:
return game_active ? (int)game_height : -1;
case GLUT_GAME_MODE_PIXEL_DEPTH:
return game_active ? (int)game_bpp : -1;
case GLUT_GAME_MODE_REFRESH_RATE:
return game_active ? (int)game_refresh : -1;
default:
return -1;
}
}


int APIENTRY
glutEnterGameMode (void)
{
if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) {
_glut_visual.bpp = game_bpp;
_glut_visual.refresh = game_refresh;

glutInitWindowSize(game_width, game_height);

if ((game = glutCreateWindow("<game>")) > 0) {
game_active = GL_TRUE;
}

return game;
} else {
return 0;
}
}


void GLUTAPIENTRY
glutLeaveGameMode (void)
{
if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE)) {
game_active = GL_FALSE;

glutDestroyWindow(game);
}
}

+ 0
- 118
src/glut/dos/stroke.c Näytä tiedosto

@@ -1,118 +0,0 @@
/*
* FxGLUT version 0.12 - GLUT for Voodoo 1 and 2 under Linux
* Copyright (C) 1999 Christopher John Purnell
* cjp@lost.org.uk
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "internal.h"


void
glutStrokeCharacter (void *font, int c)
{
const GLUTStrokeFont *sfp = _glut_font(font);
const GLUTStrokeChar *scp;
const GLUTStrokeStrip *ssp;
const GLUTStrokeVertex *svp;
unsigned i, j;

if (((unsigned)c) >= sfp->num || !(scp = sfp->table[c]))
return;

ssp = scp->strip;

for (i = 0; i < scp->num; i++, ssp++) {
svp = ssp->vertex;

glBegin(GL_LINE_STRIP);
for (j = 0; j < ssp->num; j++, svp++) {
glVertex2f(svp->x, svp->y);
}
glEnd();
}

glTranslatef(scp->right, 0.0, 0.0);
}


void
glutStrokeString (void *font, const unsigned char *string)
{
const GLUTStrokeFont *sfp = _glut_font(font);
const GLUTStrokeChar *scp;
const GLUTStrokeStrip *ssp;
const GLUTStrokeVertex *svp;
unsigned char c;
unsigned i, j;

while ((c = *(string++))) {
if (c < sfp->num && (scp = sfp->table[c])) {
ssp = scp->strip;

for (i = 0; i < scp->num; i++, ssp++) {
svp = ssp->vertex;

glBegin(GL_LINE_STRIP);
for (j = 0; j < ssp->num; j++, svp++) {
glVertex2f(svp->x, svp->y);
}
glEnd();
}

glTranslatef(scp->right, 0.0, 0.0);
}
}
}


int
glutStrokeWidth (void *font, int c)
{
const GLUTStrokeFont *sfp = _glut_font(font);
const GLUTStrokeChar *scp;

if (((unsigned)c) >= sfp->num || !(scp = sfp->table[c]))
return 0;

return scp->right;
}


int
glutStrokeLength (void *font, const unsigned char *string)
{
const GLUTStrokeFont *sfp = _glut_font(font);
const GLUTStrokeChar *scp;
unsigned char c;
int length = 0;

while ((c = *(string++))) {
if (c < sfp->num && (scp = sfp->table[c]))
length += scp->right;
}

return length;
}


GLfloat
glutStrokeHeight (void *font)
{
const GLUTStrokeFont *sfp = _glut_font(font);

return sfp->height;
}

+ 0
- 201
src/glut/dos/teapot.c Näytä tiedosto

@@ -1,201 +0,0 @@
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
*
* ALL RIGHTS RESERVED
*
* Permission to use, copy, modify, and distribute this software
* for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that
* both the copyright notice and this permission notice appear in
* supporting documentation, and that the name of Silicon
* Graphics, Inc. not be used in advertising or publicity
* pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
* "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
* OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
* EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
* ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
* INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
* SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
* NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer
* Software clause at DFARS 252.227-7013 and/or in similar or
* successor clauses in the FAR or the DOD or NASA FAR
* Supplement. Unpublished-- rights reserved under the copyright
* laws of the United States. Contractor/manufacturer is Silicon
* Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
* 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/

#include "internal.h"

/*
* Rim, body, lid, and bottom data must be reflected in x and y;
* handle and spout data across the y axis only.
*/
static int patchdata[][16] =
{
{ 102, 103, 104, 105, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15 }, /* rim */
{ 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27 }, /* body */
{ 24, 25, 26, 27, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40 },
{ 96, 96, 96, 96, 97, 98, 99, 100,
101, 101, 101, 101, 0, 1, 2, 3 }, /* lid */
{ 0, 1, 2, 3, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117 },
{ 118, 118, 118, 118, 124, 122, 119, 121,
123, 126, 125, 120, 40, 39, 38, 37 }, /* bottom */
{ 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56 }, /* handle */
{ 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 28, 65, 66, 67 },
{ 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83 }, /* spout */
{ 80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95 }
};

static float cpdata[][3] =
{
{0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7},
{0,-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
{0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125},
{1.4375, 0, 2.53125}, {1.4375, -0.805, 2.53125},
{0.805, -1.4375, 2.53125}, {0, -1.4375, 2.53125},
{1.5, 0, 2.4}, {1.5, -0.84, 2.4}, {0.84, -1.5, 2.4},
{0, -1.5, 2.4}, {1.75, 0, 1.875}, {1.75, -0.98, 1.875},
{0.98, -1.75, 1.875}, {0, -1.75, 1.875}, {2, 0, 1.35},
{2, -1.12, 1.35}, {1.12, -2, 1.35}, {0, -2, 1.35}, {2, 0, 0.9},
{2, -1.12, 0.9}, {1.12, -2, 0.9}, {0, -2, 0.9}, {-2, 0, 0.9},
{2, 0, 0.45}, {2, -1.12, 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45},
{1.5, 0, 0.225}, {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225},
{0, -1.5, 0.225}, {1.5, 0, 0.15}, {1.5, -0.84, 0.15},
{0.84, -1.5, 0.15}, {0, -1.5, 0.15}, {-1.6, 0, 2.025},
{-1.6, -0.3, 2.025}, {-1.5, -0.3, 2.25}, {-1.5, 0, 2.25},
{-2.3, 0, 2.025}, {-2.3, -0.3, 2.025}, {-2.5, -0.3, 2.25},
{-2.5, 0, 2.25}, {-2.7, 0, 2.025}, {-2.7, -0.3, 2.025},
{-3, -0.3, 2.25}, {-3, 0, 2.25}, {-2.7, 0, 1.8},
{-2.7, -0.3, 1.8}, {-3, -0.3, 1.8}, {-3, 0, 1.8},
{-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3, -0.3, 1.35},
{-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3, 1.125},
{-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2, -0.3, 0.9},
{-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0, 1.425},
{1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0, 0.6},
{2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66, 0.825},
{3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
{2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4},
{2.7, -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4},
{2.8, 0, 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
{3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
{3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
{2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4},
{0, 0, 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15},
{0.45, -0.8, 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4},
{1.4, -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4},
{0.4, 0, 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55},
{0, -0.4, 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55},
{0.728, -1.3, 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4},
{1.3, -0.728, 2.4}, {0.728, -1.3, 2.4}, {0, -1.3, 2.4},
{0, 0, 0}, {1.425, -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0},
{0.798, -1.425, 0}, {0, -1.5, 0.075}, {0, -1.425, 0},
{1.5, -0.84, 0.075}, {0.84, -1.5, 0.075}
};

static float tex[2][2][2] =
{
{ {0, 0}, {1, 0} },
{ {0, 1}, {1, 1} }
};

static void teapot( GLint grid, GLdouble scale, GLenum type )
{
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;

glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
glEnable( GL_AUTO_NORMAL );
glEnable( GL_NORMALIZE );
glEnable( GL_MAP2_VERTEX_3 );
glEnable( GL_MAP2_TEXTURE_COORD_2 );

glPushMatrix();
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);

for (i = 0; i < 10; i++)
{
for (j = 0; j < 4; j++)
{
for (k = 0; k < 4; k++)
{
for (l = 0; l < 3; l++)
{
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 1)
q[j][k][l] *= -1.0;
if (i < 6)
{
r[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 0)
r[j][k][l] *= -1.0;
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
if (l == 0)
s[j][k][l] *= -1.0;
if (l == 1)
s[j][k][l] *= -1.0;
}
}
}
}

glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
&tex[0][0][0]);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&p[0][0][0]);
glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&q[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
if (i < 6)
{
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&r[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&s[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
}
}

glPopMatrix();
glPopAttrib();
}

void glutWireTeapot(GLdouble size)
{
teapot(10, size, GL_LINE);
}

void glutSolidTeapot(GLdouble size)
{
teapot(7, size, GL_FILL);
}

+ 0
- 1018
src/glut/dos/tr10.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1301
src/glut/dos/tr24.c
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 74
src/glut/dos/util.c Näytä tiedosto

@@ -1,74 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include "internal.h"


extern GLUTStrokeFont glutStrokeRoman, glutStrokeMonoRoman;
extern GLUTBitmapFont glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, glutBitmapHelvetica18;

/* To get around the fact that DJGPP DXEs only allow functions
to be exported and no data addresses (as Unix DSOs support), the
GLUT API constants such as GLUT_STROKE_ROMAN have to get passed
through a case statement to get mapped to the actual data structure
address. */
void *
_glut_font (void *font)
{
switch ((int)font) {
case (int)GLUT_STROKE_ROMAN:
return &glutStrokeRoman;
case (int)GLUT_STROKE_MONO_ROMAN:
return &glutStrokeMonoRoman;
case (int)GLUT_BITMAP_9_BY_15:
return &glutBitmap9By15;
case (int)GLUT_BITMAP_8_BY_13:
return &glutBitmap8By13;
case (int)GLUT_BITMAP_TIMES_ROMAN_10:
return &glutBitmapTimesRoman10;
case (int)GLUT_BITMAP_TIMES_ROMAN_24:
return &glutBitmapTimesRoman24;
case (int)GLUT_BITMAP_HELVETICA_10:
return &glutBitmapHelvetica10;
case (int)GLUT_BITMAP_HELVETICA_12:
return &glutBitmapHelvetica12;
case (int)GLUT_BITMAP_HELVETICA_18:
return &glutBitmapHelvetica18;
default:
if ((font == &glutStrokeRoman) ||
(font == &glutStrokeMonoRoman) ||
(font == &glutBitmap9By15) ||
(font == &glutBitmap8By13) ||
(font == &glutBitmapTimesRoman10) ||
(font == &glutBitmapTimesRoman24) ||
(font == &glutBitmapHelvetica10) ||
(font == &glutBitmapHelvetica12) ||
(font == &glutBitmapHelvetica18)) {
return font;
}
_glut_fatal("bad font!");
return NULL;
}
}

+ 0
- 329
src/glut/dos/window.c Näytä tiedosto

@@ -1,329 +0,0 @@
/*
* DOS/DJGPP Mesa Utility Toolkit
* Version: 1.0
*
* Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include <stdio.h>

#include "internal.h"


static GLuint swaptime, swapcount;

static DMesaVisual visual = NULL;

GLUTwindow *_glut_current, *_glut_windows[MAX_WINDOWS];


static void
clean (void)
{
int i;

for (i=1; i<=MAX_WINDOWS; i++) {
glutDestroyWindow(i);
}
if (visual) DMesaDestroyVisual(visual);

pc_close_stdout();
pc_close_stderr();
}


static GLUTwindow *
_glut_window (int win)
{
if (win > 0 && --win < MAX_WINDOWS) {
return _glut_windows[win];
}
return NULL;
}


int APIENTRY
glutCreateWindow (const char *title)
{
int i;
int m8width = (_glut_default.width + 7) & ~7;

if (!(_glut_default.mode & GLUT_DOUBLE)) {
return 0;
}
/* We set the Visual once. This will be our desktop (graphic mode).
* We should do this in the `glutInit' code, but we don't have any idea
* about its geometry. Supposedly, when we are about to create one
* window, we have a slight idea about resolution.
*/
if (!visual) {
if ((visual=DMesaCreateVisual(_glut_default.x + m8width, _glut_default.y + _glut_default.height, _glut_visual.bpp, _glut_visual.refresh,
GLUT_SINGLE,
!(_glut_default.mode & GLUT_INDEX),
(_glut_default.mode & GLUT_ALPHA ) ? _glut_visual.alpha : 0,
(_glut_default.mode & GLUT_DEPTH ) ? _glut_visual.depth : 0,
(_glut_default.mode & GLUT_STENCIL) ? _glut_visual.stencil : 0,
(_glut_default.mode & GLUT_ACCUM ) ? _glut_visual.accum : 0))==NULL) {
return 0;
}

DMesaGetIntegerv(DMESA_GET_SCREEN_SIZE, _glut_visual.geometry);
DMesaGetIntegerv(DMESA_GET_DRIVER_CAPS, &_glut_visual.flags);

/* Also hook stdio/stderr once */
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}

/* Search for an empty slot.
* Each window has its own rendering Context and its own Buffer.
*/
for (i=0; i<MAX_WINDOWS; i++) {
if (_glut_windows[i] == NULL) {
DMesaContext c;
DMesaBuffer b;
GLUTwindow *w;

if ((w = (GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
return 0;
}

/* Allocate the rendering Context. */
if ((c = DMesaCreateContext(visual, NULL)) == NULL) {
free(w);
return 0;
}

/* Allocate the Buffer (displayable area).
* We have to specify buffer size and position (inside the desktop).
*/
if ((b = DMesaCreateBuffer(visual, _glut_default.x, _glut_default.y, m8width, _glut_default.height)) == NULL) {
DMesaDestroyContext(c);
free(w);
return 0;
}

/* Bind Buffer to Context and make the Context the current one. */
if (!DMesaMakeCurrent(c, b)) {
DMesaDestroyBuffer(b);
DMesaDestroyContext(c);
free(w);
return 0;
}

_glut_current = _glut_windows[i] = w;

w->num = ++i;
w->xpos = _glut_default.x;
w->ypos = _glut_default.y;
w->width = m8width;
w->height = _glut_default.height;
w->context = c;
w->buffer = b;

return i;
}
}

return 0;
}


int APIENTRY
glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}


void APIENTRY
glutDestroyWindow (int win)
{
GLUTwindow *w = _glut_window(win);
if (w != NULL) {
if (w->destroy) {
w->destroy();
}
DMesaMakeCurrent(NULL, NULL);
DMesaDestroyBuffer(w->buffer);
DMesaDestroyContext(w->context);
free(w);
_glut_windows[win - 1] = NULL;
}
}


void APIENTRY
glutPostRedisplay (void)
{
_glut_current->redisplay = GL_TRUE;
}


void APIENTRY
glutSwapBuffers (void)
{
if (_glut_current->show_mouse) {
/* XXX scare mouse */
DMesaSwapBuffers(_glut_current->buffer);
/* XXX unscare mouse */
} else {
DMesaSwapBuffers(_glut_current->buffer);
}

if (_glut_fps) {
GLint t = glutGet(GLUT_ELAPSED_TIME);
swapcount++;
if (swaptime == 0)
swaptime = t;
else if (t - swaptime > _glut_fps) {
double time = 0.001 * (t - swaptime);
double fps = (double)swapcount / time;
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps);
swaptime = t;
swapcount = 0;
}
}
}


int APIENTRY
glutGetWindow (void)
{
return _glut_current->num;
}


void APIENTRY
glutSetWindow (int win)
{
GLUTwindow *w = _glut_window(win);
if (w != NULL) {
_glut_current = w;
DMesaMakeCurrent(_glut_current->context, _glut_current->buffer);
}
}


void APIENTRY
glutSetWindowTitle (const char *title)
{
}


void APIENTRY
glutSetIconTitle (const char *title)
{
}


void APIENTRY
glutPositionWindow (int x, int y)
{
if (DMesaMoveBuffer(x, y)) {
_glut_current->xpos = x;
_glut_current->ypos = y;
}
}


void APIENTRY
glutReshapeWindow (int width, int height)
{
if (DMesaResizeBuffer(width, height)) {
_glut_current->width = width;
_glut_current->height = height;
if (_glut_current->reshape) {
_glut_current->reshape(width, height);
} else {
glViewport(0, 0, width, height);
}
}
}


void APIENTRY
glutFullScreen (void)
{
}


void APIENTRY
glutPopWindow (void)
{
}


void APIENTRY
glutPushWindow (void)
{
}


void APIENTRY
glutIconifyWindow (void)
{
}


void APIENTRY
glutShowWindow (void)
{
}


void APIENTRY
glutHideWindow (void)
{
}


void APIENTRY
glutCloseFunc (GLUTdestroyCB destroy)
{
_glut_current->destroy = destroy;
}


void APIENTRY
glutPostWindowRedisplay (int win)
{
GLUTwindow *w = _glut_window(win);
if (w != NULL) {
w->redisplay = GL_TRUE;
}
}


void * APIENTRY
glutGetWindowData (void)
{
return _glut_current->data;
}


void APIENTRY
glutSetWindowData (void *data)
{
_glut_current->data = data;
}

+ 0
- 94
src/glut/fbdev/Makefile Näytä tiedosto

@@ -1,94 +0,0 @@
# subset glut

TOP = ../../..
include $(TOP)/configs/current

GLX_SHARED = $(TOP)/src/glut/glx
MINI_SHARED = $(TOP)/src/glut/mini

GLUT_MAJOR = 3
GLUT_MINOR = 7
GLUT_TINY = 1

INCLUDES = -I$(TOP)/include -I$(GLX_SHARED)

CORE_SOURCES = \
fbdev.c \
colormap.c \
cursor.c \
menu.c \
overlay.c \
ext.c \
state.c \
input.c \
callback.c \
gamemode.c \
vidresize.c \
bitmap.c \
stroke.c

GLX_SHARED_SOURCES = \
$(GLX_SHARED)/glut_8x13.c \
$(GLX_SHARED)/glut_9x15.c \
$(GLX_SHARED)/glut_hel10.c \
$(GLX_SHARED)/glut_hel12.c \
$(GLX_SHARED)/glut_hel18.c \
$(GLX_SHARED)/glut_tr10.c \
$(GLX_SHARED)/glut_tr24.c \
$(GLX_SHARED)/glut_mroman.c \
$(GLX_SHARED)/glut_roman.c \

MINI_SHARED_SOURCES = \
$(MINI_SHARED)/models.c \
$(MINI_SHARED)/teapot.c

SOURCES = $(CORE_SOURCES) $(GLX_SHARED_SOURCES) $(MINI_SHARED_SOURCES)

OBJECTS = $(SOURCES:.c=.o)


##### RULES #####

.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@

.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@


##### TARGETS #####

default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)


# Make the library
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
$(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
$(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
$(MKLIB_OPTIONS) $(OBJECTS)

install:
$(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
$(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR)

# Run 'make -f Makefile.solo dep' to update the dependencies if you change
# what's included by any source file.
depend: $(SOURCES)
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) > /dev/null

# Emacs tags
tags:
etags `find . -name \*.[ch]` `find ../include`


# Remove .o and backup files
clean: depend
-rm -f depend depend.bak
-rm -f *.o *~ *.o *~ *.so libglut.so.3.7

include depend

+ 0
- 78
src/glut/fbdev/bitmap.c Näytä tiedosto

@@ -1,78 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/


#include "glutbitmap.h"

void glutBitmapCharacter(GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fi = (BitmapFontPtr) font;

if (c < fi->first ||
c >= fi->first + fi->num_chars)
return;
ch = fi->ch[c - fi->first];
if (!ch)
return;

glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
ch->advance, 0, ch->bitmap);
glPopClientAttrib();
}

int glutBitmapWidth (GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fi = (BitmapFontPtr) font;

if (c < fi->first || c >= fi->first + fi->num_chars)
return 0;
ch = fi->ch[c - fi->first];
if (ch)
return ch->advance;
return 0;
}

int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
{
int length = 0;

for (; *string; string++)
length += glutBitmapWidth(font, *string);
return length;
}

+ 0
- 171
src/glut/fbdev/callback.c Näytä tiedosto

@@ -1,171 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdlib.h>

#include <GL/glut.h>

#include "internal.h"

void (*DisplayFunc)(void) = NULL;
void (*ReshapeFunc)(int width, int height) = NULL;
void (*KeyboardFunc)(unsigned char key, int x, int y) = NULL;
void (*KeyboardUpFunc)(unsigned char key, int x, int y) = NULL;
void (*MouseFunc)(int key, int state, int x, int y) = NULL;
void (*MotionFunc)(int x, int y) = NULL;
void (*PassiveMotionFunc)(int x, int y) = NULL;
void (*VisibilityFunc)(int state) = NULL;
void (*SpecialFunc)(int key, int x, int y) = NULL;
void (*SpecialUpFunc)(int key, int x, int y) = NULL;
void (*IdleFunc)(void) = NULL;
void (*MenuStatusFunc)(int state, int x, int y) = NULL;
void (*MenuStateFunc)(int state) = NULL;

void glutDisplayFunc(void (*func)(void))
{
DisplayFunc = func;
}

void glutOverlayDisplayFunc(void (*func)(void))
{
}

void glutWindowStatusFunc(void (*func)(int state))
{
}

void glutReshapeFunc(void (*func)(int width, int height))
{
ReshapeFunc = func;
}

void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y))
{
KeyboardFunc = func;
}

void glutKeyboardUpFunc(void (*func)(unsigned char key, int x, int y))
{
KeyboardUpFunc = func;
}

void glutMouseFunc(void (*func)(int button, int state, int x, int y))
{
MouseFunc = func;
}

void glutMotionFunc(void (*func)(int x, int y))
{
MotionFunc = func;
}

void glutPassiveMotionFunc(void (*func)(int x, int y))
{
PassiveMotionFunc = func;
}

void glutJoystickFunc(void (*func)(unsigned int buttonMask,
int x, int y, int z), int pollInterval)
{
}

void glutVisibilityFunc(void (*func)(int state))
{
VisibilityFunc = func;
}

void glutEntryFunc(void (*func)(int state))
{
}

void glutSpecialFunc(void (*func)(int key, int x, int y))
{
SpecialFunc = func;
}

void glutSpecialUpFunc(void (*func)(int key, int x, int y))
{
SpecialUpFunc = func;
}

void glutSpaceballMotionFunc(void (*func)(int x, int y, int z))
{
}

void glutSpaceballRotateFunc(void (*func)(int x, int y, int z))
{
}

void glutSpaceballButtonFunc(void (*func)(int button, int state))
{
}

void glutButtonBoxFunc(void (*func)(int button, int state))
{
}

void glutDialsFunc(void (*func)(int dial, int value))
{
}

void glutTabletMotionFunc(void (*func)(int x, int y))
{
}

void glutTabletButtonFunc(void (*func)(int button, int state,
int x, int y))
{
}

void glutMenuStatusFunc(void (*func)(int status, int x, int y))
{
MenuStatusFunc = func;
}

void glutMenuStateFunc(void (*func)(int status))
{
MenuStateFunc = func;
}

void glutIdleFunc(void (*func)(void))
{
IdleFunc = func;
}

void glutTimerFunc(unsigned int msecs,
void (*func)(int value), int value)
{
struct GlutTimer **head = &GlutTimers, *timer = malloc(sizeof *timer);
timer->time = glutGet(GLUT_ELAPSED_TIME) + msecs;
timer->func = func;
timer->value = value;

while(*head && (*head)->time < timer->time)
head = &(*head)->next;

timer->next = *head;
*head = timer;
}

+ 0
- 177
src/glut/fbdev/colormap.c Näytä tiedosto

@@ -1,177 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdio.h>
#include <stdlib.h>

#include <linux/fb.h>

#include <GL/gl.h>
#include <GL/glut.h>

#include "internal.h"

#define TOCMAP(x)(unsigned short)((x<0?0:x>1?1:x)*(GLfloat) ((1<<16) - 1))
#define TORMAP(x)(unsigned short)((x<0?0:x>1?1:x)*(GLfloat)(REVERSECMAPSIZE-1))
#define FROMCMAP(x) (GLfloat)x / (GLfloat)((1<<16) - 1)

static struct fb_cmap ColorMap, OriginalColorMap;

unsigned short RedColorMap[256], GreenColorMap[256], BlueColorMap[256];

unsigned char ReverseColorMap[REVERSECMAPSIZE]
[REVERSECMAPSIZE]
[REVERSECMAPSIZE];

static void FindReverseMap(int r, int g, int b)
{
static int count;
int i, shift = 16 - REVERSECMAPSIZELOG;
unsigned int minv = -1, mini = 0;
for(i=0; i<256; i++) {
int val = 0;
val += abs(r-(RedColorMap[i]>>shift));
val += abs(g-(GreenColorMap[i]>>shift));
val += abs(b-(BlueColorMap[i]>>shift));
if(val < minv) {
minv = val;
mini = i;
}
}
ReverseColorMap[r][g][b] = mini;
}

static void FillItemReverseColorMap(int r, int g, int b)
{
FindReverseMap(r, g, b);
if(r > 0)
FindReverseMap(r-1, g, b);
if(r < REVERSECMAPSIZE - 1)
FindReverseMap(r+1, g, b);
if(g > 0)
FindReverseMap(r, g-1, b);
if(g < REVERSECMAPSIZE - 1)
FindReverseMap(r, g+1, b);
if(b > 0)
FindReverseMap(r, g, b-1);
if(b < REVERSECMAPSIZE - 1)
FindReverseMap(r, g, b+1);
}

static void FillReverseColorMap(void)
{
int r, g, b;
for(r = 0; r < REVERSECMAPSIZE; r++)
for(g = 0; g < REVERSECMAPSIZE; g++)
for(b = 0; b < REVERSECMAPSIZE; b++)
FindReverseMap(r, g, b);
}

void RestoreColorMap(void)
{
if(FixedInfo.visual == FB_VISUAL_TRUECOLOR)
return;

if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &ColorMap) < 0)
sprintf(exiterror, "ioctl(FBIOPUTCMAP) failed!\n");
}

void LoadColorMap(void)
{
if(FixedInfo.visual == FB_VISUAL_TRUECOLOR)
return;

ColorMap.start = 0;
ColorMap.red = RedColorMap;
ColorMap.green = GreenColorMap;
ColorMap.blue = BlueColorMap;
ColorMap.transp = NULL;

if(DisplayMode & GLUT_INDEX) {
ColorMap.len = 256;

if (ioctl(FrameBufferFD, FBIOGETCMAP, (void *) &ColorMap) < 0)
sprintf(exiterror, "ioctl(FBIOGETCMAP) failed!\n");

FillReverseColorMap();
} else {
int rcols = 1 << VarInfo.red.length;
int gcols = 1 << VarInfo.green.length;
int bcols = 1 << VarInfo.blue.length;

int i;

ColorMap.len = gcols;

for (i = 0; i < rcols ; i++)
RedColorMap[i] = (65536/(rcols-1)) * i;
for (i = 0; i < gcols ; i++)
GreenColorMap[i] = (65536/(gcols-1)) * i;
for (i = 0; i < bcols ; i++)
BlueColorMap[i] = (65536/(bcols-1)) * i;

RestoreColorMap();
}
}

void glutSetColor(int cell, GLfloat red, GLfloat green, GLfloat blue)
{
if(cell < 0 || cell >= 256)
return;

RedColorMap[cell] = TOCMAP(red);
GreenColorMap[cell] = TOCMAP(green);
BlueColorMap[cell] = TOCMAP(blue);
RestoreColorMap();

FillItemReverseColorMap(TORMAP(red), TORMAP(green), TORMAP(blue));
}

GLfloat glutGetColor(int cell, int component)
{
if(!(DisplayMode & GLUT_INDEX))
return -1.0;

if(cell < 0 || cell > 256)
return -1.0;

switch(component) {
case GLUT_RED:
return FROMCMAP(RedColorMap[cell]);
case GLUT_GREEN:
return FROMCMAP(GreenColorMap[cell]);
case GLUT_BLUE:
return FROMCMAP(BlueColorMap[cell]);
}
return -1.0;
}

void glutCopyColormap(int win)
{
}

+ 0
- 272
src/glut/fbdev/cursor.c Näytä tiedosto

@@ -1,272 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

/* these routines are written to access graphics memory directly, not using mesa
to render the cursor, this is faster, it would be good to use a hardware
cursor if it exists instead */

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>

#include <linux/fb.h>

#include <GL/glut.h>

#include "internal.h"
#include "cursors.h"

int CurrentCursor = GLUT_CURSOR_LEFT_ARROW;

static int LastMouseX, LastMouseY;
static unsigned char *MouseBuffer;

void InitializeCursor(void)
{
if(!MouseBuffer && (MouseBuffer = malloc(CURSOR_WIDTH * CURSOR_HEIGHT
* VarInfo.bits_per_pixel / 8)) == NULL) {
sprintf(exiterror, "malloc failure\n");
exit(0);
}

MouseX = VarInfo.xres / 2;
MouseY = VarInfo.yres / 2;
}

void EraseCursor(void)
{
int off = LastMouseY * FixedInfo.line_length
+ LastMouseX * VarInfo.bits_per_pixel / 8;
int stride = CURSOR_WIDTH * VarInfo.bits_per_pixel / 8;
int i;

unsigned char *src = MouseBuffer;

if(!MouseVisible || CurrentCursor < 0 || CurrentCursor >= NUM_CURSORS)
return;

for(i = 0; i<CURSOR_HEIGHT; i++) {
memcpy(BackBuffer + off, src, stride);
src += stride;
off += FixedInfo.line_length;
}
}

static void SaveCursor(int x, int y)
{
int bypp, off, stride, i;
unsigned char *src = MouseBuffer;

if(x < 0)
LastMouseX = 0;
else
if(x > (int)VarInfo.xres - CURSOR_WIDTH)
LastMouseX = VarInfo.xres - CURSOR_WIDTH;
else
LastMouseX = x;

if(y < 0)
LastMouseY = 0;
else
if(y > (int)VarInfo.yres - CURSOR_HEIGHT)
LastMouseY = VarInfo.yres - CURSOR_HEIGHT;
else
LastMouseY = y;

bypp = VarInfo.bits_per_pixel / 8;
off = LastMouseY * FixedInfo.line_length + LastMouseX * bypp;
stride = CURSOR_WIDTH * bypp;
for(i = 0; i<CURSOR_HEIGHT; i++) {
memcpy(src, BackBuffer + off, stride);
src += stride;
off += FixedInfo.line_length;
}
}

void DrawCursor(void)
{
int i, j, px, py, xoff, xlen, yoff, ylen, bypp, cstride, dstride;
unsigned char *c;
const unsigned char *d;

if(!MouseVisible || CurrentCursor < 0 || CurrentCursor >= NUM_CURSORS)
return;

px = MouseX - CursorsXOffset[CurrentCursor];
py = MouseY - CursorsYOffset[CurrentCursor];

SaveCursor(px, py);

xoff = 0;
if(px < 0)
xoff = -px;

xlen = CURSOR_WIDTH;
if(px + CURSOR_WIDTH > VarInfo.xres)
xlen = VarInfo.xres - px;

yoff = 0;
if(py < 0)
yoff = -py;

ylen = CURSOR_HEIGHT;
if(py + CURSOR_HEIGHT > VarInfo.yres)
ylen = VarInfo.yres - py;

bypp = VarInfo.bits_per_pixel / 8;

c = BackBuffer + FixedInfo.line_length * (py + yoff) + (px + xoff) * bypp;
cstride = FixedInfo.line_length - bypp * (xlen - xoff);

d = Cursors[CurrentCursor] + (CURSOR_WIDTH * yoff + xoff)*4;
dstride = (CURSOR_WIDTH - xlen + xoff) * 4;

switch(bypp) {
case 1:
{
const int shift = 8 - REVERSECMAPSIZELOG;
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220)
*c = ReverseColorMap
[(d[0]+(((int)(RedColorMap[c[0]]>>8)*d[3])>>8))>>shift]
[(d[1]+(((int)(GreenColorMap[c[0]]>>8)*d[3])>>8))>>shift]
[(d[2]+(((int)(BlueColorMap[c[0]]>>8)*d[3])>>8))>>shift];
c++;
d+=4;
}
d += dstride;
c += cstride;
}
} break;
case 2:
{
uint16_t *e = (void*)c;
cstride /= 2;
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220)
e[0] = ((((d[0] + (((int)(((e[0] >> 8) & 0xf8)
| ((c[0] >> 11) & 0x7)) * d[3]) >> 8)) & 0xf8) << 8)
| (((d[1] + (((int)(((e[0] >> 3) & 0xfc)
| ((e[0] >> 5) & 0x3)) * d[3]) >> 8)) & 0xfc) << 3)
| ((d[2] + (((int)(((e[0] << 3) & 0xf8)
| (e[0] & 0x7)) * d[3]) >> 8)) >> 3));
e++;
d+=4;
}
d += dstride;
e += cstride;
}
} break;
case 3:
case 4:
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220) {
c[0] = d[0] + (((int)c[0] * d[3]) >> 8);
c[1] = d[1] + (((int)c[1] * d[3]) >> 8);
c[2] = d[2] + (((int)c[2] * d[3]) >> 8);
}
c+=bypp;
d+=4;
}
d += dstride;
c += cstride;
} break;
}
}

#define MIN(x, y) x < y ? x : y
void SwapCursor(void)
{
int px = MouseX - CursorsXOffset[CurrentCursor];
int py = MouseY - CursorsYOffset[CurrentCursor];

int minx = MIN(px, LastMouseX);
int sizex = abs(px - LastMouseX);

int miny = MIN(py, LastMouseY);
int sizey = abs(py - LastMouseY);

if(MouseVisible)
DrawCursor();

/* now update the portion of the screen that has changed, this is also
used to hide the mouse if MouseVisible is 0 */
if(DisplayMode & GLUT_DOUBLE && ((sizex || sizey) || !MouseVisible)) {
int off, stride, i;
if(minx < 0)
minx = 0;
if(miny < 0)
miny = 0;
if(minx + sizex > VarInfo.xres - CURSOR_WIDTH)
sizex = VarInfo.xres - CURSOR_WIDTH - minx;
if(miny + sizey > VarInfo.yres - CURSOR_HEIGHT)
sizey = VarInfo.yres - CURSOR_HEIGHT - miny;
off = FixedInfo.line_length * miny
+ minx * VarInfo.bits_per_pixel / 8;
stride = (sizex + CURSOR_WIDTH) * VarInfo.bits_per_pixel / 8;

for(i = 0; i < sizey + CURSOR_HEIGHT; i++) {
memcpy(FrameBuffer+off, BackBuffer+off, stride);
off += FixedInfo.line_length;
}
}
}

void glutWarpPointer(int x, int y)
{
if(x < 0)
x = 0;
if(x >= VarInfo.xres)
x = VarInfo.xres - 1;
MouseX = x;

if(y < 0)
y = 0;
if(y >= VarInfo.yres)
y = VarInfo.yres - 1;
MouseY = y;

EraseCursor();
SwapCursor();
}

void glutSetCursor(int cursor)
{
if(cursor == GLUT_CURSOR_FULL_CROSSHAIR)
cursor = GLUT_CURSOR_CROSSHAIR;

EraseCursor();
MouseVisible = 1;
CurrentCursor = cursor;
SwapCursor();
}

+ 0
- 7099
src/glut/fbdev/cursors.h
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 154
src/glut/fbdev/ext.c Näytä tiedosto

@@ -1,154 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdio.h>

#include <GL/gl.h>
#include <GL/glut.h>

#include "internal.h"

void glutReportErrors(void)
{
GLenum error;

while ((error = glGetError()) != GL_NO_ERROR)
sprintf(exiterror, "GL error: %s", gluErrorString(error));
}

static struct {
const char *name;
const GLUTproc address;
} glut_functions[] = {
{ "glutInit", (const GLUTproc) glutInit },
{ "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
{ "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
{ "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
{ "glutMainLoop", (const GLUTproc) glutMainLoop },
{ "glutCreateWindow", (const GLUTproc) glutCreateWindow },
{ "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
{ "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
{ "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
{ "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
{ "glutGetWindow", (const GLUTproc) glutGetWindow },
{ "glutSetWindow", (const GLUTproc) glutSetWindow },
{ "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
{ "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
{ "glutPositionWindow", (const GLUTproc) glutPositionWindow },
{ "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
{ "glutPopWindow", (const GLUTproc) glutPopWindow },
{ "glutPushWindow", (const GLUTproc) glutPushWindow },
{ "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
{ "glutShowWindow", (const GLUTproc) glutShowWindow },
{ "glutHideWindow", (const GLUTproc) glutHideWindow },
{ "glutFullScreen", (const GLUTproc) glutFullScreen },
{ "glutSetCursor", (const GLUTproc) glutSetCursor },
{ "glutWarpPointer", (const GLUTproc) glutWarpPointer },
{ "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
{ "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
{ "glutUseLayer", (const GLUTproc) glutUseLayer },
{ "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
{ "glutShowOverlay", (const GLUTproc) glutShowOverlay },
{ "glutHideOverlay", (const GLUTproc) glutHideOverlay },
{ "glutCreateMenu", (const GLUTproc) glutCreateMenu },
{ "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
{ "glutGetMenu", (const GLUTproc) glutGetMenu },
{ "glutSetMenu", (const GLUTproc) glutSetMenu },
{ "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
{ "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
{ "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
{ "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
{ "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
{ "glutAttachMenu", (const GLUTproc) glutAttachMenu },
{ "glutDetachMenu", (const GLUTproc) glutDetachMenu },
{ "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
{ "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
{ "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
{ "glutMouseFunc", (const GLUTproc) glutMouseFunc },
{ "glutMotionFunc", (const GLUTproc) glutMotionFunc },
{ "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
{ "glutEntryFunc", (const GLUTproc) glutEntryFunc },
{ "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
{ "glutIdleFunc", (const GLUTproc) glutIdleFunc },
{ "glutTimerFunc", (const GLUTproc) glutTimerFunc },
{ "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
{ "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
{ "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
{ "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
{ "glutDialsFunc", (const GLUTproc) glutDialsFunc },
{ "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
{ "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
{ "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
{ "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
{ "glutSetColor", (const GLUTproc) glutSetColor },
{ "glutGetColor", (const GLUTproc) glutGetColor },
{ "glutCopyColormap", (const GLUTproc) glutCopyColormap },
{ "glutGet", (const GLUTproc) glutGet },
{ "glutDeviceGet", (const GLUTproc) glutDeviceGet },
{ "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
{ "glutGetModifiers", (const GLUTproc) glutGetModifiers },
{ "glutLayerGet", (const GLUTproc) glutLayerGet },
{ "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
{ "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
{ "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
{ "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
{ "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
{ "glutBitmapLength", (const GLUTproc) glutBitmapLength },
{ "glutStrokeLength", (const GLUTproc) glutStrokeLength },
{ "glutWireSphere", (const GLUTproc) glutWireSphere },
{ "glutSolidSphere", (const GLUTproc) glutSolidSphere },
{ "glutWireCone", (const GLUTproc) glutWireCone },
{ "glutSolidCone", (const GLUTproc) glutSolidCone },
{ "glutWireCube", (const GLUTproc) glutWireCube },
{ "glutSolidCube", (const GLUTproc) glutSolidCube },
{ "glutWireTorus", (const GLUTproc) glutWireTorus },
{ "glutSolidTorus", (const GLUTproc) glutSolidTorus },
{ "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
{ "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
{ "glutWireTeapot", (const GLUTproc) glutWireTeapot },
{ "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
{ "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
{ "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
{ "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
{ "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
{ "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
{ "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
{ "glutReportErrors", (const GLUTproc) glutReportErrors },
{ NULL, NULL }
};

GLUTproc glutGetProcAddress(const char *procName)
{
/* Try GLUT functions first */
int i;
for (i = 0; glut_functions[i].name; i++) {
if (strcmp(glut_functions[i].name, procName) == 0)
return glut_functions[i].address;
}

/* Try core GL functions */
return (GLUTproc) glFBDevGetProcAddress(procName);
}

+ 0
- 940
src/glut/fbdev/fbdev.c Näytä tiedosto

@@ -1,940 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/

#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>

#include <sys/mman.h>
#include <sys/time.h>
#include <sys/kd.h>

#include <linux/fb.h>
#include <linux/vt.h>

#include <GL/gl.h>
#include <GL/glut.h>

#include "internal.h"

#define FBMODES "/etc/fb.modes"

struct fb_fix_screeninfo FixedInfo;
struct fb_var_screeninfo VarInfo;
static struct fb_var_screeninfo OrigVarInfo;

static int DesiredDepth = 0;

int FrameBufferFD = -1;
unsigned char *FrameBuffer;
unsigned char *BackBuffer = NULL;
int DisplayMode;

struct GlutTimer *GlutTimers = NULL;

struct timeval StartTime;

/* per window data */
GLFBDevContextPtr Context;
GLFBDevBufferPtr Buffer;
GLFBDevVisualPtr Visual;

int Redisplay;
int Visible;
int VisibleSwitch;
int Active;
static int Resized;
/* we have to poll to see if we are visible
on a framebuffer that is not active */
int VisiblePoll;
int Swapping, VTSwitch;
static int FramebufferIndex;

static int Initialized;

char exiterror[256];

/* test if the active console is attached to the same framebuffer */
void TestVisible(void) {
struct fb_con2fbmap confb;
struct vt_stat st;
int ret;
ioctl(ConsoleFD, VT_GETSTATE, &st);
confb.console = st.v_active;

ret = ioctl(FrameBufferFD, FBIOGET_CON2FBMAP, &confb);

if(ret == -1 || confb.framebuffer == FramebufferIndex) {
VisibleSwitch = 1;
Visible = 0;
VisiblePoll = 0;
}
}

static void Cleanup(void)
{
/* do not handle this signal when cleaning up */
signal(SIGWINCH, SIG_IGN);

if(GameMode)
glutLeaveGameMode();

if(ConsoleFD != -1)
RestoreVT();

/* close mouse */
CloseMouse();

if(Visual)
glutDestroyWindow(1);

/* restore original variable screen info */
if(FrameBufferFD != -1) {
OrigVarInfo.xoffset = 0;
OrigVarInfo.yoffset = 0;

if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));

if(FrameBuffer)
munmap(FrameBuffer, FixedInfo.smem_len);
close(FrameBufferFD);

}

/* free allocated back buffer */
if(DisplayMode & GLUT_DOUBLE)
free(BackBuffer);

/* free menu items */
FreeMenus();

if(exiterror[0])
fprintf(stderr, "[glfbdev glut] %s", exiterror);
}

static void CrashHandler(int sig)
{
sprintf(exiterror, "Caught signal %d, cleaning up\n", sig);
exit(0);
}

static void removeArgs(int *argcp, char **argv, int num)
{
int i;
for (i = 0; argv[i+num]; i++)
argv[i] = argv[i+num];

argv[i] = NULL;
*argcp -= num;
}

#define REQPARAM(PARAM) \
if (i >= *argcp - 1) { \
fprintf(stderr, PARAM" requires a parameter\n"); \
exit(0); \
}

void glutInit (int *argcp, char **argv)
{
int i, nomouse = 0, nokeyboard = 0, usestdin = 0;
int RequiredWidth = 0, RequiredHeight;
char *fbdev;

stack_t stack;
struct sigaction sa;

/* parse out args */
for (i = 1; i < *argcp;) {
if (!strcmp(argv[i], "-geometry")) {
REQPARAM("geometry");
if(sscanf(argv[i+1], "%dx%d", &RequiredWidth,
&RequiredHeight) != 2) {
fprintf(stderr,"Please specify geometry as widthxheight\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-bpp")) {
REQPARAM("bpp");
if(sscanf(argv[i+1], "%d", &DesiredDepth) != 1) {
fprintf(stderr, "Please specify a parameter for bpp\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-vt")) {
REQPARAM("vt");
if(sscanf(argv[i+1], "%d", &CurrentVT) != 1) {
fprintf(stderr, "Please specify a parameter for vt\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-mousespeed")) {
REQPARAM("mousespeed");
if(sscanf(argv[i+1], "%lf", &MouseSpeed) != 1) {
fprintf(stderr, "Please specify a mouse speed, eg: 2.5\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-nomouse")) {
nomouse = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-nokeyboard")) {
nokeyboard = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-stdin")) {
usestdin = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-gpmmouse")) {
#ifdef HAVE_GPM
GpmMouse = 1;
#else
fprintf(stderr, "gpm support not compiled\n");
exit(0);
#endif
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "--")) {
removeArgs(argcp, &argv[i], 1);
break;
} else
i++;
}

gettimeofday(&StartTime, 0);
atexit(Cleanup);

/* set up SIGSEGV to use alternate stack */
stack.ss_flags = 0;
stack.ss_size = SIGSTKSZ;
if(!(stack.ss_sp = malloc(SIGSTKSZ)))
sprintf(exiterror, "Failed to allocate alternate stack for SIGSEGV!\n");

sigaltstack(&stack, NULL);

sa.sa_handler = CrashHandler;
sa.sa_flags = SA_ONSTACK;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, NULL);

signal(SIGINT, CrashHandler);
signal(SIGTERM, CrashHandler);
signal(SIGABRT, CrashHandler);

if(nomouse == 0)
InitializeMouse();
if(nokeyboard == 0)
InitializeVT(usestdin);

fbdev = getenv("FRAMEBUFFER");
if(fbdev) {
#ifdef MULTIHEAD
if(!sscanf(fbdev, "/dev/fb%d", &FramebufferIndex))
if(!sscanf(fbdev, "/dev/fb/%d", &FramebufferIndex))
sprintf(exiterror, "Could not determine Framebuffer index!\n");
#endif
} else {
static char fb[128];
struct fb_con2fbmap confb;
int fd = open("/dev/fb0", O_RDWR);

FramebufferIndex = 0;

confb.console = CurrentVT;
if(ioctl(fd, FBIOGET_CON2FBMAP, &confb) != -1)
FramebufferIndex = confb.framebuffer;
sprintf(fb, "/dev/fb%d", FramebufferIndex);
fbdev = fb;
close(fd);
}

/* open the framebuffer device */
FrameBufferFD = open(fbdev, O_RDWR);
if (FrameBufferFD < 0) {
sprintf(exiterror, "Error opening %s: %s\n", fbdev, strerror(errno));
exit(0);
}

/* get the fixed screen info */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}

/* get the variable screen info */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}

/* operate on a copy */
VarInfo = OrigVarInfo;

/* set the depth, resolution, etc */
if(RequiredWidth)
if(!ParseFBModes(RequiredWidth, RequiredWidth, RequiredHeight,
RequiredHeight, 0, MAX_VSYNC)) {
sprintf(exiterror, "No mode (%dx%d) found in "FBMODES"\n",
RequiredWidth, RequiredHeight);
exit(0);
}

Initialized = 1;
}

void glutInitDisplayMode (unsigned int mode)
{
DisplayMode = mode;
}

static const char *GetStrVal(const char *p, int *set, int min, int max)
{
char *endptr;
int comp = *p, val;

if(p[1] == '=')
p++;

if(*p == '\0')
return p;

val = strtol(p+1, &endptr, 10);

if(endptr == p+1)
return p;

switch(comp) {
case '!':
if(val == min)
val = max;
else
val = min;
break;
case '<':
val = min;
break;
case '>':
val = max;
break;
}

if(val < min || val > max) {
sprintf(exiterror, "display string value out of range\n");
exit(0);
}

*set = val;

return endptr;
}

static void SetAttrib(int val, int attr)
{
if(val)
DisplayMode |= attr;
else
DisplayMode &= ~attr;
}

void glutInitDisplayString(const char *string)
{
const char *p = string;
int val;
while(*p) {
if(*p == ' ')
p++;
else
if(memcmp(p, "acca", 4) == 0) {
p = GetStrVal(p+4, &AccumSize, 1, 32);
SetAttrib(AccumSize, GLUT_ACCUM);
} else
if(memcmp(p, "acc", 3) == 0) {
p = GetStrVal(p+3, &AccumSize, 1, 32);
SetAttrib(AccumSize, GLUT_ACCUM);
} else
if(memcmp(p, "depth", 5) == 0) {
p = GetStrVal(p+5, &DepthSize, 12, 32);
SetAttrib(DepthSize, GLUT_DEPTH);
} else
if(memcmp(p, "double", 6) == 0) {
val = 1;
p = GetStrVal(p+6, &val, 0, 1);
SetAttrib(val, GLUT_DOUBLE);
} else
if(memcmp(p, "index", 5) == 0) {
val = 1;
p = GetStrVal(p+5, &val, 0, 1);
SetAttrib(val, GLUT_INDEX);
} else
if(memcmp(p, "stencil", 7) == 0) {
p = GetStrVal(p+7, &StencilSize, 0, 1);
SetAttrib(StencilSize, GLUT_STENCIL);
} else
if(memcmp(p, "samples", 7) == 0) {
NumSamples = 1;
p = GetStrVal(p+7, &NumSamples, 0, 16);
SetAttrib(NumSamples, GLUT_MULTISAMPLE);
} else
if(p = strchr(p, ' '))
p++;
else
break;
}
}

void glutInitWindowPosition (int x, int y)
{
}

void glutInitWindowSize (int width, int height)
{
}

static void ProcessTimers(void)
{
while(GlutTimers && GlutTimers->time <= glutGet(GLUT_ELAPSED_TIME)) {
struct GlutTimer *timer = GlutTimers;
GlutTimers = timer->next;
timer->func(timer->value);
free(timer);
}
}

void glutMainLoop(void)
{
int idleiters;

if(ReshapeFunc)
ReshapeFunc(VarInfo.xres, VarInfo.yres);

if(!DisplayFunc) {
sprintf(exiterror, "Fatal Error: No Display Function registered\n");
exit(0);
}

for(;;) {
ProcessTimers();

if(Active)
ReceiveInput();
else
if(VisiblePoll)
TestVisible();

if(IdleFunc)
IdleFunc();
if(VisibleSwitch) {
VisibleSwitch = 0;
if(VisibilityFunc)
VisibilityFunc(Visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE);
}

if(Resized) {
SetVideoMode();
CreateBuffer();

if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}

InitializeMenus();

if(ReshapeFunc)
ReshapeFunc(VarInfo.xres, VarInfo.yres);

Redisplay = 1;
Resized = 0;
}

if(Visible && Redisplay) {
Redisplay = 0;
EraseCursor();
DisplayFunc();
if(!(DisplayMode & GLUT_DOUBLE)) {
if(ActiveMenu)
DrawMenus();
DrawCursor();
}
idleiters = 0;
} else {
/* we sleep if not receiving redisplays, and
the main loop is running faster than 2khz */

static int lasttime;
int time = glutGet(GLUT_ELAPSED_TIME);
if(time > lasttime) {
if(idleiters >= 2)
usleep(100);

idleiters = 0;
lasttime = time;
}
idleiters++;
}
}
}

int ParseFBModes(int minw, int maxw, int minh, int maxh, int minf, int maxf)
{
char buf[1024];
struct fb_var_screeninfo vi = VarInfo;

FILE *fbmodes = fopen(FBMODES, "r");

if(!fbmodes) {
sprintf(exiterror, "Warning: could not open "FBMODES"\n");
return 0;
}

while(fgets(buf, sizeof buf, fbmodes)) {
char *c;
int v, bpp, freq;

if(!(c = strstr(buf, "geometry")))
continue;
v = sscanf(c, "geometry %d %d %d %d %d", &vi.xres, &vi.yres,
&vi.xres_virtual, &vi.yres_virtual, &bpp);
if(v != 5)
continue;

if(maxw < minw) {
if(maxw < vi.xres && minw > vi.xres)
continue;
} else
if(maxw < vi.xres || minw > vi.xres)
continue;

if(maxh < minh) {
if(maxh < vi.yres && minh > vi.yres)
continue;
} else
if(maxh < vi.yres || minh > vi.yres)
continue;

fgets(buf, sizeof buf, fbmodes);
if(!(c = strstr(buf, "timings")))
continue;

v = sscanf(c, "timings %d %d %d %d %d %d %d", &vi.pixclock,
&vi.left_margin, &vi.right_margin, &vi.upper_margin,
&vi.lower_margin, &vi.hsync_len, &vi.vsync_len);

if(v != 7)
continue;

freq = 1E12/vi.pixclock
/(vi.left_margin + vi.xres + vi.right_margin + vi.hsync_len)
/(vi.upper_margin + vi.yres + vi.lower_margin + vi.vsync_len);

if(maxf < minf) {
if(maxf < freq && minf > freq)
continue;
} else
if(maxf < freq || minf > freq)
continue;

VarInfo = vi;
fclose(fbmodes);
return 1;
}

fclose(fbmodes);

return 0;
}

void SetVideoMode(void)
{
/* set new variable screen info */
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "FBIOPUT_VSCREENINFO failed: %s\n", strerror(errno));
strcat(exiterror, "Perhaps the device does not support the selected mode\n");
exit(0);
}

/* reload the screen info to update rgb bits */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}

/* reload the fixed info to update color mode */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}

if (DesiredDepth && DesiredDepth != VarInfo.bits_per_pixel) {
sprintf(exiterror, "error: Could not set set %d bpp\n", DesiredDepth);
exit(0);
}

if(DisplayMode & GLUT_INDEX && FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
sprintf(exiterror, "error: Could not set 8 bit color mode\n");
exit(0);
}

/* initialize colormap */
LoadColorMap();
}

void CreateBuffer(void)
{
int size = VarInfo.xres_virtual * VarInfo.yres_virtual
* VarInfo.bits_per_pixel / 8;

/* mmap the framebuffer into our address space */
if(FrameBuffer)
munmap(FrameBuffer, FixedInfo.smem_len);
FrameBuffer = mmap(0, FixedInfo.smem_len, PROT_READ | PROT_WRITE,
MAP_SHARED, FrameBufferFD, 0);
if (FrameBuffer == MAP_FAILED) {
sprintf(exiterror, "error: unable to mmap framebuffer: %s\n",
strerror(errno));
exit(0);
}

if(DisplayMode & GLUT_DOUBLE) {
free(BackBuffer);
if(!(BackBuffer = malloc(size))) {
sprintf(exiterror, "Failed to allocate double buffer\n");
exit(0);
}
} else
BackBuffer = FrameBuffer;

if(Buffer)
glFBDevDestroyBuffer(Buffer);

if(!(Buffer = glFBDevCreateBuffer( &FixedInfo, &VarInfo, Visual,
FrameBuffer, BackBuffer, size))) {
sprintf(exiterror, "Failure to create Buffer\n");
exit(0);
}
}

void CreateVisual(void)
{
int i, mask = DisplayMode;
int attribs[20];
for(i=0; i<sizeof(attribs)/sizeof(*attribs) && mask; i++) {
if(mask & GLUT_DOUBLE) {
attribs[i] = GLFBDEV_DOUBLE_BUFFER;
mask &= ~GLUT_DOUBLE;
continue;
}

if(mask & GLUT_INDEX) {
attribs[i] = GLFBDEV_COLOR_INDEX;
mask &= ~GLUT_INDEX;
continue;
}

if(mask & GLUT_DEPTH) {
attribs[i] = GLFBDEV_DEPTH_SIZE;
attribs[++i] = DepthSize;
mask &= ~GLUT_DEPTH;
continue;
}

if(mask & GLUT_STENCIL) {
attribs[i] = GLFBDEV_STENCIL_SIZE;
attribs[++i] = StencilSize;
mask &= ~GLUT_STENCIL;
continue;
}

if(mask & GLUT_ACCUM) {
attribs[i] = GLFBDEV_ACCUM_SIZE;
attribs[++i] = AccumSize;
mask &= ~GLUT_ACCUM;
continue;
}

if(mask & GLUT_ALPHA)
if(!(DisplayMode & GLUT_INDEX)) {
mask &= ~GLUT_ALPHA;
i--;
continue;
}

if(mask & GLUT_MULTISAMPLE) {
attribs[i] = GLFBDEV_MULTISAMPLE;
attribs[++i] = NumSamples;
mask &= ~GLUT_MULTISAMPLE;
continue;
}
sprintf(exiterror, "Invalid mode from glutInitDisplayMode\n");
exit(0);
}

attribs[i] = GLFBDEV_NONE;
if(!(Visual = glFBDevCreateVisual( &FixedInfo, &VarInfo, attribs ))) {
sprintf(exiterror, "Failure to create Visual\n");
exit(0);
}
}

static void SignalWinch(int arg)
{
/* we can't change bitdepth without destroying the visual */
int bits_per_pixel = VarInfo.bits_per_pixel;
struct fb_bitfield red = VarInfo.red, green = VarInfo.green,
blue = VarInfo.blue, transp = VarInfo.transp;

/* get the variable screen info */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}

/* restore bitdepth and color masks only */
VarInfo.bits_per_pixel = bits_per_pixel;
VarInfo.red = red;
VarInfo.green = green;
VarInfo.blue = blue;
VarInfo.transp = transp;

Resized = 1;
}

int glutCreateWindow (const char *title)
{
if(Initialized == 0) {
int argc = 0;
char *argv[] = {NULL};
glutInit(&argc, argv);
}

if(Context)
return 0;

if(DisplayMode & GLUT_INDEX)
VarInfo.bits_per_pixel = 8;
else
if(VarInfo.bits_per_pixel == 8)
VarInfo.bits_per_pixel = 32;
if (DesiredDepth)
VarInfo.bits_per_pixel = DesiredDepth;

VarInfo.xoffset = 0;
VarInfo.yoffset = 0;
VarInfo.nonstd = 0;
VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */

SetVideoMode();
CreateVisual();
CreateBuffer();

if(!(Context = glFBDevCreateContext(Visual, NULL))) {
sprintf(exiterror, "Failure to create Context\n");
exit(0);
}

if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}

InitializeCursor();
InitializeMenus();

glutSetWindowTitle(title);

signal(SIGWINCH, SignalWinch);

Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
return 1;
}

int glutCreateSubWindow(int win, int x, int y, int width, int height)
{
return 0;
}

void glutSetWindow(int win)
{
}

int glutGetWindow(void)
{
return 1;
}

void glutDestroyWindow(int win)
{
glFBDevMakeCurrent( NULL, NULL, NULL);
glFBDevDestroyContext(Context);
glFBDevDestroyBuffer(Buffer);
glFBDevDestroyVisual(Visual);
Visual = NULL;
}

void glutPostRedisplay(void)
{
Redisplay = 1;
}

void glutPostWindowRedisplay(int win)
{
Redisplay = 1;
}

void glutSwapBuffers(void)
{
glFlush();

if(!(DisplayMode & GLUT_DOUBLE))
return;

if(ActiveMenu)
DrawMenus();
DrawCursor();

if(Visible) {
Swapping = 1;
glFBDevSwapBuffers(Buffer);
Swapping = 0;
}

/* if there was a vt switch while swapping, switch now */
if(VTSwitch) {
if(ioctl(ConsoleFD, VT_ACTIVATE, VTSwitch) < 0)
sprintf(exiterror, "Error switching console\n");
VTSwitch = 0;
}
}

void glutPositionWindow(int x, int y)
{
}

void glutReshapeWindow(int width, int height)
{
if(GameMode)
return;

if(!ParseFBModes(width, width, height, height, 0, MAX_VSYNC))
return;

signal(SIGWINCH, SIG_IGN);

SetVideoMode();
signal(SIGWINCH, SignalWinch);
Resized = 1;
}

void glutFullScreen(void)
{
}

void glutPopWindow(void)
{
}

void glutPushWindow(void)
{
}

void glutShowWindow(void)
{
Visible = 1;
}

void glutHideWindow(void)
{
Visible = 0;
}

static void UnIconifyWindow(int sig)
{
if(ConsoleFD == 0)
InitializeVT(1);
else
if(ConsoleFD > 0)
InitializeVT(0);
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
exit(0);
}

RestoreColorMap();

Redisplay = 1;
VisibleSwitch = 1;
Visible = 1;
}

void glutIconifyWindow(void)
{
RestoreVT();
signal(SIGCONT, UnIconifyWindow);
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));

raise(SIGSTOP);
}

void glutSetWindowTitle(const char *name)
{
/* escape code to set title in screen */
if(getenv("TERM") && memcmp(getenv("TERM"), "screen", 6) == 0)
printf("\033k%s\033\\", name);
}

void glutSetIconTitle(const char *name)
{
}

+ 0
- 306
src/glut/fbdev/gamemode.c Näytä tiedosto

@@ -1,306 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <linux/fb.h>

#include <GL/glut.h>

#include "internal.h"

int GameMode;

static int ModePossible, DispChanged;
static struct fb_var_screeninfo NormVarInfo, GameVarInfo;

static GLFBDevContextPtr GameContext;
static GLFBDevVisualPtr NormVisual;

/* storage for non-gamemode callbacks */
void (*KeyFuncs[2])(unsigned char key, int x, int y);
static void (*NormFuncs[8])();

static const char*SetOpers(const char *p, unsigned int *min, unsigned int *max)
{
char *endptr;
int comp = *p, val, neq = 0;

if(p[1] == '=') {
neq = 0;
p++;
}

val = strtol(p+1, &endptr, 10);
if(endptr == p+1)
return p;

switch(comp) {
case '=':
*min = *max = val;
break;
case '!':
*min = val + 1;
*max = val - 1;
break;
case '<':
*max = val - neq;
break;
case '>':
*min = val + neq;
break;
}
return endptr;
}

void glutGameModeString(const char *string)
{
const char *p = string;
unsigned int minb = 15, maxb = 32;
unsigned int minw = 0, maxw = -1;
unsigned int minh, maxh = -1;
unsigned int minf = 0, maxf = MAX_VSYNC;
char *endptr;
int count = -1, val;

ModePossible = 0;

if(DisplayMode & GLUT_INDEX)
minb = maxb = 8;

again:
count++;
if((val = strtol(p, &endptr, 10)) && *endptr=='x') {
maxw = minw = val;
p = endptr + 1;
maxh = minh = strtol(p, &endptr, 10);
p = endptr;
goto again;
}

if(*p == ':') {
minb = strtol(p+1, &endptr, 10);
p = endptr;
if(DisplayMode & GLUT_INDEX) {
if(minb != 8)
return;
} else
if(minb != 15 && minb != 16 && minb != 24 && minb != 32)
return;
maxb = minb;
goto again;
}

if(*p == '@') {
minf = strtol(p+1, &endptr, 10) - 5;
maxf = minf + 10;
p = endptr;
goto again;
}

if(count == 0)
while(*p) {
if(*p == ' ')
p++;
else
if(memcmp(p, "bpp", 3) == 0)
p = SetOpers(p+3, &minb, &maxb);
else
if(memcmp(p, "height", 6) == 0)
p = SetOpers(p+6, &minh, &maxh);
else
if(memcmp(p, "hertz", 5) == 0)
p = SetOpers(p+5, &minf, &maxf);
else
if(memcmp(p, "width", 5) == 0)
p = SetOpers(p+5, &minw, &maxw);
else
if(p = strchr(p, ' '))
p++;
else
break;
}

NormVarInfo = VarInfo;
if(!ParseFBModes(minw, maxw, minh, maxh, minf, maxf))
return;

GameVarInfo = VarInfo;
VarInfo = NormVarInfo;

/* determine optimal bitdepth, make sure we have enough video memory */
if(VarInfo.bits_per_pixel && VarInfo.bits_per_pixel <= maxb)
GameVarInfo.bits_per_pixel = VarInfo.bits_per_pixel;
else
GameVarInfo.bits_per_pixel = maxb;

while(FixedInfo.smem_len < GameVarInfo.xres * GameVarInfo.yres
* GameVarInfo.bits_per_pixel / 8) {
if(GameVarInfo.bits_per_pixel < minb)
return;
GameVarInfo.bits_per_pixel = ((GameVarInfo.bits_per_pixel+1)/8)*8-8;
}
ModePossible = 1;
}
int glutEnterGameMode(void)
{
if(ActiveMenu)
return 0;

if(!ModePossible)
return 0;

if(GameMode) {
if(!memcmp(&GameVarInfo, &VarInfo, sizeof VarInfo)) {
DispChanged = 0;
return 1;
}
glutLeaveGameMode();
}

if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &GameVarInfo))
return 0;

NormVarInfo = VarInfo;
VarInfo = GameVarInfo;

NormVisual = Visual;
SetVideoMode();
CreateVisual();
CreateBuffer();

if(!(GameContext = glFBDevCreateContext(Visual, NULL))) {
sprintf(exiterror, "Failure to create Context\n");
exit(0);
}

if(!glFBDevMakeCurrent( GameContext, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Game Current\n");
exit(0);
}

InitializeCursor();

KeyFuncs[0] = KeyboardFunc;
KeyFuncs[1] = KeyboardUpFunc;

NormFuncs[0] = DisplayFunc;
NormFuncs[1] = ReshapeFunc;
NormFuncs[2] = MouseFunc;
NormFuncs[3] = MotionFunc;
NormFuncs[4] = PassiveMotionFunc;
NormFuncs[5] = VisibilityFunc;
NormFuncs[6] = SpecialFunc;
NormFuncs[7] = SpecialUpFunc;

DisplayFunc = NULL;
ReshapeFunc = NULL;
KeyboardFunc = NULL;
KeyboardUpFunc = NULL;
MouseFunc = NULL;
MotionFunc = NULL;
PassiveMotionFunc = NULL;
VisibilityFunc = NULL;
SpecialFunc = SpecialUpFunc = NULL;

DispChanged = 1;
GameMode = 1;
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
return 1;
}

void glutLeaveGameMode(void)
{
if(!GameMode)
return;

glFBDevDestroyContext(GameContext);
glFBDevDestroyVisual(Visual);

VarInfo = NormVarInfo;
Visual = NormVisual;
if(Visual) {
SetVideoMode();
CreateBuffer();
if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}
Redisplay = 1;
}

KeyboardFunc = KeyFuncs[0];
KeyboardUpFunc = KeyFuncs[1];

DisplayFunc = NormFuncs[0];
ReshapeFunc = NormFuncs[1];
MouseFunc = NormFuncs[2];
MotionFunc = NormFuncs[3];
PassiveMotionFunc = NormFuncs[4];
VisibilityFunc = NormFuncs[5];
SpecialFunc = NormFuncs[6];
SpecialUpFunc = NormFuncs[7];

GameMode = 0;
}

int glutGameModeGet(GLenum mode) {
switch(mode) {
case GLUT_GAME_MODE_ACTIVE:
return GameMode;
case GLUT_GAME_MODE_POSSIBLE:
return ModePossible;
case GLUT_GAME_MODE_DISPLAY_CHANGED:
return DispChanged;
}

if(!ModePossible)
return -1;
switch(mode) {
case GLUT_GAME_MODE_WIDTH:
return GameVarInfo.xres;
case GLUT_GAME_MODE_HEIGHT:
return GameVarInfo.yres;
case GLUT_GAME_MODE_PIXEL_DEPTH:
return GameVarInfo.bits_per_pixel;
case GLUT_GAME_MODE_REFRESH_RATE:
return 1E12/GameVarInfo.pixclock
/ (GameVarInfo.left_margin + GameVarInfo.xres
+ GameVarInfo.right_margin + GameVarInfo.hsync_len)
/ (GameVarInfo.upper_margin + GameVarInfo.yres
+ GameVarInfo.lower_margin + GameVarInfo.vsync_len);
}
}

+ 0
- 828
src/glut/fbdev/input.c Näytä tiedosto

@@ -1,828 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <inttypes.h>

#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/kd.h>

#include <linux/keyboard.h>
#include <linux/fb.h>
#include <linux/vt.h>

#include <GL/glut.h>

#include "internal.h"

#define MOUSEDEV "/dev/gpmdata"

#ifdef HAVE_GPM
#include <gpm.h>
int GpmMouse;
#endif

int CurrentVT = 0;
int ConsoleFD = -1;

int KeyboardModifiers;

int MouseX, MouseY;
int NumMouseButtons;

double MouseSpeed = 0;

int KeyRepeatMode = GLUT_KEY_REPEAT_DEFAULT;

int MouseVisible = 0;
int LastMouseTime = 0;

static int OldKDMode = -1;
static int OldMode = KD_TEXT;
static struct vt_mode OldVTMode;
static struct termios OldTermios;

static int KeyboardLedState;

static int MouseFD;

static int kbdpipe[2];

static int LastStdinKeyTime, LastStdinSpecialKey = -1, LastStdinCode = -1;

#define MODIFIER(mod) \
KeyboardModifiers = release ? KeyboardModifiers & ~mod \
: KeyboardModifiers | mod;

/* signal handler attached to SIGIO on keyboard input, vt
switching and modifiers is handled in the signal handler
other keypresses read from a pipe that leaves the handler
if a program locks up the glut loop, you can still switch
vts and kill it without Alt-SysRq hack */
static void KeyboardHandler(int sig)
{
unsigned char code;

while(read(ConsoleFD, &code, 1) == 1) {
int release, labelval;
struct kbentry entry;
static int lalt; /* only left alt does vt switch */

release = code & 0x80;
entry.kb_index = code & 0x7F;
entry.kb_table = 0;
if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}

labelval = entry.kb_value;
switch(labelval) {
case K_SHIFT:
case K_SHIFTL:
MODIFIER(GLUT_ACTIVE_SHIFT);
continue;
case K_CTRL:
MODIFIER(GLUT_ACTIVE_CTRL);
continue;
case K_ALT:
lalt = !release;
case K_ALTGR:
MODIFIER(GLUT_ACTIVE_ALT);
continue;
}

if(lalt && !release) {
/* VT switch, we must do it */
int vt = -1;
struct vt_stat st;
if(labelval >= K_F1 && labelval <= K_F12)
vt = labelval - K_F1 + 1;
if(labelval == K_LEFT)
if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
vt = st.v_active - 1;
if(labelval == K_RIGHT)
if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
vt = st.v_active + 1;
if(vt != -1) {
if(Swapping)
VTSwitch = vt;
else
if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
sprintf(exiterror, "Error switching console\n");
continue;
}
}
write(kbdpipe[1], &code, 1);
}
}

static void LedModifier(int led, int release)
{
static int releaseflag = K_CAPS | K_NUM | K_HOLD;
if(release)
releaseflag |= led;
else
if(releaseflag & led) {
KeyboardLedState ^= led;
releaseflag &= ~led;
}

ioctl(ConsoleFD, KDSKBLED, KeyboardLedState);
ioctl(ConsoleFD, KDSETLED, 0x80);
}

static void HandleKeyPress(unsigned char key, int up)
{
if(up) {
if(KeyboardUpFunc)
KeyboardUpFunc(key, MouseX, MouseY);
} else
if(KeyboardFunc)
KeyboardFunc(key, MouseX, MouseY);
else
if(key == 27)
exit(0); /* no handler, to provide a way to exit */
}

static void HandleSpecialPress(int key, int up)
{
if(up) {
if(SpecialUpFunc)
SpecialUpFunc(key, MouseX, MouseY);
} else
if(SpecialFunc)
SpecialFunc(key, MouseX, MouseY);
}

static void ReleaseStdinKey(void)
{
if(LastStdinSpecialKey != -1) {
HandleSpecialPress(LastStdinSpecialKey, 1);
LastStdinSpecialKey = -1;
}
if(LastStdinCode != -1) {
HandleKeyPress(LastStdinCode, 1);
LastStdinCode = -1;
}
}

#define READKEY read(kbdpipe[0], &code, 1)
static int ReadKey(void)
{
int release, labelval, labelvalnoshift;
unsigned char code;
int specialkey = 0;
struct kbentry entry;

if(READKEY != 1) {
/* if we are reading from stdin, we detect key releases when the key
does not repeat after a given timeout */
if(ConsoleFD == 0 && LastStdinKeyTime + 100 < glutGet(GLUT_ELAPSED_TIME))
ReleaseStdinKey();
return 0;
}

if(code == 0)
return 0;

/* stdin input escape code based */
if(ConsoleFD == 0) {
KeyboardModifiers = 0;
altset:
if(code == 27 && READKEY == 1) {
if(code != 91) {
KeyboardModifiers |= GLUT_ACTIVE_ALT;
goto altset;
}
READKEY;
switch(code) {
case 68:
specialkey = GLUT_KEY_LEFT; break;
case 65:
specialkey = GLUT_KEY_UP; break;
case 67:
specialkey = GLUT_KEY_RIGHT; break;
case 66:
specialkey = GLUT_KEY_DOWN; break;
case 52:
specialkey = GLUT_KEY_END; READKEY; break;
case 53:
specialkey = GLUT_KEY_PAGE_UP; READKEY; break;
case 54:
specialkey = GLUT_KEY_PAGE_DOWN; READKEY; break;
case 49:
READKEY;
if(code == 126)
specialkey = GLUT_KEY_HOME;
else {
specialkey = GLUT_KEY_F1 + code - 50;
READKEY;
}
break;
case 50:
READKEY;
if(code == 126)
specialkey = GLUT_KEY_INSERT;
else {
if(code > '1')
code--;
if(code > '6')
code--;
if(code > '3') {
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
code -= 12;
}
specialkey = GLUT_KEY_F1 + code - 40;
READKEY;
}
break;
case 51:
READKEY;
if(code == 126) {
code = '\b';
goto stdkey;
}
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
specialkey = GLUT_KEY_F1 + code - 45;
READKEY;
break;
case 91:
READKEY;
specialkey = GLUT_KEY_F1 + code - 65;
break;
default:
return 0;
}
}

if(specialkey) {
LastStdinKeyTime = glutGet(GLUT_ELAPSED_TIME);

if(LastStdinSpecialKey != specialkey) {
ReleaseStdinKey();
HandleSpecialPress(specialkey, 0);
LastStdinSpecialKey = specialkey;
LastStdinKeyTime += 200; /* initial repeat */
} else
if(KeyRepeatMode != GLUT_KEY_REPEAT_OFF)
HandleSpecialPress(specialkey, 0);
} else {
if(code >= 1 && code <= 26 && code != '\r') {
KeyboardModifiers |= GLUT_ACTIVE_CTRL;
code += 'a' - 1;
}
if((code >= 43 && code <= 34) || (code == 60)
|| (code >= 62 && code <= 90) || (code == 94)
|| (code == 95) || (code >= 123 && code <= 126))
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;

stdkey:
LastStdinKeyTime = glutGet(GLUT_ELAPSED_TIME);
if(LastStdinCode != code) {
ReleaseStdinKey();
HandleKeyPress(code, 0);
LastStdinCode = code;
LastStdinKeyTime += 200; /* initial repeat */
} else
if(KeyRepeatMode != GLUT_KEY_REPEAT_OFF)
HandleSpecialPress(code, 0);
}
return 1;
}

/* linux kbd reading */
release = code & 0x80;
code &= 0x7F;

if(KeyRepeatMode == GLUT_KEY_REPEAT_OFF) {
static char keystates[128];
if(release)
keystates[code] = 0;
else {
if(keystates[code])
return 1;
keystates[code] = 1;
}
}
entry.kb_index = code;
entry.kb_table = 0;

if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}

labelvalnoshift = entry.kb_value;

if(KeyboardModifiers & GLUT_ACTIVE_SHIFT)
entry.kb_table |= K_SHIFTTAB;
if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}

labelval = entry.kb_value;

switch(labelvalnoshift) {
case K_CAPS:
LedModifier(LED_CAP, release);
return 0;
case K_NUM:
LedModifier(LED_NUM, release);
return 0;
case K_HOLD: /* scroll lock suspends glut */
LedModifier(LED_SCR, release);
while(KeyboardLedState & LED_SCR) {
usleep(10000);
ReadKey();
}
return 0;
}

/* we could queue keypresses here */
if(KeyboardLedState & LED_SCR)
return 0;

if(labelvalnoshift >= K_F1 && labelvalnoshift <= K_F12)
specialkey = GLUT_KEY_F1 + labelvalnoshift - K_F1;
else
switch(labelvalnoshift) {
case K_LEFT:
specialkey = GLUT_KEY_LEFT; break;
case K_UP:
specialkey = GLUT_KEY_UP; break;
case K_RIGHT:
specialkey = GLUT_KEY_RIGHT; break;
case K_DOWN:
specialkey = GLUT_KEY_DOWN; break;
case K_PGUP:
specialkey = GLUT_KEY_PAGE_UP; break;
case K_PGDN:
specialkey = GLUT_KEY_PAGE_DOWN; break;
case K_FIND:
specialkey = GLUT_KEY_HOME; break;
case K_SELECT:
specialkey = GLUT_KEY_END; break;
case K_INSERT:
specialkey = GLUT_KEY_INSERT; break;
case K_REMOVE:
labelval = '\b';
break;
case K_ENTER:
labelval = '\r'; break;
}

/* likely a keypad input, but depends on keyboard mapping, ignore */
if(labelval == 512)
return 1;

/* dispatch callback */
if(specialkey)
HandleSpecialPress(specialkey, release);
else {
char c = labelval;

if(KeyboardLedState & LED_CAP) {
if(c >= 'A' && c <= 'Z')
c += 'a' - 'A';
else
if(c >= 'a' && c <= 'z')
c += 'A' - 'a';
}
HandleKeyPress(c, release);
}
return 1;
}

void glutIgnoreKeyRepeat(int ignore)
{
KeyRepeatMode = ignore ? GLUT_KEY_REPEAT_OFF : GLUT_KEY_REPEAT_ON;
}

void glutSetKeyRepeat(int repeatMode)
{
KeyRepeatMode = repeatMode;
}

void glutForceJoystickFunc(void)
{
}

static void HandleMousePress(int button, int pressed)
{
if(TryMenu(button, pressed))
return;
if(MouseFunc)
MouseFunc(button, pressed ? GLUT_DOWN : GLUT_UP, MouseX, MouseY);
}

static int ReadMouse(void)
{
int l, r, m;
static int ll, lm, lr;
signed char dx, dy;

#ifdef HAVE_GPM
if(GpmMouse) {
Gpm_Event event;
struct pollfd pfd;
pfd.fd = gpm_fd;
pfd.events = POLLIN;
if(poll(&pfd, 1, 1) != 1)
return 0;
if(Gpm_GetEvent(&event) != 1)
return 0;
l = event.buttons & GPM_B_LEFT;
m = event.buttons & GPM_B_MIDDLE;
r = event.buttons & GPM_B_RIGHT;

/* gpm is weird in that it gives a button number when the button
is released, with type set to GPM_UP, this is only a problem
if it is the last button released */
if(event.type & GPM_UP)
if(event.buttons == GPM_B_LEFT || event.buttons == GPM_B_MIDDLE ||
event.buttons == GPM_B_RIGHT || event.buttons == GPM_B_FOURTH)
l = m = r = 0;

dx = event.dx;
dy = event.dy;
} else
#endif
{
char data[4];

if(MouseFD == -1)
return 0;

if(read(MouseFD, data, 4) != 4)
return 0;
l = ((data[0] & 0x20) >> 3);
m = ((data[3] & 0x10) >> 3);
r = ((data[0] & 0x10) >> 4);

dx = (((data[0] & 0x03) << 6) | (data[1] & 0x3F));
dy = (((data[0] & 0x0C) << 4) | (data[2] & 0x3F));
}

MouseX += dx * MouseSpeed;
if(MouseX < 0)
MouseX = 0;
else
if(MouseX >= VarInfo.xres)
MouseX = VarInfo.xres - 1;

MouseY += dy * MouseSpeed;
if(MouseY < 0)
MouseY = 0;
else
if(MouseY >= VarInfo.yres)
MouseY = VarInfo.yres - 1;

if(l != ll)
HandleMousePress(GLUT_LEFT_BUTTON, l);
if(m != lm)
HandleMousePress(GLUT_MIDDLE_BUTTON, m);
if(r != lr)
HandleMousePress(GLUT_RIGHT_BUTTON, r);

ll = l, lm = m, lr = r;

if(dx || dy || !MouseVisible) {
if(l || m || r) {
if(MotionFunc)
MotionFunc(MouseX, MouseY);
} else
if(PassiveMotionFunc)
PassiveMotionFunc(MouseX, MouseY);

EraseCursor();

MouseVisible = 1;

if(ActiveMenu)
Redisplay = 1;
else
SwapCursor();
}

LastMouseTime = glutGet(GLUT_ELAPSED_TIME);

return 1;
}

void ReceiveInput(void)
{
if(ConsoleFD != -1)
while(ReadKey());
while(ReadMouse());

/* implement a 2 second timeout on the mouse */
if(MouseVisible && glutGet(GLUT_ELAPSED_TIME) - LastMouseTime > 2000) {
EraseCursor();
MouseVisible = 0;
SwapCursor();
}
}

static void VTSwitchHandler(int sig)
{
struct vt_stat st;
switch(sig) {
case SIGUSR1:
ioctl(ConsoleFD, VT_RELDISP, 1);
Active = 0;
#ifdef MULTIHEAD
VisiblePoll = 1;
TestVisible();
#else
VisibleSwitch = 1;
Visible = 0;
#endif
break;
case SIGUSR2:
ioctl(ConsoleFD, VT_GETSTATE, &st);
if(st.v_active)
ioctl(ConsoleFD, VT_RELDISP, VT_ACKACQ);

RestoreColorMap();

Active = 1;
Visible = 1;
VisibleSwitch = 1;

Redisplay = 1;
break;
}
}

void InitializeVT(int usestdin)
{
struct termios tio;
struct vt_mode vt;
char console[128];

signal(SIGIO, SIG_IGN);

Active = 1;

if(usestdin) {
ConsoleFD = 0;
goto setattribs;
}

/* detect the current vt if it was not specified */
if(CurrentVT == 0) {
int fd = open("/dev/tty", O_RDWR | O_NDELAY, 0);
struct vt_stat st;
if(fd == -1) {
sprintf(exiterror, "Failed to open /dev/tty\n");
exit(0);
}

if(ioctl(fd, VT_GETSTATE, &st) == -1) {
fprintf(stderr, "Could not detect current vt, specify with -vt\n");
fprintf(stderr, "Defaulting to stdin input\n");
ConsoleFD = 0;
close(fd);
goto setattribs;
}

CurrentVT = st.v_active;
close(fd);
}
/* if we close with the modifier set in glutIconifyWindow, we won't
get the signal when they are released, so set to zero here */
KeyboardModifiers = 0;

/* open the console tty */
sprintf(console, "/dev/tty%d", CurrentVT);
ConsoleFD = open(console, O_RDWR | O_NDELAY, 0);
if (ConsoleFD < 0) {
sprintf(exiterror, "error couldn't open %s,"
" defaulting to stdin \n", console);
ConsoleFD = 0;
goto setattribs;
}

signal(SIGUSR1, VTSwitchHandler);
signal(SIGUSR2, VTSwitchHandler);

if (ioctl(ConsoleFD, VT_GETMODE, &OldVTMode) < 0) {
sprintf(exiterror,"Failed to grab %s, defaulting to stdin\n", console);
close(ConsoleFD);
ConsoleFD = 0;
goto setattribs;
}

vt = OldVTMode;

vt.mode = VT_PROCESS;
vt.waitv = 0;
vt.relsig = SIGUSR1;
vt.acqsig = SIGUSR2;
if (ioctl(ConsoleFD, VT_SETMODE, &vt) < 0) {
sprintf(exiterror, "error: ioctl(VT_SETMODE) failed: %s\n",
strerror(errno));
close(ConsoleFD);
ConsoleFD = 0;
exit(1);
}

if (ioctl(ConsoleFD, KDGKBMODE, &OldKDMode) < 0) {
sprintf(exiterror, "Warning: ioctl KDGKBMODE failed!\n");
OldKDMode = K_XLATE;
}

/* use SIGIO so VT switching can work if the program is locked */
signal(SIGIO, KeyboardHandler);

pipe(kbdpipe);

if(fcntl(kbdpipe[0], F_SETFL, O_NONBLOCK | O_ASYNC) < 0) {
sprintf(exiterror, "Failed to set keyboard to non-blocking\n");
exit(0);
}

fcntl(ConsoleFD, F_SETOWN, getpid());

if(ioctl(ConsoleFD, KDGETMODE, &OldMode) < 0)
sprintf(exiterror, "Warning: Failed to get terminal mode\n");

#ifdef HAVE_GPM
if(!GpmMouse)
#endif
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");

if(ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
sprintf(exiterror, "ioctl KDSKBMODE failed!\n");
exit(0);
}

if(ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
sprintf(exiterror, "ioctl KDGKBLED failed!\n");
exit(0);
}

setattribs:
/* enable async input input */
if(fcntl(ConsoleFD, F_SETFL, O_ASYNC) < 0) {
sprintf(exiterror, "Failed to set O_ASYNC mode on fd %d\n", ConsoleFD);
exit(0);
}

/* save old terminos settings */
if (tcgetattr(ConsoleFD, &OldTermios) < 0) {
sprintf(exiterror, "tcgetattr failed\n");
exit(0);
}

tio = OldTermios;

/* terminos settings for straight-through mode */
tio.c_lflag &= ~(ICANON | ECHO | ISIG);
tio.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
tio.c_iflag |= IGNBRK;

tio.c_cc[VMIN] = 0;
tio.c_cc[VTIME] = 0;

if (tcsetattr(ConsoleFD, TCSANOW, &tio) < 0) {
sprintf(exiterror, "tcsetattr failed\n");
exit(0);
}
}

void RestoreVT(void)
{
if(ConsoleFD < 0)
return;

if (tcsetattr(ConsoleFD, TCSANOW, &OldTermios) < 0)
sprintf(exiterror, "tcsetattr failed\n");

/* setting the mode to text from graphics restores the colormap */
if(
#ifdef HAVE_GPM
!GpmMouse ||
#endif
ConsoleFD == 0)
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
goto skipioctl; /* no need to fail twice */
if(ioctl(ConsoleFD, KDSETMODE, OldMode) < 0)
fprintf(stderr, "ioctl KDSETMODE failed!\n");

skipioctl:

if(ConsoleFD == 0)
return;

/* restore keyboard state */
if (ioctl(ConsoleFD, VT_SETMODE, &OldVTMode) < 0)
fprintf(stderr, "Failed to set vtmode\n");

if (ioctl(ConsoleFD, KDSKBMODE, OldKDMode) < 0)
fprintf(stderr, "ioctl KDSKBMODE failed!\n");
close(ConsoleFD);

close(kbdpipe[0]);
close(kbdpipe[1]);
}

void InitializeMouse(void)
{
#ifdef HAVE_GPM
if(!GpmMouse)
#endif
{
const char *mousedev = getenv("MOUSE");
if(!mousedev)
mousedev = MOUSEDEV;
if((MouseFD = open(mousedev, O_RDONLY | O_NONBLOCK)) >= 0) {
if(!MouseSpeed)
MouseSpeed = 1;
NumMouseButtons = 3;
return;
}
}
#ifdef HAVE_GPM
{
Gpm_Connect conn;
int c;
conn.eventMask = ~0; /* Want to know about all the events */
conn.defaultMask = 0; /* don't handle anything by default */
conn.minMod = 0; /* want everything */
conn.maxMod = ~0; /* all modifiers included */
if(Gpm_Open(&conn, 0) != -1) {
if(!MouseSpeed)
MouseSpeed = 8;
NumMouseButtons = 3;
return;
}
fprintf(stderr, "Cannot open gpmctl.\n");
}
#endif
fprintf(stderr,"Cannot open %s.\n"
"Continuing without Mouse\n", MOUSEDEV);
}

void CloseMouse(void)
{
#ifdef HAVE_GPM
if(GpmMouse) {
if(NumMouseButtons)
Gpm_Close();
} else
#endif
if(MouseFD >= 0)
close(MouseFD);
}

+ 0
- 177
src/glut/fbdev/internal.h Näytä tiedosto

@@ -1,177 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <sys/time.h>
#include <linux/fb.h>
#include <GL/glfbdev.h>

#define MULTIHEAD /* enable multihead hacks,
it allows the program to continue drawing
without reading input when a second fbdev
has keyboard focus it can cause
screen corruption that requires C-l to fix */
#define HAVE_GPM

#define MAX_VSYNC 200

/* this causes these symbols to not be exported */
#pragma GCC visibility push(hidden)


/* --------- fbdev ------------ */
extern int Redisplay;
extern int Visible;
extern int VisibleSwitch;
extern int Active;
extern int VisiblePoll;
extern int Swapping, VTSwitch;

void TestVisible(void);
int ParseFBModes(int, int, int, int, int, int);
void SetVideoMode(void);
void CreateBuffer(void);
void CreateVisual(void);

extern int FrameBufferFD;
extern unsigned char *FrameBuffer;
extern unsigned char *BackBuffer;
extern int DisplayMode;

extern char exiterror[256];

extern struct fb_fix_screeninfo FixedInfo;
extern struct fb_var_screeninfo VarInfo;

extern GLFBDevContextPtr Context;
extern GLFBDevBufferPtr Buffer;
extern GLFBDevVisualPtr Visual;

/* --- colormap --- */
#define REVERSECMAPSIZELOG 3
#define REVERSECMAPSIZE (1<<REVERSECMAPSIZELOG)

extern unsigned short RedColorMap[256],
GreenColorMap[256],
BlueColorMap[256];
extern unsigned char ReverseColorMap[REVERSECMAPSIZE]
[REVERSECMAPSIZE]
[REVERSECMAPSIZE];

void LoadColorMap(void);
void RestoreColorMap(void);

/* --- mouse --- */
extern int MouseX, MouseY;
extern int CurrentCursor;
extern int MouseVisible;
extern int LastMouseTime;
extern int NumMouseButtons;

void InitializeCursor(void);
void EraseCursor(void);
void DrawCursor(void);
void SwapCursor(void);

/* --- menus --- */
struct GlutMenu {
int NumItems;
int x, y;
int width;
int selected;
struct {
int value;
int submenu;
char *name;
} *Items;
void (*func)(int);
};

extern struct GlutMenu *Menus;

extern int ActiveMenu;
extern int CurrentMenu;

void InitializeMenus(void);
void FreeMenus(void);
void DrawMenus(void);

int TryMenu(int, int);
void OpenMenu(void);
void CloseMenu(void);

/* --- state --- */
extern int AccumSize, DepthSize, StencilSize, NumSamples;
extern struct timeval StartTime;
extern int KeyboardModifiers;

/* --- input --- */
#ifdef HAVE_GPM
extern int GpmMouse;
#endif

extern int CurrentVT;
extern int ConsoleFD;

extern double MouseSpeed;

extern int KeyRepeatMode;

void InitializeVT(int);
void RestoreVT(void);
void CloseMouse(void);
void InitializeMouse(void);

void ReceiveInput(void);

/* --- callback --- */
extern void (*DisplayFunc)(void);
extern void (*ReshapeFunc)(int width, int height);
extern void (*KeyboardFunc)(unsigned char key, int x, int y);
extern void (*KeyboardUpFunc)(unsigned char key, int x, int y);
extern void (*MouseFunc)(int key, int state, int x, int y);
extern void (*MotionFunc)(int x, int y);
extern void (*PassiveMotionFunc)(int x, int y);
extern void (*VisibilityFunc)(int state);
extern void (*SpecialFunc)(int key, int x, int y);
extern void (*SpecialUpFunc)(int key, int x, int y);
extern void (*IdleFunc)(void);
extern void (*MenuStatusFunc)(int state, int x, int y);
extern void (*MenuStateFunc)(int state);

/* --- timers --- */
struct GlutTimer {
int time;
void (*func)(int);
int value;
struct GlutTimer *next;
};

extern struct GlutTimer *GlutTimers;

/* ------- Game Mode -------- */
extern int GameMode;

#pragma GCC visibility pop

+ 0
- 309
src/glut/fbdev/menu.c Näytä tiedosto

@@ -1,309 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <linux/fb.h>

#include <GL/glut.h>

#include "internal.h"

#define MENU_FONT_WIDTH 9
#define MENU_FONT_HEIGHT 15
#define MENU_FONT GLUT_BITMAP_9_BY_15
#define SUBMENU_OFFSET 20

struct GlutMenu *Menus;
int ActiveMenu;
int CurrentMenu;

static double MenuProjection[16];

static int AttachedMenus[3];
static int NumMenus = 1;
static int SelectedMenu;

void InitializeMenus(void)
{
glPushAttrib(GL_TRANSFORM_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, VarInfo.xres, VarInfo.yres, 0.0);
glGetDoublev(GL_PROJECTION_MATRIX, MenuProjection);

glPopMatrix();
glPopAttrib();
}

void FreeMenus(void)
{
int i, j;
for(i = 1; i<NumMenus; i++) {
for(j = 0; j<Menus[i].NumItems; j++)
free(Menus[i].Items[j].name);
free(Menus[i].Items);
}
free(Menus);
}

int TryMenu(int button, int pressed)
{
if(ActiveMenu && !pressed) {
ActiveMenu = 0;
CloseMenu();
Redisplay = 1;
return 1;
}

if(AttachedMenus[button] && pressed) {
ActiveMenu = AttachedMenus[button];
OpenMenu();
Redisplay = 1;
return 1;
}
return 0;
}

static int DrawMenu(int menu, int x, int *y)
{
int i;
int ret = 1;

for(i=0; i < Menus[menu].NumItems; i++) {
char *s = Menus[menu].Items[i].name;
int a = 0;
if(MouseY >= *y && MouseY < *y + MENU_FONT_HEIGHT &&
MouseX >= x && MouseX < x + Menus[menu].width) {
a = 1;
SelectedMenu = menu;
ret = 0;
Menus[menu].selected = i;
glColor3f(1,0,0);
} else
glColor3f(1,1,1);

*y += MENU_FONT_HEIGHT;
glRasterPos2i(x, *y);
for(; *s; s++)
glutBitmapCharacter(MENU_FONT, *s);

if(Menus[menu].selected == i)
if(Menus[menu].Items[i].submenu)
if(DrawMenu(Menus[menu].Items[i].submenu, x
+ SUBMENU_OFFSET, y)) {
if(!a)
Menus[menu].selected = -1;
} else
ret = 0;
}
return ret;
}

void DrawMenus(void)
{
int x, y;

if(GameMode)
return;

x = Menus[ActiveMenu].x;
y = Menus[ActiveMenu].y;

/* save old settings */
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT
| GL_ENABLE_BIT | GL_VIEWPORT_BIT);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixd(MenuProjection);
glViewport(0, 0, VarInfo.xres, VarInfo.yres);

glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDisable(GL_TEXTURE_2D);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_AND_REVERSE);

if(DrawMenu(ActiveMenu, x, &y))
Menus[ActiveMenu].selected = -1;
/* restore settings */
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glPopAttrib();
}

void OpenMenu(void)
{
if(MenuStatusFunc)
MenuStatusFunc(GLUT_MENU_IN_USE, MouseX, MouseY);
if(MenuStateFunc)
MenuStateFunc(GLUT_MENU_IN_USE);
Menus[ActiveMenu].x = MouseX-Menus[ActiveMenu].width/2;

if(Menus[ActiveMenu].x < 0)
Menus[ActiveMenu].x = 0;
if(Menus[ActiveMenu].x + Menus[ActiveMenu].width >= VarInfo.xres)
Menus[ActiveMenu].x = VarInfo.xres - Menus[ActiveMenu].width - 1;

Menus[ActiveMenu].y = MouseY-Menus[ActiveMenu].NumItems*MENU_FONT_HEIGHT/2;
Menus[ActiveMenu].selected = -1;
}

void CloseMenu(void)
{
if(MenuStatusFunc)
MenuStatusFunc(GLUT_MENU_NOT_IN_USE, MouseX, MouseY);
if(MenuStateFunc)
MenuStateFunc(GLUT_MENU_NOT_IN_USE);
if(SelectedMenu > 0) {
int selected = Menus[SelectedMenu].selected;
if(selected >= 0)
if(Menus[SelectedMenu].Items[selected].submenu == 0)
Menus[SelectedMenu].func(Menus[SelectedMenu].Items
[selected].value);
}

}

/* glut menu functions */

int glutCreateMenu(void (*func)(int value))
{
CurrentMenu = NumMenus;
NumMenus++;
Menus = realloc(Menus, sizeof(*Menus) * NumMenus);
Menus[CurrentMenu].NumItems = 0;
Menus[CurrentMenu].Items = NULL;
Menus[CurrentMenu].func = func;
Menus[CurrentMenu].width = 0;
return CurrentMenu;
}

void glutSetMenu(int menu)
{
CurrentMenu = menu;
}

int glutGetMenu(void)
{
return CurrentMenu;
}

void glutDestroyMenu(int menu)
{
if(menu == CurrentMenu)
CurrentMenu = 0;
}

static void NameMenuEntry(int entry, const char *name)
{
int cm = CurrentMenu;
if(!(Menus[cm].Items[entry-1].name = realloc(Menus[cm].Items[entry-1].name,
strlen(name) + 1))) {
sprintf(exiterror, "realloc failed in NameMenuEntry\n");
exit(0);
}
strcpy(Menus[cm].Items[entry-1].name, name);
if(strlen(name) * MENU_FONT_WIDTH > Menus[cm].width)
Menus[cm].width = strlen(name) * MENU_FONT_WIDTH;
}

static int AddMenuItem(const char *name)
{
int cm = CurrentMenu;
int item = Menus[cm].NumItems++;
if(!(Menus[cm].Items = realloc(Menus[cm].Items,
Menus[cm].NumItems * sizeof(*Menus[0].Items)))) {
sprintf(exiterror, "realloc failed in AddMenuItem\n");
exit(0);
}
Menus[cm].Items[item].name = NULL;
NameMenuEntry(item+1, name);
return item;
}

void glutAddMenuEntry(const char *name, int value)
{
int item = AddMenuItem(name);
Menus[CurrentMenu].Items[item].value = value;
Menus[CurrentMenu].Items[item].submenu = 0;
}

void glutAddSubMenu(const char *name, int menu)
{
int item = AddMenuItem(name);
if(menu == CurrentMenu) {
sprintf(exiterror, "Recursive menus not supported\n");
exit(0);
}
Menus[CurrentMenu].Items[item].submenu = menu;
}

void glutChangeToMenuEntry(int entry, const char *name, int value)
{
NameMenuEntry(entry, name);
Menus[CurrentMenu].Items[entry-1].value = value;
Menus[CurrentMenu].Items[entry-1].submenu = 0;
}

void glutChangeToSubMenu(int entry, const char *name, int menu)
{
NameMenuEntry(entry, name);
Menus[CurrentMenu].Items[entry-1].submenu = menu;
}

void glutRemoveMenuItem(int entry)
{
memmove(Menus[CurrentMenu].Items + entry - 1,
Menus[CurrentMenu].Items + entry,
sizeof(*Menus[0].Items) * (Menus[CurrentMenu].NumItems - entry));
Menus[CurrentMenu].NumItems--;
}

void glutAttachMenu(int button)
{
AttachedMenus[button] = CurrentMenu;
}

void glutDetachMenu(int button)
{
AttachedMenus[button] = 0;
}

+ 0
- 57
src/glut/fbdev/overlay.c Näytä tiedosto

@@ -1,57 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <stdlib.h>
#include <GL/gl.h>

void glutEstablishOverlay(void)
{
exit(0);
}

void glutUseLayer(GLenum layer)
{
}

void glutRemoveOverlay(void)
{
}

void glutPostOverlayRedisplay(void)
{
}

void glutPostWindowOverlayRedisplay(int win)
{
}

void glutShowOverlay(void)
{
}

void glutHideOverlay(void)
{
}

+ 0
- 197
src/glut/fbdev/state.c Näytä tiedosto

@@ -1,197 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

#include <string.h>
#include <sys/time.h>

#include <linux/fb.h>

#include <GL/glut.h>

#include "../../mesa/main/config.h"

#include "internal.h"

int AccumSize = 16; /* per channel size of accumulation buffer */
int DepthSize = DEFAULT_SOFTWARE_DEPTH_BITS;
int StencilSize = STENCIL_BITS;
int NumSamples = 4;

int glutGet(GLenum state)
{
switch(state) {
case GLUT_WINDOW_X:
return 0;
case GLUT_WINDOW_Y:
return 0;
case GLUT_INIT_WINDOW_WIDTH:
case GLUT_WINDOW_WIDTH:
case GLUT_SCREEN_WIDTH:
return VarInfo.xres;
case GLUT_INIT_WINDOW_HEIGHT:
case GLUT_WINDOW_HEIGHT:
case GLUT_SCREEN_HEIGHT:
return VarInfo.yres;
case GLUT_WINDOW_BUFFER_SIZE:
return VarInfo.bits_per_pixel;
case GLUT_WINDOW_STENCIL_SIZE:
return StencilSize;
case GLUT_WINDOW_DEPTH_SIZE:
return DepthSize;
case GLUT_WINDOW_RED_SIZE:
return VarInfo.red.length;
case GLUT_WINDOW_GREEN_SIZE:
return VarInfo.green.length;
case GLUT_WINDOW_BLUE_SIZE:
return VarInfo.green.length;
case GLUT_WINDOW_ALPHA_SIZE:
return VarInfo.transp.length;
case GLUT_WINDOW_ACCUM_RED_SIZE:
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
return AccumSize;
case GLUT_WINDOW_DOUBLEBUFFER:
if(DisplayMode & GLUT_DOUBLE)
return 1;
return 0;
case GLUT_WINDOW_RGBA:
if(DisplayMode & GLUT_INDEX)
return 0;
return 1;
case GLUT_WINDOW_PARENT:
return 0;
case GLUT_WINDOW_NUM_CHILDREN:
return 0;
case GLUT_WINDOW_COLORMAP_SIZE:
if(DisplayMode & GLUT_INDEX)
return 256;
return 0;
case GLUT_WINDOW_NUM_SAMPLES:
return NumSamples;
case GLUT_WINDOW_STEREO:
return 0;
case GLUT_WINDOW_CURSOR:
return CurrentCursor;
case GLUT_SCREEN_WIDTH_MM:
return VarInfo.width;
case GLUT_SCREEN_HEIGHT_MM:
return VarInfo.height;
case GLUT_MENU_NUM_ITEMS:
if(CurrentMenu)
return Menus[CurrentMenu].NumItems;
return 0;
case GLUT_DISPLAY_MODE_POSSIBLE:
if((DisplayMode & GLUT_MULTISAMPLE)
|| (DisplayMode & GLUT_STEREO)
|| (DisplayMode & GLUT_LUMINANCE)
|| (DisplayMode & GLUT_ALPHA) && (DisplayMode & GLUT_INDEX))
return 0;
return 1;
case GLUT_INIT_DISPLAY_MODE:
return DisplayMode;
case GLUT_INIT_WINDOW_X:
case GLUT_INIT_WINDOW_Y:
return 0;
case GLUT_ELAPSED_TIME:
{
static struct timeval tv;
gettimeofday(&tv, 0);
return 1000 * (tv.tv_sec - StartTime.tv_sec)
+ (tv.tv_usec - StartTime.tv_usec) / 1000;
}
}
return -1;
}

int glutLayerGet(GLenum info)
{
switch(info) {
case GLUT_OVERLAY_POSSIBLE:
return 0;
case GLUT_LAYER_IN_USE:
return GLUT_NORMAL;
case GLUT_HAS_OVERLAY:
return 0;
case GLUT_TRANSPARENT_INDEX:
return -1;
case GLUT_NORMAL_DAMAGED:
return Redisplay;
case GLUT_OVERLAY_DAMAGED:
return -1;
}
return -1;
}

int glutDeviceGet(GLenum info)
{
switch(info) {
case GLUT_HAS_KEYBOARD:
return ConsoleFD != -1 ? 1 : 0;
case GLUT_HAS_MOUSE:
case GLUT_NUM_MOUSE_BUTTONS:
return NumMouseButtons;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return 0;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return KeyRepeatMode == GLUT_KEY_REPEAT_OFF;
case GLUT_DEVICE_KEY_REPEAT:
return KeyRepeatMode;
case GLUT_JOYSTICK_POLL_RATE:
case GLUT_HAS_JOYSTICK:
case GLUT_JOYSTICK_BUTTONS:
case GLUT_JOYSTICK_AXES:
return 0;
}
return -1;
}

int glutGetModifiers(void){
return KeyboardModifiers;
}

int glutExtensionSupported(const char *extension)
{
const char *exts = (const char *) glGetString(GL_EXTENSIONS);
const char *start = exts;
int len = strlen(extension);
for(;;) {
const char *p = strstr(exts, extension);
if(!p)
break;
if((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
return 1;
exts = p + len;
}
return 0;
}

+ 0
- 81
src/glut/fbdev/stroke.c Näytä tiedosto

@@ -1,81 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/

#include <GL/glut.h>
#include "glutstroke.h"

void glutStrokeCharacter(GLUTstrokeFont font, int c)
{
const StrokeCharRec *ch;
const StrokeRec *stroke;
const CoordRec *coord;
StrokeFontPtr fontinfo = (StrokeFontPtr) font;
int i, j;

if (c < 0 || c >= fontinfo->num_chars)
return;
ch = &(fontinfo->ch[c]);
if (ch) {
for (i = ch->num_strokes, stroke = ch->stroke;
i > 0; i--, stroke++) {
glBegin(GL_LINE_STRIP);
for (j = stroke->num_coords, coord = stroke->coord;
j > 0; j--, coord++) {
glVertex2f(coord->x, coord->y);
}
glEnd();
}
glTranslatef(ch->right, 0.0, 0.0);
}
}

int glutStrokeWidth(GLUTstrokeFont font, int c)
{
StrokeFontPtr fontinfo;
const StrokeCharRec *ch;

fontinfo = (StrokeFontPtr) font;

if (c < 0 || c >= fontinfo->num_chars)
return 0;
ch = &(fontinfo->ch[c]);
if (ch)
return ch->right;

return 0;
}

int glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
{
int length = 0;

for (; *string; string++)
length += glutStrokeWidth(font, *string);
return length;
}

+ 0
- 55
src/glut/fbdev/vidresize.c Näytä tiedosto

@@ -1,55 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/

/* Notice, if you know how to implement these functions correctly
please proceed */

#include <stdlib.h>

#include <GL/glut.h>

#include "internal.h"

int glutVideoResizeGet(GLenum param)
{
return 0;
}

void glutSetupVideoResizing(void)
{
}

void glutStopVideoResizing(void)
{
}

void glutVideoResize(int x, int y, int width, int height)
{
}

void glutVideoPan(int x, int y, int width, int height)
{
}

+ 0
- 420
src/glut/os2/Makefile Näytä tiedosto

@@ -1,420 +0,0 @@
# Makefile
# Created by IBM WorkFrame/2 MakeMake at 12:46:25 on 3 June 2003
#
# The actions included in this make file are:
# Compile::C++ Compiler
# Link::Linker
# Lib::Import Lib

.SUFFIXES:

.SUFFIXES: \
.LIB .cpp .dll .obj

.cpp.obj:
@echo " Compile::C++ Compiler "
icc.exe /I..\ /I..\X86 /I..\GL /I..\swrast /I..\swrast_setup /Ss /Wcmpcndcnscnvcpydclenuextgeninilanobsordparporppcprorearettrdtruund /Tx /O /Gm /Ge- /G5 /Gf /Gi /Oi /C %s

{G:\EVGEN\MESA5\src-glut.os2pm}.cpp.obj:
@echo " Compile::C++ Compiler "
icc.exe /I..\ /I..\X86 /I..\GL /I..\swrast /I..\swrast_setup /Ss /Wcmpcndcnscnvcpydclenuextgeninilanobsordparporppcprorearettrdtruund /Tx /O /Gm /Ge- /G5 /Gf /Gi /Oi /C %s

.dll.LIB:
@echo " Lib::Import Lib "
implib.exe %|dpfF.LIB %s

{G:\EVGEN\MESA5\src-glut.os2pm}.dll.LIB:
@echo " Lib::Import Lib "
implib.exe %|dpfF.LIB %s

all: \
.\libGlut.LIB

.\libGlut.dll: \
.\os2_winproc.obj \
.\WarpWin.obj \
.\glutOverlay.obj \
.\glut_8x13.obj \
.\glut_9x15.obj \
.\glut_bitmap.obj \
.\glut_cindex.obj \
.\glut_cmap.obj \
.\glut_cursor.obj \
.\glut_event.obj \
.\glut_ext.obj \
.\glut_fullscrn.obj \
.\glut_gamemode.obj \
.\glut_get.obj \
.\glut_hel10.obj \
.\glut_hel12.obj \
.\glut_hel18.obj \
.\glut_init.obj \
.\glut_input.obj \
.\glut_key.obj \
.\glut_keyctrl.obj \
.\glut_keyup.obj \
.\glut_mesa.obj \
.\glut_modifier.obj \
.\glut_roman.obj \
.\glut_shapes.obj \
.\glut_stroke.obj \
.\glut_swap.obj \
.\glut_teapot.obj \
.\glut_tr24.obj \
.\glut_util.obj \
.\glut_vidresize.obj \
.\glut_warp.obj \
.\glut_win.obj \
.\glut_winmisc.obj \
.\os2_glx.obj \
.\os2_menu.obj \
..\si-glu\libGLU.lib \
..\MesaDll\MesaGL2.lib \
..\drv\DrvLoad\MesaDrvLoad.lib \
{$(LIB)}libGlut.DEF
@echo " Link::Linker "
icc.exe @<<
/B" /dbgpack /exepack:2 /st:200000 /packd /optfunc"
/FelibGlut.dll
..\si-glu\libGLU.lib
..\MesaDll\MesaGL2.lib
..\drv\DrvLoad\MesaDrvLoad.lib
libGlut.DEF
.\os2_winproc.obj
.\WarpWin.obj
.\glutOverlay.obj
.\glut_8x13.obj
.\glut_9x15.obj
.\glut_bitmap.obj
.\glut_cindex.obj
.\glut_cmap.obj
.\glut_cursor.obj
.\glut_event.obj
.\glut_ext.obj
.\glut_fullscrn.obj
.\glut_gamemode.obj
.\glut_get.obj
.\glut_hel10.obj
.\glut_hel12.obj
.\glut_hel18.obj
.\glut_init.obj
.\glut_input.obj
.\glut_key.obj
.\glut_keyctrl.obj
.\glut_keyup.obj
.\glut_mesa.obj
.\glut_modifier.obj
.\glut_roman.obj
.\glut_shapes.obj
.\glut_stroke.obj
.\glut_swap.obj
.\glut_teapot.obj
.\glut_tr24.obj
.\glut_util.obj
.\glut_vidresize.obj
.\glut_warp.obj
.\glut_win.obj
.\glut_winmisc.obj
.\os2_glx.obj
.\os2_menu.obj
<<

.\os2_winproc.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\os2_winproc.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
gl\os2mesa.h \
gl\gl.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2mesadef.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}context.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glapi.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}mtypes.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glheader.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}config.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glapitable.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glthread.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}math/m_matrix.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}Trace/tr_context.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}dd.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}conf.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_config.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/glext.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}Xthreads.h

.\os2_menu.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\os2_menu.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\os2_glx.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\os2_glx.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
gl\os2mesa.h \
gl\gl.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h

.\glut_winmisc.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_winmisc.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_win.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_win.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutos2.h \
gl\os2mesa.h \
gl\gl.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h

.\glut_warp.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_warp.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_vidresize.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_vidresize.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_util.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_util.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_tr24.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_tr24.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glut_teapot.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_teapot.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_swap.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_swap.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_stroke.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_stroke.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_shapes.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_shapes.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_roman.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_roman.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h

.\glut_modifier.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_modifier.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_mesa.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_mesa.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_keyup.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_keyup.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_keyctrl.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_keyctrl.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_key.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_key.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_input.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_input.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_init.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_init.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_hel18.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel18.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glut_hel12.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel12.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glut_hel10.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel10.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glut_get.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_get.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_gamemode.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_gamemode.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_fullscrn.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_fullscrn.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_ext.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_ext.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_event.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_event.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_cursor.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_cursor.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_cmap.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_cmap.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}layerutil.h

.\glut_cindex.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_cindex.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_bitmap.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_bitmap.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\glut_9x15.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_9x15.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glut_8x13.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glut_8x13.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h

.\glutOverlay.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\glutOverlay.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h

.\WarpWin.obj: \
G:\EVGEN\MESA5\src-glut.os2pm\WarpWin.cpp \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpWin.h \
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h

.\libGlut.LIB: \
.\libGlut.dll

+ 0
- 419
src/glut/os2/WarpWin.cpp Näytä tiedosto

@@ -1,419 +0,0 @@
/* 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;
}


+ 0
- 133
src/glut/os2/glutOverlay.cpp Näytä tiedosto

@@ -1,133 +0,0 @@
/***********************************************************
* Copyright (C) 1997, Be Inc. All rights reserved.
*
* FILE: glutOverlay.cpp
*
* DESCRIPTION: we don't support overlays, so this code is
* really simple
***********************************************************/

/***********************************************************
* Headers
***********************************************************/
#include <GL/glut.h>
#include "glutint.h"
#include "glutbitmap.h"
#include "glutstroke.h"

GLUTAPI void GLUTAPIENTRY
glutEstablishOverlay(void)
{
__glutFatalError("OS2PM lacks overlay support.");
}

GLUTAPI void GLUTAPIENTRY
glutUseLayer(GLenum layer) {
// ignore
}

GLUTAPI void GLUTAPIENTRY
glutRemoveOverlay(void) {
// ignore
}

GLUTAPI void GLUTAPIENTRY
glutPostOverlayRedisplay(void) {
// ignore
}

GLUTAPI void GLUTAPIENTRY
glutShowOverlay(void) {
// ignore
}

GLUTAPI void GLUTAPIENTRY glutHideOverlay(void)
{
// ignore
}

int GLUTAPIENTRY
glutLayerGet(GLenum param)
{
// ignore
}

/***********************************************************
* Unsupported callbacks
***********************************************************/
GLUTAPI void GLUTAPIENTRY
glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutDialsFunc(GLUTdialsCB dialsFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
{
}

GLUTAPI void GLUTAPIENTRY
glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
{
}
GLUTAPI void GLUTAPIENTRY
glutPostWindowOverlayRedisplay(int win)
{ //
}

void GLUTAPIENTRY
glutInitDisplayString(const char *string)
{ //
}
void GLUTAPIENTRY
glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
{ //
}

void GLUTAPIENTRY
glutForceJoystickFunc(void)
{ //
}


int GLUTAPIENTRY
glutBitmapWidth(GLUTbitmapFont font, int c)
{ return 0;
}
int GLUTAPIENTRY
glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
{ //
return 0;
}
int GLUTAPIENTRY
glutStrokeWidth(GLUTstrokeFont font, int c)
{ return 0;
}
int GLUTAPIENTRY
glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
{ return 0;
}

+ 0
- 2076
src/glut/os2/glut_8x13.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 2077
src/glut/os2/glut_9x15.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 57
src/glut/os2/glut_bitmap.cpp Näytä tiedosto

@@ -1,57 +0,0 @@

/* 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 "glutint.h"
#include "glutbitmap.h"

void GLUTAPIENTRY
glutBitmapCharacter(GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fontinfo;
GLint swapbytes, lsbfirst, rowlength;
GLint skiprows, skippixels, alignment;

#if defined(_WIN32)
fontinfo = (BitmapFontPtr) __glutFont(font);
#else
fontinfo = (BitmapFontPtr) font;
#endif

if (c < fontinfo->first ||
c >= fontinfo->first + fontinfo->num_chars)
return;
ch = fontinfo->ch[c - fontinfo->first];
if (ch) {
/* Save current modes. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
/* Little endian machines (DEC Alpha for example) could
benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
instead of GL_FALSE, but this would require changing the
generated bitmaps too. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
ch->advance, 0, ch->bitmap);
/* Restore saved modes. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
}

+ 0
- 258
src/glut/os2/glut_cindex.cpp Näytä tiedosto

@@ -1,258 +0,0 @@

/* 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 */

+ 0
- 399
src/glut/os2/glut_cmap.cpp Näytä tiedosto

@@ -1,399 +0,0 @@

/* 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. */

#ifdef __VMS
//EK#include <GL/vms_x_fix.h>
#endif

#include <stdlib.h>
#include <string.h>
#include <stdio.h> /* SunOS multithreaded assert() needs <stdio.h>. Lame. */
#include <assert.h>
#if !defined(_WIN32) && !defined(__OS2__)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
#if defined(__vms)
#include <Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
#else
#include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
#endif
#endif

/* SGI optimization introduced in IRIX 6.3 to avoid X server
round trips for interning common X atoms. */
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
#include <X11/SGIFastAtom.h>
#else
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
#endif

#include "glutint.h"
#include "layerutil.h"

GLUTcolormap *__glutColormapList = NULL;

GLUTcolormap *
__glutAssociateNewColormap(XVisualInfo * vis)
{
GLUTcolormap *cmap;
int transparentPixel, i;
unsigned long pixels[255];

cmap = (GLUTcolormap *) malloc(sizeof(GLUTcolormap));
if (!cmap)
__glutFatalError("out of memory.");
#if defined(_WIN32) || defined(__OS2__)
pixels[0] = 0; /* avoid compilation warnings on win32 */
cmap->visual = 0;
cmap->size = 256; /* always assume 256 on Win32 */
#else
cmap->visual = vis->visual;
cmap->size = vis->visual->map_entries;
#endif
cmap->refcnt = 1;
cmap->cells = (GLUTcolorcell *)
malloc(sizeof(GLUTcolorcell) * cmap->size);
if (!cmap->cells)
__glutFatalError("out of memory.");
/* make all color cell entries be invalid */
for (i = cmap->size - 1; i >= 0; i--) {
cmap->cells[i].component[GLUT_RED] = -1.0;
cmap->cells[i].component[GLUT_GREEN] = -1.0;
cmap->cells[i].component[GLUT_BLUE] = -1.0;
}
transparentPixel = __glutGetTransparentPixel(__glutDisplay, vis);
if (transparentPixel == -1 || transparentPixel >= cmap->size) {

/* If there is no transparent pixel or if the transparent
pixel is outside the range of valid colormap cells (HP
can implement their overlays this smart way since their
transparent pixel is 255), we can AllocAll the colormap.
See note below. */

cmap->cmap = XCreateColormap(__glutDisplay,
__glutRoot, cmap->visual, AllocAll);
} else {

/* On machines where zero (or some other value in the range
of 0 through map_entries-1), BadAlloc may be generated
when an AllocAll overlay colormap is allocated since the
transparent pixel precludes all the cells in the colormap
being allocated (the transparent pixel is pre-allocated).
So in this case, use XAllocColorCells to allocate
map_entries-1 pixels (that is, all but the transparent
pixel. */

#if defined(_WIN32) || defined(__OS2__)
cmap->cmap = XCreateColormap(__glutDisplay,
__glutRoot, 0, AllocNone);
#else
cmap->cmap = XCreateColormap(__glutDisplay,
__glutRoot, vis->visual, AllocNone);
XAllocColorCells(__glutDisplay, cmap->cmap, False, 0, 0,
pixels, cmap->size - 1);
#endif
}
cmap->next = __glutColormapList;
__glutColormapList = cmap;
return cmap;
}

static GLUTcolormap *
associateColormap(XVisualInfo * vis)
{
#if !defined(_WIN32) && !defined(__OS2__)
GLUTcolormap *cmap = __glutColormapList;

while (cmap != NULL) {
/* Play safe: compare visual IDs, not Visual*'s. */
if (cmap->visual->visualid == vis->visual->visualid) {
/* Already have created colormap for the visual. */
cmap->refcnt++;
return cmap;
}
cmap = cmap->next;
}
#endif
return __glutAssociateNewColormap(vis);
}

void
__glutSetupColormap(XVisualInfo * vi, GLUTcolormap ** colormap, Colormap * cmap)
{
#if defined(_WIN32) || defined(__OS2__)
if (vi->dwFlags & PFD_NEED_PALETTE || vi->iPixelType == PFD_TYPE_COLORINDEX) {
*colormap = associateColormap(vi);
*cmap = (*colormap)->cmap;
} else {
*colormap = NULL;
*cmap = 0;
}
#else
Status status;
XStandardColormap *standardCmaps;
int i, numCmaps;
static Atom hpColorRecoveryAtom = -1;
int isRGB, visualClass, rc;

#if defined(__cplusplus) || defined(c_plusplus)
visualClass = vi->c_class;
#else
visualClass = vi->class;
#endif
switch (visualClass) {
case PseudoColor:
/* Mesa might return a PseudoColor visual for RGB mode. */
rc = glXGetConfig(__glutDisplay, vi, GLX_RGBA, &isRGB);
if (rc == 0 && isRGB) {
/* Must be Mesa. */
*colormap = NULL;
if (MaxCmapsOfScreen(DefaultScreenOfDisplay(__glutDisplay)) == 1
&& vi->visual == DefaultVisual(__glutDisplay, __glutScreen)) {
char *privateCmap = getenv("MESA_PRIVATE_CMAP");

if (privateCmap) {
/* User doesn't want to share colormaps. */
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
vi->visual, AllocNone);
} else {
/* Share the root colormap. */
*cmap = DefaultColormap(__glutDisplay, __glutScreen);
}
} else {
/* Get our own PseudoColor colormap. */
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
vi->visual, AllocNone);
}
} else {
/* CI mode, real GLX never returns a PseudoColor visual
for RGB mode. */
*colormap = associateColormap(vi);
*cmap = (*colormap)->cmap;
}
break;
case TrueColor:
case DirectColor:
*colormap = NULL; /* NULL if RGBA */

/* Hewlett-Packard supports a feature called "HP Color
Recovery". Mesa has code to use HP Color Recovery. For
Mesa to use this feature, the atom
_HP_RGB_SMOOTH_MAP_LIST must be defined on the root
window AND the colormap obtainable by XGetRGBColormaps
for that atom must be set on the window. If that
colormap is not set, the output will look stripy. */

if (hpColorRecoveryAtom == -1) {
char *xvendor;

#define VENDOR_HP "Hewlett-Packard"

/* Only makes sense to make XInternAtom round-trip if we
know that we are connected to an HP X server. */
xvendor = ServerVendor(__glutDisplay);
if (!strncmp(xvendor, VENDOR_HP, sizeof(VENDOR_HP) - 1)) {
hpColorRecoveryAtom = XInternAtom(__glutDisplay, "_HP_RGB_SMOOTH_MAP_LIST", True);
} else {
hpColorRecoveryAtom = None;
}
}
if (hpColorRecoveryAtom != None) {
status = XGetRGBColormaps(__glutDisplay, __glutRoot,
&standardCmaps, &numCmaps, hpColorRecoveryAtom);
if (status == 1) {
for (i = 0; i < numCmaps; i++) {
if (standardCmaps[i].visualid == vi->visualid) {
*cmap = standardCmaps[i].colormap;
XFree(standardCmaps);
return;
}
}
XFree(standardCmaps);
}
}
#ifndef SOLARIS_2_4_BUG
/* Solaris 2.4 and 2.5 have a bug in their
XmuLookupStandardColormap implementations. Please
compile your Solaris 2.4 or 2.5 version of GLUT with
-DSOLARIS_2_4_BUG to work around this bug. The symptom
of the bug is that programs will get a BadMatch error
from X_CreateWindow when creating a GLUT window because
Solaris 2.4 and 2.5 create a corrupted RGB_DEFAULT_MAP
property. Note that this workaround prevents Colormap
sharing between applications, perhaps leading
unnecessary colormap installations or colormap flashing.
Sun fixed this bug in Solaris 2.6. */
status = XmuLookupStandardColormap(__glutDisplay,
vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP,
/* replace */ False, /* retain */ True);
if (status == 1) {
status = XGetRGBColormaps(__glutDisplay, __glutRoot,
&standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
if (status == 1) {
for (i = 0; i < numCmaps; i++) {
if (standardCmaps[i].visualid == vi->visualid) {
*cmap = standardCmaps[i].colormap;
XFree(standardCmaps);
return;
}
}
XFree(standardCmaps);
}
}
#endif
/* If no standard colormap but TrueColor, just make a
private one. */
/* XXX Should do a better job of internal sharing for
privately allocated TrueColor colormaps. */
/* XXX DirectColor probably needs ramps hand initialized! */
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
vi->visual, AllocNone);
break;
case StaticColor:
case StaticGray:
case GrayScale:
/* Mesa supports these visuals */
*colormap = NULL;
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
vi->visual, AllocNone);
break;
default:
__glutFatalError(
"could not allocate colormap for visual type: %d.",
visualClass);
}
return;
#endif
}

#if !defined(_WIN32) && !defined(__OS2__)
static int
findColormaps(GLUTwindow * window,
Window * winlist, Colormap * cmaplist, int num, int max)
{
GLUTwindow *child;
int i;

/* Do not allow more entries that maximum number of
colormaps! */
if (num >= max)
return num;
/* Is cmap for this window already on the list? */
for (i = 0; i < num; i++) {
if (cmaplist[i] == window->cmap)
goto normalColormapAlreadyListed;
}
/* Not found on the list; add colormap and window. */
winlist[num] = window->win;
cmaplist[num] = window->cmap;
num++;

normalColormapAlreadyListed:

/* Repeat above but for the overlay colormap if there one. */
if (window->overlay) {
if (num >= max)
return num;
for (i = 0; i < num; i++) {
if (cmaplist[i] == window->overlay->cmap)
goto overlayColormapAlreadyListed;
}
winlist[num] = window->overlay->win;
cmaplist[num] = window->overlay->cmap;
num++;
}
overlayColormapAlreadyListed:

/* Recursively search children. */
child = window->children;
while (child) {
num = findColormaps(child, winlist, cmaplist, num, max);
child = child->siblings;
}
return num;
}

void
__glutEstablishColormapsProperty(GLUTwindow * window)
{
/* this routine is strictly X. Win32 doesn't need to do
anything of this sort (but has to do other wacky stuff
later). */
static Atom wmColormapWindows = None;
Window *winlist;
Colormap *cmaplist;
Status status;
int maxcmaps, num;

assert(!window->parent);
maxcmaps = MaxCmapsOfScreen(ScreenOfDisplay(__glutDisplay,
__glutScreen));
/* For portability reasons we don't use alloca for winlist
and cmaplist, but we could. */
winlist = (Window *) malloc(maxcmaps * sizeof(Window));
cmaplist = (Colormap *) malloc(maxcmaps * sizeof(Colormap));
num = findColormaps(window, winlist, cmaplist, 0, maxcmaps);
if (num < 2) {
/* Property no longer needed; remove it. */
wmColormapWindows = XSGIFastInternAtom(__glutDisplay,
"WM_COLORMAP_WINDOWS", SGI_XA_WM_COLORMAP_WINDOWS, False);
if (wmColormapWindows == None) {
__glutWarning("Could not intern X atom for WM_COLORMAP_WINDOWS.");
return;
}
XDeleteProperty(__glutDisplay, window->win, wmColormapWindows);
} else {
status = XSetWMColormapWindows(__glutDisplay, window->win,
winlist, num);
/* XSetWMColormapWindows should always work unless the
WM_COLORMAP_WINDOWS property cannot be intern'ed. We
check to be safe. */
if (status == False)
__glutFatalError("XSetWMColormapWindows returned False.");
}
/* For portability reasons we don't use alloca for winlist
and cmaplist, but we could. */
free(winlist);
free(cmaplist);
}

GLUTwindow *
__glutToplevelOf(GLUTwindow * window)
{
while (window->parent) {
window = window->parent;
}
return window;
}
#endif

void
__glutFreeColormap(GLUTcolormap * cmap)
{
GLUTcolormap *cur, **prev;

cmap->refcnt--;
if (cmap->refcnt == 0) {
/* remove from colormap list */
cur = __glutColormapList;
prev = &__glutColormapList;
while (cur) {
if (cur == cmap) {
*prev = cmap->next;
break;
}
prev = &(cur->next);
cur = cur->next;
}
/* actually free colormap */
XFreeColormap(__glutDisplay, cmap->cmap);
free(cmap->cells);
free(cmap);
}
}


+ 0
- 210
src/glut/os2/glut_cursor.cpp Näytä tiedosto

@@ -1,210 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1995, 1998. */

/* 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 "glutint.h"

#if !defined(_WIN32) && !defined(__OS2PM__)
#include <X11/Xatom.h> /* For XA_CURSOR */
#include <X11/cursorfont.h>
#endif

typedef struct _CursorTable {
#if defined(_WIN32)
char* glyph;
#else
int glyph;
#endif
Cursor cursor;
} CursorTable;
/* *INDENT-OFF* */

static CursorTable cursorTable[] = {
{XC_arrow, None}, /* GLUT_CURSOR_RIGHT_ARROW */
{XC_top_left_arrow, None}, /* GLUT_CURSOR_LEFT_ARROW */
{XC_hand1, None}, /* GLUT_CURSOR_INFO */
{XC_pirate, None}, /* GLUT_CURSOR_DESTROY */
{XC_question_arrow, None}, /* GLUT_CURSOR_HELP */
{XC_exchange, None}, /* GLUT_CURSOR_CYCLE */
{XC_spraycan, None}, /* GLUT_CURSOR_SPRAY */
{XC_watch, None}, /* GLUT_CURSOR_WAIT */
{XC_xterm, None}, /* GLUT_CURSOR_TEXT */
{XC_crosshair, None}, /* GLUT_CURSOR_CROSSHAIR */
{XC_sb_v_double_arrow, None}, /* GLUT_CURSOR_UP_DOWN */
{XC_sb_h_double_arrow, None}, /* GLUT_CURSOR_LEFT_RIGHT */
{XC_top_side, None}, /* GLUT_CURSOR_TOP_SIDE */
{XC_bottom_side, None}, /* GLUT_CURSOR_BOTTOM_SIDE */
{XC_left_side, None}, /* GLUT_CURSOR_LEFT_SIDE */
{XC_right_side, None}, /* GLUT_CURSOR_RIGHT_SIDE */
{XC_top_left_corner, None}, /* GLUT_CURSOR_TOP_LEFT_CORNER */
{XC_top_right_corner, None}, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
{XC_bottom_right_corner, None}, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
{XC_bottom_left_corner, None}, /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
};
/* *INDENT-ON* */

#if !defined(_WIN32) && !defined(__OS2PM__)
static Cursor blankCursor = None;
static Cursor fullCrosshairCusor = None;

/* SGI X server's support a special property called the
_SGI_CROSSHAIR_CURSOR that when installed as a window's
cursor, becomes a full screen crosshair cursor. SGI
has special cursor generation hardware for this case. */
static Cursor
getFullCrosshairCursor(void)
{
Cursor cursor;
Atom crosshairAtom, actualType;
int rc, actualFormat;
unsigned long n, left;
unsigned long *value;

if (fullCrosshairCusor == None) {
crosshairAtom = XInternAtom(__glutDisplay,
"_SGI_CROSSHAIR_CURSOR", True);
if (crosshairAtom != None) {
value = 0; /* Make compiler happy. */
rc = XGetWindowProperty(__glutDisplay, __glutRoot,
crosshairAtom, 0, 1, False, XA_CURSOR, &actualType,
&actualFormat, &n, &left, (unsigned char **) &value);
if (rc == Success && actualFormat == 32 && n >= 1) {
cursor = value[0];
XFree(value);
return cursor;
}
}
}
return XCreateFontCursor(__glutDisplay, XC_crosshair);
}

/* X11 forces you to create a blank cursor if you want
to disable the cursor. */
static Cursor
makeBlankCursor(void)
{
static char data[1] =
{0};
Cursor cursor;
Pixmap blank;
XColor dummy;

blank = XCreateBitmapFromData(__glutDisplay, __glutRoot,
data, 1, 1);
if (blank == None)
__glutFatalError("out of memory.");
cursor = XCreatePixmapCursor(__glutDisplay, blank, blank,
&dummy, &dummy, 0, 0);
XFreePixmap(__glutDisplay, blank);

return cursor;
}
#endif /* !_WIN32 && !__OS2PM__*/

/* Win32 and X11 use this same function to accomplish
fairly different tasks. X11 lets you just define the
cursor for a window and the window system takes care
of making sure that the window's cursor is installed
when the mouse is in the window. Win32 requires the
application to handle a WM_SETCURSOR message to install
the right cursor when windows are entered. Think of
the Win32 __glutSetCursor (called from __glutWindowProc)
as "install cursor". Think of the X11 __glutSetCursor
(called from glutSetCursor) as "define cursor". */
void
__glutSetCursor(GLUTwindow *window)
{
int cursor = window->cursor;
Cursor xcursor = 0;

if (cursor >= 0 &&
cursor < sizeof(cursorTable) / sizeof(cursorTable[0])) {
if (cursorTable[cursor].cursor == None) {
cursorTable[cursor].cursor = XCreateFontCursor(__glutDisplay,
cursorTable[cursor].glyph);
}
xcursor = cursorTable[cursor].cursor;
} else {
/* Special cases. */
switch (cursor) {
case GLUT_CURSOR_INHERIT:
#if defined(_WIN32)
while (window->parent) {
window = window->parent;
if (window->cursor != GLUT_CURSOR_INHERIT) {
__glutSetCursor(window);
return;
}
}
/* XXX Default to an arrow cursor. Is this
right or should we be letting the default
window proc be installing some system cursor? */
xcursor = cursorTable[0].cursor;
if (xcursor == NULL) {
xcursor =
cursorTable[0].cursor =
LoadCursor(NULL, cursorTable[0].glyph);
}

#elif defined(__OS2PM__)
//todo
xcursor = None;

#else
xcursor = None;
#endif
break;
case GLUT_CURSOR_NONE:
#if defined(_WIN32) || defined(__OS2PM__)
xcursor = NULL;
#else
if (blankCursor == None) {
blankCursor = makeBlankCursor();
}
xcursor = blankCursor;
#endif
break;
case GLUT_CURSOR_FULL_CROSSHAIR:
#if defined(_WIN32)
xcursor = (HICON) IDC_CROSS;
#elif defined(__OS2PM__)
//todo
#else
if (fullCrosshairCusor == None) {
fullCrosshairCusor = getFullCrosshairCursor();
}
xcursor = fullCrosshairCusor;
#endif
break;
}
}
XDefineCursor(__glutDisplay,
window->win, xcursor);
XFlush(__glutDisplay);
}

/* CENTRY */
void GLUTAPIENTRY
glutSetCursor(int cursor)
{
#ifdef _WIN32
POINT point;

__glutCurrentWindow->cursor = cursor;
/* Are we in the window right now? If so,
install the cursor. */
GetCursorPos(&point);
if (__glutCurrentWindow->win == WindowFromPoint(point)) {
__glutSetCursor(__glutCurrentWindow);
}
#elif defined(__OS2PM__)
//todo
#else
__glutCurrentWindow->cursor = cursor;
__glutSetCursor(__glutCurrentWindow);
#endif
}
/* ENDCENTRY */

+ 0
- 1399
src/glut/os2/glut_event.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 204
src/glut/os2/glut_ext.cpp Näytä tiedosto

@@ -1,204 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 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 <string.h>

#include "glutint.h"

/* CENTRY */
int GLUTAPIENTRY
glutExtensionSupported(const char *extension)
{
static const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;

/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0')
return 0;

if (!extensions) {
extensions = glGetString(GL_EXTENSIONS);
}
/* It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don't be fooled by sub-strings,
etc. */
start = extensions;
for (;;) {
/* If your application crashes in the strstr routine below,
you are probably calling glutExtensionSupported without
having a current window. Calling glGetString without
a current OpenGL context has unpredictable results.
Please fix your program. */
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
break;
terminator = where + strlen(extension);
if (where == start || *(where - 1) == ' ') {
if (*terminator == ' ' || *terminator == '\0') {
return 1;
}
}
start = terminator;
}
return 0;
}


struct name_address_pair {
const char *name;
const void *address;
};

static struct name_address_pair glut_functions[] = {
{ "glutInit", (const void *) glutInit },
{ "glutInitDisplayMode", (const void *) glutInitDisplayMode },
{ "glutInitDisplayString", (const void *) glutInitDisplayString },
{ "glutInitWindowPosition", (const void *) glutInitWindowPosition },
{ "glutInitWindowSize", (const void *) glutInitWindowSize },
{ "glutMainLoop", (const void *) glutMainLoop },
{ "glutCreateWindow", (const void *) glutCreateWindow },
{ "glutCreateSubWindow", (const void *) glutCreateSubWindow },
{ "glutDestroyWindow", (const void *) glutDestroyWindow },
{ "glutPostRedisplay", (const void *) glutPostRedisplay },
{ "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay },
{ "glutSwapBuffers", (const void *) glutSwapBuffers },
{ "glutGetWindow", (const void *) glutGetWindow },
{ "glutSetWindow", (const void *) glutSetWindow },
{ "glutSetWindowTitle", (const void *) glutSetWindowTitle },
{ "glutSetIconTitle", (const void *) glutSetIconTitle },
{ "glutPositionWindow", (const void *) glutPositionWindow },
{ "glutReshapeWindow", (const void *) glutReshapeWindow },
{ "glutPopWindow", (const void *) glutPopWindow },
{ "glutPushWindow", (const void *) glutPushWindow },
{ "glutIconifyWindow", (const void *) glutIconifyWindow },
{ "glutShowWindow", (const void *) glutShowWindow },
{ "glutHideWindow", (const void *) glutHideWindow },
{ "glutFullScreen", (const void *) glutFullScreen },
{ "glutSetCursor", (const void *) glutSetCursor },
{ "glutWarpPointer", (const void *) glutWarpPointer },
{ "glutEstablishOverlay", (const void *) glutEstablishOverlay },
{ "glutRemoveOverlay", (const void *) glutRemoveOverlay },
{ "glutUseLayer", (const void *) glutUseLayer },
{ "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay },
{ "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay },
{ "glutShowOverlay", (const void *) glutShowOverlay },
{ "glutHideOverlay", (const void *) glutHideOverlay },
{ "glutCreateMenu", (const void *) glutCreateMenu },
{ "glutDestroyMenu", (const void *) glutDestroyMenu },
{ "glutGetMenu", (const void *) glutGetMenu },
{ "glutSetMenu", (const void *) glutSetMenu },
{ "glutAddMenuEntry", (const void *) glutAddMenuEntry },
{ "glutAddSubMenu", (const void *) glutAddSubMenu },
{ "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry },
{ "glutChangeToSubMenu", (const void *) glutChangeToSubMenu },
{ "glutRemoveMenuItem", (const void *) glutRemoveMenuItem },
{ "glutAttachMenu", (const void *) glutAttachMenu },
{ "glutDetachMenu", (const void *) glutDetachMenu },
{ "glutDisplayFunc", (const void *) glutDisplayFunc },
{ "glutReshapeFunc", (const void *) glutReshapeFunc },
{ "glutKeyboardFunc", (const void *) glutKeyboardFunc },
{ "glutMouseFunc", (const void *) glutMouseFunc },
{ "glutMotionFunc", (const void *) glutMotionFunc },
{ "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc },
{ "glutEntryFunc", (const void *) glutEntryFunc },
{ "glutVisibilityFunc", (const void *) glutVisibilityFunc },
{ "glutIdleFunc", (const void *) glutIdleFunc },
{ "glutTimerFunc", (const void *) glutTimerFunc },
{ "glutMenuStateFunc", (const void *) glutMenuStateFunc },
{ "glutSpecialFunc", (const void *) glutSpecialFunc },
{ "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc },
{ "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc },
{ "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc },
{ "glutButtonBoxFunc", (const void *) glutButtonBoxFunc },
{ "glutDialsFunc", (const void *) glutDialsFunc },
{ "glutTabletMotionFunc", (const void *) glutTabletMotionFunc },
{ "glutTabletButtonFunc", (const void *) glutTabletButtonFunc },
{ "glutMenuStatusFunc", (const void *) glutMenuStatusFunc },
{ "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc },
{ "glutWindowStatusFunc", (const void *) glutWindowStatusFunc },
{ "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc },
{ "glutSpecialUpFunc", (const void *) glutSpecialUpFunc },
{ "glutJoystickFunc", (const void *) glutJoystickFunc },
{ "glutSetColor", (const void *) glutSetColor },
{ "glutGetColor", (const void *) glutGetColor },
{ "glutCopyColormap", (const void *) glutCopyColormap },
{ "glutGet", (const void *) glutGet },
{ "glutDeviceGet", (const void *) glutDeviceGet },
{ "glutExtensionSupported", (const void *) glutExtensionSupported },
{ "glutGetModifiers", (const void *) glutGetModifiers },
{ "glutLayerGet", (const void *) glutLayerGet },
{ "glutGetProcAddress", (const void *) glutGetProcAddress },
{ "glutBitmapCharacter", (const void *) glutBitmapCharacter },
{ "glutBitmapWidth", (const void *) glutBitmapWidth },
{ "glutStrokeCharacter", (const void *) glutStrokeCharacter },
{ "glutStrokeWidth", (const void *) glutStrokeWidth },
{ "glutBitmapLength", (const void *) glutBitmapLength },
{ "glutStrokeLength", (const void *) glutStrokeLength },
{ "glutWireSphere", (const void *) glutWireSphere },
{ "glutSolidSphere", (const void *) glutSolidSphere },
{ "glutWireCone", (const void *) glutWireCone },
{ "glutSolidCone", (const void *) glutSolidCone },
{ "glutWireCube", (const void *) glutWireCube },
{ "glutSolidCube", (const void *) glutSolidCube },
{ "glutWireTorus", (const void *) glutWireTorus },
{ "glutSolidTorus", (const void *) glutSolidTorus },
{ "glutWireDodecahedron", (const void *) glutWireDodecahedron },
{ "glutSolidDodecahedron", (const void *) glutSolidDodecahedron },
{ "glutWireTeapot", (const void *) glutWireTeapot },
{ "glutSolidTeapot", (const void *) glutSolidTeapot },
{ "glutWireOctahedron", (const void *) glutWireOctahedron },
{ "glutSolidOctahedron", (const void *) glutSolidOctahedron },
{ "glutWireTetrahedron", (const void *) glutWireTetrahedron },
{ "glutSolidTetrahedron", (const void *) glutSolidTetrahedron },
{ "glutWireIcosahedron", (const void *) glutWireIcosahedron },
{ "glutSolidIcosahedron", (const void *) glutSolidIcosahedron },
{ "glutVideoResizeGet", (const void *) glutVideoResizeGet },
{ "glutSetupVideoResizing", (const void *) glutSetupVideoResizing },
{ "glutStopVideoResizing", (const void *) glutStopVideoResizing },
{ "glutVideoResize", (const void *) glutVideoResize },
{ "glutVideoPan", (const void *) glutVideoPan },
{ "glutReportErrors", (const void *) glutReportErrors },
{ "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat },
{ "glutSetKeyRepeat", (const void *) glutSetKeyRepeat },
{ "glutForceJoystickFunc", (const void *) glutForceJoystickFunc },
{ "glutGameModeString", (const void *) glutGameModeString },
{ "glutEnterGameMode", (const void *) glutEnterGameMode },
{ "glutLeaveGameMode", (const void *) glutLeaveGameMode },
{ "glutGameModeGet", (const void *) glutGameModeGet },
{ NULL, NULL }
};


/* XXX This isn't an official GLUT function, yet */
void * GLUTAPIENTRY
glutGetProcAddress(const char *procName)
{
/* Try GLUT functions first */
int i;
for (i = 0; glut_functions[i].name; i++) {
if (strcmp(glut_functions[i].name, procName) == 0)
return (void *) glut_functions[i].address;
}

/* Try core GL functions */
#if defined(_WIN32)
return (void *) wglGetProcAddress((LPCSTR) procName);

#elif defined(__OS2PM__)
return (void *) wglGetProcAddress((char *) procName);
#elif defined(GLX_ARB_get_proc_address)
return (void *) glXGetProcAddressARB((const GLubyte *) procName);
#else
return NULL;
#endif
}


/* ENDCENTRY */

+ 0
- 38
src/glut/os2/glut_fullscrn.cpp Näytä tiedosto

@@ -1,38 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1995, 1998. */

/* 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 <assert.h>

#include "glutint.h"

/* CENTRY */
void GLUTAPIENTRY
glutFullScreen(void)
{
assert(!__glutCurrentWindow->parent);
IGNORE_IN_GAME_MODE();
#if !defined(_WIN32) && !defined(__OS2PM__)
if (__glutMotifHints == None) {
__glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
SGI_XA__MOTIF_WM_HINTS, 0);
if (__glutMotifHints == None) {
__glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
}
}
#endif

__glutCurrentWindow->desiredX = 0;
__glutCurrentWindow->desiredY = 0;
__glutCurrentWindow->desiredWidth = __glutScreenWidth;
__glutCurrentWindow->desiredHeight = __glutScreenHeight;
__glutCurrentWindow->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;

__glutPutOnWorkList(__glutCurrentWindow,
GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
}

/* ENDCENTRY */

+ 0
- 679
src/glut/os2/glut_gamemode.cpp Näytä tiedosto

@@ -1,679 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1998. */

/* 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 <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "glutint.h"

#if !defined(_WIN32) && !defined(__OS2__)
#include <X11/Xlib.h>
#include <X11/Xatom.h>

/* SGI optimization introduced in IRIX 6.3 to avoid X server
round trips for interning common X atoms. */
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
#include <X11/SGIFastAtom.h>
#else
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
#endif
#endif /* not _WIN32 */

int __glutDisplaySettingsChanged = 0;
static DisplayMode *dmodes, *currentDm = NULL;
static int ndmodes = -1;
GLUTwindow *__glutGameModeWindow = NULL;

#ifdef TEST
static char *compstr[] =
{
"none", "=", "!=", "<=", ">=", ">", "<", "~"
};
static char *capstr[] =
{
"width", "height", "bpp", "hertz", "num"
};
#endif

#if defined(__OS2__)
void
#else
void __cdecl
#endif
__glutCloseDownGameMode(void)
{
if (__glutDisplaySettingsChanged) {
#ifdef _WIN32
/* Assumes that display settings have been changed, that
is __glutDisplaySettingsChanged is true. */
ChangeDisplaySettings(NULL, 0);
#endif
__glutDisplaySettingsChanged = 0;
}
__glutGameModeWindow = NULL;
}

void GLUTAPIENTRY
glutLeaveGameMode(void)
{
if (__glutGameModeWindow == NULL) {
__glutWarning("not in game mode so cannot leave game mode");
return;
}
__glutDestroyWindow(__glutGameModeWindow,
__glutGameModeWindow);
XFlush(__glutDisplay);
__glutGameModeWindow = NULL;
}

#ifdef _WIN32

/* Same values as from MSDN's SetDisp.c example. */
#define MIN_WIDTH 400
#define MIN_FREQUENCY 60

static void
initGameModeSupport(void)
{
DEVMODE dm;
DWORD mode;
int i;

if (ndmodes >= 0) {
/* ndmodes is initially -1 to indicate no
dmodes allocated yet. */
return;
}

/* Determine how many display modes there are. */
ndmodes = 0;
mode = 0;
while (EnumDisplaySettings(NULL, mode, &dm)) {
if (dm.dmPelsWidth >= MIN_WIDTH &&
(dm.dmDisplayFrequency == 0 ||
dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
ndmodes++;
}
mode++;
}

/* Allocate memory for a list of all the display modes. */
dmodes = (DisplayMode*)
malloc(ndmodes * sizeof(DisplayMode));

/* Now that we know how many display modes to expect,
enumerate them again and save the information in
the list we allocated above. */
i = 0;
mode = 0;
while (EnumDisplaySettings(NULL, mode, &dm)) {
/* Try to reject any display settings that seem unplausible. */
if (dm.dmPelsWidth >= MIN_WIDTH &&
(dm.dmDisplayFrequency == 0 ||
dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
dmodes[i].devmode = dm;
dmodes[i].valid = 1; /* XXX Not used for now. */
dmodes[i].cap[DM_WIDTH] = dm.dmPelsWidth;
dmodes[i].cap[DM_HEIGHT] = dm.dmPelsHeight;
dmodes[i].cap[DM_PIXEL_DEPTH] = dm.dmBitsPerPel;
if (dm.dmDisplayFrequency == 0) {
/* Guess a reasonable guess. */
/* Lame Windows 95 version of EnumDisplaySettings. */
dmodes[i].cap[DM_HERTZ] = 60;
} else {
dmodes[i].cap[DM_HERTZ] = dm.dmDisplayFrequency;
}
i++;
}
mode++;
}

assert(i == ndmodes);
}

#else

/* X Windows version of initGameModeSupport. */
static void
initGameModeSupport(void)
{
if (ndmodes >= 0) {
/* ndmodes is initially -1 to indicate no
dmodes allocated yet. */
return;
}

/* Determine how many display modes there are. */
ndmodes = 0;
}

#endif

/* This routine is based on similiar code in glut_dstr.c */
static DisplayMode *
findMatch(DisplayMode * dmodes, int ndmodes,
Criterion * criteria, int ncriteria)
{
DisplayMode *found;
int *bestScore, *thisScore;
int i, j, numok, result = 0, worse, better;

found = NULL;
numok = 1; /* "num" capability is indexed from 1,
not 0. */

/* XXX alloca canidate. */
bestScore = (int *) malloc(ncriteria * sizeof(int));
if (!bestScore) {
__glutFatalError("out of memory.");
}
for (j = 0; j < ncriteria; j++) {
/* Very negative number. */
bestScore[j] = -32768;
}

/* XXX alloca canidate. */
thisScore = (int *) malloc(ncriteria * sizeof(int));
if (!thisScore) {
__glutFatalError("out of memory.");
}

for (i = 0; i < ndmodes; i++) {
if (dmodes[i].valid) {
worse = 0;
better = 0;

for (j = 0; j < ncriteria; j++) {
int cap, cvalue, dvalue;

cap = criteria[j].capability;
cvalue = criteria[j].value;
if (cap == NUM) {
dvalue = numok;
} else {
dvalue = dmodes[i].cap[cap];
}
#ifdef TEST
if (verbose)
printf(" %s %s %d to %d\n",
capstr[cap], compstr[criteria[j].comparison], cvalue, dvalue);
#endif
switch (criteria[j].comparison) {
case EQ:
result = cvalue == dvalue;
thisScore[j] = 1;
break;
case NEQ:
result = cvalue != dvalue;
thisScore[j] = 1;
break;
case LT:
result = dvalue < cvalue;
thisScore[j] = dvalue - cvalue;
break;
case GT:
result = dvalue > cvalue;
thisScore[j] = dvalue - cvalue;
break;
case LTE:
result = dvalue <= cvalue;
thisScore[j] = dvalue - cvalue;
break;
case GTE:
result = (dvalue >= cvalue);
thisScore[j] = dvalue - cvalue;
break;
case MIN:
result = dvalue >= cvalue;
thisScore[j] = cvalue - dvalue;
break;
}

#ifdef TEST
if (verbose)
printf(" result=%d score=%d bestScore=%d\n", result, thisScore[j], bestScore[j]);
#endif

if (result) {
if (better || thisScore[j] > bestScore[j]) {
better = 1;
} else if (thisScore[j] == bestScore[j]) {
/* Keep looking. */
} else {
goto nextDM;
}
} else {
if (cap == NUM) {
worse = 1;
} else {
goto nextDM;
}
}

}

if (better && !worse) {
found = &dmodes[i];
for (j = 0; j < ncriteria; j++) {
bestScore[j] = thisScore[j];
}
}
numok++;

nextDM:;

}
}
free(bestScore);
free(thisScore);
return found;
}

/**
* Parses strings in the form of:
* 800x600
* 800x600:16
* 800x600@60
* 800x600:16@60
* @60
* :16
* :16@60
* NOTE that @ before : is not parsed.
*/
static int
specialCaseParse(char *word, Criterion * criterion, int mask)
{
char *xstr, *response;
int got;
int width, height, bpp, hertz;

switch(word[0]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* The WWWxHHH case. */
if (mask & (1 << DM_WIDTH)) {
return -1;
}
xstr = strpbrk(&word[1], "x");
if (xstr) {
width = (int) strtol(word, &response, 0);
if (response == word || response[0] != 'x') {
/* Not a valid number OR needs to be followed by 'x'. */
return -1;
}
height = (int) strtol(&xstr[1], &response, 0);
if (response == &xstr[1]) {
/* Not a valid number. */
return -1;
}
criterion[0].capability = DM_WIDTH;
criterion[0].comparison = EQ;
criterion[0].value = width;
criterion[1].capability = DM_HEIGHT;
criterion[1].comparison = EQ;
criterion[1].value = height;
got = specialCaseParse(response,
&criterion[2], 1 << DM_WIDTH);
if (got >= 0) {
return got + 2;
} else {
return -1;
}
}
return -1;
case ':':
/* The :BPP case. */
if (mask & (1 << DM_PIXEL_DEPTH)) {
return -1;
}
bpp = (int) strtol(&word[1], &response, 0);
if (response == &word[1]) {
/* Not a valid number. */
return -1;
}
criterion[0].capability = DM_PIXEL_DEPTH;
criterion[0].comparison = EQ;
criterion[0].value = bpp;
got = specialCaseParse(response,
&criterion[1], (1 << DM_WIDTH) | (1 << DM_PIXEL_DEPTH));
if (got >= 0) {
return got + 1;
} else {
return -1;
}
case '@':
/* The @HZ case. */
if (mask & (1 << DM_HERTZ)) {
return -1;
}
hertz = (int) strtol(&word[1], &response, 0);
if (response == &word[1]) {
/* Not a valid number. */
return -1;
}
criterion[0].capability = DM_HERTZ;
criterion[0].comparison = EQ;
criterion[0].value = hertz;
got = specialCaseParse(response,
&criterion[1], ~DM_HERTZ);
if (got >= 0) {
return got + 1;
} else {
return -1;
}
case '\0':
return 0;
}
return -1;
}

/* This routine is based on similiar code in glut_dstr.c */
static int
parseCriteria(char *word, Criterion * criterion)
{
char *cstr, *vstr, *response;
int comparator, value = 0;

cstr = strpbrk(word, "=><!~");
if (cstr) {
switch (cstr[0]) {
case '=':
comparator = EQ;
vstr = &cstr[1];
break;
case '~':
comparator = MIN;
vstr = &cstr[1];
break;
case '>':
if (cstr[1] == '=') {
comparator = GTE;
vstr = &cstr[2];
} else {
comparator = GT;
vstr = &cstr[1];
}
break;
case '<':
if (cstr[1] == '=') {
comparator = LTE;
vstr = &cstr[2];
} else {
comparator = LT;
vstr = &cstr[1];
}
break;
case '!':
if (cstr[1] == '=') {
comparator = NEQ;
vstr = &cstr[2];
} else {
return -1;
}
break;
default:
return -1;
}
value = (int) strtol(vstr, &response, 0);
if (response == vstr) {
/* Not a valid number. */
return -1;
}
*cstr = '\0';
} else {
comparator = NONE;
}
switch (word[0]) {
case 'b':
if (!strcmp(word, "bpp")) {
criterion[0].capability = DM_PIXEL_DEPTH;
if (comparator == NONE) {
return -1;
} else {
criterion[0].comparison = comparator;
criterion[0].value = value;
return 1;
}
}
return -1;
case 'h':
if (!strcmp(word, "height")) {
criterion[0].capability = DM_HEIGHT;
if (comparator == NONE) {
return -1;
} else {
criterion[0].comparison = comparator;
criterion[0].value = value;
return 1;
}
}
if (!strcmp(word, "hertz")) {
criterion[0].capability = DM_HERTZ;
if (comparator == NONE) {
return -1;
} else {
criterion[0].comparison = comparator;
criterion[0].value = value;
return 1;
}
}
return -1;
case 'n':
if (!strcmp(word, "num")) {
criterion[0].capability = DM_NUM;
if (comparator == NONE) {
return -1;
} else {
criterion[0].comparison = comparator;
criterion[0].value = value;
return 1;
}
}
return -1;
case 'w':
if (!strcmp(word, "width")) {
criterion[0].capability = DM_WIDTH;
if (comparator == NONE) {
return -1;
} else {
criterion[0].comparison = comparator;
criterion[0].value = value;
return 1;
}
}
return -1;
}
if (comparator == NONE) {
return specialCaseParse(word, criterion, 0);
}
return -1;
}

/* This routine is based on similiar code in glut_dstr.c */
static Criterion *
parseDisplayString(const char *display, int *ncriteria)
{
Criterion *criteria = NULL;
int n, parsed;
char *copy, *word;

copy = __glutStrdup(display);
/* Attempt to estimate how many criteria entries should be
needed. */
n = 0;
word = strtok(copy, " \t");
while (word) {
n++;
word = strtok(NULL, " \t");
}
/* Allocate number of words of criteria. A word
could contain as many as four criteria in the
worst case. Example: 800x600:16@60 */
criteria = (Criterion *) malloc(4 * n * sizeof(Criterion));
if (!criteria) {
__glutFatalError("out of memory.");
}

/* Re-copy the copy of the display string. */
strcpy(copy, display);

n = 0;
word = strtok(copy, " \t");
while (word) {
parsed = parseCriteria(word, &criteria[n]);
if (parsed >= 0) {
n += parsed;
} else {
__glutWarning("Unrecognized game mode string word: %s (ignoring)\n", word);
}
word = strtok(NULL, " \t");
}

free(copy);
*ncriteria = n;
return criteria;
}

void GLUTAPIENTRY
glutGameModeString(const char *string)
{
Criterion *criteria;
int ncriteria;

initGameModeSupport();
criteria = parseDisplayString(string, &ncriteria);
currentDm = findMatch(dmodes, ndmodes, criteria, ncriteria);
free(criteria);
}

int GLUTAPIENTRY
glutEnterGameMode(void)
{
GLUTwindow *window;
int width, height;
Window win;

if (__glutMappedMenu) {
__glutFatalUsage("entering game mode not allowed while menus in use");
}
if (__glutGameModeWindow) {
/* Already in game mode, so blow away game mode
window so apps can change resolutions. */
window = __glutGameModeWindow;
/* Setting the game mode window to NULL tricks
the window destroy code into not undoing the
screen display change since we plan on immediately
doing another mode change. */
__glutGameModeWindow = NULL;
__glutDestroyWindow(window, window);
}

/* Assume default screen size until we find out if we
can actually change the display settings. */
width = __glutScreenWidth;
height = __glutScreenHeight;

if (currentDm) {
#ifdef _WIN32
LONG status;
static int registered = 0;

status = ChangeDisplaySettings(&currentDm->devmode,
CDS_FULLSCREEN);
if (status == DISP_CHANGE_SUCCESSFUL) {
__glutDisplaySettingsChanged = 1;
width = currentDm->cap[DM_WIDTH];
height = currentDm->cap[DM_HEIGHT];
if (!registered) {
atexit(__glutCloseDownGameMode);
registered = 1;
}
} else {
/* Switch back to default resolution. */
ChangeDisplaySettings(NULL, 0);
}
#endif
}

window = __glutCreateWindow(NULL, 0, 0,
width, height, /* game mode */ 1);
win = window->win;

#if !defined(_WIN32) && !defined(__OS2__)
if (__glutMotifHints == None) {
__glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
SGI_XA__MOTIF_WM_HINTS, 0);
if (__glutMotifHints == None) {
__glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
}
}

/* Game mode window is a toplevel window. */
XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1);
#endif

/* Schedule the fullscreen property to be added and to
make sure the window is configured right. Win32
doesn't need this. */
window->desiredX = 0;
window->desiredY = 0;
window->desiredWidth = width;
window->desiredHeight = height;
window->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;
#ifdef _WIN32
/* Win32 does not want to use GLUT_FULL_SCREEN_WORK
for game mode because we need to be maximizing
the window in game mode, not just sizing it to
take up the full screen. The Win32-ness of game
mode happens when you pass 1 in the gameMode parameter
to __glutCreateWindow above. A gameMode of creates
a WS_POPUP window, not a standard WS_OVERLAPPEDWINDOW
window. WS_POPUP ensures the taskbar is hidden. */
__glutPutOnWorkList(window,
GLUT_CONFIGURE_WORK);
#else
__glutPutOnWorkList(window,
GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
#endif

__glutGameModeWindow = window;
return window->num + 1;
}

int GLUTAPIENTRY
glutGameModeGet(GLenum mode)
{
switch (mode) {
case GLUT_GAME_MODE_ACTIVE:
return __glutGameModeWindow != NULL;
case GLUT_GAME_MODE_POSSIBLE:
return currentDm != NULL;
case GLUT_GAME_MODE_WIDTH:
return currentDm ? currentDm->cap[DM_WIDTH] : -1;
case GLUT_GAME_MODE_HEIGHT:
return currentDm ? currentDm->cap[DM_HEIGHT] : -1;
case GLUT_GAME_MODE_PIXEL_DEPTH:
return currentDm ? currentDm->cap[DM_PIXEL_DEPTH] : -1;
case GLUT_GAME_MODE_REFRESH_RATE:
return currentDm ? currentDm->cap[DM_HERTZ] : -1;
case GLUT_GAME_MODE_DISPLAY_CHANGED:
return __glutDisplaySettingsChanged;
default:
return -1;
}
}

+ 0
- 232
src/glut/os2/glut_get.cpp Näytä tiedosto

@@ -1,232 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */

/* 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 <assert.h>
#include <stdlib.h> /* SunOS 4 needs NULL defined for GETTIMEOFDAY macro. */
#include "glutint.h"

/* CENTRY */
int GLUTAPIENTRY
glutGet(GLenum param)
{
Window win, root;
int x, y, value;
unsigned int width, height, border, depth;

switch (param) {
case GLUT_INIT_WINDOW_X:
return __glutInitX;
case GLUT_INIT_WINDOW_Y:
return __glutInitY;
case GLUT_INIT_WINDOW_WIDTH:
return __glutInitWidth;
case GLUT_INIT_WINDOW_HEIGHT:
return __glutInitHeight;
case GLUT_INIT_DISPLAY_MODE:
return __glutDisplayMode;
case GLUT_WINDOW_X:
XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
__glutRoot, 0, 0, &x, &y, &win);
return x;
case GLUT_WINDOW_Y:
XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
__glutRoot, 0, 0, &x, &y, &win);
return y;
case GLUT_WINDOW_WIDTH:
if (!__glutCurrentWindow->reshape) {
XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
&root, &x, &y,
&width, &height, &border, &depth);
return width;
}
return __glutCurrentWindow->width;
case GLUT_WINDOW_HEIGHT:
if (!__glutCurrentWindow->reshape) {
XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
&root, &x, &y,
&width, &height, &border, &depth);
return height;
}
return __glutCurrentWindow->height;
#ifdef __OS2__
#define GET_CONFIG(attrib) \
{ if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) \
glXGetConfig( __glutCurrentWindow->vis, attrib, &value); \
else \
glXGetConfig(__glutCurrentWindow->overlay->vis, attrib, &value); \
} \

#else

#define GET_CONFIG(attrib) { \
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) { \
glXGetConfig(__glutDisplay, __glutCurrentWindow->vis, \
attrib, &value); \
} else { \
glXGetConfig(__glutDisplay, __glutCurrentWindow->overlay->vis, \
attrib, &value); \
} \
}
#endif

case GLUT_WINDOW_BUFFER_SIZE:
GET_CONFIG(GLX_BUFFER_SIZE);
return value;
case GLUT_WINDOW_STENCIL_SIZE:
GET_CONFIG(GLX_STENCIL_SIZE);
return value;
case GLUT_WINDOW_DEPTH_SIZE:
GET_CONFIG(GLX_DEPTH_SIZE);
return value;
case GLUT_WINDOW_RED_SIZE:
GET_CONFIG(GLX_RED_SIZE);
return value;
case GLUT_WINDOW_GREEN_SIZE:
GET_CONFIG(GLX_GREEN_SIZE);
return value;
case GLUT_WINDOW_BLUE_SIZE:
GET_CONFIG(GLX_BLUE_SIZE);
return value;
case GLUT_WINDOW_ALPHA_SIZE:
GET_CONFIG(GLX_ALPHA_SIZE);
return value;
case GLUT_WINDOW_ACCUM_RED_SIZE:
GET_CONFIG(GLX_ACCUM_RED_SIZE);
return value;
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
GET_CONFIG(GLX_ACCUM_GREEN_SIZE);
return value;
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
GET_CONFIG(GLX_ACCUM_BLUE_SIZE);
return value;
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
GET_CONFIG(GLX_ACCUM_ALPHA_SIZE);
return value;
case GLUT_WINDOW_DOUBLEBUFFER:
GET_CONFIG(GLX_DOUBLEBUFFER);
return value;
case GLUT_WINDOW_RGBA:
GET_CONFIG(GLX_RGBA);
return value;
case GLUT_WINDOW_COLORMAP_SIZE:
GET_CONFIG(GLX_RGBA);
if (value) {
return 0;
} else {
#if defined(_WIN32) || defined(__OS2__)
/* KLUDGE: we always assume 256 colors in CI mode on
Win32 */
return 256;
#else
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
return __glutCurrentWindow->vis->visual->map_entries;
} else {
return __glutCurrentWindow->overlay->vis->visual->map_entries;
}
#endif /* _WIN32 */
}
case GLUT_WINDOW_PARENT:
return __glutCurrentWindow->parent ?
__glutCurrentWindow->parent->num + 1 : 0;
case GLUT_WINDOW_NUM_CHILDREN:
{
int num = 0;
GLUTwindow *children = __glutCurrentWindow->children;

while (children) {
num++;
children = children->siblings;
}
return num;
}
case GLUT_WINDOW_NUM_SAMPLES:
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
if (__glutIsSupportedByGLX("GLX_SGIS_multisample")) {
GET_CONFIG(GLX_SAMPLES_SGIS);
return value;
} else {
return 0;
}
#else
/* Independent of GLX server support, multisampling not
supported by GLX client-side. */
return 0;
#endif
case GLUT_WINDOW_STEREO:
GET_CONFIG(GLX_STEREO);
return value;
case GLUT_WINDOW_CURSOR:
return __glutCurrentWindow->cursor;
case GLUT_SCREEN_WIDTH:
return DisplayWidth(__glutDisplay, __glutScreen);
case GLUT_SCREEN_HEIGHT:
return DisplayHeight(__glutDisplay, __glutScreen);
case GLUT_SCREEN_WIDTH_MM:
return DisplayWidthMM(__glutDisplay, __glutScreen);
case GLUT_SCREEN_HEIGHT_MM:
return DisplayHeightMM(__glutDisplay, __glutScreen);
case GLUT_MENU_NUM_ITEMS:
return __glutCurrentMenu->num;
case GLUT_DISPLAY_MODE_POSSIBLE:
{
XVisualInfo *vi;
Bool dummy, visAlloced;
void *fbc;

#if defined(_WIN32)
/* Our fake glXChooseVisual (which is called by
__glutDetermineVisual) needs an HDC to work with, so grab one
from the "root" window. */
XHDC = GetDC(GetDesktopWindow());
#endif
vi = __glutDetermineWindowVisual(&dummy, &visAlloced, &fbc);
#if defined(_WIN32)
ReleaseDC(GetDesktopWindow(), XHDC);
#endif
if (vi) {
if (visAlloced)
XFree(vi);
return 1;
}
return 0;
}
case GLUT_ELAPSED_TIME:
{
#ifdef OLD_VMS
struct timeval6 elapsed, beginning, now;
#else
struct timeval elapsed, beginning, now;
#endif

__glutInitTime(&beginning);
GETTIMEOFDAY(&now);
TIMEDELTA(elapsed, now, beginning);
/* Return elapsed milliseconds. */
#if defined(__vms) && ( __VMS_VER < 70000000 )
return (int) (elapsed.val / TICKS_PER_MILLISECOND);
#else
return (int) ((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
#endif
}
case GLUT_WINDOW_FORMAT_ID:
#if defined(__OS2__)
return wglGetPixelFormat(__glutCurrentWindow->hdc);
#elif defined(_WIN32)
return GetPixelFormat(__glutCurrentWindow->hdc);
#else
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
return (int) __glutCurrentWindow->vis->visualid;
} else {
return (int) __glutCurrentWindow->overlay->vis->visualid;
}
#endif
default:
__glutWarning("invalid glutGet parameter: %d", param);
return -1;
}
}
/* ENDCENTRY */

+ 0
- 1781
src/glut/os2/glut_hel10.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1791
src/glut/os2/glut_hel12.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 1900
src/glut/os2/glut_hel18.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 451
src/glut/os2/glut_init.cpp Näytä tiedosto

@@ -1,451 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 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. */

#ifdef __VMS
#include <GL/vms_x_fix.h>
#endif

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#if !defined(_WIN32) && !defined(__OS2__)
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif

/* SGI optimization introduced in IRIX 6.3 to avoid X server
round trips for interning common X atoms. */
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
#include <X11/SGIFastAtom.h>
#else
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
#endif

#include "glutint.h"

/* GLUT inter-file variables */
/* *INDENT-OFF* */
char *__glutProgramName = NULL;
int __glutArgc = 0;
char **__glutArgv = NULL;
char *__glutGeometry = NULL;
Display *__glutDisplay = NULL;
int __glutScreen;
Window __glutRoot;
int __glutScreenHeight;
int __glutScreenWidth;
GLboolean __glutIconic = GL_FALSE;
GLboolean __glutDebug = GL_FALSE;
unsigned int __glutDisplayMode =
GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
char *__glutDisplayString = NULL;
int __glutConnectionFD;
XSizeHints __glutSizeHints = {0};
int __glutInitWidth = 300, __glutInitHeight = 300;
int __glutInitX = -1, __glutInitY = -1;
GLboolean __glutForceDirect = GL_FALSE,
__glutTryDirect = GL_TRUE;
Atom __glutWMDeleteWindow;
/* *INDENT-ON* */

#ifdef _WIN32
void (__cdecl *__glutExitFunc)(int retval) = NULL;
#endif

static Bool synchronize = False;

#if defined(__OS2__)

MRESULT EXPENTRY GlutWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
MRESULT EXPENTRY GlutWindowChildProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );


void __glutOpenOS2Connection(char* display)
{
static char *classname=NULL;
extern HAB hab; /* PM anchor block handle */
ERRORID erridErrorCode;/* last error id code */
int ii;

/* Make sure we register the window only once. */
if(classname)
return;

classname = "GLUT";

if ( !WinRegisterClass( hab, /* PM anchor block handle */
classname,/* window class name */
GlutWindowProc,/* address of window procedure*/
CS_SIZEREDRAW, /* |CS_SYNCPAINT size changes cause redrawing */
0UL ) ) /* window data */
{ erridErrorCode = WinGetLastError(hab);
ii = erridErrorCode;
return;
}

classname = "GLUTCHILD";

if ( !WinRegisterClass( hab, /* PM anchor block handle */
classname,/* window class name */
GlutWindowChildProc,/* address of window procedure*/
CS_SIZEREDRAW, /* size changes cause redrawing */
0UL ) ) /* window data */
{ erridErrorCode = WinGetLastError(hab);
ii = erridErrorCode;
return;
}

__glutScreenWidth = GetSystemMetrics(SM_CXSCREEN);
__glutScreenHeight = GetSystemMetrics(SM_CYSCREEN);

/* Set the root window to NULL because windows creates a top-level
window when the parent is NULL. X creates a top-level window
when the parent is the root window. */
__glutRoot = NULLHANDLE;

/* Set the display to 1 -- we shouldn't be using this anywhere
(except as an argument to X calls). */
__glutDisplay = (Display*)1;

/* There isn't any concept of multiple screens in Win32, therefore,
we don't need to keep track of the screen we're on... it's always
the same one. */
__glutScreen = 0;
}

#elif defined(_WIN32)

#ifdef __BORLANDC__
#include <float.h> /* For masking floating point exceptions. */
#endif

void
__glutOpenWin32Connection(char* display)
{
static char *classname;
WNDCLASS wc;
HINSTANCE hInstance = GetModuleHandle(NULL);

/* Make sure we register the window only once. */
if(classname)
return;

#ifdef __BORLANDC__
/* Under certain conditions (e.g. while rendering solid surfaces with
lighting enabled) Microsoft OpenGL libraries cause some illegal
operations like floating point overflow or division by zero. The
default behaviour of Microsoft compilers is to mask (ignore)
floating point exceptions, while Borland compilers do not. The
following function of Borland RTL allows to mask exceptions.
Advice from Pier Giorgio Esposito (mc2172@mclink.it). */
_control87(MCW_EM,MCW_EM);
#endif

classname = "GLUT";

/* Clear (important!) and then fill in the window class structure. */
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)__glutWindowProc;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, "GLUT_ICON");
wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = classname;

/* Fill in a default icon if one isn't specified as a resource. */
if(!wc.hIcon)
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);

if(!RegisterClass(&wc)) {
__glutFatalError("RegisterClass() failed:"
"Cannot register GLUT window class.");
}

__glutScreenWidth = GetSystemMetrics(SM_CXSCREEN);
__glutScreenHeight = GetSystemMetrics(SM_CYSCREEN);

/* Set the root window to NULL because windows creates a top-level
window when the parent is NULL. X creates a top-level window
when the parent is the root window. */
__glutRoot = NULL;

/* Set the display to 1 -- we shouldn't be using this anywhere
(except as an argument to X calls). */
__glutDisplay = (Display*)1;

/* There isn't any concept of multiple screens in Win32, therefore,
we don't need to keep track of the screen we're on... it's always
the same one. */
__glutScreen = 0;
}
#else /* !_WIN32 */
void
__glutOpenXConnection(char *display)
{
int errorBase, eventBase;

__glutDisplay = XOpenDisplay(display);
if (!__glutDisplay)
__glutFatalError("could not open display: %s",
XDisplayName(display));
if (synchronize)
XSynchronize(__glutDisplay, True);
if (!glXQueryExtension(__glutDisplay, &errorBase, &eventBase))
__glutFatalError(
"OpenGL GLX extension not supported by display: %s",
XDisplayName(display));
__glutScreen = DefaultScreen(__glutDisplay);
__glutRoot = RootWindow(__glutDisplay, __glutScreen);
__glutScreenWidth = DisplayWidth(__glutDisplay, __glutScreen);
__glutScreenHeight = DisplayHeight(__glutDisplay,
__glutScreen);
__glutConnectionFD = ConnectionNumber(__glutDisplay);
__glutWMDeleteWindow = XSGIFastInternAtom(__glutDisplay,
"WM_DELETE_WINDOW", SGI_XA_WM_DELETE_WINDOW, False);
}
#endif /* _WIN32 */

void
#ifdef OLD_VMS
__glutInitTime(struct timeval6 *beginning)
#else
__glutInitTime(struct timeval *beginning)
#endif
{
static int beenhere = 0;
#ifdef OLD_VMS
static struct timeval6 genesis;
#else
static struct timeval genesis;
#endif

if (!beenhere) {
GETTIMEOFDAY(&genesis);
beenhere = 1;
}
*beginning = genesis;
}

static void
removeArgs(int *argcp, char **argv, int numToRemove)
{
int i, j;

for (i = 0, j = numToRemove; argv[j]; i++, j++) {
argv[i] = argv[j];
}
argv[i] = NULL;
*argcp -= numToRemove;
}

void GLUTAPIENTRY
glutInit(int *argcp, char **argv)
{
char *display = NULL;
char *str, *geometry = NULL;
#ifdef OLD_VMS
struct timeval6 unused;
#else
struct timeval unused;
#endif
int i;

if (__glutDisplay) {
__glutWarning("glutInit being called a second time.");
return;
}
/* Determine temporary program name. */
str = strrchr(argv[0], '/');
if (str == NULL) {
__glutProgramName = argv[0];
} else {
__glutProgramName = str + 1;
}

/* Make private copy of command line arguments. */
__glutArgc = *argcp;
__glutArgv = (char **) malloc(__glutArgc * sizeof(char *));
if (!__glutArgv)
__glutFatalError("out of memory.");
for (i = 0; i < __glutArgc; i++) {
__glutArgv[i] = __glutStrdup(argv[i]);
if (!__glutArgv[i])
__glutFatalError("out of memory.");
}

/* determine permanent program name */
str = strrchr(__glutArgv[0], '/');
if (str == NULL) {
__glutProgramName = __glutArgv[0];
} else {
__glutProgramName = str + 1;
}

/* parse arguments for standard options */
for (i = 1; i < __glutArgc; i++) {
if (!strcmp(__glutArgv[i], "-display")) {
#if defined(_WIN32)
__glutWarning("-display option not supported by Win32 GLUT.");
#endif
if (++i >= __glutArgc) {
__glutFatalError(
"follow -display option with X display name.");
}
display = __glutArgv[i];
removeArgs(argcp, &argv[1], 2);
} else if (!strcmp(__glutArgv[i], "-geometry")) {
if (++i >= __glutArgc) {
__glutFatalError(
"follow -geometry option with geometry parameter.");
}
geometry = __glutArgv[i];
removeArgs(argcp, &argv[1], 2);
} else if (!strcmp(__glutArgv[i], "-direct")) {
#if defined(_WIN32)
__glutWarning("-direct option not supported by Win32 GLUT.");
#endif
if (!__glutTryDirect)
__glutFatalError(
"cannot force both direct and indirect rendering.");
__glutForceDirect = GL_TRUE;
removeArgs(argcp, &argv[1], 1);
} else if (!strcmp(__glutArgv[i], "-indirect")) {
#if defined(_WIN32)
__glutWarning("-indirect option not supported by Win32 GLUT.");
#endif
if (__glutForceDirect)
__glutFatalError(
"cannot force both direct and indirect rendering.");
__glutTryDirect = GL_FALSE;
removeArgs(argcp, &argv[1], 1);
} else if (!strcmp(__glutArgv[i], "-iconic")) {
__glutIconic = GL_TRUE;
removeArgs(argcp, &argv[1], 1);
} else if (!strcmp(__glutArgv[i], "-gldebug")) {
__glutDebug = GL_TRUE;
removeArgs(argcp, &argv[1], 1);
} else if (!strcmp(__glutArgv[i], "-sync")) {
#if defined(_WIN32)
__glutWarning("-sync option not supported by Win32 GLUT.");
#endif
synchronize = GL_TRUE;
removeArgs(argcp, &argv[1], 1);
} else {
/* Once unknown option encountered, stop command line
processing. */
break;
}
}
#if defined(__OS2__)
__glutOpenOS2Connection(display);
#elif defined(_WIN32)
__glutOpenWin32Connection(display);
#else
__glutOpenXConnection(display);
#endif
if (geometry) {
int flags, x, y, width, height;

/* Fix bogus "{width|height} may be used before set"
warning */
width = 0;
height = 0;

flags = XParseGeometry(geometry, &x, &y,
(unsigned int *) &width, (unsigned int *) &height);
if (WidthValue & flags) {
/* Careful because X does not allow zero or negative
width windows */
if (width > 0)
__glutInitWidth = width;
}
if (HeightValue & flags) {
/* Careful because X does not allow zero or negative
height windows */
if (height > 0)
__glutInitHeight = height;
}
glutInitWindowSize(__glutInitWidth, __glutInitHeight);
if (XValue & flags) {
if (XNegative & flags)
x = DisplayWidth(__glutDisplay, __glutScreen) +
x - __glutSizeHints.width;
/* Play safe: reject negative X locations */
if (x >= 0)
__glutInitX = x;
}
if (YValue & flags) {
if (YNegative & flags)
y = DisplayHeight(__glutDisplay, __glutScreen) +
y - __glutSizeHints.height;
/* Play safe: reject negative Y locations */
if (y >= 0)
__glutInitY = y;
}
glutInitWindowPosition(__glutInitX, __glutInitY);
}
__glutInitTime(&unused);

/* check if GLUT_FPS env var is set */
{
const char *fps = getenv("GLUT_FPS");
if (fps) {
sscanf(fps, "%d", &__glutFPS);
if (__glutFPS <= 0)
__glutFPS = 5000; /* 5000 milliseconds */
}
}
}

#ifdef _WIN32
void APIENTRY
__glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int))
{
__glutExitFunc = exitfunc;
glutInit(argcp, argv);
}
#endif

/* CENTRY */
void GLUTAPIENTRY
glutInitWindowPosition(int x, int y)
{
__glutInitX = x;
__glutInitY = y;
if (x >= 0 && y >= 0) {
__glutSizeHints.x = x;
__glutSizeHints.y = y;
__glutSizeHints.flags |= USPosition;
} else {
__glutSizeHints.flags &= ~USPosition;
}
}

void GLUTAPIENTRY
glutInitWindowSize(int width, int height)
{
__glutInitWidth = width;
__glutInitHeight = height;
if (width > 0 && height > 0) {
__glutSizeHints.width = width;
__glutSizeHints.height = height;
__glutSizeHints.flags |= USSize;
} else {
__glutSizeHints.flags &= ~USSize;
}
}

void GLUTAPIENTRY
glutInitDisplayMode(unsigned int mask)
{
__glutDisplayMode = mask;
}

/* ENDCENTRY */

+ 0
- 628
src/glut/os2/glut_input.cpp Näytä tiedosto

@@ -1,628 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */

/* 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 <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "glutint.h"
#define POFIG 0
#if POFIG

int __glutNumDials = 0;
int __glutNumSpaceballButtons = 0;
int __glutNumButtonBoxButtons = 0;
int __glutNumTabletButtons = 0;
int __glutNumMouseButtons = 3; /* Good guess. */
XDevice *__glutTablet = NULL;
XDevice *__glutDials = NULL;
XDevice *__glutSpaceball = NULL;

int __glutHasJoystick = 0;
int __glutNumJoystickButtons = 0;
int __glutNumJoystickAxes = 0;

#if !defined(_WIN32)
typedef struct _Range {
int min;
int range;
} Range;

#define NUM_SPACEBALL_AXIS 6
#define NUM_TABLET_AXIS 2
#define NUM_DIALS_AXIS 8

Range __glutSpaceballRange[NUM_SPACEBALL_AXIS];
Range __glutTabletRange[NUM_TABLET_AXIS];
int *__glutDialsResolution;

/* Safely assumes 0 is an illegal event type for X Input
extension events. */
int __glutDeviceMotionNotify = 0;
int __glutDeviceButtonPress = 0;
int __glutDeviceButtonPressGrab = 0;
int __glutDeviceButtonRelease = 0;
int __glutDeviceStateNotify = 0;

static int
normalizeTabletPos(int axis, int rawValue)
{
assert(rawValue >= __glutTabletRange[axis].min);
assert(rawValue <= __glutTabletRange[axis].min
+ __glutTabletRange[axis].range);
/* Normalize rawValue to between 0 and 4000. */
return ((rawValue - __glutTabletRange[axis].min) * 4000) /
__glutTabletRange[axis].range;
}

static int
normalizeDialAngle(int axis, int rawValue)
{
/* XXX Assumption made that the resolution of the device is
number of clicks for one complete dial revolution. This
is true for SGI's dial & button box. */
return (rawValue * 360.0) / __glutDialsResolution[axis];
}

static int
normalizeSpaceballAngle(int axis, int rawValue)
{
assert(rawValue >= __glutSpaceballRange[axis].min);
assert(rawValue <= __glutSpaceballRange[axis].min +
__glutSpaceballRange[axis].range);
/* Normalize rawValue to between -1800 and 1800. */
return ((rawValue - __glutSpaceballRange[axis].min) * 3600) /
__glutSpaceballRange[axis].range - 1800;
}

static int
normalizeSpaceballDelta(int axis, int rawValue)
{
assert(rawValue >= __glutSpaceballRange[axis].min);
assert(rawValue <= __glutSpaceballRange[axis].min +
__glutSpaceballRange[axis].range);
/* Normalize rawValue to between -1000 and 1000. */
return ((rawValue - __glutSpaceballRange[axis].min) * 2000) /
__glutSpaceballRange[axis].range - 1000;
}

static void
queryTabletPos(GLUTwindow * window)
{
XDeviceState *state;
XInputClass *any;
XValuatorState *v;
int i;

state = XQueryDeviceState(__glutDisplay, __glutTablet);
any = state->data;
for (i = 0; i < state->num_classes; i++) {
#if defined(__cplusplus) || defined(c_plusplus)
switch (any->c_class) {
#else
switch (any->class) {
#endif
case ValuatorClass:
v = (XValuatorState *) any;
if (v->num_valuators < 2)
goto end;
if (window->tabletPos[0] == -1)
window->tabletPos[0] = normalizeTabletPos(0, v->valuators[0]);
if (window->tabletPos[1] == -1)
window->tabletPos[1] = normalizeTabletPos(1, v->valuators[1]);
}
any = (XInputClass *) ((char *) any + any->length);
}
end:
XFreeDeviceState(state);
}

static void
tabletPosChange(GLUTwindow * window, int first, int count, int *data)
{
int i, value, genEvent = 0;

for (i = first; i < first + count; i++) {
switch (i) {
case 0: /* X axis */
case 1: /* Y axis */
value = normalizeTabletPos(i, data[i - first]);
if (value != window->tabletPos[i]) {
window->tabletPos[i] = value;
genEvent = 1;
}
break;
}
}
if (window->tabletPos[0] == -1 || window->tabletPos[1] == -1)
queryTabletPos(window);
if (genEvent)
window->tabletMotion(window->tabletPos[0], window->tabletPos[1]);
}
#endif /* !_WIN32 */

static int
__glutProcessDeviceEvents(XEvent * event)
{
#if !defined(_WIN32)
GLUTwindow *window;

/* XXX Ugly code fan out. */

/* Can't use switch/case since X Input event types are
dynamic. */

if (__glutDeviceMotionNotify && event->type == __glutDeviceMotionNotify) {
XDeviceMotionEvent *devmot = (XDeviceMotionEvent *) event;

window = __glutGetWindow(devmot->window);
if (window) {
if (__glutTablet
&& devmot->deviceid == __glutTablet->device_id
&& window->tabletMotion) {
tabletPosChange(window, devmot->first_axis, devmot->axes_count,
devmot->axis_data);
} else if (__glutDials
&& devmot->deviceid == __glutDials->device_id
&& window->dials) {
int i, first = devmot->first_axis, count = devmot->axes_count;

for (i = first; i < first + count; i++)
window->dials(i + 1,
normalizeDialAngle(i, devmot->axis_data[i - first]));
} else if (__glutSpaceball
&& devmot->deviceid == __glutSpaceball->device_id) {
/* XXX Assume that space ball motion events come in as
all the first 6 axes. Assume first 3 axes are XYZ
translations; second 3 axes are XYZ rotations. */
if (devmot->first_axis == 0 && devmot->axes_count == 6) {
if (window->spaceMotion)
window->spaceMotion(
normalizeSpaceballDelta(0, devmot->axis_data[0]),
normalizeSpaceballDelta(1, devmot->axis_data[1]),
normalizeSpaceballDelta(2, devmot->axis_data[2]));
if (window->spaceRotate)
window->spaceRotate(
normalizeSpaceballAngle(3, devmot->axis_data[3]),
normalizeSpaceballAngle(4, devmot->axis_data[4]),
normalizeSpaceballAngle(5, devmot->axis_data[5]));
}
}
return 1;
}
} else if (__glutDeviceButtonPress
&& event->type == __glutDeviceButtonPress) {
XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;

window = __glutGetWindow(devbtn->window);
if (window) {
if (__glutTablet
&& devbtn->deviceid == __glutTablet->device_id
&& window->tabletButton
&& devbtn->first_axis == 0
&& devbtn->axes_count == 2) {
tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
devbtn->axis_data);
window->tabletButton(devbtn->button, GLUT_DOWN,
window->tabletPos[0], window->tabletPos[1]);
} else if (__glutDials
&& devbtn->deviceid == __glutDials->device_id
&& window->buttonBox) {
window->buttonBox(devbtn->button, GLUT_DOWN);
} else if (__glutSpaceball
&& devbtn->deviceid == __glutSpaceball->device_id
&& window->spaceButton) {
window->spaceButton(devbtn->button, GLUT_DOWN);
}
return 1;
}
} else if (__glutDeviceButtonRelease
&& event->type == __glutDeviceButtonRelease) {
XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;

window = __glutGetWindow(devbtn->window);
if (window) {
if (__glutTablet
&& devbtn->deviceid == __glutTablet->device_id
&& window->tabletButton
&& devbtn->first_axis == 0
&& devbtn->axes_count == 2) {
tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
devbtn->axis_data);
window->tabletButton(devbtn->button, GLUT_UP,
window->tabletPos[0], window->tabletPos[1]);
} else if (__glutDials
&& devbtn->deviceid == __glutDials->device_id
&& window->buttonBox) {
window->buttonBox(devbtn->button, GLUT_UP);
} else if (__glutSpaceball
&& devbtn->deviceid == __glutSpaceball->device_id
&& window->spaceButton) {
window->spaceButton(devbtn->button, GLUT_UP);
}
return 1;
}
}
#else
{
JOYINFOEX info;
JOYCAPS joyCaps;

memset(&info, 0, sizeof(JOYINFOEX));
info.dwSize = sizeof(JOYINFOEX);
info.dwFlags = JOY_RETURNALL;

if (joyGetPosEx(JOYSTICKID1,&info) != JOYERR_NOERROR) {
__glutHasJoystick = 1;
joyGetDevCaps(JOYSTICKID1, &joyCaps, sizeof(joyCaps));
__glutNumJoystickButtons = joyCaps.wNumButtons;
__glutNumJoystickAxes = joyCaps.wNumAxes;
} else {
__glutHasJoystick = 0;
__glutNumJoystickButtons = 0;
__glutNumJoystickAxes = 0;
}
}
#endif /* !_WIN32 */
return 0;
}

static GLUTeventParser eventParser =
{__glutProcessDeviceEvents, NULL};

static void
addDeviceEventParser(void)
{
static Bool been_here = False;

if (been_here)
return;
been_here = True;
__glutRegisterEventParser(&eventParser);
}

static int
probeDevices(void)
{
static Bool been_here = False;
static int support;
#if !defined(_WIN32)
XExtensionVersion *version;
XDeviceInfoPtr device_info, device;
XAnyClassPtr any;
XButtonInfoPtr b;
XValuatorInfoPtr v;
XAxisInfoPtr a;
int num_dev = 0, btns = 0, dials = 0;
int i, j, k;
#endif /* !_WIN32 */

if (been_here) {
return support;
}
been_here = True;

#if !defined(_WIN32)
version = XGetExtensionVersion(__glutDisplay, "XInputExtension");
/* Ugh. XInput extension API forces annoying cast of a pointer
to a long so it can be compared with the NoSuchExtension
value (#defined to 1). */
if (version == NULL || ((long) version) == NoSuchExtension) {
support = 0;
return support;
}
XFree(version);
device_info = XListInputDevices(__glutDisplay, &num_dev);
if (device_info) {
for (i = 0; i < num_dev; i++) {
/* XXX These are SGI names for these devices;
unfortunately, no good standard exists for standard
types of X input extension devices. */

device = &device_info[i];
any = (XAnyClassPtr) device->inputclassinfo;

if (!__glutSpaceball && !strcmp(device->name, "spaceball")) {
v = NULL;
b = NULL;
for (j = 0; j < device->num_classes; j++) {
#if defined(__cplusplus) || defined(c_plusplus)
switch (any->c_class) {
#else
switch (any->class) {
#endif
case ButtonClass:
b = (XButtonInfoPtr) any;
btns = b->num_buttons;
break;
case ValuatorClass:
v = (XValuatorInfoPtr) any;
/* Sanity check: at least 6 valuators? */
if (v->num_axes < NUM_SPACEBALL_AXIS)
goto skip_device;
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
for (k = 0; k < NUM_SPACEBALL_AXIS; k++, a++) {
__glutSpaceballRange[k].min = a->min_value;
__glutSpaceballRange[k].range = a->max_value - a->min_value;
}
break;
}
any = (XAnyClassPtr) ((char *) any + any->length);
}
if (v) {
__glutSpaceball = XOpenDevice(__glutDisplay, device->id);
if (__glutSpaceball) {
__glutNumSpaceballButtons = btns;
addDeviceEventParser();
}
}
} else if (!__glutDials && !strcmp(device->name, "dial+buttons")) {
v = NULL;
b = NULL;
for (j = 0; j < device->num_classes; j++) {
#if defined(__cplusplus) || defined(c_plusplus)
switch (any->c_class) {
#else
switch (any->class) {
#endif
case ButtonClass:
b = (XButtonInfoPtr) any;
btns = b->num_buttons;
break;
case ValuatorClass:
v = (XValuatorInfoPtr) any;
/* Sanity check: at least 8 valuators? */
if (v->num_axes < NUM_DIALS_AXIS)
goto skip_device;
dials = v->num_axes;
__glutDialsResolution = (int *) malloc(sizeof(int) * dials);
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
for (k = 0; k < dials; k++, a++) {
__glutDialsResolution[k] = a->resolution;
}
break;
}
any = (XAnyClassPtr) ((char *) any + any->length);
}
if (v) {
__glutDials = XOpenDevice(__glutDisplay, device->id);
if (__glutDials) {
__glutNumButtonBoxButtons = btns;
__glutNumDials = dials;
addDeviceEventParser();
}
}
} else if (!__glutTablet && !strcmp(device->name, "tablet")) {
v = NULL;
b = NULL;
for (j = 0; j < device->num_classes; j++) {
#if defined(__cplusplus) || defined(c_plusplus)
switch (any->c_class) {
#else
switch (any->class) {
#endif
case ButtonClass:
b = (XButtonInfoPtr) any;
btns = b->num_buttons;
break;
case ValuatorClass:
v = (XValuatorInfoPtr) any;
/* Sanity check: exactly 2 valuators? */
if (v->num_axes != NUM_TABLET_AXIS)
goto skip_device;
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
for (k = 0; k < NUM_TABLET_AXIS; k++, a++) {
__glutTabletRange[k].min = a->min_value;
__glutTabletRange[k].range = a->max_value - a->min_value;
}
break;
}
any = (XAnyClassPtr) ((char *) any + any->length);
}
if (v) {
__glutTablet = XOpenDevice(__glutDisplay, device->id);
if (__glutTablet) {
__glutNumTabletButtons = btns;
addDeviceEventParser();
}
}
} else if (!strcmp(device->name, "mouse")) {
for (j = 0; j < device->num_classes; j++) {
#if defined(__cplusplus) || defined(c_plusplus)
if (any->c_class == ButtonClass) {
#else
if (any->class == ButtonClass) {
#endif
b = (XButtonInfoPtr) any;
__glutNumMouseButtons = b->num_buttons;
}
any = (XAnyClassPtr) ((char *) any + any->length);
}
}
skip_device:;
}
XFreeDeviceList(device_info);
}
#else /* _WIN32 */
__glutNumMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
#endif /* !_WIN32 */
/* X Input extension might be supported, but only if there is
a tablet, dials, or spaceball do we claim devices are
supported. */
support = __glutTablet || __glutDials || __glutSpaceball;
return support;
}

void
__glutUpdateInputDeviceMask(GLUTwindow * window)
{
#if !defined(_WIN32)
/* 5 (dial and buttons) + 5 (tablet locator and buttons) + 5
(Spaceball buttons and axis) = 15 */
XEventClass eventList[15];
int rc, numEvents;

rc = probeDevices();
if (rc) {
numEvents = 0;
if (__glutTablet) {
if (window->tabletMotion) {
DeviceMotionNotify(__glutTablet, __glutDeviceMotionNotify,
eventList[numEvents]);
numEvents++;
}
if (window->tabletButton) {
DeviceButtonPress(__glutTablet, __glutDeviceButtonPress,
eventList[numEvents]);
numEvents++;
DeviceButtonPressGrab(__glutTablet, __glutDeviceButtonPressGrab,
eventList[numEvents]);
numEvents++;
DeviceButtonRelease(__glutTablet, __glutDeviceButtonRelease,
eventList[numEvents]);
numEvents++;
}
if (window->tabletMotion || window->tabletButton) {
DeviceStateNotify(__glutTablet, __glutDeviceStateNotify,
eventList[numEvents]);
numEvents++;
}
}
if (__glutDials) {
if (window->dials) {
DeviceMotionNotify(__glutDials, __glutDeviceMotionNotify,
eventList[numEvents]);
numEvents++;
}
if (window->buttonBox) {
DeviceButtonPress(__glutDials, __glutDeviceButtonPress,
eventList[numEvents]);
numEvents++;
DeviceButtonPressGrab(__glutDials, __glutDeviceButtonPressGrab,
eventList[numEvents]);
numEvents++;
DeviceButtonRelease(__glutDials, __glutDeviceButtonRelease,
eventList[numEvents]);
numEvents++;
}
if (window->dials || window->buttonBox) {
DeviceStateNotify(__glutDials, __glutDeviceStateNotify,
eventList[numEvents]);
numEvents++;
}
}
if (__glutSpaceball) {
if (window->spaceMotion || window->spaceRotate) {
DeviceMotionNotify(__glutSpaceball, __glutDeviceMotionNotify,
eventList[numEvents]);
numEvents++;
}
if (window->spaceButton) {
DeviceButtonPress(__glutSpaceball, __glutDeviceButtonPress,
eventList[numEvents]);
numEvents++;
DeviceButtonPressGrab(__glutSpaceball, __glutDeviceButtonPressGrab,
eventList[numEvents]);
numEvents++;
DeviceButtonRelease(__glutSpaceball, __glutDeviceButtonRelease,
eventList[numEvents]);
numEvents++;
}
if (window->spaceMotion || window->spaceRotate || window->spaceButton) {
DeviceStateNotify(__glutSpaceball, __glutDeviceStateNotify,
eventList[numEvents]);
numEvents++;
}
}
#if 0
if (window->children) {
GLUTwindow *child = window->children;

do {
XChangeDeviceDontPropagateList(__glutDisplay, child->win,
numEvents, eventList, AddToList);
child = child->siblings;
} while (child);
}
#endif
XSelectExtensionEvent(__glutDisplay, window->win,
eventList, numEvents);
if (window->overlay) {
XSelectExtensionEvent(__glutDisplay, window->overlay->win,
eventList, numEvents);
}
} else {
/* X Input extension not supported; no chance for exotic
input devices. */
}
#endif /* !_WIN32 */
}

#endif //POFIG

/* CENTRY */
int GLUTAPIENTRY
glutDeviceGet(GLenum param)
{
#if POFIG
probeDevices();
#endif
switch (param) {
case GLUT_HAS_KEYBOARD:
case GLUT_HAS_MOUSE:
/* Assume window system always has mouse and keyboard. */
return 1;
#if POFIG
case GLUT_HAS_SPACEBALL:
return __glutSpaceball != NULL;
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
return __glutDials != NULL;
case GLUT_HAS_TABLET:
return __glutTablet != NULL;
case GLUT_NUM_MOUSE_BUTTONS:
return __glutNumMouseButtons;
case GLUT_NUM_SPACEBALL_BUTTONS:
return __glutNumSpaceballButtons;
case GLUT_NUM_BUTTON_BOX_BUTTONS:
return __glutNumButtonBoxButtons;
case GLUT_NUM_DIALS:
return __glutNumDials;
case GLUT_NUM_TABLET_BUTTONS:
return __glutNumTabletButtons;
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return __glutCurrentWindow->ignoreKeyRepeat;
#ifndef _WIN32
case GLUT_DEVICE_KEY_REPEAT:
{
XKeyboardState state;

XGetKeyboardControl(__glutDisplay, &state);
return state.global_auto_repeat;
}
case GLUT_JOYSTICK_POLL_RATE:
return 0;
#else
case GLUT_DEVICE_KEY_REPEAT:
/* Win32 cannot globally disable key repeat. */
return GLUT_KEY_REPEAT_ON;
case GLUT_JOYSTICK_POLL_RATE:
return __glutCurrentWindow->joyPollInterval;
#endif
case GLUT_HAS_JOYSTICK:
return __glutHasJoystick;
case GLUT_JOYSTICK_BUTTONS:
return __glutNumJoystickButtons;
case GLUT_JOYSTICK_AXES:
return __glutNumJoystickAxes;
#endif //POFIG
default:
__glutWarning("invalid glutDeviceGet parameter: %d", param);
return -1;
}
}
/* ENDCENTRY */

+ 0
- 29
src/glut/os2/glut_key.cpp Näytä tiedosto

@@ -1,29 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 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"

/* CENTRY */
void GLUTAPIENTRY
glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
{
__glutChangeWindowEventMask(KeyPressMask,
keyboardFunc != NULL || __glutCurrentWindow->special != NULL);
__glutCurrentWindow->keyboard = keyboardFunc;
}

void GLUTAPIENTRY
glutSpecialFunc(GLUTspecialCB specialFunc)
{
__glutChangeWindowEventMask(KeyPressMask,
specialFunc != NULL || __glutCurrentWindow->keyboard != NULL);
__glutCurrentWindow->special = specialFunc;
}

/* ENDCENTRY */

+ 0
- 29
src/glut/os2/glut_keyctrl.cpp Näytä tiedosto

@@ -1,29 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 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 "glutint.h"

/* CENTRY */
void GLUTAPIENTRY
glutIgnoreKeyRepeat(int ignore)
{
__glutCurrentWindow->ignoreKeyRepeat = ignore;
}

void GLUTAPIENTRY
glutSetKeyRepeat(int repeatMode)
{
#if !defined(_WIN32) && !defined(__OS2PM__)
XKeyboardControl values;

/* GLUT's repeatMode #define's match the Xlib API values. */
values.auto_repeat_mode = repeatMode;
XChangeKeyboardControl(__glutDisplay, KBAutoRepeatMode, &values);
#endif
}

/* ENDCENTRY */

+ 0
- 29
src/glut/os2/glut_keyup.cpp Näytä tiedosto

@@ -1,29 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 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"

/* CENTRY */
void GLUTAPIENTRY
glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
{
__glutChangeWindowEventMask(KeyReleaseMask,
keyboardUpFunc != NULL || __glutCurrentWindow->specialUp != NULL);
__glutCurrentWindow->keyboardUp = keyboardUpFunc;
}

void GLUTAPIENTRY
glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
{
__glutChangeWindowEventMask(KeyReleaseMask,
specialUpFunc != NULL || __glutCurrentWindow->keyboardUp != NULL);
__glutCurrentWindow->specialUp = specialUpFunc;
}

/* ENDCENTRY */

+ 0
- 57
src/glut/os2/glut_mesa.cpp Näytä tiedosto

@@ -1,57 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1996. */

/* 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 <string.h>
#include "glutint.h"

int __glutMesaSwapHackSupport = 0; /* Not supported until
proven otherwise. */

/* Use the "Mesa swap hack" if reasonable if and only if
MESA_SWAP_HACK is set to something whose first character is
not "N" or "n" AND "Brian Paul" is the vendor string AND
"Mesa X11"* (or "Mesa" for backward compatibility) is the
renderer string.

Anyone who modifies Mesa so that glXSwapBuffers does not
simply blit the previously rendered back buffer should
change either their vendor or renderer string to avoid
confusing GLUT. */

void
__glutDetermineMesaSwapHackSupport(void)
{
static int doneAlready = 0;
char *env, *vendor, *renderer;

if (doneAlready)
return;
env = getenv("MESA_SWAP_HACK");
if (env) {
if ((env[0] != 'n') && (env[0] != 'N')) {
vendor = (char *) glGetString(GL_VENDOR);
renderer = (char *) glGetString(GL_RENDERER);

/* Old versions of X11 Mesa uses the renderer string
"Mesa"; Brian plans to start using "Mesa X11" to
distinguish the X version of Mesa from other flavor
such as Windows or 3Dfx. */

#define MESA_X11 "Mesa X11"

/* XXX At some point in the future, eliminate the
backward compatibility for the old "Mesa" renderer
string. */

if (!strcmp(vendor, "Brian Paul") && (!strcmp(renderer, "Mesa") ||
!strncmp(renderer, MESA_X11, sizeof(MESA_X11) - 1)))
__glutMesaSwapHackSupport = 1;
}
}
doneAlready = 1;
}

+ 0
- 31
src/glut/os2/glut_modifier.cpp Näytä tiedosto

@@ -1,31 +0,0 @@

/* 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 "glutint.h"

/* CENTRY */
int GLUTAPIENTRY
glutGetModifiers(void)
{
int modifiers;

if(__glutModifierMask == (unsigned int) ~0) {
__glutWarning(
"glutCurrentModifiers: do not call outside core input callback.");
return 0;
}
modifiers = 0;
if(__glutModifierMask & (ShiftMask|LockMask))
modifiers |= GLUT_ACTIVE_SHIFT;
if(__glutModifierMask & ControlMask)
modifiers |= GLUT_ACTIVE_CTRL;
if(__glutModifierMask & Mod1Mask)
modifiers |= GLUT_ACTIVE_ALT;
return modifiers;
}

/* ENDCENTRY */

+ 0
- 2451
src/glut/os2/glut_roman.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 595
src/glut/os2/glut_shapes.cpp Näytä tiedosto

@@ -1,595 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 1997. */

/**
(c) Copyright 1993, Silicon Graphics, Inc.

ALL RIGHTS RESERVED

Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.

THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.

US Government Users Restricted Rights

Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.

OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/

#include <math.h>
#include "glutint.h"

/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

static GLUquadricObj *quadObj;

#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }

static void
initQuadObj(void)
{
quadObj = gluNewQuadric();
if (!quadObj)
__glutFatalError("out of memory.");
}

/* CENTRY */
void GLUTAPIENTRY
glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}

void GLUTAPIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}

void GLUTAPIENTRY
glutWireCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}

void GLUTAPIENTRY
glutSolidCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}

/* ENDCENTRY */

static void
drawBox(GLfloat size, GLenum type)
{
static GLfloat n[6][3] =
{
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{1.0, 0.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static GLint faces[6][4] =
{
{0, 1, 2, 3},
{3, 2, 6, 7},
{7, 6, 5, 4},
{4, 5, 1, 0},
{5, 6, 2, 1},
{7, 4, 0, 3}
};
GLfloat v[8][3];
GLint i;

v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;

for (i = 5; i >= 0; i--) {
glBegin(type);
glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
glVertex3fv(&v[faces[i][3]][0]);
glEnd();
}
}

/* CENTRY */
void GLUTAPIENTRY
glutWireCube(GLdouble size)
{
drawBox(size, GL_LINE_LOOP);
}

void GLUTAPIENTRY
glutSolidCube(GLdouble size)
{
drawBox(size, GL_QUADS);
}

/* ENDCENTRY */

static void
doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
{
int i, j;
GLfloat theta, phi, theta1;
GLfloat cosTheta, sinTheta;
GLfloat cosTheta1, sinTheta1;
GLfloat ringDelta, sideDelta;

ringDelta = 2.0 * M_PI / rings;
sideDelta = 2.0 * M_PI / nsides;

theta = 0.0;
cosTheta = 1.0;
sinTheta = 0.0;
for (i = rings - 1; i >= 0; i--) {
theta1 = theta + ringDelta;
cosTheta1 = cos(theta1);
sinTheta1 = sin(theta1);
glBegin(GL_QUAD_STRIP);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
GLfloat cosPhi, sinPhi, dist;

phi += sideDelta;
cosPhi = cos(phi);
sinPhi = sin(phi);
dist = R + r * cosPhi;

glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
}
glEnd();
theta = theta1;
cosTheta = cosTheta1;
sinTheta = sinTheta1;
}
}

/* CENTRY */
void GLUTAPIENTRY
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
doughnut(innerRadius, outerRadius, nsides, rings);
glPopAttrib();
}

void GLUTAPIENTRY
glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
doughnut(innerRadius, outerRadius, nsides, rings);
}

/* ENDCENTRY */

static GLfloat dodec[20][3];

static void
initDodecahedron(void)
{
GLfloat alpha, beta;

alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
/* *INDENT-OFF* */
dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
/* *INDENT-ON* */

}

#define DIFF3(_a,_b,_c) { \
(_c)[0] = (_a)[0] - (_b)[0]; \
(_c)[1] = (_a)[1] - (_b)[1]; \
(_c)[2] = (_a)[2] - (_b)[2]; \
}

static void
crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
{
GLfloat p[3]; /* in case prod == v1 or v2 */

p[0] = v1[1] * v2[2] - v2[1] * v1[2];
p[1] = v1[2] * v2[0] - v2[2] * v1[0];
p[2] = v1[0] * v2[1] - v2[0] * v1[1];
prod[0] = p[0];
prod[1] = p[1];
prod[2] = p[2];
}

static void
normalize(GLfloat v[3])
{
GLfloat d;

d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
if (d == 0.0) {
__glutWarning("normalize: zero length vector");
v[0] = d = 1.0;
}
d = 1 / d;
v[0] *= d;
v[1] *= d;
v[2] *= d;
}

static void
pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
{
GLfloat n0[3], d1[3], d2[3];

DIFF3(dodec[a], dodec[b], d1);
DIFF3(dodec[b], dodec[c], d2);
crossprod(d1, d2, n0);
normalize(n0);

glBegin(shadeType);
glNormal3fv(n0);
glVertex3fv(&dodec[a][0]);
glVertex3fv(&dodec[b][0]);
glVertex3fv(&dodec[c][0]);
glVertex3fv(&dodec[d][0]);
glVertex3fv(&dodec[e][0]);
glEnd();
}

static void
dodecahedron(GLenum type)
{
static int inited = 0;

if (inited == 0) {
inited = 1;
initDodecahedron();
}
pentagon(0, 1, 9, 16, 5, type);
pentagon(1, 0, 3, 18, 7, type);
pentagon(1, 7, 11, 10, 9, type);
pentagon(11, 7, 18, 19, 6, type);
pentagon(8, 17, 16, 9, 10, type);
pentagon(2, 14, 15, 6, 19, type);
pentagon(2, 13, 12, 4, 14, type);
pentagon(2, 19, 18, 3, 13, type);
pentagon(3, 0, 5, 12, 13, type);
pentagon(6, 15, 8, 10, 11, type);
pentagon(4, 17, 8, 15, 14, type);
pentagon(4, 12, 5, 16, 17, type);
}

/* CENTRY */
void GLUTAPIENTRY glutWireDodecahedron(void)
{
dodecahedron(GL_LINE_LOOP);
}

void GLUTAPIENTRY
glutSolidDodecahedron(void)
{
dodecahedron(GL_TRIANGLE_FAN);
}

/* ENDCENTRY */

static void
recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
GLenum shadeType)
{
GLfloat q0[3], q1[3];

DIFF3(n1, n2, q0);
DIFF3(n2, n3, q1);
crossprod(q0, q1, q1);
normalize(q1);

glBegin(shadeType);
glNormal3fv(q1);
glVertex3fv(n1);
glVertex3fv(n2);
glVertex3fv(n3);
glEnd();
}

static void
subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
GLenum shadeType)
{
int depth;
GLfloat w0[3], w1[3], w2[3];
GLfloat l;
int i, j, k, n;

depth = 1;
for (i = 0; i < depth; i++) {
for (j = 0; i + j < depth; j++) {
k = depth - i - j;
for (n = 0; n < 3; n++) {
w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
/ depth;
w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
/ depth;
}
l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
w0[0] /= l;
w0[1] /= l;
w0[2] /= l;
l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
w1[0] /= l;
w1[1] /= l;
w1[2] /= l;
l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
w2[0] /= l;
w2[1] /= l;
w2[2] /= l;
recorditem(w1, w0, w2, shadeType);
}
}
}

static void
drawtriangle(int i, GLfloat data[][3], int ndx[][3],
GLenum shadeType)
{
GLfloat *x0, *x1, *x2;

x0 = data[ndx[i][0]];
x1 = data[ndx[i][1]];
x2 = data[ndx[i][2]];
subdivide(x0, x1, x2, shadeType);
}

/* octahedron data: The octahedron produced is centered at the
origin and has radius 1.0 */
static GLfloat odata[6][3] =
{
{1.0, 0.0, 0.0},
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};

static int ondex[8][3] =
{
{0, 4, 2},
{1, 2, 4},
{0, 3, 4},
{1, 4, 3},
{0, 2, 5},
{1, 5, 2},
{0, 5, 3},
{1, 3, 5}
};

static void
octahedron(GLenum shadeType)
{
int i;

for (i = 7; i >= 0; i--) {
drawtriangle(i, odata, ondex, shadeType);
}
}

/* CENTRY */
void GLUTAPIENTRY
glutWireOctahedron(void)
{
octahedron(GL_LINE_LOOP);
}

void GLUTAPIENTRY
glutSolidOctahedron(void)
{
octahedron(GL_TRIANGLES);
}

/* ENDCENTRY */

/* icosahedron data: These numbers are rigged to make an
icosahedron of radius 1.0 */

#define X .525731112119133606
#define Z .850650808352039932

static GLfloat idata[12][3] =
{
{-X, 0, Z},
{X, 0, Z},
{-X, 0, -Z},
{X, 0, -Z},
{0, Z, X},
{0, Z, -X},
{0, -Z, X},
{0, -Z, -X},
{Z, X, 0},
{-Z, X, 0},
{Z, -X, 0},
{-Z, -X, 0}
};

static int index[20][3] =
{
{0, 4, 1},
{0, 9, 4},
{9, 5, 4},
{4, 5, 8},
{4, 8, 1},
{8, 10, 1},
{8, 3, 10},
{5, 3, 8},
{5, 2, 3},
{2, 7, 3},
{7, 10, 3},
{7, 6, 10},
{7, 11, 6},
{11, 0, 6},
{0, 1, 6},
{6, 1, 10},
{9, 0, 11},
{9, 11, 2},
{9, 2, 5},
{7, 2, 11},
};

static void
icosahedron(GLenum shadeType)
{
int i;

for (i = 19; i >= 0; i--) {
drawtriangle(i, idata, index, shadeType);
}
}

/* CENTRY */
void GLUTAPIENTRY
glutWireIcosahedron(void)
{
icosahedron(GL_LINE_LOOP);
}

void GLUTAPIENTRY
glutSolidIcosahedron(void)
{
icosahedron(GL_TRIANGLES);
}

/* ENDCENTRY */

/* tetrahedron data: */

#define T 1.73205080756887729

static GLfloat tdata[4][3] =
{
{T, T, T},
{T, -T, -T},
{-T, T, -T},
{-T, -T, T}
};

static int tndex[4][3] =
{
{0, 1, 3},
{2, 1, 0},
{3, 2, 0},
{1, 2, 3}
};

static void
tetrahedron(GLenum shadeType)
{
int i;

for (i = 3; i >= 0; i--)
drawtriangle(i, tdata, tndex, shadeType);
}

/* CENTRY */
void GLUTAPIENTRY
glutWireTetrahedron(void)
{
tetrahedron(GL_LINE_LOOP);
}

void GLUTAPIENTRY
glutSolidTetrahedron(void)
{
tetrahedron(GL_TRIANGLES);
}

/* ENDCENTRY */

+ 0
- 42
src/glut/os2/glut_stroke.cpp Näytä tiedosto

@@ -1,42 +0,0 @@

/* 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 "glutint.h"
#include "glutstroke.h"

void GLUTAPIENTRY
glutStrokeCharacter(GLUTstrokeFont font, int c)
{
const StrokeCharRec *ch;
const StrokeRec *stroke;
const CoordRec *coord;
StrokeFontPtr fontinfo;
int i, j;


#if defined(_WIN32)
fontinfo = (StrokeFontPtr) __glutFont(font);
#else
fontinfo = (StrokeFontPtr) font;
#endif

if (c < 0 || c >= fontinfo->num_chars)
return;
ch = &(fontinfo->ch[c]);
if (ch) {
for (i = ch->num_strokes, stroke = ch->stroke;
i > 0; i--, stroke++) {
glBegin(GL_LINE_STRIP);
for (j = stroke->num_coords, coord = stroke->coord;
j > 0; j--, coord++) {
glVertex2f(coord->x, coord->y);
}
glEnd();
}
glTranslatef(ch->right, 0.0, 0.0);
}
}

+ 0
- 67
src/glut/os2/glut_swap.cpp Näytä tiedosto

@@ -1,67 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 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 <stdio.h>
#include "glutint.h"

GLint __glutFPS = 0;
GLint __glutSwapCount = 0;
GLint __glutSwapTime = 0;

/* CENTRY */
void GLUTAPIENTRY
glutSwapBuffers(void)
{
GLUTwindow *window = __glutCurrentWindow;

if (window->renderWin == window->win) {
if (__glutCurrentWindow->treatAsSingle) {
/* Pretend the double buffered window is single buffered,
so treat glutSwapBuffers as a no-op. */
return;
}
} else {
if (__glutCurrentWindow->overlay->treatAsSingle) {
/* Pretend the double buffered overlay is single
buffered, so treat glutSwapBuffers as a no-op. */
return;
}
}

/* For the MESA_SWAP_HACK. */
window->usedSwapBuffers = 1;

SWAP_BUFFERS_LAYER(__glutCurrentWindow);

/* I considered putting the window being swapped on the
GLUT_FINISH_WORK work list because you could call
glutSwapBuffers from an idle callback which doesn't call
__glutSetWindow which normally adds indirect rendering
windows to the GLUT_FINISH_WORK work list. Not being put
on the list could lead to the buffering up of multiple
redisplays and buffer swaps and hamper interactivity. I
consider this an application bug due to not using
glutPostRedisplay to trigger redraws. If
glutPostRedisplay were used, __glutSetWindow would be
called and a glFinish to throttle buffering would occur. */

if (__glutFPS) {
GLint t = glutGet(GLUT_ELAPSED_TIME);
__glutSwapCount++;
if (__glutSwapTime == 0)
__glutSwapTime = t;
else if (t - __glutSwapTime > __glutFPS) {
float time = 0.001 * (t - __glutSwapTime);
float fps = (float) __glutSwapCount / time;
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n",
__glutSwapCount, time, fps);
__glutSwapTime = t;
__glutSwapCount = 0;
}
}
}
/* ENDCENTRY */

+ 0
- 210
src/glut/os2/glut_teapot.cpp Näytä tiedosto

@@ -1,210 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994. */

/**
(c) Copyright 1993, Silicon Graphics, Inc.

ALL RIGHTS RESERVED

Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.

THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.

US Government Users Restricted Rights

Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.

OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/

#include "glutint.h"

/* Rim, body, lid, and bottom data must be reflected in x and
y; handle and spout data across the y axis only. */

static int patchdata[][16] =
{
/* rim */
{102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15},
/* body */
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27},
{24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40},
/* lid */
{96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
101, 0, 1, 2, 3,},
{0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117},
/* bottom */
{118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
125, 120, 40, 39, 38, 37},
/* handle */
{41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56},
{53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
28, 65, 66, 67},
/* spout */
{68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83},
{80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95}
};
/* *INDENT-OFF* */

static float cpdata[][3] =
{
{0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
{0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
{1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
{0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
{1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
{1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
-1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
-0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
{-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
-0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
-0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
{2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
-0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
{3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
{3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
{2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
-0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
{0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
-0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
{0.84, -1.5, 0.075}
};

static float tex[2][2][2] =
{
{ {0, 0},
{1, 0}},
{ {0, 1},
{1, 1}}
};

/* *INDENT-ON* */

static void
teapot(GLint grid, GLdouble scale, GLenum type)
{
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;

glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_TEXTURE_COORD_2);
glPushMatrix();
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);
for (i = 0; i < 10; i++) {
for (j = 0; j < 4; j++) {
for (k = 0; k < 4; k++) {
for (l = 0; l < 3; l++) {
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 1)
q[j][k][l] *= -1.0;
if (i < 6) {
r[j][k][l] =
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 0)
r[j][k][l] *= -1.0;
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
if (l == 0)
s[j][k][l] *= -1.0;
if (l == 1)
s[j][k][l] *= -1.0;
}
}
}
}
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
&tex[0][0][0]);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&p[0][0][0]);
glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&q[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
if (i < 6) {
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&r[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&s[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
}
}
glPopMatrix();
glPopAttrib();
}

/* CENTRY */
void GLUTAPIENTRY
glutSolidTeapot(GLdouble scale)
{
teapot(7, scale, GL_FILL);
}

void GLUTAPIENTRY
glutWireTeapot(GLdouble scale)
{
teapot(10, scale, GL_LINE);
}

/* ENDCENTRY */

+ 0
- 2063
src/glut/os2/glut_tr24.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 90
src/glut/os2/glut_util.cpp Näytä tiedosto

@@ -1,90 +0,0 @@

/* 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 <stdarg.h>
#include <string.h>
#include <stdio.h>

#include "glutint.h"

#if !defined(__OS2__)

/* strdup is actually not a standard ANSI C or POSIX routine
so implement a private one for GLUT. OpenVMS does not have a
strdup; Linux's standard libc doesn't declare strdup by default
(unless BSD or SVID interfaces are requested). */
char *
__glutStrdup(const char *string)
{
char *copy;

copy = (char*) malloc(strlen(string) + 1);
if (copy == NULL)
return NULL;
strcpy(copy, string);
return copy;
}
#endif

void
__glutWarning(char *format,...)
{
va_list args;

va_start(args, format);
fprintf(stderr, "GLUT: Warning in %s: ",
__glutProgramName ? __glutProgramName : "(unamed)");
vfprintf(stderr, format, args);
va_end(args);
putc('\n', stderr);
}

/* CENTRY */
void GLUTAPIENTRY
glutReportErrors(void)
{
GLenum error;

while ((error = glGetError()) != GL_NO_ERROR)
__glutWarning("GL error: %s", gluErrorString(error));
}
/* ENDCENTRY */

void
__glutFatalError(char *format,...)
{
va_list args;

va_start(args, format);
fprintf(stderr, "GLUT: Fatal Error in %s: ",
__glutProgramName ? __glutProgramName : "(unamed)");
vfprintf(stderr, format, args);
va_end(args);
putc('\n', stderr);
/* || defined(__OS2__) */
#if defined(_WIN32)
if (__glutExitFunc) {
__glutExitFunc(1);
}
#endif
exit(1);
}

void
__glutFatalUsage(char *format,...)
{
va_list args;

va_start(args, format);
fprintf(stderr, "GLUT: Fatal API Usage in %s: ",
__glutProgramName ? __glutProgramName : "(unamed)");
vfprintf(stderr, format, args);
va_end(args);
putc('\n', stderr);
abort();
}

+ 0
- 232
src/glut/os2/glut_vidresize.cpp Näytä tiedosto

@@ -1,232 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1996. */

/* 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>

#ifdef __sgi
#include <dlfcn.h>
#endif

#include "glutint.h"

/* Grumble. The IRIX 6.3 and early IRIX 6.4 OpenGL headers
support the video resize extension, but failed to define
GLX_SGIX_video_resize. */
#if 0
#ifdef GLX_SYNC_FRAME_SGIX
#define GLX_SGIX_video_resize 1
#endif
#endif

#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
static int canVideoResize = -1;
static int videoResizeChannel;
#else
static int canVideoResize = 0;
#endif
static int videoResizeInUse = 0;
static int dx = -1, dy = -1, dw = -1, dh = -1;

/* XXX Note that IRIX 6.2, 6.3, and some 6.4 versions have a
bug where programs seg-fault when they attempt video
resizing from an indirect OpenGL context (either local or
over a network). */

#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)

static volatile int errorCaught;

/* ARGSUSED */
static int
catchXSGIvcErrors(Display * dpy, XErrorEvent * event)
{
errorCaught = 1;
return 0;
}
#endif

/* CENTRY */

int GLUTAPIENTRY
glutVideoResizeGet(GLenum param)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (canVideoResize < 0) {
canVideoResize = __glutIsSupportedByGLX("GLX_SGIX_video_resize");
if (canVideoResize) {
#if defined(__sgi) && __sgi
/* This is a hack because IRIX 6.2, 6.3, and some 6.4
versions were released with GLX_SGIX_video_resize
being advertised by the X server though the video
resize extension is not actually supported. We try to
determine if the libGL.so we are using actually has a
video resize entrypoint before we try to use the
feature. */
void (*func) (void);
void *glxDso = dlopen("libGL.so", RTLD_LAZY);

func = (void (*)(void)) dlsym(glxDso, "glXQueryChannelDeltasSGIX");
if (!func) {
canVideoResize = 0;
} else
#endif
{
char *channelString;
int (*handler) (Display *, XErrorEvent *);

channelString = getenv("GLUT_VIDEO_RESIZE_CHANNEL");
videoResizeChannel = channelString ? atoi(channelString) : 0;

/* Work around another annoying problem with SGI's
GLX_SGIX_video_resize implementation. Early IRIX
6.4 OpenGL's advertise the extension and have the
video resize API, but an XSGIvc X protocol errors
result trying to use the API. Set up an error
handler to intercept what would otherwise be a fatal
error. If an error was recieved, do not report that
video resize is possible. */
handler = XSetErrorHandler(catchXSGIvcErrors);

errorCaught = 0;

#if defined(GLX_GLXEXT_PROTOTYPES)
#endif

__glut_glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, &dx, &dy, &dw, &dh);

/* glXQueryChannelDeltasSGIX is an inherent X server
round-trip so we know we will have gotten either the
correct reply or and error by this time. */
XSetErrorHandler(handler);

/* Still yet another work around. In IRIX 6.4 betas,
glXQueryChannelDeltasSGIX will return as if it
succeeded, but the values are filled with junk.
Watch to make sure the delta variables really make
sense. */
if (errorCaught ||
dx < 0 || dy < 0 || dw < 0 || dh < 0 ||
dx > 2048 || dy > 2048 || dw > 2048 || dh > 2048) {
canVideoResize = 0;
}
}
}
}
#endif /* GLX_SGIX_video_resize */

switch (param) {
case GLUT_VIDEO_RESIZE_POSSIBLE:
return canVideoResize;
case GLUT_VIDEO_RESIZE_IN_USE:
return videoResizeInUse;
case GLUT_VIDEO_RESIZE_X_DELTA:
return dx;
case GLUT_VIDEO_RESIZE_Y_DELTA:
return dy;
case GLUT_VIDEO_RESIZE_WIDTH_DELTA:
return dw;
case GLUT_VIDEO_RESIZE_HEIGHT_DELTA:
return dh;
case GLUT_VIDEO_RESIZE_X:
case GLUT_VIDEO_RESIZE_Y:
case GLUT_VIDEO_RESIZE_WIDTH:
case GLUT_VIDEO_RESIZE_HEIGHT:
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (videoResizeInUse) {
int x, y, width, height;

__glut_glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, &x, &y, &width, &height);
switch (param) {
case GLUT_VIDEO_RESIZE_X:
return x;
case GLUT_VIDEO_RESIZE_Y:
return y;
case GLUT_VIDEO_RESIZE_WIDTH:
return width;
case GLUT_VIDEO_RESIZE_HEIGHT:
return height;
}
}
#endif
return -1;
default:
__glutWarning("invalid glutVideoResizeGet parameter: %d", param);
return -1;
}
}

void GLUTAPIENTRY
glutSetupVideoResizing(void)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
__glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, __glutCurrentWindow->win);
videoResizeInUse = 1;
} else
#endif
__glutFatalError("glutEstablishVideoResizing: video resizing not possible.\n");
}

void GLUTAPIENTRY
glutStopVideoResizing(void)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
if (videoResizeInUse) {
__glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, None);
videoResizeInUse = 0;
}
}
#endif
}

/* ARGSUSED */
void GLUTAPIENTRY
glutVideoResize(int x, int y, int width, int height)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (videoResizeInUse) {
#ifdef GLX_SYNC_SWAP_SGIX
/* glXChannelRectSyncSGIX introduced in a patch to IRIX
6.2; the original unpatched IRIX 6.2 behavior is always
GLX_SYNC_SWAP_SGIX. */
__glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, GLX_SYNC_SWAP_SGIX);
#endif
__glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, x, y, width, height);
}
#endif
}

/* ARGSUSED */
void GLUTAPIENTRY
glutVideoPan(int x, int y, int width, int height)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
if (videoResizeInUse) {
#ifdef GLX_SYNC_FRAME_SGIX
/* glXChannelRectSyncSGIX introduced in a patch to IRIX
6.2; the original unpatched IRIX 6.2 behavior is always
GLX_SYNC_SWAP_SGIX. We just ignore that we cannot
accomplish GLX_SYNC_FRAME_SGIX on IRIX unpatched 6.2;
this means you'd need a glutSwapBuffers to actually
realize the video resize. */
__glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, GLX_SYNC_FRAME_SGIX);
#endif
__glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
videoResizeChannel, x, y, width, height);
}
#endif
}

/* ENDCENTRY */

+ 0
- 29
src/glut/os2/glut_warp.cpp Näytä tiedosto

@@ -1,29 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 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 <stdarg.h>
#include <stdio.h>

#include "glutint.h"

/* CENTRY */
void GLUTAPIENTRY
glutWarpPointer(int x, int y)
{
// XWarpPointer(__glutDisplay, None, __glutCurrentWindow->win,
// 0, 0, 0, 0, x, y);
POINTL point;
point.x = x;
point.y = y;
WinMapWindowPoints(__glutCurrentWindow->win,HWND_DESKTOP,&point,1);
WinSetPointerPos(HWND_DESKTOP, point.x, point.y);

XFlush(__glutDisplay);
}

/* ENDCENTRY */

+ 0
- 1220
src/glut/os2/glut_win.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 126
src/glut/os2/glut_winmisc.cpp Näytä tiedosto

@@ -1,126 +0,0 @@

/* 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 */

+ 0
- 32
src/glut/os2/glutbitmap.h Näytä tiedosto

@@ -1,32 +0,0 @@
#ifndef __glutbitmap_h__
#define __glutbitmap_h__

/* Copyright (c) Mark J. Kilgard, 1994, 1998. */

/* 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. */

#define GLUT_NO_LIB_PRAGMA /* Avoid auto library linking when building
the GLUT library itself. */
#include <GL/glut.h>

typedef struct {
const GLsizei width;
const GLsizei height;
const GLfloat xorig;
const GLfloat yorig;
const GLfloat advance;
const GLubyte *bitmap;
} BitmapCharRec, *BitmapCharPtr;

typedef struct {
const char *name;
const int num_chars;
const int first;
const BitmapCharRec * const *ch;
} BitmapFontRec, *BitmapFontPtr;

typedef void *GLUTbitmapFont;

#endif /* __glutbitmap_h__ */

+ 0
- 36
src/glut/os2/glutos2.h Näytä tiedosto

@@ -1,36 +0,0 @@
#ifndef __glutos2_h__
#define __glutos2_h__


/* Win32 "equivalent" cursors - eventually, the X glyphs should be
converted to Win32 cursors -- then they will look the same */
#define XC_arrow IDC_ARROW
#define XC_top_left_arrow IDC_ARROW
#define XC_hand1 IDC_SIZEALL
#define XC_pirate IDC_NO
#define XC_question_arrow IDC_HELP
#define XC_exchange IDC_NO
#define XC_spraycan IDC_SIZEALL
#define XC_watch IDC_WAIT
#define XC_xterm IDC_IBEAM
#define XC_crosshair IDC_CROSS
#define XC_sb_v_double_arrow IDC_SIZENS
#define XC_sb_h_double_arrow IDC_SIZEWE
#define XC_top_side IDC_UPARROW
#define XC_bottom_side IDC_SIZENS
#define XC_left_side IDC_SIZEWE
#define XC_right_side IDC_SIZEWE
#define XC_top_left_corner IDC_SIZENWSE
#define XC_top_right_corner IDC_SIZENESW
#define XC_bottom_right_corner IDC_SIZENWSE
#define XC_bottom_left_corner IDC_SIZENESW

#define XA_STRING 0

/* Private routines from win32_util.c */
extern int gettimeofday(struct timeval* tp, void* tzp);
//extern void *__glutFont(void *font);
extern int __glutGetTransparentPixel(Display *dpy, XVisualInfo *vinfo);
extern void __glutAdjustCoords(Window parent, int *x, int *y, int *width, int *height);

#endif /* __glutos2_h__ */

+ 0
- 42
src/glut/os2/glutstroke.h Näytä tiedosto

@@ -1,42 +0,0 @@
#ifndef __glutstroke_h__
#define __glutstroke_h__

/* 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. */

#if defined(_WIN32)
#pragma warning (disable:4244) /* disable bogus conversion warnings */
#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
#endif

typedef struct {
float x;
float y;
} CoordRec, *CoordPtr;

typedef struct {
int num_coords;
const CoordRec *coord;
} StrokeRec, *StrokePtr;

typedef struct {
int num_strokes;
const StrokeRec *stroke;
float center;
float right;
} StrokeCharRec, *StrokeCharPtr;

typedef struct {
const char *name;
int num_chars;
const StrokeCharRec *ch;
float top;
float bottom;
} StrokeFontRec, *StrokeFontPtr;

typedef void *GLUTstrokeFont;

#endif /* __glutstroke_h__ */

+ 0
- 59
src/glut/os2/layerutil.h Näytä tiedosto

@@ -1,59 +0,0 @@
#ifndef __layerutil_h__
#define __layerutil_h__

/* Copyright (c) Mark J. Kilgard, 1993, 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. */

/* Based on XLayerUtil.h: Revision: 1.3 */

#ifdef __VMS
#include <GL/vms_x_fix.h>
#endif

#if !defined(_WIN32) && !defined(__OS2__)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xmd.h>
#endif /* !_WIN32 */

/* Transparent type values */
/* None 0 */
#define TransparentPixel 1
#define TransparentMask 2

/* layered visual info template flags */
#define VisualLayerMask 0x200
#define VisualTransparentType 0x400
#define VisualTransparentValue 0x800
#define VisualAllLayerMask 0xFFF

/* layered visual info structure */
typedef struct _XLayerVisualInfo {
XVisualInfo vinfo;
long layer;
long type;
unsigned long value;
} XLayerVisualInfo;

/* SERVER_OVERLAY_VISUALS property element */
typedef struct _OverlayInfo {
/* Avoid 64-bit portability problems by being careful to use
longs due to the way XGetWindowProperty is specified. Note
that these parameters are passed as CARD32s over X
protocol. */
long overlay_visual;
long transparent_type;
long value;
long layer;
} OverlayInfo;

extern int __glutGetTransparentPixel(Display *, XVisualInfo *);
extern XLayerVisualInfo *__glutXGetLayerVisualInfo(Display *,
long, XLayerVisualInfo *, int *);
extern Status __glutXMatchLayerVisualInfo(Display *,
int, int, int, int, XLayerVisualInfo *);

#endif /* __layerutil_h__ */

+ 0
- 94
src/glut/os2/libGlut.DEF Näytä tiedosto

@@ -1,94 +0,0 @@

;-----------------------------------------------------
; def Module definition file for the DLL
;-----------------------------------------------------

LIBRARY libGlut INITINSTANCE TERMINSTANCE
PROTMODE
DATA MULTIPLE NONSHARED READWRITE LOADONCALL
CODE LOADONCALL
EXPORTS ; Names of exported functions and data

;*********************************
;MesaGLUT
glutCommandFunc @3001
glutCreateWindow @3002
glutCreateSubWindow @3003
glutDestroyWindow @3004
glutDisplayFunc @3005
glutEntryFunc @3006
glutExtensionSupported @3007
glutIdleFunc @3008
glutInit @3009
glutInitDisplayMode @3010
glutInitWindowPosition @3011
glutInitWindowSize @3012
glutMainLoop @3013
glutGet @3014
glutGetColor @3015
glutGetWindow @3016
glutKeyboardFunc @3017
glutMouseFunc @3018
glutSpecialFunc @3019
glutStrokeCharacter @3020
glutSetColor @3021
glutSetIconTitle @3022
glutSetWindow @3023
glutSetWindowTitle @3024

glutReshapeFunc @3025
glutReshapeWindow @3026


glutSwapBuffers @3027
glutPostRedisplay @3028
glutPositionWindow @3029
glutVisibilityFunc @3030
glutTimerFunc @3031
glutMotionFunc @3032

glutCreateMenu @3033
glutAttachMenu @3034
glutDestroyMenu @3035
glutAddMenuEntry @3036
glutPassiveMotionFunc @3037

glutSolidCone @3038
glutSolidCube @3039
glutSolidDodecahedron @3040
glutSolidOctahedron @3041
glutSolidIcosahedron @3042
glutSolidSphere @3043
glutSolidTeapot @3044
glutSolidTetrahedron @3045
glutSolidTorus @3046

glutWireCone @3047
glutWireCube @3048
glutWireDodecahedron @3049
glutWireIcosahedron @3050
glutWireOctahedron @3051
glutWireSphere @3052
glutWireTetrahedron @3053
glutWireTorus @3054
glutWireTeapot @3055

;GL_GLEXT_PROTOTYPES
glutBitmapCharacter @3101
glutBitmap9By15 @3102
glutBitmapHelvetica10 @3103
glutBitmapHelvetica12 @3104
glutBitmapHelvetica18 @3105
glutBitmapTimesRoman24 @3106
glutStrokeRoman @3107
glutBitmap8By13 @3108
;Global constants
; hab @12001
; /* PM anchor block handle */
; hpsCurrent @12002
XHDC @12004
XHWND @12005




+ 0
- 145
src/glut/os2/os2_glx.cpp Näytä tiedosto

@@ -1,145 +0,0 @@
/* 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 */


+ 0
- 532
src/glut/os2/os2_menu.cpp Näytä tiedosto

@@ -1,532 +0,0 @@

/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
/* Copyright (c) Nate Robins, 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. */

/* This file completely re-implements glut_menu.c and glut_menu2.c
for Win32. Note that neither glut_menu.c nor glut_menu2.c are
compiled into Win32 GLUT. */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>

#include "glutint.h"

void (GLUTCALLBACK *__glutMenuStatusFunc) (int, int, int);
//GLUTmenu *__glutMappedMenu;
//GLUTwindow *__glutMenuWindow;
GLUTmenuItem *__glutItemSelected;
unsigned __glutMenuButton;

static GLUTmenu **menuList = NULL;
static int menuListSize = 0;
static UINT uniqueMenuHandler = 1;

/* DEPRICATED, use glutMenuStatusFunc instead. */
void GLUTAPIENTRY
glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
{
__glutMenuStatusFunc = (GLUTmenuStatusCB) menuStateFunc;
}

void GLUTAPIENTRY
glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
{
__glutMenuStatusFunc = menuStatusFunc;
}

void
__glutSetMenu(GLUTmenu * menu)
{
__glutCurrentMenu = menu;
}

static void
unmapMenu(GLUTmenu * menu)
{
if (menu->cascade) {
unmapMenu(menu->cascade);
menu->cascade = NULL;
}
menu->anchor = NULL;
menu->highlighted = NULL;
}

void
__glutFinishMenu(Window win, int x, int y)
{

unmapMenu(__glutMappedMenu);

/* XXX Put in a GdiFlush just in case. Probably unnecessary. -mjk */
// GdiFlush();

if (__glutMenuStatusFunc) {
__glutSetWindow(__glutMenuWindow);
__glutSetMenu(__glutMappedMenu);

/* Setting __glutMappedMenu to NULL permits operations that
change menus or destroy the menu window again. */
__glutMappedMenu = NULL;

__glutMenuStatusFunc(GLUT_MENU_NOT_IN_USE, x, y);
}
/* Setting __glutMappedMenu to NULL permits operations that
change menus or destroy the menu window again. */
__glutMappedMenu = NULL;

/* If an item is selected and it is not a submenu trigger,
generate menu callback. */
if (__glutItemSelected && !__glutItemSelected->isTrigger) {
__glutSetWindow(__glutMenuWindow);
/* When menu callback is triggered, current menu should be
set to the callback menu. */
__glutSetMenu(__glutItemSelected->menu);
__glutItemSelected->menu->select(__glutItemSelected->value);
}
__glutMenuWindow = NULL;
}

static void
mapMenu(GLUTmenu * menu, int x, int y)
{
//todo
// TrackPopupMenu((HMENU) menu->win, TPM_LEFTALIGN |
// (__glutMenuButton == TPM_RIGHTBUTTON) ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON,
// x, y, 0, __glutCurrentWindow->win, NULL);
}

void
__glutStartMenu(GLUTmenu * menu, GLUTwindow * window,
int x, int y, int x_win, int y_win)
{
assert(__glutMappedMenu == NULL);
__glutMappedMenu = menu;
__glutMenuWindow = window;
__glutItemSelected = NULL;
if (__glutMenuStatusFunc) {
__glutSetMenu(menu);
__glutSetWindow(window);
__glutMenuStatusFunc(GLUT_MENU_IN_USE, x_win, y_win);
}
mapMenu(menu, x, y);
}

GLUTmenuItem *
__glutGetUniqueMenuItem(GLUTmenu * menu, UINT unique)
{
GLUTmenuItem *item;
int i;

i = menu->num;
item = menu->list;
while (item) {
if (item->unique == unique) {
return item;
}
if (item->isTrigger) {
GLUTmenuItem *subitem;
subitem = __glutGetUniqueMenuItem(menuList[item->value], unique);
if (subitem) {
return subitem;
}
}
i--;
item = item->next;
}
return NULL;
}

GLUTmenuItem *
__glutGetMenuItem(GLUTmenu * menu, Window win, int *which)
{
GLUTmenuItem *item;
int i;

i = menu->num;
item = menu->list;
while (item) {
if (item->win == win) {
*which = i;
return item;
}
if (item->isTrigger) {
GLUTmenuItem *subitem;

subitem = __glutGetMenuItem(menuList[item->value],
win, which);
if (subitem) {
return subitem;
}
}
i--;
item = item->next;
}
return NULL;
}

GLUTmenu *
__glutGetMenu(Window win)
{
GLUTmenu *menu;

menu = __glutMappedMenu;
while (menu) {
if (win == menu->win) {
return menu;
}
menu = menu->cascade;
}
return NULL;
}

GLUTmenu *
__glutGetMenuByNum(int menunum)
{
if (menunum < 1 || menunum > menuListSize) {
return NULL;
}
return menuList[menunum - 1];
}

static int
getUnusedMenuSlot(void)
{
int i;

/* Look for allocated, unused slot. */
for (i = 0; i < menuListSize; i++) {
if (!menuList[i]) {
return i;
}
}
/* Allocate a new slot. */
menuListSize++;
if (menuList) {
menuList = (GLUTmenu **)
realloc(menuList, menuListSize * sizeof(GLUTmenu *));
} else {
/* XXX Some realloc's do not correctly perform a malloc
when asked to perform a realloc on a NULL pointer,
though the ANSI C library spec requires this. */
menuList = (GLUTmenu **) malloc(sizeof(GLUTmenu *));
}
if (!menuList) {
__glutFatalError("out of memory.");
}
menuList[menuListSize - 1] = NULL;
return menuListSize - 1;
}

static void
menuModificationError(void)
{
/* XXX Remove the warning after GLUT 3.0. */
__glutWarning("The following is a new check for GLUT 3.0; update your code.");
__glutFatalError("menu manipulation not allowed while menus in use.");
}

int GLUTAPIENTRY
glutCreateMenu(GLUTselectCB selectFunc)
{
GLUTmenu *menu;
int menuid;

if (__glutMappedMenu) {
menuModificationError();
}
menuid = getUnusedMenuSlot();
menu = (GLUTmenu *) malloc(sizeof(GLUTmenu));
if (!menu) {
__glutFatalError("out of memory.");
}
menu->id = menuid;
menu->num = 0;
menu->submenus = 0;
menu->select = selectFunc;
menu->list = NULL;
menu->cascade = NULL;
menu->highlighted = NULL;
menu->anchor = NULL;
//todo
// menu->win = (HWND) CreatePopupMenu();
menuList[menuid] = menu;
__glutSetMenu(menu);
return menuid + 1;
}


void GLUTAPIENTRY
glutDestroyMenu(int menunum)
{
GLUTmenu *menu = __glutGetMenuByNum(menunum);
GLUTmenuItem *item, *next;

if (__glutMappedMenu) {
menuModificationError();
}
assert(menu->id == menunum - 1);
//todo DestroyMenu( (HMENU) menu->win);
menuList[menunum - 1] = NULL;
/* free all menu entries */
item = menu->list;
while (item) {
assert(item->menu == menu);
next = item->next;
free(item->label);
free(item);
item = next;
}
if (__glutCurrentMenu == menu) {
__glutCurrentMenu = NULL;
}
free(menu);
}

int GLUTAPIENTRY
glutGetMenu(void)
{
if (__glutCurrentMenu) {
return __glutCurrentMenu->id + 1;
} else {
return 0;
}
}

void GLUTAPIENTRY
glutSetMenu(int menuid)
{
GLUTmenu *menu;

if (menuid < 1 || menuid > menuListSize) {
__glutWarning("glutSetMenu attempted on bogus menu.");
return;
}
menu = menuList[menuid - 1];
if (!menu) {
__glutWarning("glutSetMenu attempted on bogus menu.");
return;
}
__glutSetMenu(menu);
}

static void
setMenuItem(GLUTmenuItem * item, const char *label,
int value, Bool isTrigger)
{
GLUTmenu *menu;

menu = item->menu;
item->label = __glutStrdup(label);
if (!item->label) {
__glutFatalError("out of memory.");
}
item->isTrigger = isTrigger;
item->len = (int) strlen(label);
item->value = value;
item->unique = uniqueMenuHandler++;
//todo
// if (isTrigger) {
// AppendMenu((HMENU) menu->win, MF_POPUP, (UINT)item->win, label);
// } else {
// AppendMenu((HMENU) menu->win, MF_STRING, item->unique, label);
// }
}

void GLUTAPIENTRY
glutAddMenuEntry(const char *label, int value)
{
GLUTmenuItem *entry;

if (__glutMappedMenu) {
menuModificationError();
}
entry = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
if (!entry) {
__glutFatalError("out of memory.");
}
entry->menu = __glutCurrentMenu;
setMenuItem(entry, label, value, FALSE);
__glutCurrentMenu->num++;
entry->next = __glutCurrentMenu->list;
__glutCurrentMenu->list = entry;
}

void GLUTAPIENTRY
glutAddSubMenu(const char *label, int menu)
{
GLUTmenuItem *submenu;
GLUTmenu *popupmenu;

if (__glutMappedMenu) {
menuModificationError();
}
submenu = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
if (!submenu) {
__glutFatalError("out of memory.");
}
__glutCurrentMenu->submenus++;
submenu->menu = __glutCurrentMenu;
popupmenu = __glutGetMenuByNum(menu);
if (popupmenu) {
submenu->win = popupmenu->win;
}
setMenuItem(submenu, label, /* base 0 */ menu - 1, TRUE);
__glutCurrentMenu->num++;
submenu->next = __glutCurrentMenu->list;
__glutCurrentMenu->list = submenu;
}

void GLUTAPIENTRY
glutChangeToMenuEntry(int num, const char *label, int value)
{
GLUTmenuItem *item;
int i;

if (__glutMappedMenu) {
menuModificationError();
}
i = __glutCurrentMenu->num;
item = __glutCurrentMenu->list;
while (item) {
if (i == num) {
if (item->isTrigger) {
/* If changing a submenu trigger to a menu entry, we
need to account for submenus. */
item->menu->submenus--;
/* Nuke the Win32 menu. */
//todo
// DestroyMenu((HMENU) item->win);
}
free(item->label);

item->label = strdup(label);
if (!item->label)
__glutFatalError("out of memory");
item->isTrigger = FALSE;
item->len = (int) strlen(label);
item->value = value;
item->unique = uniqueMenuHandler++;
//todo
// ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
// MF_BYPOSITION | MFT_STRING, item->unique, label);

return;
}
i--;
item = item->next;
}
__glutWarning("Current menu has no %d item.", num);
}

void GLUTAPIENTRY
glutChangeToSubMenu(int num, const char *label, int menu)
{
GLUTmenu *popupmenu;
GLUTmenuItem *item;
int i;

if (__glutMappedMenu) {
menuModificationError();
}
i = __glutCurrentMenu->num;
item = __glutCurrentMenu->list;
while (item) {
if (i == num) {
if (!item->isTrigger) {
/* If changing a menu entry to as submenu trigger, we
need to account for submenus. */
item->menu->submenus++;
//todo
// item->win = (HWND) CreatePopupMenu();
}
free(item->label);

item->label = strdup(label);
if (!item->label)
__glutFatalError("out of memory");
item->isTrigger = TRUE;
item->len = (int) strlen(label);
item->value = menu - 1;
item->unique = uniqueMenuHandler++;
popupmenu = __glutGetMenuByNum(menu);
if (popupmenu)
item->win = popupmenu->win;
//todo
// ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
// MF_BYPOSITION | MF_POPUP, (UINT) item->win, label);
return;
}
i--;
item = item->next;
}
__glutWarning("Current menu has no %d item.", num);
}

void GLUTAPIENTRY
glutRemoveMenuItem(int num)
{
GLUTmenuItem *item, **prev;
int i;

if (__glutMappedMenu) {
menuModificationError();
}
i = __glutCurrentMenu->num;
prev = &__glutCurrentMenu->list;
item = __glutCurrentMenu->list;
while (item) {
if (i == num) {
/* Found the menu item in list to remove. */
__glutCurrentMenu->num--;

/* Patch up menu's item list. */
*prev = item->next;
//todo
// RemoveMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1, MF_BYPOSITION);

free(item->label);
free(item);
return;
}
i--;
prev = &item->next;
item = item->next;
}
__glutWarning("Current menu has no %d item.", num);
}

void GLUTAPIENTRY
glutAttachMenu(int button)
{
if (__glutCurrentWindow == __glutGameModeWindow) {
__glutWarning("cannot attach menus in game mode.");
return;
}
if (__glutMappedMenu) {
menuModificationError();
}
if (__glutCurrentWindow->menu[button] < 1) {
__glutCurrentWindow->buttonUses++;
}
__glutCurrentWindow->menu[button] = __glutCurrentMenu->id + 1;
}

void GLUTAPIENTRY
glutDetachMenu(int button)
{
if (__glutMappedMenu) {
menuModificationError();
}
if (__glutCurrentWindow->menu[button] > 0) {
__glutCurrentWindow->buttonUses--;
__glutCurrentWindow->menu[button] = 0;
}
}


+ 0
- 1296
src/glut/os2/os2_winproc.cpp
File diff suppressed because it is too large
Näytä tiedosto


BIN
src/glut/os2/src-glut_os2pm.zip Näytä tiedosto


Loading…
Peruuta
Tallenna