fix slerp, add auto-generate-mipmaps

This commit is contained in:
David Rose 2005-02-07 04:11:29 +00:00
parent c71fd12dc7
commit ac5246e4f2
6 changed files with 59 additions and 42 deletions

View File

@ -127,6 +127,14 @@ ConfigVariableBool depth_offset_decals
"because it appears that many graphics drivers have issues with " "because it appears that many graphics drivers have issues with "
"their depth offset implementation.")); "their depth offset implementation."));
ConfigVariableBool auto_generate_mipmaps
("auto-generate-mipmaps", false,
PRC_DESC("Set this true to use the hardware to generate mipmaps "
"automatically in all cases, if supported. Set it false "
"to generate mipmaps in software when possible. This is "
"false by default because some drivers (Intel) seem to do a "
"poor job of generating mipmaps when needed."));
ConfigVariableInt win_size ConfigVariableInt win_size
("win-size", "640 480", ("win-size", "640 480",
PRC_DESC("This is the default size at which to open a new window. This " PRC_DESC("This is the default size at which to open a new window. This "

View File

@ -36,47 +36,48 @@ ConfigureDecl(config_display, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(display, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(display, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(gsg, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(gsg, EXPCL_PANDA, EXPTP_PANDA);
extern ConfigVariableBool view_frustum_cull; extern EXPCL_PANDA ConfigVariableBool view_frustum_cull;
extern ConfigVariableBool pstats_unused_states; extern EXPCL_PANDA ConfigVariableBool pstats_unused_states;
extern ConfigVariableString threading_model; extern EXPCL_PANDA ConfigVariableString threading_model;
extern ConfigVariableBool auto_flip; extern EXPCL_PANDA ConfigVariableBool auto_flip;
extern ConfigVariableBool yield_timeslice; extern EXPCL_PANDA ConfigVariableBool yield_timeslice;
extern ConfigVariableString screenshot_filename; extern EXPCL_PANDA ConfigVariableString screenshot_filename;
extern ConfigVariableString screenshot_extension; extern EXPCL_PANDA ConfigVariableString screenshot_extension;
extern ConfigVariableBool show_buffers; extern EXPCL_PANDA ConfigVariableBool show_buffers;
extern ConfigVariableBool prefer_parasite_buffer; extern EXPCL_PANDA ConfigVariableBool prefer_parasite_buffer;
extern ConfigVariableBool prefer_single_buffer; extern EXPCL_PANDA ConfigVariableBool prefer_single_buffer;
extern ConfigVariableBool copy_texture_inverted; extern EXPCL_PANDA ConfigVariableBool copy_texture_inverted;
extern ConfigVariableBool window_inverted; extern EXPCL_PANDA ConfigVariableBool window_inverted;
extern ConfigVariableBool depth_offset_decals; extern EXPCL_PANDA ConfigVariableBool depth_offset_decals;
extern EXPCL_PANDA ConfigVariableBool auto_generate_mipmaps;
extern ConfigVariableInt win_size; extern EXPCL_PANDA ConfigVariableInt win_size;
extern ConfigVariableInt win_origin; extern EXPCL_PANDA ConfigVariableInt win_origin;
extern ConfigVariableInt win_width; extern EXPCL_PANDA ConfigVariableInt win_width;
extern ConfigVariableInt win_height; extern EXPCL_PANDA ConfigVariableInt win_height;
extern ConfigVariableInt win_origin_x; extern EXPCL_PANDA ConfigVariableInt win_origin_x;
extern ConfigVariableInt win_origin_y; extern EXPCL_PANDA ConfigVariableInt win_origin_y;
extern ConfigVariableBool fullscreen; extern EXPCL_PANDA ConfigVariableBool fullscreen;
extern ConfigVariableBool undecorated; extern EXPCL_PANDA ConfigVariableBool undecorated;
extern ConfigVariableBool cursor_hidden; extern EXPCL_PANDA ConfigVariableBool cursor_hidden;
extern ConfigVariableFilename icon_filename; extern EXPCL_PANDA ConfigVariableFilename icon_filename;
extern ConfigVariableFilename cursor_filename; extern EXPCL_PANDA ConfigVariableFilename cursor_filename;
extern ConfigVariableEnum<WindowProperties::ZOrder> z_order; extern EXPCL_PANDA ConfigVariableEnum<WindowProperties::ZOrder> z_order;
extern ConfigVariableString window_title; extern EXPCL_PANDA ConfigVariableString window_title;
extern ConfigVariableString framebuffer_mode; extern EXPCL_PANDA ConfigVariableString framebuffer_mode;
extern ConfigVariableInt depth_bits; extern EXPCL_PANDA ConfigVariableInt depth_bits;
extern ConfigVariableInt color_bits; extern EXPCL_PANDA ConfigVariableInt color_bits;
extern ConfigVariableInt alpha_bits; extern EXPCL_PANDA ConfigVariableInt alpha_bits;
extern ConfigVariableInt stencil_bits; extern EXPCL_PANDA ConfigVariableInt stencil_bits;
extern ConfigVariableInt multisamples; extern EXPCL_PANDA ConfigVariableInt multisamples;
extern ConfigVariableDouble background_color; extern EXPCL_PANDA ConfigVariableDouble background_color;
extern EXPCL_PANDA void init_libdisplay(); extern EXPCL_PANDA void init_libdisplay();

View File

@ -3319,7 +3319,8 @@ specify_texture(Texture *tex) {
} }
#endif #endif
if (_supports_generate_mipmap) { if (_supports_generate_mipmap &&
(auto_generate_mipmaps || !tex->might_have_ram_image())) {
// If the hardware can automatically generate mipmaps, ask it to // If the hardware can automatically generate mipmaps, ask it to
// do so now, but only if the texture requires them. // do so now, but only if the texture requires them.
GLP(TexParameteri)(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, uses_mipmaps); GLP(TexParameteri)(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, uses_mipmaps);
@ -3453,7 +3454,7 @@ apply_texture_immediate(CLP(TextureContext) *gtc, Texture *tex) {
<< (int)type << ", " << tex->get_name() << ")\n"; << (int)type << ", " << tex->get_name() << ")\n";
#endif #endif
bool uses_mipmaps = tex->uses_mipmaps() && !CLP(ignore_mipmaps); bool uses_mipmaps = (tex->uses_mipmaps() && !CLP(ignore_mipmaps)) || CLP(force_mipmaps);
#ifndef NDEBUG #ifndef NDEBUG
if (CLP(force_mipmaps)) { if (CLP(force_mipmaps)) {
@ -3470,7 +3471,7 @@ apply_texture_immediate(CLP(TextureContext) *gtc, Texture *tex) {
} else } else
#endif #endif
if (!_supports_generate_mipmap) { if (!_supports_generate_mipmap || !auto_generate_mipmaps) {
// We only need to build the mipmaps by hand if the GL // We only need to build the mipmaps by hand if the GL
// doesn't support generating them automatically. // doesn't support generating them automatically.
GLUP(Build2DMipmaps)(GL_TEXTURE_2D, internal_format, GLUP(Build2DMipmaps)(GL_TEXTURE_2D, internal_format,

View File

@ -233,9 +233,11 @@ angle_rad(const FLOATNAME(LVector3) &other) const {
// This algorithm yields better results than acos(dot(other)), which // This algorithm yields better results than acos(dot(other)), which
// behaves poorly as dot(other) approaches 1.0. // behaves poorly as dot(other) approaches 1.0.
if (dot(other) < 0.0f) { if (dot(other) < 0.0f) {
return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin((-(*this)-other).length()); FLOATTYPE a = ((*this)+other).length() / 2.0f;
return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin(min(a, (FLOATTYPE)1.0));
} else { } else {
return 2.0f * casin(((*this)-other).length() / 2.0f); FLOATTYPE a = ((*this)-other).length() / 2.0f;
return 2.0f * casin(min(a, (FLOATTYPE)1.0));
} }
} }

View File

@ -114,7 +114,7 @@ ns_load_font(const string &str) {
return NULL; return NULL;
} }
_fonts[filename] = font; _fonts[index_str] = font;
return font; return font;
} }
@ -124,9 +124,14 @@ ns_load_font(const string &str) {
// Description: The nonstatic implementation of add_font(). // Description: The nonstatic implementation of add_font().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FontPool:: void FontPool::
ns_add_font(const string &filename, TextFont *font) { ns_add_font(const string &str, TextFont *font) {
string index_str;
Filename filename;
int face_index;
lookup_filename(str, index_str, filename, face_index);
// We blow away whatever font was there previously, if any. // We blow away whatever font was there previously, if any.
_fonts[filename] = font; _fonts[index_str] = font;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -56,7 +56,7 @@ private:
bool ns_has_font(const string &str); bool ns_has_font(const string &str);
TextFont *ns_load_font(const string &str); TextFont *ns_load_font(const string &str);
void ns_add_font(const string &filename, TextFont *font); void ns_add_font(const string &str, TextFont *font);
void ns_release_font(const string &filename); void ns_release_font(const string &filename);
void ns_release_all_fonts(); void ns_release_all_fonts();
int ns_garbage_collect(); int ns_garbage_collect();