Some style and whitespace fixes
parent
60ae9b1959
commit
3b585d9f51
|
@ -899,7 +899,7 @@ CBotString CBotVarInt::GetValString()
|
|||
res.LoadString(TX_UNDEF);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if ( m_binit == CBotVar::InitType::IS_NAN )
|
||||
{
|
||||
res.LoadString(TX_NAN);
|
||||
|
|
|
@ -40,10 +40,10 @@ CInput::CInput()
|
|||
m_kmodState = 0;
|
||||
m_mousePos = Math::Point();
|
||||
m_mouseButtonsState = 0;
|
||||
|
||||
|
||||
for(int i=0; i<INPUT_SLOT_MAX; i++)
|
||||
m_keyPresses[i] = false;
|
||||
|
||||
|
||||
m_joystickDeadzone = 0.2f;
|
||||
SetDefaultInputBindings();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void CInput::EventProcess(Event& event)
|
|||
// Use the occasion to update kmods
|
||||
m_kmodState = event.kmodState;
|
||||
}
|
||||
|
||||
|
||||
// Use the occasion to update mouse button state
|
||||
if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
||||
{
|
||||
|
@ -66,29 +66,29 @@ void CInput::EventProcess(Event& event)
|
|||
{
|
||||
m_mouseButtonsState &= ~event.mouseButton.button;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(event.type == EVENT_KEY_DOWN ||
|
||||
event.type == EVENT_KEY_UP)
|
||||
{
|
||||
event.key.slot = FindBinding(event.key.key);
|
||||
}
|
||||
|
||||
|
||||
event.kmodState = m_kmodState;
|
||||
event.mousePos = m_mousePos;
|
||||
event.mouseButtonsState = m_mouseButtonsState;
|
||||
|
||||
|
||||
|
||||
|
||||
if (event.type == EVENT_KEY_DOWN ||
|
||||
event.type == EVENT_KEY_UP)
|
||||
{
|
||||
m_keyPresses[event.key.slot] = (event.type == EVENT_KEY_DOWN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Motion vector management */
|
||||
|
||||
|
||||
if (event.type == EVENT_KEY_DOWN && !(event.kmodState & KEY_MOD(ALT) ) )
|
||||
{
|
||||
if (event.key.slot == INPUT_SLOT_UP ) m_keyMotion.y = 1.0f;
|
||||
|
@ -115,14 +115,14 @@ void CInput::EventProcess(Event& event)
|
|||
if (GetJoyAxisBinding(JOY_AXIS_SLOT_X).invert)
|
||||
m_joyMotion.x *= -1.0f;
|
||||
}
|
||||
|
||||
|
||||
if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Y).axis)
|
||||
{
|
||||
m_joyMotion.y = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
|
||||
if (GetJoyAxisBinding(JOY_AXIS_SLOT_Y).invert)
|
||||
m_joyMotion.y *= -1.0f;
|
||||
}
|
||||
|
||||
|
||||
if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Z).axis)
|
||||
{
|
||||
m_joyMotion.z = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
|
||||
|
@ -130,7 +130,7 @@ void CInput::EventProcess(Event& event)
|
|||
m_joyMotion.z *= -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
event.motionInput = Math::Clamp(m_joyMotion + m_keyMotion, Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
|
@ -180,13 +180,13 @@ void CInput::SetDefaultInputBindings()
|
|||
{
|
||||
m_inputBindings[i].primary = m_inputBindings[i].secondary = KEY_INVALID;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++)
|
||||
{
|
||||
m_joyAxisBindings[i].axis = AXIS_INVALID;
|
||||
m_joyAxisBindings[i].invert = false;
|
||||
}
|
||||
|
||||
|
||||
m_inputBindings[INPUT_SLOT_LEFT ].primary = KEY(LEFT);
|
||||
m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
|
||||
m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
|
||||
|
@ -220,7 +220,7 @@ void CInput::SetDefaultInputBindings()
|
|||
m_inputBindings[INPUT_SLOT_CAMERA_DOWN].primary = KEY(PAGEDOWN);
|
||||
m_inputBindings[INPUT_SLOT_PAUSE].primary = KEY(PAUSE);
|
||||
m_inputBindings[INPUT_SLOT_PAUSE].secondary = KEY(p);
|
||||
|
||||
|
||||
m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0;
|
||||
m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1;
|
||||
m_joyAxisBindings[JOY_AXIS_SLOT_Z].axis = 2;
|
||||
|
@ -309,7 +309,7 @@ void CInput::SaveKeyBindings()
|
|||
for (int i = 0; i < INPUT_SLOT_MAX; i++)
|
||||
{
|
||||
InputBinding b = GetInputBinding(static_cast<InputSlot>(i));
|
||||
|
||||
|
||||
key.clear();
|
||||
key.str("");
|
||||
key << b.primary << " " << b.secondary;
|
||||
|
@ -385,14 +385,14 @@ std::string CInput::GetKeysString(InputBinding b)
|
|||
if ( GetResource(RES_KEY, b.primary, iNameStr) )
|
||||
{
|
||||
ss << iNameStr;
|
||||
|
||||
|
||||
if ( b.secondary != KEY_INVALID )
|
||||
{
|
||||
if ( GetResource(RES_KEY, b.secondary, iNameStr) )
|
||||
{
|
||||
std::string textStr;
|
||||
GetResource(RES_TEXT, RT_KEY_OR, textStr);
|
||||
|
||||
|
||||
ss << textStr << iNameStr;
|
||||
}
|
||||
}
|
||||
|
@ -410,4 +410,4 @@ std::string CInput::GetKeysString(InputSlot slot)
|
|||
{
|
||||
InputBinding b = GetInputBinding(slot);
|
||||
return GetKeysString(b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ struct InputBinding
|
|||
//! Primary and secondary bindings
|
||||
//! Can be regular key, virtual key or virtual joystick button
|
||||
unsigned int primary, secondary;
|
||||
|
||||
|
||||
InputBinding(unsigned int p = KEY_INVALID, unsigned int s = KEY_INVALID)
|
||||
: primary(p), secondary(s) {}
|
||||
};
|
||||
|
@ -70,93 +70,93 @@ class CInput : public CSingleton<CInput>
|
|||
public:
|
||||
//! Constructor
|
||||
CInput();
|
||||
|
||||
|
||||
//! Process an incoming event, also sets .kmodState, .mousePos, .mouseButtonsState and .key.slot
|
||||
void EventProcess(Event &event);
|
||||
|
||||
|
||||
//! Called by CApplication on SDL MOUSE_MOTION event
|
||||
void MouseMove(Math::IntPoint pos);
|
||||
|
||||
|
||||
|
||||
|
||||
//! Returns the current key modifiers
|
||||
int GetKmods() const;
|
||||
|
||||
|
||||
//! Returns whether the given kmod is active
|
||||
bool GetKmodState(int kmod) const;
|
||||
|
||||
|
||||
//! Returns whether the key is pressed
|
||||
bool GetKeyState(InputSlot key) const;
|
||||
|
||||
|
||||
//! Returns whether the mouse button is pressed
|
||||
bool GetMouseButtonState(int index) const;
|
||||
|
||||
|
||||
//! Resets tracked key states and modifiers
|
||||
void ResetKeyStates();
|
||||
|
||||
|
||||
//! Returns the position of mouse cursor (in interface coords)
|
||||
Math::Point GetMousePos() const;
|
||||
|
||||
|
||||
|
||||
|
||||
//! Sets the default input bindings (keys and joystick axes)
|
||||
void SetDefaultInputBindings();
|
||||
|
||||
|
||||
//! Management of input bindings
|
||||
//@{
|
||||
void SetInputBinding(InputSlot slot, InputBinding binding);
|
||||
const InputBinding& GetInputBinding(InputSlot slot);
|
||||
//@}
|
||||
|
||||
|
||||
//! Management of joystick axis bindings
|
||||
//@{
|
||||
void SetJoyAxisBinding(JoyAxisSlot slot, JoyAxisBinding binding);
|
||||
const JoyAxisBinding& GetJoyAxisBinding(JoyAxisSlot slot);
|
||||
//@}
|
||||
|
||||
|
||||
//! Management of joystick deadzone
|
||||
//@{
|
||||
void SetJoystickDeadzone(float zone);
|
||||
float GetJoystickDeadzone();
|
||||
//@}
|
||||
|
||||
|
||||
//! Get binding slot for given key
|
||||
InputSlot FindBinding(unsigned int key);
|
||||
|
||||
|
||||
//! Saving/loading key bindings to colobot.ini
|
||||
//@{
|
||||
void SaveKeyBindings();
|
||||
void LoadKeyBindings();
|
||||
//@}
|
||||
|
||||
|
||||
//! Seeks a InputSlot by id. Returns INPUT_SLOT_MAX if not found
|
||||
InputSlot SearchKeyById(std::string name);
|
||||
|
||||
|
||||
//! Returns string describing keys to be pressed
|
||||
//@{
|
||||
std::string GetKeysString(InputBinding binding);
|
||||
std::string GetKeysString(InputSlot slot);
|
||||
//@}
|
||||
|
||||
|
||||
private:
|
||||
//! Current state of key modifiers (bitmask of SDLMod)
|
||||
unsigned int m_kmodState;
|
||||
//! Current state of keys
|
||||
bool m_keyPresses[INPUT_SLOT_MAX];
|
||||
|
||||
|
||||
|
||||
|
||||
//! Current position of mouse cursor
|
||||
Math::Point m_mousePos;
|
||||
//! Current state of mouse buttons (bitmask of MouseButton enum values)
|
||||
unsigned int m_mouseButtonsState;
|
||||
|
||||
|
||||
|
||||
|
||||
//! Motion vector set by keyboard or joystick buttons
|
||||
Math::Vector m_keyMotion;
|
||||
//! Motion vector set by joystick axes
|
||||
Math::Vector m_joyMotion;
|
||||
|
||||
|
||||
|
||||
|
||||
//! Bindings for user inputs
|
||||
InputBinding m_inputBindings[INPUT_SLOT_MAX];
|
||||
JoyAxisBinding m_joyAxisBindings[JOY_AXIS_SLOT_MAX];
|
||||
float m_joystickDeadzone;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -111,12 +111,12 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
|||
InitializeEventTypeTexts();
|
||||
|
||||
logger.Info("%s starting\n", COLOBOT_FULLNAME);
|
||||
|
||||
|
||||
int code = 0;
|
||||
while(true) {
|
||||
CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
systemUtils->Init();
|
||||
|
||||
|
||||
CApplication* app = new CApplication(); // single instance of the application
|
||||
|
||||
ParseArgsStatus status = app->ParseArguments(argc, argv);
|
||||
|
|
|
@ -448,8 +448,8 @@ void CImage::SetDataPixels(void *pixels){
|
|||
}
|
||||
}
|
||||
|
||||
void CImage::flipVertically(){
|
||||
|
||||
void CImage::FlipVertically()
|
||||
{
|
||||
SDL_Surface* result = SDL_CreateRGBSurface( m_data->surface->flags,
|
||||
m_data->surface->w,
|
||||
m_data->surface->h,
|
||||
|
@ -467,7 +467,8 @@ void CImage::flipVertically(){
|
|||
Uint32 pitch = m_data->surface->pitch;
|
||||
Uint32 pxLength = pitch*m_data->surface->h;
|
||||
|
||||
for(int line = 0; line < m_data->surface->h; ++line) {
|
||||
for (int line = 0; line < m_data->surface->h; ++line)
|
||||
{
|
||||
Uint32 pos = line * pitch;
|
||||
memcpy(&resultPixels[pos], &srcPixels[(pxLength-pos)-pitch], pitch);
|
||||
}
|
||||
|
|
|
@ -113,9 +113,9 @@ public:
|
|||
std::string GetError();
|
||||
|
||||
//! Flips the image vertically
|
||||
void flipVertically();
|
||||
|
||||
//! sets/replaces the pixels from the surface
|
||||
void FlipVertically();
|
||||
|
||||
//! sets/replaces the pixels from the surface
|
||||
void SetDataPixels(void *pixels);
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,7 +31,7 @@ unsigned int GetVirtualKey(unsigned int key)
|
|||
return VIRTUAL_KMOD(META);
|
||||
|
||||
if(key == KEY(KP_ENTER))
|
||||
return KEY(RETURN);
|
||||
return KEY(RETURN);
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ enum InputSlot
|
|||
INPUT_SLOT_CAMERA_UP,
|
||||
INPUT_SLOT_CAMERA_DOWN,
|
||||
INPUT_SLOT_PAUSE,
|
||||
|
||||
|
||||
INPUT_SLOT_MAX
|
||||
};
|
||||
|
||||
|
@ -115,6 +115,6 @@ enum JoyAxisSlot
|
|||
JOY_AXIS_SLOT_X,
|
||||
JOY_AXIS_SLOT_Y,
|
||||
JOY_AXIS_SLOT_Z,
|
||||
|
||||
|
||||
JOY_AXIS_SLOT_MAX
|
||||
};
|
||||
};
|
||||
|
|
|
@ -258,4 +258,4 @@ void AddExt(char* filename, const char* ext)
|
|||
int GetCurrentTimestamp()
|
||||
{
|
||||
return std::chrono::seconds(std::time(NULL)).count();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,4 @@ private:
|
|||
std::string m_langPath;
|
||||
//! Save path
|
||||
std::string m_savePath;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -41,6 +41,3 @@ boost::smatch RegexUtils::AssertRegexMatch(const std::string& text, const std::s
|
|||
|
||||
return matches;
|
||||
}
|
||||
|
||||
/*
|
||||
boost::cmatch matches;*/
|
|
@ -487,7 +487,7 @@ bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height
|
|||
CImage img({width, height});
|
||||
|
||||
img.SetDataPixels(pixels);
|
||||
img.flipVertically();
|
||||
img.FlipVertically();
|
||||
|
||||
if ( img.SavePNG(fileName.c_str()) )
|
||||
{
|
||||
|
|
|
@ -339,10 +339,10 @@ bool CTerrain::RandomizeRelief()
|
|||
// Perlin noise
|
||||
// Based on Python implementation by Marek Rogalski (mafik)
|
||||
// http://amt2014.pl/archiwum/perlin.py
|
||||
|
||||
|
||||
int size = (m_mosaicCount*m_brickCount)+1;
|
||||
const int ilosc_oktaw = 6;
|
||||
|
||||
|
||||
float* oktawy[ilosc_oktaw];
|
||||
for(int i=0; i<ilosc_oktaw; i++)
|
||||
{
|
||||
|
@ -353,14 +353,14 @@ bool CTerrain::RandomizeRelief()
|
|||
oktawy[i][j] = Math::Rand();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int y2=0; y2 < size; y2++)
|
||||
{
|
||||
float y = static_cast<float>(y2) / size;
|
||||
for(int x2=0; x2 < size; x2++)
|
||||
{
|
||||
float x = static_cast<float>(x2) / size;
|
||||
|
||||
|
||||
float wart = 0;
|
||||
for(int i=0; i<ilosc_oktaw; i++)
|
||||
{
|
||||
|
@ -368,18 +368,18 @@ bool CTerrain::RandomizeRelief()
|
|||
double xi, yi, a, b;
|
||||
a = modf(x * (rozmiar_oktawy-1), &xi);
|
||||
b = modf(y * (rozmiar_oktawy-1), &yi);
|
||||
|
||||
|
||||
float lg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi)];
|
||||
float pg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi + 1)];
|
||||
float ld = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi)];
|
||||
float pd = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi + 1)];
|
||||
|
||||
|
||||
float g = pg * a + lg * (1-a);
|
||||
float d = pd * a + ld * (1-a);
|
||||
float res = d * b + g * (1-b);
|
||||
wart += res;
|
||||
}
|
||||
|
||||
|
||||
wart /= ilosc_oktaw;
|
||||
|
||||
m_relief[x2+y2*size] = wart * 255.0f;
|
||||
|
|
|
@ -619,24 +619,24 @@ Texture CGL21Device::CreateTexture(ImageData *data, const TextureCreateParams &p
|
|||
// Set mipmap level and automatic mipmap generation if neccesary
|
||||
if (params.mipmap)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
|
||||
}
|
||||
|
||||
// Set anisotropy level if available
|
||||
if (m_anisotropyAvailable)
|
||||
{
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
}
|
||||
|
||||
bool convert = false;
|
||||
|
|
|
@ -647,22 +647,22 @@ Texture CGL33Device::CreateTexture(ImageData *data, const TextureCreateParams &p
|
|||
// Set mipmap level and automatic mipmap generation if neccesary
|
||||
if (params.mipmap)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
}
|
||||
|
||||
// Set anisotropy level if available
|
||||
if (m_anisotropyAvailable)
|
||||
{
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
}
|
||||
|
||||
bool convert = false;
|
||||
|
|
|
@ -592,24 +592,24 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
|
|||
// Set mipmap level and automatic mipmap generation if neccesary
|
||||
if (params.mipmap)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapLevel - 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
|
||||
// Has to be set to 0 because no mipmaps are generated
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
|
||||
}
|
||||
|
||||
// Set anisotropy level if available
|
||||
if (m_anisotropyAvailable)
|
||||
{
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
float level = Math::Min(m_maxAnisotropy, CEngine::GetInstance().GetTextureAnisotropyLevel());
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
|
||||
}
|
||||
|
||||
bool convert = false;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Gfx {
|
|||
/**
|
||||
* \class CGLFramebuffer
|
||||
* \brief Implementation of CFramebuffer interface in OpenGL 3.0+
|
||||
*
|
||||
*
|
||||
* Provides the concrete implementation of core framebuffers.
|
||||
* Can be used in OpenGL 3.0+ and with ARB_framebuffer_object supported.
|
||||
*/
|
||||
|
|
|
@ -73,22 +73,22 @@ out vec4 out_FragColor;
|
|||
void main()
|
||||
{
|
||||
vec4 color = data.Color;
|
||||
|
||||
|
||||
if (uni_LightingEnabled)
|
||||
{
|
||||
vec4 ambient = vec4(0.0f);
|
||||
vec4 diffuse = vec4(0.0f);
|
||||
vec4 specular = vec4(0.0f);
|
||||
|
||||
|
||||
for(int i=0; i<8; i++)
|
||||
{
|
||||
if(uni_Light[i].Enabled)
|
||||
{
|
||||
vec3 normal = (gl_FrontFacing ? data.Normal : -data.Normal);
|
||||
|
||||
|
||||
vec3 lightDirection = vec3(0.0f);
|
||||
float atten;
|
||||
|
||||
|
||||
// Directional light
|
||||
if(uni_Light[i].Position[3] == 0.0f)
|
||||
{
|
||||
|
@ -100,55 +100,55 @@ void main()
|
|||
{
|
||||
vec3 lightDirection = normalize(uni_Light[i].Position.xyz - data.Position.xyz);
|
||||
float dist = distance(uni_Light[i].Position.xyz, data.Position.xyz);
|
||||
|
||||
|
||||
atten = 1.0f / (uni_Light[i].Attenuation.x
|
||||
+ uni_Light[i].Attenuation.y * dist
|
||||
+ uni_Light[i].Attenuation.z * dist * dist);
|
||||
}
|
||||
|
||||
|
||||
vec3 reflectDirection = -reflect(lightDirection, normal);
|
||||
|
||||
|
||||
ambient += uni_Light[i].Ambient;
|
||||
diffuse += atten * clamp(dot(normal, lightDirection), 0.0f, 1.0f) * uni_Light[i].Diffuse;
|
||||
specular += atten * clamp(pow(dot(normal, lightDirection + reflectDirection), 10.0f), 0.0f, 1.0f) * uni_Light[i].Specular;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vec4 result = uni_AmbientColor * ambient
|
||||
+ uni_DiffuseColor * diffuse
|
||||
+ uni_SpecularColor * specular;
|
||||
|
||||
|
||||
color.rgb = min(vec3(1.0f), result.rgb);
|
||||
color.a = 1.0f; //min(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
if (uni_PrimaryTextureEnabled)
|
||||
{
|
||||
color = color * texture(uni_PrimaryTexture, data.TexCoord0);
|
||||
}
|
||||
|
||||
|
||||
if (uni_SecondaryTextureEnabled)
|
||||
{
|
||||
color = color * texture(uni_SecondaryTexture, data.TexCoord1);
|
||||
}
|
||||
|
||||
|
||||
if (uni_ShadowTextureEnabled)
|
||||
{
|
||||
color = color * mix(uni_ShadowColor, 1.0f, texture(uni_ShadowTexture, data.ShadowCoord.xyz));
|
||||
}
|
||||
|
||||
|
||||
if (uni_FogEnabled)
|
||||
{
|
||||
float interpolate = (data.Distance - uni_FogRange.x) / (uni_FogRange.y - uni_FogRange.x);
|
||||
|
||||
|
||||
color = mix(color, uni_FogColor, clamp(interpolate, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
if (uni_AlphaTestEnabled)
|
||||
{
|
||||
if(color.a < uni_AlphaReference)
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
out_FragColor = color;
|
||||
}
|
||||
|
|
|
@ -52,34 +52,34 @@ out vec4 out_FragColor;
|
|||
void main()
|
||||
{
|
||||
vec4 color = data.Color;
|
||||
|
||||
|
||||
if (uni_PrimaryTextureEnabled)
|
||||
{
|
||||
color = color * texture(uni_PrimaryTexture, data.TexCoord0);
|
||||
}
|
||||
|
||||
|
||||
if (uni_SecondaryTextureEnabled)
|
||||
{
|
||||
color = color * texture(uni_SecondaryTexture, data.TexCoord1);
|
||||
}
|
||||
|
||||
|
||||
if (uni_ShadowTextureEnabled)
|
||||
{
|
||||
color = color * mix(uni_ShadowColor, 1.0f, texture(uni_ShadowTexture, data.ShadowCoord.xyz));
|
||||
}
|
||||
|
||||
|
||||
if (uni_FogEnabled)
|
||||
{
|
||||
float interpolate = (data.Distance - uni_FogRange.x) / (uni_FogRange.y - uni_FogRange.x);
|
||||
|
||||
|
||||
color = mix(color, uni_FogColor, clamp(interpolate, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
if (uni_AlphaTestEnabled)
|
||||
{
|
||||
if(color.a < uni_AlphaReference)
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
out_FragColor = color;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ void main()
|
|||
gl_Position = uni_ProjectionMatrix * eyeSpace;
|
||||
|
||||
vec3 normal = normalize((uni_NormalMatrix * vec4(in_Normal, 0.0f)).xyz);
|
||||
|
||||
|
||||
data.Color = in_Color;
|
||||
data.Normal = normal;
|
||||
data.TexCoord0 = in_TexCoord0;
|
||||
|
|
|
@ -518,7 +518,7 @@ inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2
|
|||
inline Math::Vector SegmentPoint(const Math::Vector &p1, const Math::Vector &p2, float dist)
|
||||
{
|
||||
Math::Vector direction = p2 - p1;
|
||||
|
||||
|
||||
direction.Normalize();
|
||||
|
||||
return p1 + direction * dist;
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
enum MissionType {
|
||||
enum MissionType
|
||||
{
|
||||
MISSION_NORMAL = 0,
|
||||
MISSION_RETRO,
|
||||
MISSION_CODE_BATTLE
|
||||
};
|
||||
};
|
||||
|
|
|
@ -173,4 +173,4 @@ void CAudioChangeCondition::Read(CLevelParserLine* line)
|
|||
CSceneCondition::Read(line);
|
||||
this->music = std::string("../")+line->GetParam("filename")->AsPath("music");
|
||||
this->repeat = line->GetParam("repeat")->AsBool(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,4 +102,4 @@ public:
|
|||
|
||||
//! Read from line in scene file
|
||||
virtual void Read(CLevelParserLine* line);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -88,4 +88,4 @@ void CTaskDeleteMark::DeleteMark()
|
|||
{
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,4 @@ protected:
|
|||
void DeleteMark();
|
||||
protected:
|
||||
bool m_bExecuted;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -143,7 +143,7 @@ void CColor::Draw()
|
|||
m_engine->SetTexture("textures/interface/button1.png");
|
||||
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||
CControl::Draw();
|
||||
|
||||
|
||||
p1.x = m_pos.x + (3.0f / 640.0f);
|
||||
p1.y = m_pos.y + (3.0f / 480.0f);
|
||||
p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f);
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
void StartEditScript(CScript *script, std::string name, Program* program);
|
||||
bool StopEditScript(bool bCancel);
|
||||
|
||||
|
||||
void SetInfoText(std::string text, bool bClickable);
|
||||
|
||||
protected:
|
||||
|
@ -94,7 +94,7 @@ protected:
|
|||
std::string SearchDirectory(bool bCreate);
|
||||
bool ReadProgram();
|
||||
bool WriteProgram();
|
||||
|
||||
|
||||
void SetFilenameField(CEdit* edit, const std::string& filename);
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue