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 opengl;
static MwWidget label;
unsigned short d_8to16table[256];
unsigned d_8to24table[256];
@ -89,23 +89,19 @@ 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)
{
static void uninstall_grabs(void) {
if(!win)
return;
@ -189,8 +185,20 @@ 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;
@ -201,11 +209,9 @@ static void HandleEvents(void)
if(dowarp) {
/* move the mouse to the window center again */
}
}
static void IN_DeactivateMouse( void )
{
static void IN_DeactivateMouse(void) {
if(!mouse_avail || !win)
return;
@ -215,8 +221,7 @@ static void IN_DeactivateMouse( void )
}
}
static void IN_ActivateMouse( void )
{
static void IN_ActivateMouse(void) {
if(!mouse_avail || !win)
return;
@ -227,9 +232,7 @@ static void IN_ActivateMouse( void )
}
}
void VID_Shutdown(void)
{
void VID_Shutdown(void) {
IN_DeactivateMouse();
if(win) {
MwDestroyWidget(win);
@ -238,15 +241,13 @@ void VID_Shutdown(void)
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,13 +262,11 @@ void InitSig(void)
#endif
}
void VID_ShiftPalette(unsigned char *p)
{
void VID_ShiftPalette(unsigned char* p) {
// VID_SetPalette(p);
}
void VID_SetPalette (unsigned char *palette)
{
void VID_SetPalette(unsigned char* palette) {
byte* pal;
unsigned r, g, b;
unsigned v;
@ -284,8 +283,7 @@ void VID_SetPalette (unsigned char *palette)
//
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];
@ -326,8 +324,7 @@ void VID_SetPalette (unsigned char *palette)
GL_Init
===============
*/
void GL_Init (void)
{
void GL_Init(void) {
gl_vendor = glGetString(GL_VENDOR);
Con_Printf("GL_VENDOR: %s\n", gl_vendor);
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;
*x = *y = 0;
@ -381,20 +377,16 @@ void GL_BeginRendering (int *x, int *y, int *width, int *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;
@ -408,8 +400,7 @@ static void Check_Gamma (unsigned char *pal)
} else
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);
inf = f * 255 + 0.5;
if(inf < 0)
@ -422,8 +413,7 @@ static void Check_Gamma (unsigned char *pal)
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,7 +422,6 @@ void VID_Init(unsigned char *palette)
int MajorVersion, MinorVersion;
int actualWidth, actualHeight;
MwSizeHints sh;
MwWidget label;
mouse_avail = 1;
@ -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,6 +484,7 @@ 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) {
/* todo */
@ -528,23 +517,19 @@ void VID_Init(unsigned char *palette)
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,8 +537,7 @@ void IN_Shutdown(void)
IN_Commands
===========
*/
void IN_Commands (void)
{
void IN_Commands(void) {
if(!win)
return;
@ -568,13 +552,11 @@ void IN_Commands (void)
IN_Move
===========
*/
void IN_MouseMove (usercmd_t *cmd)
{
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;
}
@ -593,16 +575,13 @@ void IN_MouseMove (usercmd_t *cmd)
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)
cl.viewangles[PITCH] = 80;
if(cl.viewangles[PITCH] < -70)
cl.viewangles[PITCH] = -70;
}
else
{
} else {
if((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward.value * my;
else
@ -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);
}