- attempt to throw exception (instead of assert) on bad texture detection

This commit is contained in:
Mark Vejvoda 2011-01-11 00:49:06 +00:00
parent 8bf83c03a8
commit 5fa01b0b8c
3 changed files with 15 additions and 223 deletions

View File

@ -1,154 +0,0 @@
SubDir TOP ;
UseAutoconf ;
Package license.txt readme.txt ;
#ALWAYS getSVNVersion : @getSVNVersion_action ;
rule getSVNVersion {
echo 'hi' ;
}
actions getSVNVersion_action
{
# echo '"'`svnversion`'"' >sources/glest_game/facilities/svn_version_tmp.h
echo '"'`svnversion`'"' ;
echo 'hi' ;
# if diff -N svn_version_tmp.hpp src/svn_version.hpp >/dev/null; then
# rm svn_version_tmp.hpp
# else
# mv svn_version_tmp.hpp src/svn_version.hpp
# fi
}
ALWAYS getSVNVersion ;
#### Library ####
SubDir TOP shared_lib sources ;
LIB_STREFLOP_DIRS =
streflop/libm/flt-32
streflop/libm/headers
;
LIB_STREFLOP_INCLUDE_DIRS = ../include/$(LIB_STREFLOP_DIRS) ;
for i in $(LIB_STREFLOP_DIRS) {
LIB_STREFLOP_SOURCES += [ Wildcard $(i) : *.c *.cpp *.h ] ;
}
Library strefloplib : $(LIB_STREFLOP_SOURCES) ;
#ExternalLibs strefloplib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL IRCCLIENT ;
ExternalLibs strefloplib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL ;
IncludeDir strefloplib : $(LIB_STREFLOP_INCLUDE_DIRS) ;
#### Library ####
SubDir TOP shared_lib sources ;
LIB_DIRS =
platform/common
platform/sdl
platform/posix
platform/unix
util
graphics
graphics/gl
sound
sound/openal
xml
map
glew
lua
streflop
streflop/libm_flt32_source
;
LIB_INCLUDE_DIRS = ../include/$(LIB_DIRS) ;
for i in $(LIB_DIRS) {
LIB_SOURCES += [ Wildcard $(i) : *.c *.cpp *.h ] ;
}
Library glestlib : $(LIB_SOURCES) ;
LinkWith glestlib : strefloplib ;
ExternalLibs glestlib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL ;
IncludeDir glestlib : $(LIB_INCLUDE_DIRS) ;
#### Game ####
SubDir TOP glest_game ;
GLEST_DIRS =
.
ai
facilities
game
global
graphics
gui
main
menu
network
sound
type_instances
types
world
;
for i in $(GLEST_DIRS) {
GLEST_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
}
Application glest.bin : $(GLEST_SOURCES) ;
LinkWith glest.bin : glestlib strefloplib ;
ExternalLibs glest.bin : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL X11 ;
IncludeDir glest.bin : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_DIRS) ;
#### Editor ####
if $(WX_AVAILABLE) = "yes" {
SubDir TOP glest_map_editor ;
GLEST_MAP_DIRS = . ;
for i in $(GLEST_DIRS) {
GLEST_MAP_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
}
Application glest_editor : $(GLEST_MAP_SOURCES) ;
LinkWith glest_editor : glestlib strefloplib ;
ExternalLibs glest_editor : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL WX CURL ;
IncludeDir glest_editor : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_MAP_DIRS) ;
}
### Viewer ###
if $(WX_AVAILABLE) = "yes" {
SubDir TOP g3d_viewer ;
GLEST_VIEWER_DIRS =
.
;
for i in $(GLEST_VIEWER_DIRS) {
GLEST_VIEWER_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
}
Application glest_g3dviewer : $(GLEST_VIEWER_SOURCES) ../glest_game/graphics/unit_particle_type.cpp ../glest_game/graphics/particle_type.cpp ;
LinkWith glest_g3dviewer : glestlib strefloplib ;
ExternalLibs glest_g3dviewer : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL WX X11 ;
IncludeDir glest_g3dviewer : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_VIEWER_DIRS) ../glest_game/graphics ../glest_game/global ../glest_game/sound ../glest_game/game ;
}
### Configurator ###
SubDir TOP configurator ;
GLEST_CONFIG_DIRS = . ;
for i in $(GLEST_DIRS) {
GLEST_CONFIG_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
}
Application glest_configurator : $(GLEST_CONFIG_SOURCES) ;
LinkWith glest_configurator : glestlib strefloplib ;
ExternalLibs glest_configurator : SDL GL GLU XERCES WX CURL ;
IncludeDir glest_configurator : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_CONFIG_DIRS) ;

View File

@ -1,57 +0,0 @@
if ! $(top_builddir)
{
top_builddir = $(TOP) ;
}
top_srcdir = $(TOP) ;
MUDFLAP_FLAGS = -g -DGLIBCXX_FORCE_NEW ;
MUDFLAP_LIBS = ;
#MUDFLAP_FLAGS = -fmudflapth -include mf-runtime.h
#MUDFLAP_LIBS = -lmudflapth
MGFLAGS = -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse $(MUDFLAP_FLAGS) ;
JAMCONFIG ?= $(top_builddir)/Jamconfig ;
include $(JAMCONFIG) ;
if ! $(JAMCONFIG_READ)
{
EXIT "Couldn't find config. Please run 'configure' first." ;
}
if $(USE_STLPORT_DEBUG)
{
CPPFLAGS += -I/usr/include/stlport ;
CPPFLAGS += -D_STLP_DEBUG=1 -D_STLP_DEBUG_UNINITIALIZED=1 ;
CPPFLAGS += -D_STLP_SHRED_BYTE=0xA3 ;
LIBS += -lstlport_gcc_debug ;
}
# if using streflop then add some special compiler defines
if $(USE_STREFLOP)
{
CPPFLAGS += $(MGFLAGS) ;
COMPILER_CFLAGS += $(MGFLAGS) ;
COMPILER_CFLAGS_optimize += $(MGFLAGS) ;
COMPILER_CXXFLAGS_optimize += $(MGFLAGS) ;
}
CPPFLAGS += $(MGFLAGS) ;
COMPILER_CFLAGS += -Wall -W -Wno-unused -Wno-sign-compare $(MGFLAGS) ;
COMPILER_CFLAGS_optimize += -O3 -DNDEBUG $(MGFLAGS) ;
COMPILER_CXXFLAGS_optimize += -O3 -DNDEBUG $(MGFLAGS) ;
COMPILER_LIBS_optimize += $(MUDFLAP_LIBS) ;
COMPILER_CFLAGS_debug += -DDEBUG -g3 ;
COMPILER_CXXFLAGS_debug += -DDEBUG -g3 ;
COMPILER_LIBS_debug += -g3 $(MUDFLAP_LIBS) ;
COMPILER_CFLAGS_profile += -O3 -fno-inline -pg ;
COMPILER_CXXFLAGS_profile += -O3 -fno-inline -g3 -pg ;
COMPILER_LIBS_profile += -pg $(MUDFLAP_LIBS) ;
LINK = $(CXX) ;
# Include build rules
include $(TOP)/mk/jam/build.jam ;
# Include Dirs
IncludeDir $(top_builddir) ; # for config.h

View File

@ -3,9 +3,9 @@
//
// Copyright (C) 2001-2008 Martio Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
@ -50,7 +50,7 @@ void ModelRendererGl::begin(bool renderNormals, bool renderTextures, bool render
//push attribs
glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_POLYGON_BIT | GL_CURRENT_BIT | GL_TEXTURE_BIT);
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
//init opengl
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 0);
@ -106,7 +106,7 @@ void ModelRendererGl::render(const Model *model){
for(uint32 i=0; i<model->getMeshCount(); ++i){
renderMesh(model->getMesh(i));
}
//assertions
assertGl();
}
@ -118,9 +118,9 @@ void ModelRendererGl::renderNormalsOnly(const Model *model){
//render every mesh
for(uint32 i=0; i<model->getMeshCount(); ++i){
renderMeshNormals(model->getMesh(i));
renderMeshNormals(model->getMesh(i));
}
//assertions
assertGl();
}
@ -128,7 +128,7 @@ void ModelRendererGl::renderNormalsOnly(const Model *model){
// ===================== PRIVATE =======================
void ModelRendererGl::renderMesh(const Mesh *mesh){
//assertions
assertGl();
@ -150,7 +150,10 @@ void ModelRendererGl::renderMesh(const Mesh *mesh){
const Texture2DGl *texture= static_cast<const Texture2DGl*>(mesh->getTexture(mtDiffuse));
if(texture != NULL && renderTextures){
if(lastTexture != texture->getHandle()){
assert(glIsTexture(texture->getHandle()));
//assert(glIsTexture(texture->getHandle()));
if(glIsTexture(texture->getHandle()) == false) {
throw runtime_error("glIsTexture(texture->getHandle()) == false");
}
glBindTexture(GL_TEXTURE_2D, texture->getHandle());
lastTexture= texture->getHandle();
}
@ -167,10 +170,10 @@ void ModelRendererGl::renderMesh(const Mesh *mesh){
//misc vars
uint32 vertexCount= mesh->getVertexCount();
uint32 indexCount= mesh->getIndexCount();
//assertions
assertGl();
//vertices
glVertexPointer(3, GL_FLOAT, 0, mesh->getInterpolationData()->getVertices());
@ -217,7 +220,7 @@ void ModelRendererGl::renderMeshNormals(const Mesh *mesh){
for(unsigned int i= 0; i<mesh->getIndexCount(); ++i){
const Vec3f &vertex= mesh->getInterpolationData()->getVertices()[mesh->getIndices()[i]];
const Vec3f &normal= vertex + mesh->getInterpolationData()->getNormals()[mesh->getIndices()[i]];
glVertex3fv(vertex.ptr());
glVertex3fv(normal.ptr());
}