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 opengl;
|
||||
|
||||
static MwWidget label;
|
||||
|
||||
unsigned short d_8to16table[256];
|
||||
unsigned d_8to24table[256];
|
||||
|
|
@ -63,24 +63,24 @@ static qboolean vidmode_active = qfalse;
|
|||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//int texture_mode = GL_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||
// int texture_mode = GL_NEAREST;
|
||||
// int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||
// int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||
int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
// int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
// int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
const char* gl_vendor;
|
||||
const char* gl_renderer;
|
||||
const char* gl_version;
|
||||
const char* gl_extensions;
|
||||
|
||||
void (*qglColorTableEXT) (int, int, int, int, int, const void*);
|
||||
void (*qgl3DfxSetPaletteEXT) (GLuint *);
|
||||
void (*qglColorTableEXT)(int, int, int, int, int, const void*);
|
||||
void (*qgl3DfxSetPaletteEXT)(GLuint*);
|
||||
|
||||
static float vid_gamma = 1.0;
|
||||
|
||||
|
|
@ -89,24 +89,20 @@ qboolean isPermedia = 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);
|
||||
MwGrabPointer(opengl, 1);
|
||||
mouse_active = qtrue;
|
||||
}
|
||||
|
||||
static void uninstall_grabs(void)
|
||||
{
|
||||
if (!win)
|
||||
static void uninstall_grabs(void) {
|
||||
if(!win)
|
||||
return;
|
||||
|
||||
MwGrabPointer(opengl, 0);
|
||||
|
|
@ -114,7 +110,7 @@ static void uninstall_grabs(void)
|
|||
mouse_active = qfalse;
|
||||
}
|
||||
|
||||
static int MilskoToQuakeKey(int key){
|
||||
static int MilskoToQuakeKey(int key) {
|
||||
if(key == MwLLKeyEnter) key = K_ENTER;
|
||||
if(key == MwLLKeyEscape) key = K_ESCAPE;
|
||||
if(key == MwLLKeyBackSpace) key = K_BACKSPACE;
|
||||
|
|
@ -130,7 +126,7 @@ static int MilskoToQuakeKey(int key){
|
|||
return key;
|
||||
}
|
||||
|
||||
static int MilskoToQuakeMouse(int btn){
|
||||
static int MilskoToQuakeMouse(int btn) {
|
||||
int b = 0;
|
||||
if(btn == MwLLMouseLeft) b = 0;
|
||||
if(btn == MwLLMouseMiddle) b = 2;
|
||||
|
|
@ -146,13 +142,13 @@ void mousemove(MwWidget handle, void* user, void* call) {
|
|||
int vecX = p->x;
|
||||
int vecY = p->y;
|
||||
|
||||
if (mouse_active) {
|
||||
if(mouse_active) {
|
||||
mx += vecX * 2;
|
||||
my += vecY * 2;
|
||||
}
|
||||
}
|
||||
|
||||
void key(MwWidget handle, void* user, void* call){
|
||||
void key(MwWidget handle, void* user, void* call) {
|
||||
int k = *(int*)call;
|
||||
k = MilskoToQuakeKey(k);
|
||||
if(k == -0xdead) return;
|
||||
|
|
@ -160,7 +156,7 @@ void key(MwWidget handle, void* user, void* call){
|
|||
Key_Event(k, 1);
|
||||
}
|
||||
|
||||
void keyrelease(MwWidget handle, void* user, void* call){
|
||||
void keyrelease(MwWidget handle, void* user, void* call) {
|
||||
int k = *(int*)call;
|
||||
k = MilskoToQuakeKey(k);
|
||||
if(k == -0xdead) return;
|
||||
|
|
@ -168,85 +164,90 @@ void keyrelease(MwWidget handle, void* user, void* call){
|
|||
Key_Event(k, 0);
|
||||
}
|
||||
|
||||
void mousedown(MwWidget handle, void* user, void* call){
|
||||
void mousedown(MwWidget handle, void* user, void* call) {
|
||||
MwLLMouse* m = call;
|
||||
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;
|
||||
Key_Event(MilskoToQuakeMouse(m->button), 0);
|
||||
}
|
||||
|
||||
void focusin(MwWidget handle, void* user, void* call){
|
||||
if(mouse_active){
|
||||
void focusin(MwWidget handle, void* user, void* call) {
|
||||
if(mouse_active) {
|
||||
MwGrabPointer(opengl, 0);
|
||||
MwGrabPointer(opengl, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void focusout(MwWidget handle, void* user, void* call){
|
||||
void focusout(MwWidget handle, void* user, void* call) {
|
||||
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;
|
||||
qboolean dowarp = qfalse;
|
||||
int mwx = vid.width/2;
|
||||
int mwy = vid.height/2;
|
||||
int mwx = vid.width / 2;
|
||||
int mwy = vid.height / 2;
|
||||
|
||||
if(MwPending(win)) MwStep(win);
|
||||
|
||||
if (dowarp) {
|
||||
if(dowarp) {
|
||||
/* move the mouse to the window center again */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void IN_DeactivateMouse( void )
|
||||
{
|
||||
if (!mouse_avail || !win)
|
||||
static void IN_DeactivateMouse(void) {
|
||||
if(!mouse_avail || !win)
|
||||
return;
|
||||
|
||||
if (mouse_active) {
|
||||
if(mouse_active) {
|
||||
uninstall_grabs();
|
||||
mouse_active = qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
static void IN_ActivateMouse( void )
|
||||
{
|
||||
if (!mouse_avail || !win)
|
||||
static void IN_ActivateMouse(void) {
|
||||
if(!mouse_avail || !win)
|
||||
return;
|
||||
|
||||
if (!mouse_active) {
|
||||
if(!mouse_active) {
|
||||
mx = my = 0; // don't spazz
|
||||
install_grabs();
|
||||
mouse_active = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
void VID_Shutdown(void) {
|
||||
IN_DeactivateMouse();
|
||||
if (win) {
|
||||
if(win) {
|
||||
MwDestroyWidget(win);
|
||||
}
|
||||
vidmode_active = qfalse;
|
||||
win = NULL;
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
void signal_handler(int sig) {
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
Sys_Quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void InitSig(void)
|
||||
{
|
||||
void InitSig(void) {
|
||||
#ifndef _WIN32
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
|
|
@ -261,63 +262,60 @@ void InitSig(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
// VID_SetPalette(p);
|
||||
void VID_ShiftPalette(unsigned char* p) {
|
||||
// VID_SetPalette(p);
|
||||
}
|
||||
|
||||
void VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
byte *pal;
|
||||
unsigned r,g,b;
|
||||
void VID_SetPalette(unsigned char* palette) {
|
||||
byte* pal;
|
||||
unsigned r, g, b;
|
||||
unsigned v;
|
||||
int r1,g1,b1;
|
||||
int j,k,l,m;
|
||||
int r1, g1, b1;
|
||||
int j, k, l, m;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
unsigned* table;
|
||||
FILE* f;
|
||||
char s[255];
|
||||
int dist, bestdist;
|
||||
|
||||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
pal = palette;
|
||||
table = d_8to24table;
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
for(i = 0; i < 256; i++) {
|
||||
r = pal[0];
|
||||
g = pal[1];
|
||||
b = pal[2];
|
||||
pal += 3;
|
||||
|
||||
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||
v = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
|
||||
*table++ = v;
|
||||
}
|
||||
d_8to24table[255] &= 0xffffff; // 255 is transparent
|
||||
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
for(i = 0; i < (1 << 15); i++) {
|
||||
/* Maps
|
||||
000000000000000
|
||||
000000000011111 = Red = 0x1F
|
||||
000001111100000 = Blue = 0x03E0
|
||||
111110000000000 = Grn = 0x7C00
|
||||
*/
|
||||
r = ((i & 0x1F) << 3)+4;
|
||||
g = ((i & 0x03E0) >> 2)+4;
|
||||
b = ((i & 0x7C00) >> 7)+4;
|
||||
pal = (unsigned char *)d_8to24table;
|
||||
for (v=0,k=0,bestdist=10000*10000; v<256; v++,pal+=4) {
|
||||
r = ((i & 0x1F) << 3) + 4;
|
||||
g = ((i & 0x03E0) >> 2) + 4;
|
||||
b = ((i & 0x7C00) >> 7) + 4;
|
||||
pal = (unsigned char*)d_8to24table;
|
||||
for(v = 0, k = 0, bestdist = 10000 * 10000; v < 256; v++, pal += 4) {
|
||||
r1 = (int)r - (int)pal[0];
|
||||
g1 = (int)g - (int)pal[1];
|
||||
b1 = (int)b - (int)pal[2];
|
||||
dist = (r1*r1)+(g1*g1)+(b1*b1);
|
||||
if (dist < bestdist) {
|
||||
k=v;
|
||||
dist = (r1 * r1) + (g1 * g1) + (b1 * b1);
|
||||
if(dist < bestdist) {
|
||||
k = v;
|
||||
bestdist = dist;
|
||||
}
|
||||
}
|
||||
d_15to8table[i]=k;
|
||||
d_15to8table[i] = k;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,38 +324,37 @@ void VID_SetPalette (unsigned char *palette)
|
|||
GL_Init
|
||||
===============
|
||||
*/
|
||||
void GL_Init (void)
|
||||
{
|
||||
gl_vendor = glGetString (GL_VENDOR);
|
||||
Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
|
||||
gl_renderer = glGetString (GL_RENDERER);
|
||||
Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
|
||||
void GL_Init(void) {
|
||||
gl_vendor = glGetString(GL_VENDOR);
|
||||
Con_Printf("GL_VENDOR: %s\n", gl_vendor);
|
||||
gl_renderer = glGetString(GL_RENDERER);
|
||||
Con_Printf("GL_RENDERER: %s\n", gl_renderer);
|
||||
|
||||
gl_version = glGetString (GL_VERSION);
|
||||
Con_Printf ("GL_VERSION: %s\n", gl_version);
|
||||
gl_extensions = glGetString (GL_EXTENSIONS);
|
||||
// Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
|
||||
gl_version = glGetString(GL_VERSION);
|
||||
Con_Printf("GL_VERSION: %s\n", gl_version);
|
||||
gl_extensions = glGetString(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);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.666);
|
||||
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
||||
glShadeModel (GL_FLAT);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
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_WRAP_S, 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);
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
void GL_EndRendering(void) {
|
||||
glFlush();
|
||||
MwOpenGLSwapBuffer(opengl);
|
||||
}
|
||||
|
||||
qboolean VID_Is8bit(void)
|
||||
{
|
||||
qboolean VID_Is8bit(void) {
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
static void Check_Gamma (unsigned char *pal)
|
||||
{
|
||||
static void Check_Gamma(unsigned char* pal) {
|
||||
float f, inf;
|
||||
unsigned char palette[768];
|
||||
int i;
|
||||
|
||||
if ((i = COM_CheckParm("-gamma")) == 0) {
|
||||
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
|
||||
if((i = COM_CheckParm("-gamma")) == 0) {
|
||||
if((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
|
||||
(gl_vendor && strstr(gl_vendor, "3Dfx")))
|
||||
vid_gamma = 1;
|
||||
else
|
||||
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
|
||||
} else
|
||||
vid_gamma = Q_atof(com_argv[i+1]);
|
||||
vid_gamma = Q_atof(com_argv[i + 1]);
|
||||
|
||||
for (i=0 ; i<768 ; i++)
|
||||
{
|
||||
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
|
||||
inf = f*255 + 0.5;
|
||||
if (inf < 0)
|
||||
for(i = 0; i < 768; i++) {
|
||||
f = pow((pal[i] + 1) / 256.0, vid_gamma);
|
||||
inf = f * 255 + 0.5;
|
||||
if(inf < 0)
|
||||
inf = 0;
|
||||
if (inf > 255)
|
||||
if(inf > 255)
|
||||
inf = 255;
|
||||
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;
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
|
|
@ -432,45 +422,44 @@ void VID_Init(unsigned char *palette)
|
|||
int MajorVersion, MinorVersion;
|
||||
int actualWidth, actualHeight;
|
||||
MwSizeHints sh;
|
||||
MwWidget label;
|
||||
|
||||
mouse_avail = 1;
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
vid.fullbright = 256 - LittleLong(*((int*)vid.colormap + 2048));
|
||||
|
||||
MwLibraryInit();
|
||||
|
||||
// interpret command-line params
|
||||
// interpret command-line params
|
||||
|
||||
// set vid parameters
|
||||
if ((i = COM_CheckParm("-window")) != 0)
|
||||
// set vid parameters
|
||||
if((i = COM_CheckParm("-window")) != 0)
|
||||
fullscreen = qfalse;
|
||||
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i + 1]);
|
||||
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i+1]);
|
||||
if((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i + 1]);
|
||||
|
||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = Q_atoi(com_argv[i+1]);
|
||||
if((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = Q_atoi(com_argv[i + 1]);
|
||||
else
|
||||
vid.conwidth = 640;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
|
||||
if (vid.conwidth < 320)
|
||||
if(vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
// 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)
|
||||
vid.conheight = Q_atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
if((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = Q_atoi(com_argv[i + 1]);
|
||||
if(vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
win = MwVaCreateWidget(MwWindowClass, "Quake", NULL, MwDEFAULT, MwDEFAULT, width, height + 24,
|
||||
|
|
@ -481,10 +470,9 @@ void VID_Init(unsigned char *palette)
|
|||
NULL);
|
||||
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,
|
||||
MwNsizeHints, &sh,
|
||||
MwNwidth, width,
|
||||
MwNheight, height,
|
||||
NULL);
|
||||
|
||||
MwOpenGLMakeCurrent(opengl);
|
||||
|
|
@ -496,17 +484,18 @@ void VID_Init(unsigned char *palette)
|
|||
MwAddUserHandler(opengl, MwNmouseUpHandler, mouseup, NULL);
|
||||
MwAddUserHandler(opengl, MwNfocusInHandler, focusin, NULL);
|
||||
MwAddUserHandler(opengl, MwNfocusOutHandler, focusout, NULL);
|
||||
MwAddUserHandler(win, MwNresizeHandler, resize, NULL);
|
||||
|
||||
if(fullscreen){
|
||||
if(fullscreen) {
|
||||
/* todo */
|
||||
}
|
||||
|
||||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
if (vid.conheight > height)
|
||||
if(vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
if(vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
|
|
@ -518,33 +507,29 @@ void VID_Init(unsigned char *palette)
|
|||
|
||||
GL_Init();
|
||||
|
||||
sprintf (gldir, "%s/mwquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
sprintf(gldir, "%s/mwquake", com_gamedir);
|
||||
Sys_mkdir(gldir);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
void Sys_SendKeyEvents(void) {
|
||||
if(win == NULL) return;
|
||||
HandleEvents();
|
||||
}
|
||||
|
||||
void Force_CenterView_f (void)
|
||||
{
|
||||
void Force_CenterView_f(void) {
|
||||
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
|
||||
===========
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
{
|
||||
if (!win)
|
||||
void IN_Commands(void) {
|
||||
if(!win)
|
||||
return;
|
||||
|
||||
if (vidmode_active || key_dest == key_game)
|
||||
if(vidmode_active || key_dest == key_game)
|
||||
IN_ActivateMouse();
|
||||
else
|
||||
IN_DeactivateMouse ();
|
||||
IN_DeactivateMouse();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -568,13 +552,11 @@ void IN_Commands (void)
|
|||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
if (!mouse_avail)
|
||||
void IN_MouseMove(usercmd_t* cmd) {
|
||||
if(!mouse_avail)
|
||||
return;
|
||||
|
||||
if (1)
|
||||
{
|
||||
if(1) {
|
||||
mx = (mx + old_mouse_x) * 0.5;
|
||||
my = (my + old_mouse_y) * 0.5;
|
||||
}
|
||||
|
|
@ -584,26 +566,23 @@ void IN_MouseMove (usercmd_t *cmd)
|
|||
mx *= sensitivity.value;
|
||||
my *= sensitivity.value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
// add mouse X/Y movement to cmd
|
||||
if((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
|
||||
cmd->sidemove += m_side.value * mx;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw.value * mx;
|
||||
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
if(in_mlook.state & 1)
|
||||
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;
|
||||
if (cl.viewangles[PITCH] > 80)
|
||||
if(cl.viewangles[PITCH] > 80)
|
||||
cl.viewangles[PITCH] = 80;
|
||||
if (cl.viewangles[PITCH] < -70)
|
||||
if(cl.viewangles[PITCH] < -70)
|
||||
cl.viewangles[PITCH] = -70;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
} else {
|
||||
if((in_strafe.state & 1) && noclip_anglehack)
|
||||
cmd->upmove -= m_forward.value * my;
|
||||
else
|
||||
cmd->forwardmove -= m_forward.value * my;
|
||||
|
|
@ -611,9 +590,6 @@ void IN_MouseMove (usercmd_t *cmd)
|
|||
mx = my = 0;
|
||||
}
|
||||
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
void IN_Move(usercmd_t* cmd) {
|
||||
IN_MouseMove(cmd);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue