[0.0-42] gl_expand_textures is available if your gfx chip is old
This commit is contained in:
parent
3d90071c0f
commit
6de42fdbc7
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"antialiasinglevel": 0,
|
"antialiasinglevel": 0,
|
||||||
"smoothlighting": true,
|
"smoothlighting": true,
|
||||||
|
"gl_expand_textures": false,
|
||||||
"gl_chunk_size": 16,
|
"gl_chunk_size": 16,
|
||||||
"gl_visible_chunks": 49,
|
"gl_visible_chunks": 49,
|
||||||
"gl_chunks_tesselated_per_frame": 2,
|
"gl_chunks_tesselated_per_frame": 2,
|
||||||
|
@ -37,6 +37,10 @@ clsave/config.json:
|
|||||||
shadows between cubes.
|
shadows between cubes.
|
||||||
Disable for a faster FPS.
|
Disable for a faster FPS.
|
||||||
|
|
||||||
|
"gl_expand_textures" expands textures to powers of 2 in OpenGL mode
|
||||||
|
This is for backwards-compatibility with old graphics cards.
|
||||||
|
Disable this unless all the text is white or something.
|
||||||
|
|
||||||
"gl_chunk_size" sets the size of the map chunks in OpenGL mode
|
"gl_chunk_size" sets the size of the map chunks in OpenGL mode
|
||||||
The bigger chunks are, the more time it will take to rebuild them when
|
The bigger chunks are, the more time it will take to rebuild them when
|
||||||
modified.
|
modified.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_X 0
|
#define VERSION_X 0
|
||||||
#define VERSION_Y 0
|
#define VERSION_Y 0
|
||||||
#define VERSION_A 0
|
#define VERSION_A 0
|
||||||
#define VERSION_Z 41
|
#define VERSION_Z 42
|
||||||
// Remember to bump "Z" basically every time you change the engine!
|
// Remember to bump "Z" basically every time you change the engine!
|
||||||
// Remember to bump the version in Lua too!
|
// Remember to bump the version in Lua too!
|
||||||
// Remember to document API changes in a new version!
|
// Remember to document API changes in a new version!
|
||||||
@ -436,6 +436,7 @@ extern int screen_cubeshift;
|
|||||||
extern int screen_fullscreen;
|
extern int screen_fullscreen;
|
||||||
extern int screen_antialiasing_level;
|
extern int screen_antialiasing_level;
|
||||||
extern int screen_smooth_lighting;
|
extern int screen_smooth_lighting;
|
||||||
|
extern int gl_expand_textures;
|
||||||
extern int gl_use_vbo;
|
extern int gl_use_vbo;
|
||||||
extern int gl_chunk_size;
|
extern int gl_chunk_size;
|
||||||
extern int gl_visible_chunks;
|
extern int gl_visible_chunks;
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
VERSION_ENGINE = {
|
VERSION_ENGINE = {
|
||||||
cmp={0,0,0,0,41},
|
cmp={0,0,0,0,42},
|
||||||
num=41,
|
num=42,
|
||||||
str="0.0-41",
|
str="0.0-42",
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION_BUGS = {
|
VERSION_BUGS = {
|
||||||
@ -63,5 +63,6 @@ VERSION_BUGS = {
|
|||||||
{intro=38, fix=nil, msg="[OpenGL] Preliminary stutter-reduced rendering (WIP)"},
|
{intro=38, fix=nil, msg="[OpenGL] Preliminary stutter-reduced rendering (WIP)"},
|
||||||
{intro=nil, fix=40, msg="[OpenGL] Chunks rendering options not supported in game engine config file"},
|
{intro=nil, fix=40, msg="[OpenGL] Chunks rendering options not supported in game engine config file"},
|
||||||
{intro=nil, fix=41, msg="[OpenGL] option to disable VBOs not available"},
|
{intro=nil, fix=41, msg="[OpenGL] option to disable VBOs not available"},
|
||||||
|
{intro=nil, fix=42, msg="[OpenGL] lack of support for cards w/o non-power-of-2 texture support"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,33 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
void expandtex_gl(int *iw, int *ih)
|
||||||
|
{
|
||||||
|
if(gl_expand_textures)
|
||||||
|
{
|
||||||
|
(*iw)--;
|
||||||
|
(*iw) |= (*iw)>>1;
|
||||||
|
(*iw) |= (*iw)>>2;
|
||||||
|
(*iw) |= (*iw)>>4;
|
||||||
|
(*iw) |= (*iw)>>8;
|
||||||
|
(*iw) |= (*iw)>>16;
|
||||||
|
(*iw)++;
|
||||||
|
|
||||||
|
(*ih)--;
|
||||||
|
(*ih) |= (*ih)>>1;
|
||||||
|
(*ih) |= (*ih)>>2;
|
||||||
|
(*ih) |= (*ih)>>4;
|
||||||
|
(*ih) |= (*ih)>>8;
|
||||||
|
(*ih) |= (*ih)>>16;
|
||||||
|
(*ih)++;
|
||||||
|
|
||||||
|
if((*iw) < 64)
|
||||||
|
*iw = 64;
|
||||||
|
if((*ih) < 64)
|
||||||
|
*ih = 64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void render_blit_img_toimg(uint32_t *pixels, int width, int height, int pitch,
|
void render_blit_img_toimg(uint32_t *pixels, int width, int height, int pitch,
|
||||||
img_t *src, int dx, int dy, int bw, int bh, int sx, int sy, uint32_t color);
|
img_t *src, int dx, int dy, int bw, int bh, int sx, int sy, uint32_t color);
|
||||||
|
|
||||||
@ -24,7 +51,17 @@ void render_blit_img(uint32_t *pixels, int width, int height, int pitch,
|
|||||||
img_t *src, int dx, int dy, int bw, int bh, int sx, int sy, uint32_t color)
|
img_t *src, int dx, int dy, int bw, int bh, int sx, int sy, uint32_t color)
|
||||||
{
|
{
|
||||||
if(pixels != screen->pixels)
|
if(pixels != screen->pixels)
|
||||||
|
{
|
||||||
|
expandtex_gl(&width, &height);
|
||||||
|
pitch = width;
|
||||||
return render_blit_img_toimg(pixels,width,height,pitch,src,dx,dy,bw,bh,sx,sy,color);
|
return render_blit_img_toimg(pixels,width,height,pitch,src,dx,dy,bw,bh,sx,sy,color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int iw, ih;
|
||||||
|
iw = src->head.width;
|
||||||
|
ih = src->head.height;
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
|
|
||||||
// TODO: cache shit so we don't have to constantly upload the same image over and over again
|
// TODO: cache shit so we don't have to constantly upload the same image over and over again
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
if(src->tex_dirty)
|
if(src->tex_dirty)
|
||||||
@ -33,7 +70,7 @@ void render_blit_img(uint32_t *pixels, int width, int height, int pitch,
|
|||||||
glGenTextures(1, &(src->tex));
|
glGenTextures(1, &(src->tex));
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, src->tex);
|
glBindTexture(GL_TEXTURE_2D, src->tex);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src->head.width, src->head.height, 0, GL_BGRA, GL_UNSIGNED_BYTE, src->pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iw, ih, 0, GL_BGRA, GL_UNSIGNED_BYTE, src->pixels);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
@ -59,10 +96,10 @@ void render_blit_img(uint32_t *pixels, int width, int height, int pitch,
|
|||||||
float dx2 = dx+bw;
|
float dx2 = dx+bw;
|
||||||
float dy2 = dy+bh;
|
float dy2 = dy+bh;
|
||||||
|
|
||||||
float sx1 = (sx)/(float)src->head.width;
|
float sx1 = (sx)/(float)iw;
|
||||||
float sx2 = (sx+bw)/(float)src->head.width;
|
float sx2 = (sx+bw)/(float)iw;
|
||||||
float sy1 = (sy)/(float)src->head.height;
|
float sy1 = (sy)/(float)ih;
|
||||||
float sy2 = (sy+bh)/(float)src->head.height;
|
float sy2 = (sy+bh)/(float)ih;
|
||||||
|
|
||||||
glColor4f(((color>>16)&255)/255.0f,((color>>8)&255)/255.0f,((color)&255)/255.0f,((color>>24)&255)/255.0f);
|
glColor4f(((color>>16)&255)/255.0f,((color>>8)&255)/255.0f,((color)&255)/255.0f,((color>>24)&255)/255.0f);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
@ -135,10 +172,14 @@ void render_blit_img_toimg(uint32_t *pixels, int width, int height, int pitch,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// get pointers
|
// get pointers
|
||||||
|
int iw, ih;
|
||||||
|
iw = src->head.width;
|
||||||
|
ih = src->head.height;
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
uint32_t *ps = src->pixels;
|
uint32_t *ps = src->pixels;
|
||||||
ps = &ps[sx+sy*src->head.width];
|
ps = &ps[sx+sy*iw];
|
||||||
uint32_t *pd = &(pixels[dx+dy*pitch]);
|
uint32_t *pd = &(pixels[dx+dy*pitch]);
|
||||||
int spitch = src->head.width - bw;
|
int spitch = iw - bw;
|
||||||
int dpitch = pitch - bw;
|
int dpitch = pitch - bw;
|
||||||
|
|
||||||
//printf("[%i %i] [%i %i] %016llX %016llX %i %i %08X\n"
|
//printf("[%i %i] [%i %i] %016llX %016llX %i %i %08X\n"
|
||||||
|
22
src/img.c
22
src/img.c
@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
void expandtex_gl(int *iw, int *ih);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t img_convert_color_to_32(uint32_t v, int bits)
|
uint32_t img_convert_color_to_32(uint32_t v, int bits)
|
||||||
{
|
{
|
||||||
switch(bits)
|
switch(bits)
|
||||||
@ -76,7 +80,14 @@ img_t *img_parse_tga(int len, const char *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allocate + stash
|
// allocate + stash
|
||||||
img_t *img = (img_t*)malloc(sizeof(img_t)+4*head.width*head.height);
|
int iw, ih;
|
||||||
|
iw = head.width;
|
||||||
|
ih = head.height;
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
|
#endif
|
||||||
|
printf("TEX: %i %i\n", iw, ih);
|
||||||
|
img_t *img = (img_t*)malloc(sizeof(img_t)+4*iw*ih);
|
||||||
// TODO: check if NULL
|
// TODO: check if NULL
|
||||||
img->head = head;
|
img->head = head;
|
||||||
img->udtype = UD_IMG;
|
img->udtype = UD_IMG;
|
||||||
@ -87,7 +98,7 @@ img_t *img_parse_tga(int len, const char *data)
|
|||||||
|
|
||||||
// copy stuff
|
// copy stuff
|
||||||
int bplen = ((head.bpp-1)>>3)+1;
|
int bplen = ((head.bpp-1)>>3)+1;
|
||||||
int idx = (head.flags & 32 ? 0 : head.height-1)*head.width;
|
int idx = (head.flags & 32 ? 0 : head.height-1)*iw;
|
||||||
for(y = 0; y < head.height; y++)
|
for(y = 0; y < head.height; y++)
|
||||||
{
|
{
|
||||||
if(head.imgtype & 8)
|
if(head.imgtype & 8)
|
||||||
@ -128,18 +139,19 @@ img_t *img_parse_tga(int len, const char *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idx += iw-head.width;
|
||||||
if(!(head.flags & 32))
|
if(!(head.flags & 32))
|
||||||
idx -= 2*head.width;
|
idx -= 2*iw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert pixels
|
// convert pixels
|
||||||
if((head.imgtype&7) == 1)
|
if((head.imgtype&7) == 1)
|
||||||
{
|
{
|
||||||
for(i = head.width*head.height-1; i >= 0; i--)
|
for(i = iw*ih-1; i >= 0; i--)
|
||||||
img->pixels[i] = palette[(img->pixels[i] + head.cmoffs) % head.cmlen];
|
img->pixels[i] = palette[(img->pixels[i] + head.cmoffs) % head.cmlen];
|
||||||
//printf("cm %i %i\n", head.cmoffs, head.cmlen);
|
//printf("cm %i %i\n", head.cmoffs, head.cmlen);
|
||||||
} else {
|
} else {
|
||||||
for(i = head.width*head.height-1; i >= 0; i--)
|
for(i = iw*ih-1; i >= 0; i--)
|
||||||
img->pixels[i] = img_convert_color_to_32(img->pixels[i], head.bpp);
|
img->pixels[i] = img_convert_color_to_32(img->pixels[i], head.bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,6 +347,11 @@ int icelua_init(void)
|
|||||||
if(!lua_isnil(Lc, -1)) gl_use_vbo = v;
|
if(!lua_isnil(Lc, -1)) gl_use_vbo = v;
|
||||||
lua_pop(Lc, 1);
|
lua_pop(Lc, 1);
|
||||||
|
|
||||||
|
lua_getfield(Lc, -1, "gl_expand_textures");
|
||||||
|
v = lua_toboolean(Lc, -1);
|
||||||
|
if(!lua_isnil(Lc, -1)) gl_expand_textures = v;
|
||||||
|
lua_pop(Lc, 1);
|
||||||
|
|
||||||
lua_getfield(Lc, -1, "gl_chunk_size");
|
lua_getfield(Lc, -1, "gl_chunk_size");
|
||||||
v = lua_tointeger(Lc, -1);
|
v = lua_tointeger(Lc, -1);
|
||||||
if(v > 0) gl_chunk_size = v;
|
if(v > 0) gl_chunk_size = v;
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
|
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
void expandtex_gl(int *iw, int *ih);
|
||||||
|
#endif
|
||||||
|
|
||||||
// client functions
|
// client functions
|
||||||
int icelua_fn_client_img_blit(lua_State *L)
|
int icelua_fn_client_img_blit(lua_State *L)
|
||||||
@ -114,11 +117,16 @@ int icelua_fn_common_img_new(lua_State *L)
|
|||||||
|
|
||||||
int w = lua_tointeger(L, 1);
|
int w = lua_tointeger(L, 1);
|
||||||
int h = lua_tointeger(L, 2);
|
int h = lua_tointeger(L, 2);
|
||||||
|
int iw = w;
|
||||||
|
int ih = h;
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(w < 1 || h < 1)
|
if(w < 1 || h < 1)
|
||||||
return luaL_error(L, "image too small");
|
return luaL_error(L, "image too small");
|
||||||
|
|
||||||
img_t *img = (img_t*)malloc(sizeof(img_t)+(w*h*sizeof(uint32_t)));
|
img_t *img = (img_t*)malloc(sizeof(img_t)+(iw*ih*sizeof(uint32_t)));
|
||||||
if(img == NULL)
|
if(img == NULL)
|
||||||
return luaL_error(L, "could not allocate memory");
|
return luaL_error(L, "could not allocate memory");
|
||||||
|
|
||||||
@ -135,7 +143,7 @@ int icelua_fn_common_img_new(lua_State *L)
|
|||||||
img->head.bpp = 32;
|
img->head.bpp = 32;
|
||||||
img->head.flags = 0x20;
|
img->head.flags = 0x20;
|
||||||
|
|
||||||
for(i = 0; i < w*h; i++)
|
for(i = 0; i < iw*ih; i++)
|
||||||
img->pixels[i] = 0x00000000;
|
img->pixels[i] = 0x00000000;
|
||||||
|
|
||||||
img->udtype = UD_IMG;
|
img->udtype = UD_IMG;
|
||||||
@ -161,8 +169,14 @@ int icelua_fn_common_img_pixel_set(lua_State *L)
|
|||||||
|
|
||||||
if(x < 0 || y < 0 || x >= img->head.width || y >= img->head.height)
|
if(x < 0 || y < 0 || x >= img->head.width || y >= img->head.height)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
int iw = img->head.width;
|
||||||
|
int ih = img->head.height;
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
|
#endif
|
||||||
|
|
||||||
img->pixels[y*img->head.width+x] = color;
|
img->pixels[y*iw+x] = color;
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
img->tex_dirty = 1;
|
img->tex_dirty = 1;
|
||||||
#endif
|
#endif
|
||||||
@ -181,7 +195,12 @@ int icelua_fn_common_img_fill(lua_State *L)
|
|||||||
return luaL_error(L, "not an image");
|
return luaL_error(L, "not an image");
|
||||||
uint32_t color = lua_tointeger(L, 2);
|
uint32_t color = lua_tointeger(L, 2);
|
||||||
|
|
||||||
for (i=0; i<(img->head.width*img->head.height); i++)
|
int iw = img->head.width;
|
||||||
|
int ih = img->head.height;
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
expandtex_gl(&iw, &ih);
|
||||||
|
#endif
|
||||||
|
for (i=0; i<(iw*ih); i++)
|
||||||
img->pixels[i] = color;
|
img->pixels[i] = color;
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
|
@ -30,6 +30,7 @@ int screen_cubeshift = 0;
|
|||||||
int screen_fullscreen = 0;
|
int screen_fullscreen = 0;
|
||||||
int screen_antialiasing_level = 0;
|
int screen_antialiasing_level = 0;
|
||||||
int screen_smooth_lighting = 0;
|
int screen_smooth_lighting = 0;
|
||||||
|
int gl_expand_textures = 0;
|
||||||
int gl_chunk_size = 16;
|
int gl_chunk_size = 16;
|
||||||
int gl_visible_chunks = 49;
|
int gl_visible_chunks = 49;
|
||||||
int gl_chunks_tesselated_per_frame = 2;
|
int gl_chunks_tesselated_per_frame = 2;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
export ZIPNAME=nubdist/iceballfornoobs-0.0-41.zip
|
export ZIPNAME=nubdist/iceballfornoobs-0.0-42.zip
|
||||||
|
|
||||||
#zip -r $ZIPNAME *.dll *.exe *.txt *.bat docs/ \
|
#zip -r $ZIPNAME *.dll *.exe *.txt *.bat docs/ \
|
||||||
# pkg/base/*.lua \
|
# pkg/base/*.lua \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user