mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-22 16:01:25 +00:00
include/tga.h source/tga.c:
new function WriteTGAfile. Also, put in the tga header structure. NOTE: this is currently broken for non gcc ocmilers. you will get a #error message. include/quakefs.h source/quakefs.c: new function COM_WriteBuffers. Like COM_WriteFile, but scatter/gather style. source/gl_screen.c source/screen.c: misc cleanups. differences are getting fewer. should be mostly mergable soon (minus truly sw/gl specific code).
This commit is contained in:
parent
d1ef9bbc3f
commit
0bd4b8d288
6 changed files with 95 additions and 82 deletions
|
@ -49,6 +49,8 @@ extern char com_gamedir[MAX_OSPATH];
|
|||
extern char gamedirfile[MAX_OSPATH];
|
||||
|
||||
void COM_WriteFile (char *filename, void *data, int len);
|
||||
void COM_WriteBuffers (const char *filename, int count, ...);
|
||||
|
||||
int _COM_FOpenFile (char *filename, QFile **gzfile, char *foundname, int zip);
|
||||
int COM_FOpenFile (char *filename, QFile **gzfile);
|
||||
void COM_CloseFile (QFile *h);
|
||||
|
|
|
@ -29,9 +29,29 @@
|
|||
#ifndef __tga_h
|
||||
#define __tga_h
|
||||
|
||||
#include "gcc_attr.h"
|
||||
#include "qtypes.h"
|
||||
|
||||
byte *
|
||||
LoadTGA (QFile *fin);
|
||||
#ifndef __GNUC__
|
||||
#error do some data packing magic here (#pragma pack?)
|
||||
#endif
|
||||
|
||||
typedef struct _TargaHeader {
|
||||
unsigned char id_length __attribute__((packed));
|
||||
unsigned char colormap_type __attribute__((packed));
|
||||
unsigned char image_type __attribute__((packed));
|
||||
unsigned short colormap_index __attribute__((packed));
|
||||
unsigned short colormap_length __attribute__((packed));
|
||||
unsigned char colormap_size __attribute__((packed));
|
||||
unsigned short x_origin __attribute__((packed));
|
||||
unsigned short y_origin __attribute__((packed));
|
||||
unsigned short width __attribute__((packed));
|
||||
unsigned short height __attribute__((packed));
|
||||
unsigned char pixel_size __attribute__((packed));
|
||||
unsigned char attributes __attribute__((packed));
|
||||
} TargaHeader;
|
||||
|
||||
byte *LoadTGA (QFile *fin);
|
||||
void WriteTGAfile (const char *tganame, byte *data, int width, int height);
|
||||
|
||||
#endif // __tga_h
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "sbar.h"
|
||||
#include "skin.h"
|
||||
#include "sys.h"
|
||||
#include "tga.h"
|
||||
#include "view.h"
|
||||
|
||||
/*
|
||||
|
@ -182,7 +183,6 @@ SCR_CenterPrint (char *str)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SCR_DrawCenterString (void)
|
||||
{
|
||||
|
@ -490,8 +490,6 @@ SCR_DrawFPS (void)
|
|||
fps_count = 0;
|
||||
lastframetime = t;
|
||||
}
|
||||
/* Misty: I really do need to read about snprintf a bit. This thing keeps
|
||||
chewing on my foot! */
|
||||
snprintf (st, sizeof (st), "%-3d FPS", lastfps);
|
||||
/* Misty: New trick! (for me) the ? makes this work like a if then else -
|
||||
IE: if cl_hudswap->int_val is not null, do first case, else (else is a
|
||||
|
@ -620,15 +618,6 @@ SCR_DrawConsole (void)
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
typedef struct _TargaHeader {
|
||||
unsigned char id_length, colormap_type, image_type;
|
||||
unsigned short colormap_index, colormap_length;
|
||||
unsigned char colormap_size;
|
||||
unsigned short x_origin, y_origin, width, height;
|
||||
unsigned char pixel_size, attributes;
|
||||
} TargaHeader;
|
||||
|
||||
|
||||
/*
|
||||
SCR_ScreenShot_f
|
||||
*/
|
||||
|
@ -645,21 +634,10 @@ SCR_ScreenShot_f (void)
|
|||
Con_Printf ("SCR_ScreenShot_f: Couldn't create a TGA file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
buffer = malloc (glwidth * glheight * 3 + 18);
|
||||
memset (buffer, 0, 18);
|
||||
buffer[2] = 2; // uncompressed type
|
||||
buffer[12] = glwidth & 255;
|
||||
buffer[13] = glwidth >> 8;
|
||||
buffer[14] = glheight & 255;
|
||||
buffer[15] = glheight >> 8;
|
||||
buffer[16] = 24; // pixel size
|
||||
|
||||
buffer = malloc (glwidth * glheight * 3);
|
||||
glReadPixels (glx, gly, glwidth, glheight, GL_BGR, GL_UNSIGNED_BYTE,
|
||||
buffer + 18);
|
||||
COM_WriteFile (pcxname, buffer, glwidth * glheight * 3 + 18);
|
||||
|
||||
buffer);
|
||||
WriteTGAfile (pcxname, buffer, glwidth, glheight);
|
||||
free (buffer);
|
||||
Con_Printf ("Wrote %s\n", pcxname);
|
||||
}
|
||||
|
@ -850,14 +828,10 @@ SCR_RSShot_f (void)
|
|||
free (newbuf);
|
||||
|
||||
Con_Printf ("Wrote %s\n", pcxname);
|
||||
Con_Printf ("Sending shot to server...\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
char *scr_notifystring;
|
||||
|
|
|
@ -29,21 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "qtypes.h"
|
||||
#include "quakefs.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "draw.h"
|
||||
#include "cmd.h"
|
||||
#include "cvar.h"
|
||||
#include "commdef.h"
|
||||
#include "qendian.h"
|
||||
#include "info.h"
|
||||
#include "server.h"
|
||||
#include "va.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
@ -67,6 +55,20 @@
|
|||
#define _POSIX_
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include "qtypes.h"
|
||||
|
||||
#include "quakefs.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "draw.h"
|
||||
#include "cmd.h"
|
||||
#include "cvar.h"
|
||||
#include "commdef.h"
|
||||
#include "qendian.h"
|
||||
#include "info.h"
|
||||
#include "server.h"
|
||||
#include "va.h"
|
||||
#include "qargs.h"
|
||||
|
||||
// LordHavoc: win32 would not compile without this
|
||||
#ifndef __const
|
||||
|
@ -393,6 +395,40 @@ COM_WriteFile (char *filename, void *data, int len)
|
|||
Qclose (f);
|
||||
}
|
||||
|
||||
/*
|
||||
COM_WriteBuffers
|
||||
|
||||
The filename will be prefixed by the current game directory
|
||||
*/
|
||||
void
|
||||
COM_WriteBuffers (const char *filename, int count, ...)
|
||||
{
|
||||
QFile *f;
|
||||
char name[MAX_OSPATH];
|
||||
va_list args;
|
||||
|
||||
va_start (args, count);
|
||||
|
||||
snprintf (name, sizeof (name), "%s/%s", com_gamedir, filename);
|
||||
|
||||
f = Qopen (name, "wb");
|
||||
if (!f) {
|
||||
Sys_mkdir (com_gamedir);
|
||||
f = Qopen (name, "wb");
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s", filename);
|
||||
}
|
||||
|
||||
Sys_Printf ("COM_WriteFile: %s\n", name);
|
||||
while (count--) {
|
||||
void *data = va_arg (args, void*);
|
||||
int len = va_arg (args, int);
|
||||
Qwrite (f, data, len);
|
||||
}
|
||||
Qclose (f);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
COM_CreatePath
|
||||
|
|
|
@ -183,26 +183,6 @@ SCR_CenterPrint (char *str)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SCR_EraseCenterString (void)
|
||||
{
|
||||
int y;
|
||||
|
||||
if (scr_erase_center++ > vid.numpages) {
|
||||
scr_erase_lines = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (scr_center_lines <= 4)
|
||||
y = vid.height * 0.35;
|
||||
else
|
||||
y = 48;
|
||||
|
||||
scr_copytop = 1;
|
||||
Draw_TileClear (0, y, vid.width,
|
||||
min (8 * scr_erase_lines, vid.height - y - 1));
|
||||
}
|
||||
|
||||
void
|
||||
SCR_DrawCenterString (void)
|
||||
{
|
||||
|
@ -624,13 +604,8 @@ SCR_SetUpToDrawConsole (void)
|
|||
}
|
||||
|
||||
if (clearconsole++ < vid.numpages) {
|
||||
scr_copytop = 1;
|
||||
Draw_TileClear (0, (int) scr_con_current, vid.width,
|
||||
vid.height - (int) scr_con_current);
|
||||
Sbar_Changed ();
|
||||
} else if (clearnotify++ < vid.numpages) {
|
||||
scr_copytop = 1;
|
||||
Draw_TileClear (0, 0, vid.width, con_notifylines);
|
||||
} else
|
||||
con_notifylines = 0;
|
||||
}
|
||||
|
@ -871,7 +846,7 @@ SCR_RSShot_f (void)
|
|||
// mapped in
|
||||
// for linear writes all the time
|
||||
|
||||
// Con_Printf ("Wrote %s\n", pcxname);
|
||||
Con_Printf ("Wrote %s\n", pcxname);
|
||||
Con_Printf ("Sending shot to server...\n");
|
||||
}
|
||||
|
||||
|
@ -993,7 +968,6 @@ SCR_UpdateScreen (void)
|
|||
|
||||
|
||||
SCR_SetUpToDrawConsole ();
|
||||
SCR_EraseCenterString ();
|
||||
|
||||
D_DisableBackBufferAccess (); // for adapters that can't stay
|
||||
// mapped in
|
||||
|
|
25
source/tga.c
25
source/tga.c
|
@ -30,19 +30,11 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "qendian.h"
|
||||
#include "quakefs.h"
|
||||
#include "sys.h"
|
||||
#include "tga.h"
|
||||
|
||||
typedef struct _TargaHeader {
|
||||
unsigned char id_length, colormap_type, image_type;
|
||||
unsigned short colormap_index, colormap_length;
|
||||
unsigned char colormap_size;
|
||||
unsigned short x_origin, y_origin, width, height;
|
||||
unsigned char pixel_size, attributes;
|
||||
} TargaHeader;
|
||||
|
||||
|
||||
static int
|
||||
fgetLittleShort (QFile *f)
|
||||
{
|
||||
|
@ -229,3 +221,18 @@ LoadTGA (QFile *fin)
|
|||
Qclose (fin);
|
||||
return targa_rgba;
|
||||
}
|
||||
|
||||
void
|
||||
WriteTGAfile (const char *tganame, byte *data, int width, int height)
|
||||
{
|
||||
TargaHeader header;
|
||||
|
||||
memset (&header, 0, sizeof (header));
|
||||
header.image_type = 2; // uncompressed type
|
||||
header.width = LittleShort (width);
|
||||
header.height = LittleShort (height);
|
||||
header.pixel_size = 24;
|
||||
|
||||
COM_WriteBuffers (tganame, 2, &header, sizeof (header), data,
|
||||
width * height * 3);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue