This commit is contained in:
Deve 2014-02-02 10:54:40 +01:00
commit 9b2b6c1c78
14 changed files with 53 additions and 48 deletions

2
.gitignore vendored
View File

@ -1,3 +1,4 @@
bld/
build/
build-32/
build-64/
@ -37,3 +38,4 @@ data/.svn
packets_log.txt
history.dat
README.dependencies

View File

@ -11,7 +11,7 @@ void main()
vec3 col = texture(tex, uv).xyz;
float luma = dot(weights, col);
col *= smoothstep(low, 0.9, luma);
col *= smoothstep(1., 2., luma);
FragColor = vec4(col, 1.0);
}

View File

@ -210,11 +210,13 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
}
#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG)
#if defined(_IRR_COMPILE_WITH_X11_)
static bool XErrorSignaled = false;
int IrrPrintXError(Display *display, XErrorEvent *event)
{
char msg[256];
char msg2[256];
XErrorSignaled = true;
snprintf(msg, 256, "%d", event->request_code);
XGetErrorDatabaseText(display, "XRequest", msg, "unknown", msg2, 256);
@ -370,10 +372,8 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand )
bool CIrrDeviceLinux::createWindow()
{
#ifdef _IRR_COMPILE_WITH_X11_
#ifdef _DEBUG
os::Printer::log("Creating X window...", ELL_INFORMATION);
XSetErrorHandler(IrrPrintXError);
#endif
display = XOpenDisplay(0);
if (!display)
@ -750,12 +750,22 @@ bool CIrrDeviceLinux::createWindow()
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
None
};
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = 0;
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
// create glx context
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, context_attribs);
if (XErrorSignaled)
{
int context_attribs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
None
};
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, context_attribs);
XErrorSignaled = false;
}
if (Context)
{
if (!glXMakeContextCurrent(display, glxWin, glxWin, Context))

View File

@ -4397,12 +4397,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
if (target==video::ERT_MULTI_RENDER_TEXTURES || target==video::ERT_RENDER_TEXTURE || target==video::ERT_STEREO_BOTH_BUFFERS)
return 0;
// allows to read pixels in top-to-bottom order
#ifdef GL_MESA_pack_invert
if (FeatureAvailable[IRR_MESA_pack_invert])
glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
#endif
if (format==video::ECF_UNKNOWN)
format=getColorFormat();
GLenum fmt;
@ -4542,11 +4536,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
glReadBuffer(GL_BACK);
}
#ifdef GL_MESA_pack_invert
if (FeatureAvailable[IRR_MESA_pack_invert])
glPixelStorei(GL_PACK_INVERT_MESA, GL_FALSE);
else
#endif
if (pixels)
{
// opengl images are horizontally flipped, so we have to fix that here.

View File

@ -61,9 +61,9 @@
#include <GL/gl.h>
#include <GL/glx.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h"
#include <GL/glext.h>
#undef GLX_ARB_get_proc_address // avoid problems with local glxext.h
#include "glxext.h"
#include <GL/glxext.h>
#endif
#endif

View File

@ -24,11 +24,13 @@
#include "config/player.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "input/wiimote_manager.hpp"
#include "io/file_manager.hpp"
#include "states_screens/kart_selection.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
#include "input/wiimote_manager.hpp"
#define INPUT_MODE_DEBUG 0
@ -56,18 +58,18 @@ bool DeviceManager::initialize()
if(UserConfigParams::logMisc())
{
printf("Initializing Device Manager\n");
printf("---------------------------\n");
Log::info("Device manager","Initializing Device Manager");
Log::info("-","---------------------------");
}
deserialize();
// Assign a configuration to the keyboard, or create one if we haven't yet
if(UserConfigParams::logMisc()) printf("Initializing keyboard support.\n");
if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support.");
if (m_keyboard_configs.size() == 0)
{
if(UserConfigParams::logMisc())
printf("No keyboard configuration exists, creating one.\n");
Log::info("Device manager","No keyboard configuration exists, creating one.");
m_keyboard_configs.push_back(new KeyboardConfig());
created = true;
}
@ -79,13 +81,13 @@ bool DeviceManager::initialize()
}
if(UserConfigParams::logMisc())
printf("Initializing gamepad support.\n");
Log::info("Device manager","Initializing gamepad support.");
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);
int num_gamepads = m_irrlicht_gamepads.size();
if(UserConfigParams::logMisc())
{
printf("Irrlicht reports %d gamepads are attached to the system.\n",
Log::info("Device manager","Irrlicht reports %d gamepads are attached to the system.",
num_gamepads);
}
@ -109,19 +111,19 @@ bool DeviceManager::initialize()
if (UserConfigParams::logMisc())
{
printf("#%d: %s detected...", id, name.c_str());
Log::info("Device manager","#%d: %s detected...", id, name.c_str());
}
// Returns true if new configuration was created
if (getConfigForGamepad(id, name, &gamepadConfig) == true)
{
if(UserConfigParams::logMisc())
printf("creating new configuration.\n");
Log::info("Device manager","creating new configuration.");
created = true;
}
else
{
if(UserConfigParams::logMisc())
printf("using existing configuration.\n");
Log::info("Device manager","using existing configuration.");
}
gamepadConfig->setPlugged();
@ -440,12 +442,12 @@ bool DeviceManager::deserialize()
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
if(UserConfigParams::logMisc())
printf("Deserializing input.xml...\n");
Log::info("Device manager","Deserializing input.xml...");
if(!file_manager->fileExists(filepath))
{
if(UserConfigParams::logMisc())
printf("Warning: no configuration file exists.\n");
Log::warn("Device manager","No configuration file exists.");
}
else
{
@ -499,15 +501,15 @@ bool DeviceManager::deserialize()
{
if(keyboard_config != NULL)
if(!keyboard_config->deserializeAction(xml))
std::cerr << "Ignoring an ill-formed keyboard action in input config.\n";
Log::error("Device manager","Ignoring an ill-formed keyboard action in input config.");
}
else if(reading_now == GAMEPAD)
{
if(gamepad_config != NULL)
if(!gamepad_config->deserializeAction(xml))
std::cerr << "Ignoring an ill-formed gamepad action in input config.\n";
Log::error("Device manager","Ignoring an ill-formed gamepad action in input config.");
}
else std::cerr << "Warning: An action is placed in an unexpected area in the input config file.\n";
else Log::warn("Device manager","An action is placed in an unexpected area in the input config file.");
}
}
break;
@ -534,7 +536,7 @@ bool DeviceManager::deserialize()
if(UserConfigParams::logMisc())
{
printf("Found %d keyboard and %d gamepad configurations.\n",
Log::info("Device manager","Found %d keyboard and %d gamepad configurations.",
m_keyboard_configs.size(), m_gamepad_configs.size());
}
@ -557,7 +559,7 @@ bool DeviceManager::deserialize()
void DeviceManager::serialize()
{
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
if(UserConfigParams::logMisc()) printf("Serializing input.xml...\n");
if(UserConfigParams::logMisc()) Log::info("Device manager","Serializing input.xml...");
std::ofstream configfile;
@ -565,8 +567,7 @@ void DeviceManager::serialize()
if(!configfile.is_open())
{
std::cerr << "Failed to open " << filepath.c_str()
<< " for writing, controls won't be saved\n";
Log::error("Device manager","Failed to open %s for writing, controls won't be saved",filepath.c_str());
return;
}
@ -584,7 +585,7 @@ void DeviceManager::serialize()
configfile << "</input>\n";
configfile.close();
if(UserConfigParams::logMisc()) printf("Serialization complete.\n\n");
if(UserConfigParams::logMisc()) Log::info("Device manager","Serialization complete.");
} // serialize
// -----------------------------------------------------------------------------

View File

@ -946,7 +946,6 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
continue;
if (!m_karts[index[pos]]->hasFinishedRace()) continue;
assert(index[pos] >= 0);
assert(index[pos] < m_karts.size());
Kart *k = (Kart*)m_karts[index[pos]];

View File

@ -123,7 +123,7 @@ void NetworkManager::notifyEvent(Event* event)
((addr>>24)&0xff),
((addr>>16)&0xff),
((addr>>8)&0xff),
(addr&0xff), event->data().c_str());
(addr & 0xff), event->data().std_string().c_str());
}

View File

@ -146,16 +146,20 @@ class NetworkString
return *this;
}
const char* c_str() const
const std::string std_string() const
{
std::string str(m_string.begin(), m_string.end());
return str.c_str();
return str;
}
int size() const
{
return m_string.size();
}
uint8_t* getBytes() { return &m_string[0]; };
const uint8_t* getBytes() const { return &m_string[0]; };
template<typename T, size_t n>
T get(int pos) const
{

View File

@ -144,7 +144,7 @@ void ProtocolManager::notifyEvent(Event* event)
pthread_mutex_unlock(&m_protocols_mutex);
if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug
{
Log::debug("ProtocolManager", "NO PROTOCOL : Message is \"%s\"", event2->data().c_str());
Log::debug("ProtocolManager", "NO PROTOCOL : Message is \"%s\"", event2->data().std_string().c_str());
}
if (protocols_ids.size() != 0)

View File

@ -302,7 +302,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries)
void STKHost::broadcastPacket(const NetworkString& data, bool reliable)
{
ENetPacket* packet = enet_packet_create(data.c_str(), data.size()+1,
ENetPacket* packet = enet_packet_create(data.getBytes(), data.size() + 1,
(reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED));
enet_host_broadcast(m_host, 0, packet);
STKHost::logPacket(data, false);

View File

@ -95,7 +95,7 @@ void STKPeer::sendPacket(NetworkString const& data, bool reliable)
data.size(), (m_peer->address.host>>0)&0xff,
(m_peer->address.host>>8)&0xff,(m_peer->address.host>>16)&0xff,
(m_peer->address.host>>24)&0xff,m_peer->address.port);
ENetPacket* packet = enet_packet_create(data.c_str(), data.size()+1,
ENetPacket* packet = enet_packet_create(data.getBytes(), data.size() + 1,
(reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED));
/* to debug the packet output
printf("STKPeer: ");

View File

@ -87,7 +87,7 @@ private:
// --------------------------------------------------------------------
const UserPointer *getUserPointer(unsigned int n) const
{
assert(n>=0 && n<=1);
assert(n<=1);
return m_up[n];
} // getUserPointer
// --------------------------------------------------------------------

View File

@ -142,7 +142,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
const std::string& kart)
{
assert(kart.size() > 0);
assert(0<=player_id && player_id <m_local_player_karts.size());
assert(player_id <m_local_player_karts.size());
assert(kart_properties_manager->getKart(kart) != NULL);
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id);
@ -156,7 +156,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
*/
void RaceManager::setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team)
{
assert(0<=player_id && player_id <m_local_player_karts.size());
assert(player_id <m_local_player_karts.size());
m_local_player_karts[player_id].setSoccerTeam(team);
}