mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
-x11 now works (qw, anyway)
This commit is contained in:
parent
311cbdbe59
commit
3e484da3b8
3 changed files with 38 additions and 103 deletions
|
@ -67,6 +67,7 @@ typedef struct {
|
||||||
int (*surf_cache_size)(int width, int height);
|
int (*surf_cache_size)(int width, int height);
|
||||||
void (*flush_caches)(void);
|
void (*flush_caches)(void);
|
||||||
void (*init_caches)(void *cache, int size);
|
void (*init_caches)(void *cache, int size);
|
||||||
|
void (*do_screen_buffer)(void);
|
||||||
} viddef_t;
|
} viddef_t;
|
||||||
|
|
||||||
extern viddef_t vid; // global video state
|
extern viddef_t vid; // global video state
|
||||||
|
|
|
@ -47,11 +47,6 @@ VID_InitBuffers (void)
|
||||||
if (vid.surf_cache_size)
|
if (vid.surf_cache_size)
|
||||||
cachesize = vid.surf_cache_size (vid.width, vid.height);
|
cachesize = vid.surf_cache_size (vid.width, vid.height);
|
||||||
|
|
||||||
// Free the old screen buffer
|
|
||||||
if (vid.buffer) {
|
|
||||||
free (vid.buffer);
|
|
||||||
vid.conbuffer = vid.buffer = NULL;
|
|
||||||
}
|
|
||||||
// Free the old z-buffer
|
// Free the old z-buffer
|
||||||
if (vid.zbuffer) {
|
if (vid.zbuffer) {
|
||||||
free (vid.zbuffer);
|
free (vid.zbuffer);
|
||||||
|
@ -64,10 +59,19 @@ VID_InitBuffers (void)
|
||||||
free (vid.surfcache);
|
free (vid.surfcache);
|
||||||
vid.surfcache = NULL;
|
vid.surfcache = NULL;
|
||||||
}
|
}
|
||||||
// Allocate the new screen buffer
|
if (vid.do_screen_buffer) {
|
||||||
vid.conbuffer = vid.buffer = calloc (buffersize, 1);
|
vid.do_screen_buffer ();
|
||||||
if (!vid.conbuffer) {
|
} else {
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
// Free the old screen buffer
|
||||||
|
if (vid.buffer) {
|
||||||
|
free (vid.buffer);
|
||||||
|
vid.conbuffer = vid.buffer = NULL;
|
||||||
|
}
|
||||||
|
// Allocate the new screen buffer
|
||||||
|
vid.conbuffer = vid.buffer = calloc (buffersize, 1);
|
||||||
|
if (!vid.conbuffer) {
|
||||||
|
Sys_Error ("Not enough memory for video mode\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Allocate the new z-buffer
|
// Allocate the new z-buffer
|
||||||
vid.zbuffer = calloc (zbuffersize, 1);
|
vid.zbuffer = calloc (zbuffersize, 1);
|
||||||
|
|
|
@ -89,7 +89,7 @@ int XShmQueryExtension (Display *);
|
||||||
int XShmGetEventBase (Display *);
|
int XShmGetEventBase (Display *);
|
||||||
|
|
||||||
static qboolean doShm;
|
static qboolean doShm;
|
||||||
//static XShmSegmentInfo x_shminfo[2];
|
static XShmSegmentInfo x_shminfo[2];
|
||||||
|
|
||||||
static int current_framebuffer;
|
static int current_framebuffer;
|
||||||
static XImage *x_framebuffer[2] = { 0, 0 };
|
static XImage *x_framebuffer[2] = { 0, 0 };
|
||||||
|
@ -303,45 +303,11 @@ D_EndDirectRect (int x, int y, int width, int height)
|
||||||
static void
|
static void
|
||||||
ResetFrameBuffer (void)
|
ResetFrameBuffer (void)
|
||||||
{
|
{
|
||||||
#if 0 //XXX not yet
|
|
||||||
int tbuffersize, tcachesize;
|
|
||||||
|
|
||||||
void *vid_surfcache;
|
|
||||||
int mem, pwidth;
|
int mem, pwidth;
|
||||||
|
|
||||||
// Calculate the sizes we want first
|
|
||||||
tbuffersize = vid.width * vid.height * sizeof (*d_pzbuffer);
|
|
||||||
tcachesize = D_SurfaceCacheForRes (vid.width, vid.height);
|
|
||||||
|
|
||||||
if (x_framebuffer[0]) {
|
if (x_framebuffer[0]) {
|
||||||
XDestroyImage (x_framebuffer[0]);
|
XDestroyImage (x_framebuffer[0]);
|
||||||
}
|
}
|
||||||
// Free the old z-buffer
|
|
||||||
if (d_pzbuffer) {
|
|
||||||
free (d_pzbuffer);
|
|
||||||
d_pzbuffer = NULL;
|
|
||||||
}
|
|
||||||
// Free the old surface cache
|
|
||||||
vid_surfcache = D_SurfaceCacheAddress ();
|
|
||||||
if (vid_surfcache) {
|
|
||||||
D_FlushCaches ();
|
|
||||||
free (vid_surfcache);
|
|
||||||
vid_surfcache = NULL;
|
|
||||||
}
|
|
||||||
// Allocate the new z-buffer
|
|
||||||
d_pzbuffer = calloc (tbuffersize, 1);
|
|
||||||
if (!d_pzbuffer) {
|
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
|
||||||
}
|
|
||||||
// Allocate the new surface cache; free the z-buffer if we fail
|
|
||||||
vid_surfcache = calloc (tcachesize, 1);
|
|
||||||
if (!vid_surfcache) {
|
|
||||||
free (d_pzbuffer);
|
|
||||||
d_pzbuffer = NULL;
|
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
D_InitCaches (vid_surfcache, tcachesize);
|
|
||||||
|
|
||||||
pwidth = x_visinfo->depth / 8;
|
pwidth = x_visinfo->depth / 8;
|
||||||
|
|
||||||
|
@ -349,6 +315,7 @@ ResetFrameBuffer (void)
|
||||||
pwidth = 4;
|
pwidth = 4;
|
||||||
mem = ((vid.width * pwidth + 7) & ~7) * vid.height;
|
mem = ((vid.width * pwidth + 7) & ~7) * vid.height;
|
||||||
|
|
||||||
|
// allocate new screen buffer
|
||||||
x_framebuffer[0] = XCreateImage (x_disp, x_vis, x_visinfo->depth,
|
x_framebuffer[0] = XCreateImage (x_disp, x_vis, x_visinfo->depth,
|
||||||
ZPixmap, 0, malloc (mem), vid.width,
|
ZPixmap, 0, malloc (mem), vid.width,
|
||||||
vid.height, 32, 0);
|
vid.height, 32, 0);
|
||||||
|
@ -356,52 +323,16 @@ ResetFrameBuffer (void)
|
||||||
if (!x_framebuffer[0]) {
|
if (!x_framebuffer[0]) {
|
||||||
Sys_Error ("VID: XCreateImage failed\n");
|
Sys_Error ("VID: XCreateImage failed\n");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ResetSharedFrameBuffers (void)
|
ResetSharedFrameBuffers (void)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
int tbuffersize, tcachesize;
|
|
||||||
void *vid_surfcache;
|
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int key;
|
int key;
|
||||||
int minsize = getpagesize ();
|
int minsize = getpagesize ();
|
||||||
int frm;
|
int frm;
|
||||||
|
|
||||||
// Calculate the sizes we want first
|
|
||||||
tbuffersize = vid.width * vid.height * sizeof (*d_pzbuffer);
|
|
||||||
tcachesize = D_SurfaceCacheForRes (vid.width, vid.height);
|
|
||||||
|
|
||||||
// Free the old z-buffer
|
|
||||||
if (d_pzbuffer) {
|
|
||||||
free (d_pzbuffer);
|
|
||||||
d_pzbuffer = NULL;
|
|
||||||
}
|
|
||||||
// Free the old surface cache
|
|
||||||
vid_surfcache = D_SurfaceCacheAddress ();
|
|
||||||
if (vid_surfcache) {
|
|
||||||
D_FlushCaches ();
|
|
||||||
free (vid_surfcache);
|
|
||||||
vid_surfcache = NULL;
|
|
||||||
}
|
|
||||||
// Allocate the new z-buffer
|
|
||||||
d_pzbuffer = calloc (tbuffersize, 1);
|
|
||||||
if (!d_pzbuffer) {
|
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
|
||||||
}
|
|
||||||
// Allocate the new surface cache; free the z-buffer if we fail
|
|
||||||
vid_surfcache = calloc (tcachesize, 1);
|
|
||||||
if (!vid_surfcache) {
|
|
||||||
free (d_pzbuffer);
|
|
||||||
d_pzbuffer = NULL;
|
|
||||||
Sys_Error ("Not enough memory for video mode\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
D_InitCaches (vid_surfcache, tcachesize);
|
|
||||||
|
|
||||||
for (frm = 0; frm < 2; frm++) {
|
for (frm = 0; frm < 2; frm++) {
|
||||||
|
|
||||||
// free up old frame buffer memory
|
// free up old frame buffer memory
|
||||||
|
@ -441,7 +372,25 @@ ResetSharedFrameBuffers (void)
|
||||||
shmctl (x_shminfo[frm].shmid, IPC_RMID, 0);
|
shmctl (x_shminfo[frm].shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
x11_init_buffers (void)
|
||||||
|
{
|
||||||
|
if (doShm)
|
||||||
|
ResetSharedFrameBuffers ();
|
||||||
|
else
|
||||||
|
ResetFrameBuffer ();
|
||||||
|
|
||||||
|
vid.direct = 0;
|
||||||
|
vid.rowbytes = x_framebuffer[0]->bytes_per_line;
|
||||||
|
vid.buffer = x_framebuffer[current_framebuffer]->data;
|
||||||
|
vid.conbuffer = vid.buffer;
|
||||||
|
vid.conwidth = vid.width;
|
||||||
|
vid.conheight = vid.height;
|
||||||
|
vid.conrowbytes = vid.rowbytes;
|
||||||
|
vid.aspect = ((float) vid.height / (float) vid.width) * (320.0 / 240.0);
|
||||||
|
current_framebuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -588,20 +537,10 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
if (doShm) {
|
if (doShm) {
|
||||||
x_shmeventtype = XShmGetEventBase (x_disp) + ShmCompletion;
|
x_shmeventtype = XShmGetEventBase (x_disp) + ShmCompletion;
|
||||||
ResetSharedFrameBuffers ();
|
|
||||||
} else {
|
|
||||||
ResetFrameBuffer ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_framebuffer = 0;
|
vid.do_screen_buffer = x11_init_buffers;
|
||||||
vid.rowbytes = x_framebuffer[0]->bytes_per_line;
|
VID_InitBuffers ();
|
||||||
vid.buffer = x_framebuffer[0]->data;
|
|
||||||
vid.direct = 0;
|
|
||||||
vid.conbuffer = x_framebuffer[0]->data;
|
|
||||||
vid.conrowbytes = vid.rowbytes;
|
|
||||||
vid.conwidth = vid.width;
|
|
||||||
vid.conheight = vid.height;
|
|
||||||
vid.aspect = ((float) vid.height / (float) vid.width) * (320.0 / 240.0);
|
|
||||||
|
|
||||||
// XSynchronize (x_disp, False);
|
// XSynchronize (x_disp, False);
|
||||||
X11_AddEvent (x_shmeventtype, event_shm);
|
X11_AddEvent (x_shmeventtype, event_shm);
|
||||||
|
@ -684,17 +623,8 @@ VID_Update (vrect_t *rects)
|
||||||
vid.width = config_notify_width & ~7;
|
vid.width = config_notify_width & ~7;
|
||||||
vid.height = config_notify_height;
|
vid.height = config_notify_height;
|
||||||
|
|
||||||
if (doShm)
|
VID_InitBuffers ();
|
||||||
ResetSharedFrameBuffers ();
|
|
||||||
else
|
|
||||||
ResetFrameBuffer ();
|
|
||||||
|
|
||||||
vid.rowbytes = x_framebuffer[0]->bytes_per_line;
|
|
||||||
vid.buffer = x_framebuffer[current_framebuffer]->data;
|
|
||||||
vid.conbuffer = vid.buffer;
|
|
||||||
vid.conwidth = vid.width;
|
|
||||||
vid.conheight = vid.height;
|
|
||||||
vid.conrowbytes = vid.rowbytes;
|
|
||||||
vid.recalc_refdef = 1; /* force a surface cache flush */
|
vid.recalc_refdef = 1; /* force a surface cache flush */
|
||||||
Con_CheckResize ();
|
Con_CheckResize ();
|
||||||
Con_Clear_f ();
|
Con_Clear_f ();
|
||||||
|
|
Loading…
Reference in a new issue