crude resize support

This commit is contained in:
IoIxD 2026-03-27 17:43:14 -07:00
commit 5e751163ee
3 changed files with 232 additions and 236 deletions

19
.clang-format Normal file
View 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
View file

@ -0,0 +1 @@
../milsko/include/Mw/

118
src/gl.c
View file

@ -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];
@ -89,23 +89,19 @@ 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;
@ -189,8 +185,20 @@ 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;
@ -201,11 +209,9 @@ static void HandleEvents(void)
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;
@ -215,8 +221,7 @@ static void IN_DeactivateMouse( void )
} }
} }
static void IN_ActivateMouse( void ) static void IN_ActivateMouse(void) {
{
if(!mouse_avail || !win) if(!mouse_avail || !win)
return; return;
@ -227,9 +232,7 @@ static void IN_ActivateMouse( void )
} }
} }
void VID_Shutdown(void) {
void VID_Shutdown(void)
{
IN_DeactivateMouse(); IN_DeactivateMouse();
if(win) { if(win) {
MwDestroyWidget(win); MwDestroyWidget(win);
@ -238,15 +241,13 @@ void VID_Shutdown(void)
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,13 +262,11 @@ 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;
@ -284,8 +283,7 @@ void VID_SetPalette (unsigned char *palette)
// //
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];
@ -326,8 +324,7 @@ 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);
@ -367,8 +364,7 @@ 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;
@ -381,20 +377,16 @@ void GL_BeginRendering (int *x, int *y, int *width, int *height)
// 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;
@ -408,8 +400,7 @@ static void Check_Gamma (unsigned char *pal)
} 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)
@ -422,8 +413,7 @@ static void Check_Gamma (unsigned char *pal)
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,7 +422,6 @@ 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;
@ -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,6 +484,7 @@ 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 */
@ -528,23 +517,19 @@ void VID_Init(unsigned char *palette)
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,8 +537,7 @@ void IN_Shutdown(void)
IN_Commands IN_Commands
=========== ===========
*/ */
void IN_Commands (void) void IN_Commands(void) {
{
if(!win) if(!win)
return; return;
@ -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;
} }
@ -593,16 +575,13 @@ void IN_MouseMove (usercmd_t *cmd)
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
@ -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);
} }