*** empty log message ***

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1178 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2007-07-26 01:48:04 +00:00
parent a13aadb796
commit 01a71302e7
7 changed files with 63 additions and 40 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ void conline(const char *sf, bool highlight) // add a line to the console
}
}
const int CONSPAD = FONTH/3;
#define CONSPAD (FONTH/3)
void conoutf(const char *s, ...)
{
@@ -50,7 +50,7 @@ void conoutf(const char *s, ...)
puts(sp);
s = sf;
vector<char *> lines;
text_block(s, VIRTW*2-2*CONSPAD-2*FONTH/3, lines);
text_block(s, curfont ? VIRTW*2-2*CONSPAD-2*FONTH/3 : 0, lines);
loopv(lines) conline(lines[i], i!=0);
lines.deletecontentsa();
}
-5
View File
@@ -88,11 +88,6 @@ extern int maxclients;
extern hashtable<char *, enet_uint32> mapinfo;
extern bool hasTE, hasMT, hasMDA;
extern int VIRTW; // virtual screen size for text & HUD
#define VIRTH 1800
#define FONTH 64
#define PIXELTAB (VIRTW/12)
#include "protos.h" // external function decls
#define AC_VERSION 930
+6 -7
View File
@@ -42,7 +42,6 @@ void fatal(char *s, char *o) // failure exit
}
SDL_Surface *screen = NULL;
int VIRTW;
static bool initing = false, restoredinits = false;
bool initwarning()
@@ -327,16 +326,16 @@ int main(int argc, char **argv)
keyrepeat(false);
SDL_ShowCursor(0);
initlog("gl");
gl_init(scr_w, scr_h, colorbits, depthbits, fsaa);
crosshair = textureload("packages/misc/crosshairs/default.png");
if(!crosshair) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
initlog("console");
if(!execfile("config/font.cfg")) fatal("cannot find font definitions");
if(!setfont("default")) fatal("no default font specified");
initlog("gl");
gl_init(scr_w, scr_h, colorbits, depthbits, fsaa);
crosshair = textureload("packages/misc/crosshairs/default.png");
if(!crosshair) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
loadingscreen();
particleinit();
+21
View File
@@ -193,6 +193,27 @@ extern void keyrepeat(bool on);
extern bool initwarning();
// rendertext
struct font
{
struct charinfo
{
short x, y, w, h;
};
char *name;
Texture *tex;
vector<charinfo> chars;
short defaultw, defaulth;
short offsetx, offsety, offsetw, offseth;
};
#define VIRTH 1800
#define FONTH (curfont->defaulth)
#define PIXELTAB (VIRTW/12)
extern int VIRTW; // virtual screen size for text & HUD
extern font *curfont;
extern bool setfont(char *name);
extern void draw_text(const char *str, int left, int top);
extern void draw_textf(const char *fstr, int left, int top, ...);
+3 -2
View File
@@ -331,8 +331,9 @@ void drawreflection(float hf, int w, int h, float changelod, bool refract)
reflecting = true;
refracting = refract;
int size = 1<<reflectres;
while(size > w || size > h) size /= 2;
extern int hwtexsize;
int size = 1<<reflectres, sizelimit = min(hwtexsize, min(w, h));
while(size > sizelimit) size /= 2;
if(size!=reflectlastsize)
{
if(reflecttex) glDeleteTextures(1, &reflecttex);
+5 -15
View File
@@ -2,22 +2,12 @@
#include "cube.h"
struct font
{
struct charinfo
{
short x, y, w, h;
};
char *name;
Texture *tex;
vector<charinfo> chars;
short defaultw, defaulth;
short offsetx, offsety, offsetw, offseth;
};
int VIRTW;
static hashtable<char *, font> fonts;
static font *fontdef = NULL, *curfont = NULL;
static font *fontdef = NULL;
font *curfont = NULL;
void newfont(char *name, char *tex, char *defaultw, char *defaulth, char *offsetx, char *offsety, char *offsetw, char *offseth)
{
@@ -144,7 +134,7 @@ void text_block(const char *str, int max, vector<char *> &lines)
{
if(!str) return;
int visible;
while((visible = text_visible(str, max)))
while((visible = max ? text_visible(str, max) : strlen(str)))
{
const char *newline = (const char *)memchr(str, '\n', visible);
if(newline) visible = newline+1-str;
+26 -9
View File
@@ -5,7 +5,8 @@
Texture *crosshair = NULL;
hashtable<char *, Texture> textures;
VAR(maxtexsize, 0, -1, 4096);
VAR(hwtexsize, 1, 0, 0);
VARP(maxtexsize, 0, 0, 4096);
void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, GLenum format)
{
@@ -17,14 +18,17 @@ void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
int tw = w, th = h;
if(maxtexsize<0) glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&maxtexsize);
if(maxtexsize) while(tw>maxtexsize || th>maxtexsize) { tw /= 2; th /= 2; }
if(tw!=w || th!=h)
if(pixels)
{
if(gluScaleImage(format, w, h, GL_UNSIGNED_BYTE, pixels, tw, th, GL_UNSIGNED_BYTE, pixels))
int sizelimit = maxtexsize ? min(maxtexsize, hwtexsize) : hwtexsize;
while(tw>sizelimit || th>sizelimit) { tw /= 2; th /= 2; }
if(tw!=w || th!=h)
{
tw = w;
th = h;
if(gluScaleImage(format, w, h, GL_UNSIGNED_BYTE, pixels, tw, th, GL_UNSIGNED_BYTE, pixels))
{
tw = w;
th = h;
}
}
}
if(mipmap)
@@ -34,11 +38,22 @@ void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap,
else glTexImage2D(GL_TEXTURE_2D, 0, format, tw, th, 0, format, GL_UNSIGNED_BYTE, pixels);
}
GLenum texformat(int bpp)
{
switch(bpp)
{
case 24: return GL_RGB;
case 32: return GL_RGBA;
default: return 0;
}
}
GLuint loadsurface(const char *texname, int &xs, int &ys, int clamp)
{
SDL_Surface *s = IMG_Load(findfile(texname, "rb"));
if(!s) { conoutf("couldn't load texture %s", texname); return 0; }
if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32)
GLenum format = texformat(s->format->BitsPerPixel);
if(!format)
{
SDL_FreeSurface(s);
conoutf("texture must be 24bpp or 32bpp: %s", texname);
@@ -46,7 +61,7 @@ GLuint loadsurface(const char *texname, int &xs, int &ys, int clamp)
}
GLuint tnum;
glGenTextures(1, &tnum);
createtexture(tnum, s->w, s->h, s->pixels, clamp, true, s->format->BitsPerPixel==24 ? GL_RGB : GL_RGBA);
createtexture(tnum, s->w, s->h, s->pixels, clamp, true, format);
xs = s->w;
ys = s->h;
SDL_FreeSurface(s);
@@ -314,6 +329,8 @@ void setuptmu(int n, const char *rgbfunc, const char *alphafunc)
void inittmus()
{
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&hwtexsize);
if(hasTE && !hasMT) maxtmus = 1;
else if(hasTE && hasMT)
{