crude resize support
This commit is contained in:
parent
6fff3eeb37
commit
5e751163ee
3 changed files with 232 additions and 236 deletions
19
.clang-format
Normal file
19
.clang-format
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
UseTab: Always
|
||||||
|
TabWidth: 8
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: true
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: true
|
||||||
|
IndentWidth: 8
|
||||||
|
PointerAlignment: Left
|
||||||
|
ColumnLimit: 0
|
||||||
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
SortIncludes: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
#IndentPPDirectives: AfterHash
|
||||||
1
include/Mw
Symbolic link
1
include/Mw
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../milsko/include/Mw/
|
||||||
334
src/gl.c
334
src/gl.c
|
|
@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
static MwWidget win;
|
static MwWidget win;
|
||||||
static MwWidget opengl;
|
static MwWidget opengl;
|
||||||
|
static MwWidget label;
|
||||||
|
|
||||||
unsigned short d_8to16table[256];
|
unsigned short d_8to16table[256];
|
||||||
unsigned d_8to24table[256];
|
unsigned d_8to24table[256];
|
||||||
|
|
@ -63,24 +63,24 @@ static qboolean vidmode_active = qfalse;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
//int texture_mode = GL_NEAREST;
|
// int texture_mode = GL_NEAREST;
|
||||||
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
// int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||||
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
// int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||||
int texture_mode = GL_LINEAR;
|
int texture_mode = GL_LINEAR;
|
||||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
// int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
// int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||||
|
|
||||||
int texture_extension_number = 1;
|
int texture_extension_number = 1;
|
||||||
|
|
||||||
float gldepthmin, gldepthmax;
|
float gldepthmin, gldepthmax;
|
||||||
|
|
||||||
const char *gl_vendor;
|
const char* gl_vendor;
|
||||||
const char *gl_renderer;
|
const char* gl_renderer;
|
||||||
const char *gl_version;
|
const char* gl_version;
|
||||||
const char *gl_extensions;
|
const char* gl_extensions;
|
||||||
|
|
||||||
void (*qglColorTableEXT) (int, int, int, int, int, const void*);
|
void (*qglColorTableEXT)(int, int, int, int, int, const void*);
|
||||||
void (*qgl3DfxSetPaletteEXT) (GLuint *);
|
void (*qgl3DfxSetPaletteEXT)(GLuint*);
|
||||||
|
|
||||||
static float vid_gamma = 1.0;
|
static float vid_gamma = 1.0;
|
||||||
|
|
||||||
|
|
@ -89,24 +89,20 @@ qboolean isPermedia = qfalse;
|
||||||
qboolean gl_mtexable = qfalse;
|
qboolean gl_mtexable = qfalse;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
void D_BeginDirectRect(int x, int y, byte* pbitmap, int width, int height) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D_EndDirectRect (int x, int y, int width, int height)
|
void D_EndDirectRect(int x, int y, int width, int height) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void install_grabs(void)
|
static void install_grabs(void) {
|
||||||
{
|
|
||||||
MwHideCursor(opengl);
|
MwHideCursor(opengl);
|
||||||
MwGrabPointer(opengl, 1);
|
MwGrabPointer(opengl, 1);
|
||||||
mouse_active = qtrue;
|
mouse_active = qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninstall_grabs(void)
|
static void uninstall_grabs(void) {
|
||||||
{
|
if(!win)
|
||||||
if (!win)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MwGrabPointer(opengl, 0);
|
MwGrabPointer(opengl, 0);
|
||||||
|
|
@ -114,7 +110,7 @@ static void uninstall_grabs(void)
|
||||||
mouse_active = qfalse;
|
mouse_active = qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MilskoToQuakeKey(int key){
|
static int MilskoToQuakeKey(int key) {
|
||||||
if(key == MwLLKeyEnter) key = K_ENTER;
|
if(key == MwLLKeyEnter) key = K_ENTER;
|
||||||
if(key == MwLLKeyEscape) key = K_ESCAPE;
|
if(key == MwLLKeyEscape) key = K_ESCAPE;
|
||||||
if(key == MwLLKeyBackSpace) key = K_BACKSPACE;
|
if(key == MwLLKeyBackSpace) key = K_BACKSPACE;
|
||||||
|
|
@ -130,7 +126,7 @@ static int MilskoToQuakeKey(int key){
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MilskoToQuakeMouse(int btn){
|
static int MilskoToQuakeMouse(int btn) {
|
||||||
int b = 0;
|
int b = 0;
|
||||||
if(btn == MwLLMouseLeft) b = 0;
|
if(btn == MwLLMouseLeft) b = 0;
|
||||||
if(btn == MwLLMouseMiddle) b = 2;
|
if(btn == MwLLMouseMiddle) b = 2;
|
||||||
|
|
@ -146,13 +142,13 @@ void mousemove(MwWidget handle, void* user, void* call) {
|
||||||
int vecX = p->x;
|
int vecX = p->x;
|
||||||
int vecY = p->y;
|
int vecY = p->y;
|
||||||
|
|
||||||
if (mouse_active) {
|
if(mouse_active) {
|
||||||
mx += vecX * 2;
|
mx += vecX * 2;
|
||||||
my += vecY * 2;
|
my += vecY * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void key(MwWidget handle, void* user, void* call){
|
void key(MwWidget handle, void* user, void* call) {
|
||||||
int k = *(int*)call;
|
int k = *(int*)call;
|
||||||
k = MilskoToQuakeKey(k);
|
k = MilskoToQuakeKey(k);
|
||||||
if(k == -0xdead) return;
|
if(k == -0xdead) return;
|
||||||
|
|
@ -160,7 +156,7 @@ void key(MwWidget handle, void* user, void* call){
|
||||||
Key_Event(k, 1);
|
Key_Event(k, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyrelease(MwWidget handle, void* user, void* call){
|
void keyrelease(MwWidget handle, void* user, void* call) {
|
||||||
int k = *(int*)call;
|
int k = *(int*)call;
|
||||||
k = MilskoToQuakeKey(k);
|
k = MilskoToQuakeKey(k);
|
||||||
if(k == -0xdead) return;
|
if(k == -0xdead) return;
|
||||||
|
|
@ -168,85 +164,90 @@ void keyrelease(MwWidget handle, void* user, void* call){
|
||||||
Key_Event(k, 0);
|
Key_Event(k, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mousedown(MwWidget handle, void* user, void* call){
|
void mousedown(MwWidget handle, void* user, void* call) {
|
||||||
MwLLMouse* m = call;
|
MwLLMouse* m = call;
|
||||||
Key_Event(MilskoToQuakeMouse(m->button), 1);
|
Key_Event(MilskoToQuakeMouse(m->button), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseup(MwWidget handle, void* user, void* call){
|
void mouseup(MwWidget handle, void* user, void* call) {
|
||||||
MwLLMouse* m = call;
|
MwLLMouse* m = call;
|
||||||
Key_Event(MilskoToQuakeMouse(m->button), 0);
|
Key_Event(MilskoToQuakeMouse(m->button), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void focusin(MwWidget handle, void* user, void* call){
|
void focusin(MwWidget handle, void* user, void* call) {
|
||||||
if(mouse_active){
|
if(mouse_active) {
|
||||||
MwGrabPointer(opengl, 0);
|
MwGrabPointer(opengl, 0);
|
||||||
MwGrabPointer(opengl, 1);
|
MwGrabPointer(opengl, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void focusout(MwWidget handle, void* user, void* call){
|
void focusout(MwWidget handle, void* user, void* call) {
|
||||||
MwGrabPointer(opengl, 0);
|
MwGrabPointer(opengl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleEvents(void)
|
void resize(MwWidget handle, void* user, void* call) {
|
||||||
{
|
scr_width = MwGetInteger(handle, MwNwidth);
|
||||||
|
scr_height = MwGetInteger(handle, MwNheight);
|
||||||
|
vid.width = MwGetInteger(handle, MwNwidth);
|
||||||
|
vid.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
MwVaApply(opengl, MwNx, 0, MwNy, 0, MwNwidth, vid.width, MwNheight, vid.height, NULL);
|
||||||
|
MwVaApply(label, MwNx, vid.height, MwNy, 0, MwNwidth, vid.width, MwNheight, 24, NULL);
|
||||||
|
|
||||||
|
glwidth = vid.width;
|
||||||
|
glheight = vid.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void HandleEvents(void) {
|
||||||
int b;
|
int b;
|
||||||
qboolean dowarp = qfalse;
|
qboolean dowarp = qfalse;
|
||||||
int mwx = vid.width/2;
|
int mwx = vid.width / 2;
|
||||||
int mwy = vid.height/2;
|
int mwy = vid.height / 2;
|
||||||
|
|
||||||
if(MwPending(win)) MwStep(win);
|
if(MwPending(win)) MwStep(win);
|
||||||
|
|
||||||
if (dowarp) {
|
if(dowarp) {
|
||||||
/* move the mouse to the window center again */
|
/* move the mouse to the window center again */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_DeactivateMouse( void )
|
static void IN_DeactivateMouse(void) {
|
||||||
{
|
if(!mouse_avail || !win)
|
||||||
if (!mouse_avail || !win)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mouse_active) {
|
if(mouse_active) {
|
||||||
uninstall_grabs();
|
uninstall_grabs();
|
||||||
mouse_active = qfalse;
|
mouse_active = qfalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_ActivateMouse( void )
|
static void IN_ActivateMouse(void) {
|
||||||
{
|
if(!mouse_avail || !win)
|
||||||
if (!mouse_avail || !win)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!mouse_active) {
|
if(!mouse_active) {
|
||||||
mx = my = 0; // don't spazz
|
mx = my = 0; // don't spazz
|
||||||
install_grabs();
|
install_grabs();
|
||||||
mouse_active = qtrue;
|
mouse_active = qtrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VID_Shutdown(void) {
|
||||||
void VID_Shutdown(void)
|
|
||||||
{
|
|
||||||
IN_DeactivateMouse();
|
IN_DeactivateMouse();
|
||||||
if (win) {
|
if(win) {
|
||||||
MwDestroyWidget(win);
|
MwDestroyWidget(win);
|
||||||
}
|
}
|
||||||
vidmode_active = qfalse;
|
vidmode_active = qfalse;
|
||||||
win = NULL;
|
win = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal_handler(int sig)
|
void signal_handler(int sig) {
|
||||||
{
|
|
||||||
printf("Received signal %d, exiting...\n", sig);
|
printf("Received signal %d, exiting...\n", sig);
|
||||||
Sys_Quit();
|
Sys_Quit();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSig(void)
|
void InitSig(void) {
|
||||||
{
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
signal(SIGHUP, signal_handler);
|
signal(SIGHUP, signal_handler);
|
||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
|
|
@ -261,63 +262,60 @@ void InitSig(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_ShiftPalette(unsigned char *p)
|
void VID_ShiftPalette(unsigned char* p) {
|
||||||
{
|
// VID_SetPalette(p);
|
||||||
// VID_SetPalette(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_SetPalette (unsigned char *palette)
|
void VID_SetPalette(unsigned char* palette) {
|
||||||
{
|
byte* pal;
|
||||||
byte *pal;
|
unsigned r, g, b;
|
||||||
unsigned r,g,b;
|
|
||||||
unsigned v;
|
unsigned v;
|
||||||
int r1,g1,b1;
|
int r1, g1, b1;
|
||||||
int j,k,l,m;
|
int j, k, l, m;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned* table;
|
||||||
FILE *f;
|
FILE* f;
|
||||||
char s[255];
|
char s[255];
|
||||||
int dist, bestdist;
|
int dist, bestdist;
|
||||||
|
|
||||||
//
|
//
|
||||||
// 8 8 8 encoding
|
// 8 8 8 encoding
|
||||||
//
|
//
|
||||||
pal = palette;
|
pal = palette;
|
||||||
table = d_8to24table;
|
table = d_8to24table;
|
||||||
for (i=0 ; i<256 ; i++)
|
for(i = 0; i < 256; i++) {
|
||||||
{
|
|
||||||
r = pal[0];
|
r = pal[0];
|
||||||
g = pal[1];
|
g = pal[1];
|
||||||
b = pal[2];
|
b = pal[2];
|
||||||
pal += 3;
|
pal += 3;
|
||||||
|
|
||||||
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
v = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
|
||||||
*table++ = v;
|
*table++ = v;
|
||||||
}
|
}
|
||||||
d_8to24table[255] &= 0xffffff; // 255 is transparent
|
d_8to24table[255] &= 0xffffff; // 255 is transparent
|
||||||
|
|
||||||
for (i=0; i < (1<<15); i++) {
|
for(i = 0; i < (1 << 15); i++) {
|
||||||
/* Maps
|
/* Maps
|
||||||
000000000000000
|
000000000000000
|
||||||
000000000011111 = Red = 0x1F
|
000000000011111 = Red = 0x1F
|
||||||
000001111100000 = Blue = 0x03E0
|
000001111100000 = Blue = 0x03E0
|
||||||
111110000000000 = Grn = 0x7C00
|
111110000000000 = Grn = 0x7C00
|
||||||
*/
|
*/
|
||||||
r = ((i & 0x1F) << 3)+4;
|
r = ((i & 0x1F) << 3) + 4;
|
||||||
g = ((i & 0x03E0) >> 2)+4;
|
g = ((i & 0x03E0) >> 2) + 4;
|
||||||
b = ((i & 0x7C00) >> 7)+4;
|
b = ((i & 0x7C00) >> 7) + 4;
|
||||||
pal = (unsigned char *)d_8to24table;
|
pal = (unsigned char*)d_8to24table;
|
||||||
for (v=0,k=0,bestdist=10000*10000; v<256; v++,pal+=4) {
|
for(v = 0, k = 0, bestdist = 10000 * 10000; v < 256; v++, pal += 4) {
|
||||||
r1 = (int)r - (int)pal[0];
|
r1 = (int)r - (int)pal[0];
|
||||||
g1 = (int)g - (int)pal[1];
|
g1 = (int)g - (int)pal[1];
|
||||||
b1 = (int)b - (int)pal[2];
|
b1 = (int)b - (int)pal[2];
|
||||||
dist = (r1*r1)+(g1*g1)+(b1*b1);
|
dist = (r1 * r1) + (g1 * g1) + (b1 * b1);
|
||||||
if (dist < bestdist) {
|
if(dist < bestdist) {
|
||||||
k=v;
|
k = v;
|
||||||
bestdist = dist;
|
bestdist = dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d_15to8table[i]=k;
|
d_15to8table[i] = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,38 +324,37 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
GL_Init
|
GL_Init
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void GL_Init (void)
|
void GL_Init(void) {
|
||||||
{
|
gl_vendor = glGetString(GL_VENDOR);
|
||||||
gl_vendor = glGetString (GL_VENDOR);
|
Con_Printf("GL_VENDOR: %s\n", gl_vendor);
|
||||||
Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
|
gl_renderer = glGetString(GL_RENDERER);
|
||||||
gl_renderer = glGetString (GL_RENDERER);
|
Con_Printf("GL_RENDERER: %s\n", gl_renderer);
|
||||||
Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
|
|
||||||
|
|
||||||
gl_version = glGetString (GL_VERSION);
|
gl_version = glGetString(GL_VERSION);
|
||||||
Con_Printf ("GL_VERSION: %s\n", gl_version);
|
Con_Printf("GL_VERSION: %s\n", gl_version);
|
||||||
gl_extensions = glGetString (GL_EXTENSIONS);
|
gl_extensions = glGetString(GL_EXTENSIONS);
|
||||||
// Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
|
// Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
|
||||||
|
|
||||||
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
|
// Con_Printf ("%s %s\n", gl_renderer, gl_version);
|
||||||
|
|
||||||
glClearColor (1,0,0,0);
|
glClearColor(1, 0, 0, 0);
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
glAlphaFunc(GL_GREATER, 0.666);
|
glAlphaFunc(GL_GREATER, 0.666);
|
||||||
|
|
||||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glShadeModel (GL_FLAT);
|
glShadeModel(GL_FLAT);
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,63 +364,56 @@ GL_BeginRendering
|
||||||
|
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
void GL_BeginRendering(int* x, int* y, int* width, int* height) {
|
||||||
{
|
|
||||||
extern cvar_t gl_clear;
|
extern cvar_t gl_clear;
|
||||||
|
|
||||||
*x = *y = 0;
|
*x = *y = 0;
|
||||||
*width = scr_width;
|
*width = scr_width;
|
||||||
*height = scr_height;
|
*height = scr_height;
|
||||||
|
|
||||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||||
// Sys_Error ("wglMakeCurrent failed");
|
// Sys_Error ("wglMakeCurrent failed");
|
||||||
|
|
||||||
// glViewport (*x, *y, *width, *height);
|
// glViewport (*x, *y, *width, *height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GL_EndRendering(void) {
|
||||||
void GL_EndRendering (void)
|
|
||||||
{
|
|
||||||
glFlush();
|
glFlush();
|
||||||
MwOpenGLSwapBuffer(opengl);
|
MwOpenGLSwapBuffer(opengl);
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean VID_Is8bit(void)
|
qboolean VID_Is8bit(void) {
|
||||||
{
|
|
||||||
return is8bit;
|
return is8bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Check_Gamma (unsigned char *pal)
|
static void Check_Gamma(unsigned char* pal) {
|
||||||
{
|
|
||||||
float f, inf;
|
float f, inf;
|
||||||
unsigned char palette[768];
|
unsigned char palette[768];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((i = COM_CheckParm("-gamma")) == 0) {
|
if((i = COM_CheckParm("-gamma")) == 0) {
|
||||||
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
|
if((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
|
||||||
(gl_vendor && strstr(gl_vendor, "3Dfx")))
|
(gl_vendor && strstr(gl_vendor, "3Dfx")))
|
||||||
vid_gamma = 1;
|
vid_gamma = 1;
|
||||||
else
|
else
|
||||||
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
|
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
|
||||||
} else
|
} else
|
||||||
vid_gamma = Q_atof(com_argv[i+1]);
|
vid_gamma = Q_atof(com_argv[i + 1]);
|
||||||
|
|
||||||
for (i=0 ; i<768 ; i++)
|
for(i = 0; i < 768; i++) {
|
||||||
{
|
f = pow((pal[i] + 1) / 256.0, vid_gamma);
|
||||||
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
|
inf = f * 255 + 0.5;
|
||||||
inf = f*255 + 0.5;
|
if(inf < 0)
|
||||||
if (inf < 0)
|
|
||||||
inf = 0;
|
inf = 0;
|
||||||
if (inf > 255)
|
if(inf > 255)
|
||||||
inf = 255;
|
inf = 255;
|
||||||
palette[i] = inf;
|
palette[i] = inf;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (pal, palette, sizeof(palette));
|
memcpy(pal, palette, sizeof(palette));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_Init(unsigned char *palette)
|
void VID_Init(unsigned char* palette) {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
char gldir[MAX_OSPATH];
|
char gldir[MAX_OSPATH];
|
||||||
int width = 640, height = 480;
|
int width = 640, height = 480;
|
||||||
|
|
@ -432,45 +422,44 @@ void VID_Init(unsigned char *palette)
|
||||||
int MajorVersion, MinorVersion;
|
int MajorVersion, MinorVersion;
|
||||||
int actualWidth, actualHeight;
|
int actualWidth, actualHeight;
|
||||||
MwSizeHints sh;
|
MwSizeHints sh;
|
||||||
MwWidget label;
|
|
||||||
|
|
||||||
mouse_avail = 1;
|
mouse_avail = 1;
|
||||||
|
|
||||||
vid.maxwarpwidth = WARP_WIDTH;
|
vid.maxwarpwidth = WARP_WIDTH;
|
||||||
vid.maxwarpheight = WARP_HEIGHT;
|
vid.maxwarpheight = WARP_HEIGHT;
|
||||||
vid.colormap = host_colormap;
|
vid.colormap = host_colormap;
|
||||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
vid.fullbright = 256 - LittleLong(*((int*)vid.colormap + 2048));
|
||||||
|
|
||||||
MwLibraryInit();
|
MwLibraryInit();
|
||||||
|
|
||||||
// interpret command-line params
|
// interpret command-line params
|
||||||
|
|
||||||
// set vid parameters
|
// set vid parameters
|
||||||
if ((i = COM_CheckParm("-window")) != 0)
|
if((i = COM_CheckParm("-window")) != 0)
|
||||||
fullscreen = qfalse;
|
fullscreen = qfalse;
|
||||||
|
|
||||||
if ((i = COM_CheckParm("-width")) != 0)
|
if((i = COM_CheckParm("-width")) != 0)
|
||||||
width = atoi(com_argv[i+1]);
|
width = atoi(com_argv[i + 1]);
|
||||||
|
|
||||||
if ((i = COM_CheckParm("-height")) != 0)
|
if((i = COM_CheckParm("-height")) != 0)
|
||||||
height = atoi(com_argv[i+1]);
|
height = atoi(com_argv[i + 1]);
|
||||||
|
|
||||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
if((i = COM_CheckParm("-conwidth")) != 0)
|
||||||
vid.conwidth = Q_atoi(com_argv[i+1]);
|
vid.conwidth = Q_atoi(com_argv[i + 1]);
|
||||||
else
|
else
|
||||||
vid.conwidth = 640;
|
vid.conwidth = 640;
|
||||||
|
|
||||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||||
|
|
||||||
if (vid.conwidth < 320)
|
if(vid.conwidth < 320)
|
||||||
vid.conwidth = 320;
|
vid.conwidth = 320;
|
||||||
|
|
||||||
// pick a conheight that matches with correct aspect
|
// pick a conheight that matches with correct aspect
|
||||||
vid.conheight = vid.conwidth*3 / 4;
|
vid.conheight = vid.conwidth * 3 / 4;
|
||||||
|
|
||||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
if((i = COM_CheckParm("-conheight")) != 0)
|
||||||
vid.conheight = Q_atoi(com_argv[i+1]);
|
vid.conheight = Q_atoi(com_argv[i + 1]);
|
||||||
if (vid.conheight < 200)
|
if(vid.conheight < 200)
|
||||||
vid.conheight = 200;
|
vid.conheight = 200;
|
||||||
|
|
||||||
win = MwVaCreateWidget(MwWindowClass, "Quake", NULL, MwDEFAULT, MwDEFAULT, width, height + 24,
|
win = MwVaCreateWidget(MwWindowClass, "Quake", NULL, MwDEFAULT, MwDEFAULT, width, height + 24,
|
||||||
|
|
@ -481,10 +470,9 @@ void VID_Init(unsigned char *palette)
|
||||||
NULL);
|
NULL);
|
||||||
opengl = MwCreateWidget(MwOpenGLClass, "OpenGL", win, 0, 0, width, height);
|
opengl = MwCreateWidget(MwOpenGLClass, "OpenGL", win, 0, 0, width, height);
|
||||||
|
|
||||||
sh.min_width = sh.max_width = width;
|
|
||||||
sh.min_height = sh.max_height = height + 24;
|
|
||||||
MwVaApply(win,
|
MwVaApply(win,
|
||||||
MwNsizeHints, &sh,
|
MwNwidth, width,
|
||||||
|
MwNheight, height,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwOpenGLMakeCurrent(opengl);
|
MwOpenGLMakeCurrent(opengl);
|
||||||
|
|
@ -496,17 +484,18 @@ void VID_Init(unsigned char *palette)
|
||||||
MwAddUserHandler(opengl, MwNmouseUpHandler, mouseup, NULL);
|
MwAddUserHandler(opengl, MwNmouseUpHandler, mouseup, NULL);
|
||||||
MwAddUserHandler(opengl, MwNfocusInHandler, focusin, NULL);
|
MwAddUserHandler(opengl, MwNfocusInHandler, focusin, NULL);
|
||||||
MwAddUserHandler(opengl, MwNfocusOutHandler, focusout, NULL);
|
MwAddUserHandler(opengl, MwNfocusOutHandler, focusout, NULL);
|
||||||
|
MwAddUserHandler(win, MwNresizeHandler, resize, NULL);
|
||||||
|
|
||||||
if(fullscreen){
|
if(fullscreen) {
|
||||||
/* todo */
|
/* todo */
|
||||||
}
|
}
|
||||||
|
|
||||||
scr_width = width;
|
scr_width = width;
|
||||||
scr_height = height;
|
scr_height = height;
|
||||||
|
|
||||||
if (vid.conheight > height)
|
if(vid.conheight > height)
|
||||||
vid.conheight = height;
|
vid.conheight = height;
|
||||||
if (vid.conwidth > width)
|
if(vid.conwidth > width)
|
||||||
vid.conwidth = width;
|
vid.conwidth = width;
|
||||||
vid.width = vid.conwidth;
|
vid.width = vid.conwidth;
|
||||||
vid.height = vid.conheight;
|
vid.height = vid.conheight;
|
||||||
|
|
@ -518,33 +507,29 @@ void VID_Init(unsigned char *palette)
|
||||||
|
|
||||||
GL_Init();
|
GL_Init();
|
||||||
|
|
||||||
sprintf (gldir, "%s/mwquake", com_gamedir);
|
sprintf(gldir, "%s/mwquake", com_gamedir);
|
||||||
Sys_mkdir (gldir);
|
Sys_mkdir(gldir);
|
||||||
|
|
||||||
VID_SetPalette(palette);
|
VID_SetPalette(palette);
|
||||||
|
|
||||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
Con_SafePrintf("Video mode %dx%d initialized.\n", width, height);
|
||||||
|
|
||||||
vid.recalc_refdef = 1; // force a surface cache flush
|
vid.recalc_refdef = 1; // force a surface cache flush
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_SendKeyEvents(void)
|
void Sys_SendKeyEvents(void) {
|
||||||
{
|
|
||||||
if(win == NULL) return;
|
if(win == NULL) return;
|
||||||
HandleEvents();
|
HandleEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Force_CenterView_f (void)
|
void Force_CenterView_f(void) {
|
||||||
{
|
|
||||||
cl.viewangles[PITCH] = 0;
|
cl.viewangles[PITCH] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Init(void)
|
void IN_Init(void) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Shutdown(void)
|
void IN_Shutdown(void) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -552,15 +537,14 @@ void IN_Shutdown(void)
|
||||||
IN_Commands
|
IN_Commands
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
void IN_Commands (void)
|
void IN_Commands(void) {
|
||||||
{
|
if(!win)
|
||||||
if (!win)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vidmode_active || key_dest == key_game)
|
if(vidmode_active || key_dest == key_game)
|
||||||
IN_ActivateMouse();
|
IN_ActivateMouse();
|
||||||
else
|
else
|
||||||
IN_DeactivateMouse ();
|
IN_DeactivateMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -568,13 +552,11 @@ void IN_Commands (void)
|
||||||
IN_Move
|
IN_Move
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
void IN_MouseMove (usercmd_t *cmd)
|
void IN_MouseMove(usercmd_t* cmd) {
|
||||||
{
|
if(!mouse_avail)
|
||||||
if (!mouse_avail)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (1)
|
if(1) {
|
||||||
{
|
|
||||||
mx = (mx + old_mouse_x) * 0.5;
|
mx = (mx + old_mouse_x) * 0.5;
|
||||||
my = (my + old_mouse_y) * 0.5;
|
my = (my + old_mouse_y) * 0.5;
|
||||||
}
|
}
|
||||||
|
|
@ -584,26 +566,23 @@ void IN_MouseMove (usercmd_t *cmd)
|
||||||
mx *= sensitivity.value;
|
mx *= sensitivity.value;
|
||||||
my *= sensitivity.value;
|
my *= sensitivity.value;
|
||||||
|
|
||||||
// add mouse X/Y movement to cmd
|
// add mouse X/Y movement to cmd
|
||||||
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
if((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
|
||||||
cmd->sidemove += m_side.value * mx;
|
cmd->sidemove += m_side.value * mx;
|
||||||
else
|
else
|
||||||
cl.viewangles[YAW] -= m_yaw.value * mx;
|
cl.viewangles[YAW] -= m_yaw.value * mx;
|
||||||
|
|
||||||
if (in_mlook.state & 1)
|
if(in_mlook.state & 1)
|
||||||
V_StopPitchDrift ();
|
V_StopPitchDrift();
|
||||||
|
|
||||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
if((in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
||||||
{
|
|
||||||
cl.viewangles[PITCH] += m_pitch.value * my;
|
cl.viewangles[PITCH] += m_pitch.value * my;
|
||||||
if (cl.viewangles[PITCH] > 80)
|
if(cl.viewangles[PITCH] > 80)
|
||||||
cl.viewangles[PITCH] = 80;
|
cl.viewangles[PITCH] = 80;
|
||||||
if (cl.viewangles[PITCH] < -70)
|
if(cl.viewangles[PITCH] < -70)
|
||||||
cl.viewangles[PITCH] = -70;
|
cl.viewangles[PITCH] = -70;
|
||||||
}
|
} else {
|
||||||
else
|
if((in_strafe.state & 1) && noclip_anglehack)
|
||||||
{
|
|
||||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
|
||||||
cmd->upmove -= m_forward.value * my;
|
cmd->upmove -= m_forward.value * my;
|
||||||
else
|
else
|
||||||
cmd->forwardmove -= m_forward.value * my;
|
cmd->forwardmove -= m_forward.value * my;
|
||||||
|
|
@ -611,9 +590,6 @@ void IN_MouseMove (usercmd_t *cmd)
|
||||||
mx = my = 0;
|
mx = my = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Move (usercmd_t *cmd)
|
void IN_Move(usercmd_t* cmd) {
|
||||||
{
|
|
||||||
IN_MouseMove(cmd);
|
IN_MouseMove(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue