Merged default into minor

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2014-08-30 22:08:10 -03:00
9 changed files with 71 additions and 80 deletions
+20
View File
@@ -109,6 +109,9 @@ void Graphics::restoreState(const DisplayState &s)
setColorMask(s.colorMask);
setWireframe(s.wireframe);
setDefaultFilter(s.defaultFilter);
setDefaultMipmapFilter(s.defaultMipmapFilter, s.defaultMipmapSharpness);
}
void Graphics::restoreStateChecked(const DisplayState &s)
@@ -166,6 +169,9 @@ void Graphics::restoreStateChecked(const DisplayState &s)
if (s.wireframe != cur.wireframe)
setWireframe(s.wireframe);
setDefaultFilter(s.defaultFilter);
setDefaultMipmapFilter(s.defaultMipmapFilter, s.defaultMipmapSharpness);
}
void Graphics::setViewportSize(int width, int height)
@@ -847,6 +853,7 @@ Graphics::BlendMode Graphics::getBlendMode() const
void Graphics::setDefaultFilter(const Texture::Filter &f)
{
Texture::setDefaultFilter(f);
states.back().defaultFilter = f;
}
const Texture::Filter &Graphics::getDefaultFilter() const
@@ -858,6 +865,9 @@ void Graphics::setDefaultMipmapFilter(Texture::FilterMode filter, float sharpnes
{
Image::setDefaultMipmapFilter(filter);
Image::setDefaultMipmapSharpness(sharpness);
states.back().defaultMipmapFilter = filter;
states.back().defaultMipmapSharpness = sharpness;
}
void Graphics::getDefaultMipmapFilter(Texture::FilterMode *filter, float *sharpness) const
@@ -1365,6 +1375,9 @@ Graphics::DisplayState::DisplayState()
, font(nullptr)
, shader(nullptr)
, wireframe(false)
, defaultFilter()
, defaultMipmapFilter(Texture::FILTER_NEAREST)
, defaultMipmapSharpness(0.0f)
{
// We should just directly initialize the array in the initializer list, but
// that feature of C++11 is broken in Visual Studio 2013...
@@ -1387,6 +1400,9 @@ Graphics::DisplayState::DisplayState(const DisplayState &other)
, shader(other.shader)
, canvases(other.canvases)
, wireframe(other.wireframe)
, defaultFilter(other.defaultFilter)
, defaultMipmapFilter(other.defaultMipmapFilter)
, defaultMipmapSharpness(other.defaultMipmapSharpness)
{
for (int i = 0; i < 4; i++)
colorMask[i] = other.colorMask[i];
@@ -1419,6 +1435,10 @@ Graphics::DisplayState &Graphics::DisplayState::operator = (const DisplayState &
wireframe = other.wireframe;
defaultFilter = other.defaultFilter;
defaultMipmapFilter = other.defaultMipmapFilter;
defaultMipmapSharpness = other.defaultMipmapSharpness;
return *this;
}
+7
View File
@@ -456,6 +456,13 @@ private:
bool wireframe;
// Default filter.
Texture::Filter defaultFilter;
// Default mipmap filter and sharpness.
Texture::FilterMode defaultMipmapFilter;
float defaultMipmapSharpness;
DisplayState();
DisplayState(const DisplayState &other);
~DisplayState();
-52
View File
@@ -529,58 +529,6 @@ void OpenGL::setTextureFilter(graphics::Texture::Filter &f)
f.anisotropy = 1.0f;
}
graphics::Texture::Filter OpenGL::getTextureFilter()
{
GLint gmin, gmag;
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &gmin);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &gmag);
Texture::Filter f;
switch (gmin)
{
case GL_NEAREST:
f.min = Texture::FILTER_NEAREST;
f.mipmap = Texture::FILTER_NONE;
break;
case GL_NEAREST_MIPMAP_NEAREST:
f.min = f.mipmap = Texture::FILTER_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
f.min = Texture::FILTER_NEAREST;
f.mipmap = Texture::FILTER_LINEAR;
break;
case GL_LINEAR_MIPMAP_NEAREST:
f.min = Texture::FILTER_LINEAR;
f.mipmap = Texture::FILTER_NEAREST;
break;
case GL_LINEAR_MIPMAP_LINEAR:
f.min = f.mipmap = Texture::FILTER_LINEAR;
break;
case GL_LINEAR:
default:
f.min = Texture::FILTER_LINEAR;
f.mipmap = Texture::FILTER_NONE;
break;
}
switch (gmag)
{
case GL_NEAREST:
f.mag = Texture::FILTER_NEAREST;
break;
case GL_LINEAR:
default:
f.mag = Texture::FILTER_LINEAR;
break;
}
if (GLAD_EXT_texture_filter_anisotropic)
glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &f.anisotropy);
return f;
}
void OpenGL::setTextureWrap(const graphics::Texture::Wrap &w)
{
GLint gs, gt;
-5
View File
@@ -276,11 +276,6 @@ public:
**/
void setTextureFilter(graphics::Texture::Filter &f);
/**
* Returns the texture filter mode for the currently bound texture.
**/
graphics::Texture::Filter getTextureFilter();
/**
* Sets the texture wrap mode for the currently bound texture.
**/
+1 -1
View File
@@ -58,7 +58,7 @@ public:
* a single block of memory containing all the images.
*
* @param[in] filedata The data to parse.
* @param[out] image The list of sub-images generated. Byte data is a pointer
* @param[out] images The list of sub-images generated. Byte data is a pointer
* to the returned data.
* @param[out] dataSize The total size in bytes of the returned data.
* @param[out] format The format of the Compressed Data.
+12 -8
View File
@@ -218,8 +218,8 @@ bool JoystickModule::setGamepadMapping(const std::string &guid, Joystick::Gamepa
joyinputstream << "b" << joyinput.button;
break;
case Joystick::INPUT_TYPE_HAT:
if (joyinput.hat.value >= 0 && Joystick::getConstant(joyinput.hat.value, sdlhat))
joyinputstream << "h" << joyinput.hat.value << "." << int(sdlhat);
if (joyinput.hat.index >= 0 && Joystick::getConstant(joyinput.hat.value, sdlhat))
joyinputstream << "h" << joyinput.hat.index << "." << int(sdlhat);
break;
default:
break;
@@ -297,7 +297,7 @@ Joystick::JoystickInput JoystickModule::getGamepadMapping(const std::string &gui
if (findpos == std::string::npos)
return jinput;
size_t endpos = mapstr.find_first_of(',', findpos);
size_t endpos = mapstr.find_first_of(',', findpos + 1);
if (endpos == std::string::npos)
{
// Assume end-of-string if we can't find the next comma.
@@ -364,19 +364,19 @@ Joystick::JoystickInput JoystickModule::JoystickInputFromString(const std::strin
{
case 'a':
jinput.type = Joystick::INPUT_TYPE_AXIS;
jinput.axis = atoi(bindvalues.c_str());
jinput.axis = (int) strtol(bindvalues.c_str(), nullptr, 10);
break;
case 'b':
jinput.type = Joystick::INPUT_TYPE_BUTTON;
jinput.button = atoi(bindvalues.c_str());
jinput.button = (int) strtol(bindvalues.c_str(), nullptr, 10);
break;
case 'h':
// Hat string syntax is "index.value".
if (bindvalues.length() < 3)
break;
jinput.type = Joystick::INPUT_TYPE_HAT;
jinput.hat.index = atoi(bindvalues.substr(0, 1).c_str());
sdlhat = (Uint8) atoi(bindvalues.substr(2, 1).c_str());
jinput.hat.index = (int) strtol(bindvalues.substr(0, 1).c_str(), nullptr, 10);
sdlhat = (Uint8) strtol(bindvalues.substr(2).c_str(), nullptr, 10);
if (!Joystick::getConstant(sdlhat, jinput.hat.value))
{
// Return an invalid value if we can't find the hat constant.
@@ -405,10 +405,14 @@ void JoystickModule::removeBindFromMapString(std::string &mapstr, const std::str
if (joybindpos == std::string::npos)
return;
// Find the start of the entire bind.
// Find the start of the entire bind by looking for the separator between
// the end of one section of the map string and the start of this section.
size_t bindstart = mapstr.rfind(',', joybindpos);
if (bindstart != std::string::npos && bindstart < mapstr.length() - 1)
{
// The start of the bind is directly after the separator.
bindstart++;
size_t bindend = mapstr.find(',', bindstart + 1);
if (bindend == std::string::npos)
bindend = mapstr.length() - 1;