Render mode setting, refactoring

- finished SetState in CEngine
- refactored Size and IntSize back to Point and IntPoint
- other minor changes in CEngine
dev-ui
Piotr Dziwinski 2012-08-11 17:17:04 +02:00
parent 63257034c9
commit 7f80ca2971
11 changed files with 298 additions and 437 deletions

View File

@ -285,7 +285,7 @@ bool CApplication::CreateVideoSurface()
if (m_deviceConfig.hardwareAccel)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
m_private->surface = SDL_SetVideoMode(m_deviceConfig.size.w, m_deviceConfig.size.h,
m_private->surface = SDL_SetVideoMode(m_deviceConfig.size.x, m_deviceConfig.size.y,
m_deviceConfig.bpp, videoFlags);
return true;
@ -761,7 +761,7 @@ Gfx::GLDeviceConfig CApplication::GetVideoConfig()
return m_deviceConfig;
}
VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntSize> &resolutions,
VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
bool fullScreen, bool resizeable)
{
resolutions.clear();
@ -799,7 +799,7 @@ VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntSize>
for (int i = 0; modes[i] != NULL; ++i)
resolutions.push_back(Math::IntSize(modes[i]->w, modes[i]->h));
resolutions.push_back(Math::IntPoint(modes[i]->w, modes[i]->h));
return VIDEO_QUERY_OK;
}

View File

@ -132,7 +132,7 @@ public:
void Destroy();
//! Returns a list of possible video modes
VideoQueryResult GetVideoResolutionList(std::vector<Math::IntSize> &resolutions,
VideoQueryResult GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
bool fullScreen, bool resizeable);
//! Returns the current video mode

View File

@ -25,7 +25,7 @@
#include "graphics/core/material.h"
#include "graphics/core/texture.h"
#include "graphics/core/vertex.h"
#include "math/intsize.h"
#include "math/intpoint.h"
#include "math/matrix.h"
#include <string>
@ -46,7 +46,7 @@ namespace Gfx {
struct DeviceConfig
{
//! Screen size
Math::IntSize size;
Math::IntPoint size;
//! Bits per pixel
int bpp;
//! Full screen
@ -64,7 +64,7 @@ struct DeviceConfig
//! Loads the default values
inline void LoadDefault()
{
size = Math::IntSize(800, 600);
size = Math::IntPoint(800, 600);
bpp = 32;
fullScreen = false;
resizeable = false;

View File

@ -18,7 +18,7 @@
#pragma once
#include "math/intsize.h"
#include "math/intpoint.h"
namespace Gfx {
@ -194,7 +194,7 @@ struct Texture
//! ID of the texture in graphics engine
unsigned int id;
//! Size of texture
Math::IntSize size;
Math::IntPoint size;
//! Whether the texture has alpha channel
bool alpha;

View File

@ -80,9 +80,7 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_terrain = nullptr;
m_focus = 0.75f;
m_baseTime = 0;
m_lastTime = 0;
m_absTime = 0.0f;
m_rankView = 0;
m_ambientColor[0] = Gfx::Color(0.5f, 0.5f, 0.5f, 0.5f);
@ -147,15 +145,6 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_forceStateColor = true;
m_stateColor = false;
m_blackSrcBlend[0] = 0;
m_blackDestBlend[0] = 0;
m_whiteSrcBlend[0] = 0;
m_whiteDestBlend[0] = 0;
m_diffuseSrcBlend[0] = 0;
m_diffuseDestBlend[0] = 0;
m_alphaSrcBlend[0] = 0;
m_alphaDestBlend[0] = 0;
m_updateGeometry = false;
m_mice[Gfx::ENG_MOUSE_NORM] = Gfx::EngineMouse( 0, 1, 32, Gfx::ENG_RSTATE_TCOLOR_WHITE, Gfx::ENG_RSTATE_TCOLOR_BLACK, Math::Point( 1.0f, 1.0f));
@ -188,8 +177,8 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_objectTree.reserve(LEVEL1_PREALLOCATE_COUNT);
m_objects.reserve(OBJECT_PREALLOCATE_COUNT);
m_shadow.reserve(SHADOW_PREALLOCATE_COUNT);
m_groundSpot.reserve(GROUNDSPOT_PREALLOCATE_COUNT);
m_shadows.reserve(SHADOW_PREALLOCATE_COUNT);
m_groundSpots.reserve(GROUNDSPOT_PREALLOCATE_COUNT);
}
Gfx::CEngine::~CEngine()
@ -372,38 +361,6 @@ void Gfx::CEngine::StepSimulation(float rTime)
m_app->StepSimulation(rTime);
}
void Gfx::CEngine::TimeInit()
{
/* TODO!
m_baseTime = timeGetTime();
m_lastTime = 0;
m_absTime = 0.0f;*/
}
void Gfx::CEngine::TimeEnterGel()
{
/* TODO!
m_stopTime = timeGetTime();*/
}
void Gfx::CEngine::TimeExitGel()
{
/* TODO!
m_baseTime += timeGetTime() - m_stopTime;*/
}
float Gfx::CEngine::TimeGet()
{
/* TODO!
float aTime = (timeGetTime()-m_baseTime)*0.001f; // in ms
float rTime = (aTime - m_lastTime)*m_speed;
m_absTime += rTime;
m_lastTime = aTime;
return rTime;*/
return 0.0f;
}
bool Gfx::CEngine::WriteScreenShot(const std::string& fileName, int width, int height)
{
// TODO!
@ -457,38 +414,38 @@ void Gfx::CEngine::SetRenderEnable(bool enable)
m_render = enable;
}
Math::IntSize Gfx::CEngine::GetWindowSize()
Math::IntPoint Gfx::CEngine::GetWindowSize()
{
return m_size;
}
Math::IntSize Gfx::CEngine::GetLastWindowSize()
Math::IntPoint Gfx::CEngine::GetLastWindowSize()
{
return m_lastSize;
}
Math::Point Gfx::CEngine::WindowToInterfaceCoords(Math::IntPoint pos)
{
return Math::Point( static_cast<float>(pos.x) / static_cast<float>(m_size.w),
1.0f - static_cast<float>(pos.y) / static_cast<float>(m_size.h) );
return Math::Point( static_cast<float>(pos.x) / static_cast<float>(m_size.x),
1.0f - static_cast<float>(pos.y) / static_cast<float>(m_size.y) );
}
Math::IntPoint Gfx::CEngine::InterfaceToWindowCoords(Math::Point pos)
{
return Math::IntPoint(static_cast<int>(pos.x * m_size.w),
static_cast<int>((1.0f - pos.y) * m_size.h));
return Math::IntPoint(static_cast<int>(pos.x * m_size.x),
static_cast<int>((1.0f - pos.y) * m_size.y));
}
Math::Size Gfx::CEngine::WindowToInterfaceSize(Math::IntSize size)
Math::Point Gfx::CEngine::WindowToInterfaceSize(Math::IntPoint size)
{
return Math::Size( static_cast<float>(size.w) / static_cast<float>(m_size.w),
static_cast<float>(size.h) / static_cast<float>(m_size.h) );
return Math::Point(static_cast<float>(size.x) / static_cast<float>(m_size.x),
static_cast<float>(size.y) / static_cast<float>(m_size.y));
}
Math::IntSize Gfx::CEngine::InterfaceToWindowSize(Math::Size size)
Math::IntPoint Gfx::CEngine::InterfaceToWindowSize(Math::Point size)
{
return Math::IntSize(static_cast<int>(size.w * m_size.w),
static_cast<int>(size.h * m_size.h));
return Math::IntPoint(static_cast<int>(size.x * m_size.x),
static_cast<int>(size.y * m_size.y));
}
std::string Gfx::CEngine::GetTextureDir()
@ -874,7 +831,18 @@ bool Gfx::CEngine::IsVisible(int objRank)
bool Gfx::CEngine::TransformPoint(Math::Vector& p2D, int objRank, Math::Vector p3D)
{
// TODO!
p3D = Math::Transform(m_objects[objRank].transform, p3D);
p3D = Math::Transform(m_matView, p3D);
if (p3D.z < 2.0f) return false; // behind?
p2D.x = (p3D.x/p3D.z)*m_matProj.Get(1,1);
p2D.y = (p3D.y/p3D.z)*m_matProj.Get(2,2);
p2D.z = p3D.z;
p2D.x = (p2D.x+1.0f)/2.0f; // [-1..1] -> [0..1]
p2D.y = (p2D.y+1.0f)/2.0f;
return true;
}
@ -888,13 +856,13 @@ bool Gfx::CEngine::TransformPoint(Math::Vector& p2D, int objRank, Math::Vector p
void Gfx::CEngine::SetState(int state, const Gfx::Color& color)
{
if ( state == m_lastState && color == m_lastColor )
if (state == m_lastState && color == m_lastColor)
return;
m_lastState = state;
m_lastColor = color;
if ( m_alphaMode != 1 && (state & Gfx::ENG_RSTATE_ALPHA) )
if (m_alphaMode != 1 && (state & Gfx::ENG_RSTATE_ALPHA))
{
state &= ~Gfx::ENG_RSTATE_ALPHA;
@ -902,133 +870,150 @@ void Gfx::CEngine::SetState(int state, const Gfx::Color& color)
state |= Gfx::ENG_RSTATE_TTEXTURE_BLACK;
}
// TODO other modes & thorough testing
if (state & Gfx::ENG_RSTATE_TTEXTURE_BLACK) // The transparent black texture?
if (state & Gfx::ENG_RSTATE_TTEXTURE_BLACK) // transparent black texture?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_ONE, Gfx::BLEND_INV_SRC_COLOR);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetBlendFunc(Gfx::BLEND_ONE, Gfx::BLEND_INV_SRC_COLOR);
m_device->SetTextureEnabled(0, true);
m_device->SetTextureFactor(color);
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_MODULATE;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.colorArg2 = Gfx::TEX_MIX_ARG_FACTOR;
params.alphaOperation = Gfx::TEX_MIX_OPER_MODULATE;
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
}
else if (state & Gfx::ENG_RSTATE_TTEXTURE_WHITE) // The transparent white texture?
else if (state & Gfx::ENG_RSTATE_TTEXTURE_WHITE) // transparent white texture?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_DST_COLOR, Gfx::BLEND_ZERO);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetBlendFunc(Gfx::BLEND_DST_COLOR, Gfx::BLEND_ZERO);
m_device->SetTextureEnabled(0, true);
m_device->SetTextureFactor(color.Inverse());
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_ADD;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.colorArg2 = Gfx::TEX_MIX_ARG_FACTOR;
params.alphaOperation = Gfx::TEX_MIX_OPER_MODULATE;
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
}
else if (state & Gfx::ENG_RSTATE_TCOLOR_BLACK) // The transparent black color?
else if (state & Gfx::ENG_RSTATE_TCOLOR_BLACK) // transparent black color?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_ONE, Gfx::BLEND_INV_SRC_COLOR);
m_device->SetTextureFactor(color);
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, Gfx::TextureStageParams());
}
else if (state & Gfx::ENG_RSTATE_TCOLOR_WHITE) // The transparent white color?
else if (state & Gfx::ENG_RSTATE_TCOLOR_WHITE) // transparent white color?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_DST_COLOR, Gfx::BLEND_ZERO);
m_device->SetTextureFactor(color.Inverse());
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, Gfx::TextureStageParams());
}
else if (state & Gfx::ENG_RSTATE_TDIFFUSE) // diffuse color as transparent?
{
/*m_device->SetRenderState(D3DRENDERSTATE_FOGENABLE, false);
m_device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
m_device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true);
m_device->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false);
m_device->SetRenderState(D3DRENDERSTATE_SRCBLEND, m_diffuseSrcBlend[1]);
m_device->SetRenderState(D3DRENDERSTATE_DESTBLEND, m_diffuseDestBlend[1]);
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);*/
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_SRC_ALPHA, Gfx::BLEND_DST_ALPHA);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_REPLACE;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
}
else if (state & Gfx::ENG_RSTATE_TEXT) // font rendering?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false); // TODO: depth test setting elsewhere!
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetBlendFunc(Gfx::BLEND_SRC_ALPHA, Gfx::BLEND_INV_SRC_ALPHA);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT; // default modulate operation
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // default modulate operation
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
}
else if (state & Gfx::ENG_RSTATE_ALPHA) // image with alpha channel?
{
/*m_device->SetRenderState(D3DRENDERSTATE_FOGENABLE, true);
m_device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
m_device->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false);
m_device->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, true);
m_device->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DCMP_GREATER);
m_device->SetRenderState(D3DRENDERSTATE_ALPHAREF, (DWORD)(128));
m_device->SetRenderState(D3DRENDERSTATE_SRCBLEND, m_alphaSrcBlend[1]);
m_device->SetRenderState(D3DRENDERSTATE_DESTBLEND, m_alphaSrcBlend[1]);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, false);
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, true);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, true);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, true);
m_device->SetAlphaTestFunc(Gfx::COMP_FUNC_GREATER, 0.5f);
m_device->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR, color);
m_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);*/
}
else if (state & Gfx::ENG_RSTATE_TEXT)
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, true);
m_device->SetTextureFactor(color);
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_MODULATE;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.colorArg2 = Gfx::TEX_MIX_ARG_SRC_COLOR;
params.alphaOperation = Gfx::TEX_MIX_OPER_REPLACE;
params.alphaArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, Gfx::TextureStageParams());
m_device->SetBlendFunc(Gfx::BLEND_SRC_ALPHA, Gfx::BLEND_INV_SRC_ALPHA);
m_device->SetTextureStageParams(0, params);
}
else // normal ?
{
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, true);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, true);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, false);
m_device->SetRenderState(Gfx::RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
m_device->SetRenderState(Gfx::RENDER_STATE_BLENDING, false);
m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, true);
m_device->SetRenderState(Gfx::RENDER_STATE_FOG, true);
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT; // default modulate
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, Gfx::TextureStageParams());
/*m_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);*/
m_device->SetTextureStageParams(0, params);
}
if (state & Gfx::ENG_RSTATE_FOG)
@ -1040,21 +1025,25 @@ void Gfx::CEngine::SetState(int state, const Gfx::Color& color)
if ( !m_groundSpotVisible && (state & Gfx::ENG_RSTATE_SECOND) != 0 ) second = false;
if ( !m_dirty && (state & Gfx::ENG_RSTATE_SECOND) == 0 ) second = false;
if ( (state & ENG_RSTATE_DUAL_BLACK) && second )
if ((state & ENG_RSTATE_DUAL_BLACK) && second)
{
/*m_device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
m_device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);*/
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_MODULATE;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.colorArg2 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: ???
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(1, params);
}
else if ( (state & ENG_RSTATE_DUAL_WHITE) && second )
else if ((state & ENG_RSTATE_DUAL_WHITE) && second)
{
/*m_device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
m_device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
m_device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);*/
Gfx::TextureStageParams params;
params.colorOperation = Gfx::TEX_MIX_OPER_ADD;
params.colorArg1 = Gfx::TEX_MIX_ARG_TEXTURE;
params.colorArg2 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
params.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; // TODO: ???
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(1, params);
}
else
{
@ -1063,18 +1052,25 @@ void Gfx::CEngine::SetState(int state, const Gfx::Color& color)
if (state & Gfx::ENG_RSTATE_WRAP)
{
/*m_device->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
m_device->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);*/
// TODO: separate function for setting wrap mode?
Gfx::TextureStageParams p1 = m_device->GetTextureStageParams(0);
p1.wrapS = p1.wrapT = Gfx::TEX_WRAP_REPEAT;
m_device->SetTextureStageParams(0, p1);
Gfx::TextureStageParams p2 = m_device->GetTextureStageParams(1);
p2.wrapS = p2.wrapT = Gfx::TEX_WRAP_REPEAT;
m_device->SetTextureStageParams(1, p2);
}
else if (state & Gfx::ENG_RSTATE_CLAMP)
else // if (state & Gfx::ENG_RSTATE_CLAMP) or otherwise
{
/*m_device->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
m_device->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);*/
}
else
{
/*m_device->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
m_device->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);*/
Gfx::TextureStageParams p1 = m_device->GetTextureStageParams(0);
p1.wrapS = p1.wrapT = Gfx::TEX_WRAP_CLAMP;
m_device->SetTextureStageParams(0, p1);
Gfx::TextureStageParams p2 = m_device->GetTextureStageParams(1);
p2.wrapS = p2.wrapT = Gfx::TEX_WRAP_CLAMP;
m_device->SetTextureStageParams(1, p2);
}
if (state & Gfx::ENG_RSTATE_2FACE)
@ -1197,13 +1193,13 @@ float Gfx::CEngine::GetLimitLOD(int rank, bool last)
if (last)
{
limit = m_limitLOD[rank];
limit *= m_lastSize.w/640.0f; // limit further if large window!
limit *= m_lastSize.x/640.0f; // limit further if large window!
limit += m_limitLOD[0]*(m_lastObjectDetail*2.0f);
}
else
{
limit = m_limitLOD[rank];
limit *= m_size.w/640.0f; // limit further if large window!
limit *= m_size.x/640.0f; // limit further if large window!
limit += m_limitLOD[0]*(m_objectDetail*2.0f);
}
@ -1222,7 +1218,7 @@ void Gfx::CEngine::SetFocus(float focus)
m_focus = focus;
m_size = m_app->GetVideoConfig().size;
float aspect = (static_cast<float>(m_size.h)) / m_size.w;
float aspect = (static_cast<float>(m_size.y)) / m_size.x;
Math::LoadProjectionMatrix(m_matProj, m_focus, aspect, 0.5f, m_deepView[0]);
}
@ -1698,15 +1694,6 @@ void Gfx::CEngine::ApplyChange()
viewport, and renders the scene. */
void Gfx::CEngine::Render()
{
/* TODO!
D3DObjLevel1* p1;
D3DObjLevel2* p2;
D3DObjLevel3* p3;
D3DObjLevel4* p4;
D3DObjLevel5* p5;
D3DVERTEX2* pv;
int l1, l2, l3, l4, l5, objRank;*/
if (! m_render) return;
m_statisticTriangle = 0;
@ -1729,19 +1716,27 @@ void Gfx::CEngine::Render()
if (m_drawWorld)
{
Draw3DScene();
}
DrawInterface();
// End the scene
m_device->EndScene();
}
void Gfx::CEngine::Draw3DScene()
{
/* TODO!
D3DObjLevel1* p1;
D3DObjLevel2* p2;
D3DObjLevel3* p3;
D3DObjLevel4* p4;
D3DObjLevel5* p5;
D3DVERTEX2* pv;
int l1, l2, l3, l4, l5, objRank;*/
if (m_groundSpotVisible)
UpdateGroundSpotTextures();
@ -2153,11 +2148,11 @@ void Gfx::CEngine::DrawShadow()
float endDeepView = m_deepView[m_rankView];
float lastIntensity = -1.0f;
for (int i = 0; i < static_cast<int>( m_shadow.size() ); i++)
for (int i = 0; i < static_cast<int>( m_shadows.size() ); i++)
{
if (m_shadow[i].hide) continue;
if (m_shadows[i].hide) continue;
Math::Vector pos = m_shadow[i].pos; // pos = center of the shadow on the ground
Math::Vector pos = m_shadows[i].pos; // pos = center of the shadow on the ground
if (m_eyePt.y == pos.y) continue; // camera at the same level?
@ -2169,7 +2164,7 @@ void Gfx::CEngine::DrawShadow()
if (m_eyePt.y > pos.y) // camera on?
{
float height = m_eyePt.y-pos.y;
float h = m_shadow[i].radius;
float h = m_shadows[i].radius;
float max = height*0.5f;
if ( h > max ) h = max;
if ( h > 4.0f ) h = 4.0f;
@ -2185,7 +2180,7 @@ void Gfx::CEngine::DrawShadow()
else // camera underneath?
{
float height = pos.y-m_eyePt.y;
float h = m_shadow[i].radius;
float h = m_shadows[i].radius;
float max = height*0.1f;
if ( h > max ) h = max;
if ( h > 4.0f ) h = 4.0f;
@ -2201,20 +2196,20 @@ void Gfx::CEngine::DrawShadow()
// The hFactor decreases the intensity and size increases more
// the object is high relative to the ground.
float hFactor = m_shadow[i].height/20.0f;
float hFactor = m_shadows[i].height/20.0f;
if ( hFactor < 0.0f ) hFactor = 0.0f;
if ( hFactor > 1.0f ) hFactor = 1.0f;
hFactor = powf(1.0f-hFactor, 2.0f);
if ( hFactor < 0.2f ) hFactor = 0.2f;
float radius = m_shadow[i].radius*1.5f;
float radius = m_shadows[i].radius*1.5f;
radius *= 2.0f-hFactor; // greater if high
radius *= 1.0f-d/D; // smaller if close
Math::Vector corner[4];
if (m_shadow[i].type == Gfx::ENG_SHADOW_NORM)
if (m_shadows[i].type == Gfx::ENG_SHADOW_NORM)
{
corner[0].x = +radius;
corner[0].z = +radius;
@ -2239,27 +2234,27 @@ void Gfx::CEngine::DrawShadow()
{
Math::Point rot;
rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(radius, radius));
rot = Math::RotatePoint(-m_shadows[i].angle, Math::Point(radius, radius));
corner[0].x = rot.x;
corner[0].z = rot.y;
corner[0].y = 0.0f;
rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(-radius, radius));
rot = Math::RotatePoint(-m_shadows[i].angle, Math::Point(-radius, radius));
corner[1].x = rot.x;
corner[1].z = rot.y;
corner[1].y = 0.0f;
rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(radius, -radius));
rot = Math::RotatePoint(-m_shadows[i].angle, Math::Point(radius, -radius));
corner[2].x = rot.x;
corner[2].z = rot.y;
corner[2].y = 0.0f;
rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(-radius, -radius));
rot = Math::RotatePoint(-m_shadows[i].angle, Math::Point(-radius, -radius));
corner[3].x = rot.x;
corner[3].z = rot.y;
corner[3].y = 0.0f;
if (m_shadow[i].type == Gfx::ENG_SHADOW_WORM)
if (m_shadows[i].type == Gfx::ENG_SHADOW_WORM)
{
ts.x = 96.0f/256.0f;
ti.x = 128.0f/256.0f;
@ -2271,10 +2266,10 @@ void Gfx::CEngine::DrawShadow()
}
}
corner[0] = Math::CrossProduct(corner[0], m_shadow[i].normal);
corner[1] = Math::CrossProduct(corner[1], m_shadow[i].normal);
corner[2] = Math::CrossProduct(corner[2], m_shadow[i].normal);
corner[3] = Math::CrossProduct(corner[3], m_shadow[i].normal);
corner[0] = Math::CrossProduct(corner[0], m_shadows[i].normal);
corner[1] = Math::CrossProduct(corner[1], m_shadows[i].normal);
corner[2] = Math::CrossProduct(corner[2], m_shadows[i].normal);
corner[3] = Math::CrossProduct(corner[3], m_shadows[i].normal);
corner[0] += pos;
corner[1] += pos;
@ -2292,7 +2287,7 @@ void Gfx::CEngine::DrawShadow()
Gfx::Vertex(corner[2], n, Math::Point(ti.x, ti.y))
};
float intensity = (0.5f+m_shadow[i].intensity*0.5f)*hFactor;
float intensity = (0.5f+m_shadows[i].intensity*0.5f)*hFactor;
// Decreases the intensity of the shade if you're in the area
// between the beginning and the end of the fog.

View File

@ -19,17 +19,15 @@
#pragma once
#include "app/system.h"
#include "common/event.h"
#include "graphics/core/color.h"
#include "graphics/core/material.h"
#include "graphics/core/texture.h"
#include "graphics/core/vertex.h"
#include "math/intpoint.h"
#include "math/intsize.h"
#include "math/matrix.h"
#include "math/point.h"
#include "math/size.h"
#include "math/vector.h"
@ -567,15 +565,6 @@ public:
//! Evolved throughout the game
void StepSimulation(float rTime);
//! Initialize timestamps at the beginning of animation
void TimeInit();
//! Suspend animation
void TimeEnterGel();
//! Resume animation
void TimeExitGel();
//! Returns the relative time since last animation update
float TimeGet();
//! Writes a screenshot containing the current frame
bool WriteScreenShot(const std::string& fileName, int width, int height);
@ -608,22 +597,24 @@ public:
void SetRenderEnable(bool enable);
//! Returns current size of viewport window
Math::IntSize GetWindowSize();
Math::IntPoint GetWindowSize();
//! Returns the last size of viewport window
Math::IntSize GetLastWindowSize();
Math::IntPoint GetLastWindowSize();
//! Converts window coords to interface coords
/** Conversion of the position of the mouse from window coords to interface coords:
- x: 0=left, 1=right
- y: 0=down, 1=up */
//@{
//! Conversion functions between window and interface coordinates
/** Window coordinates are from top-left (0,0) to bottom-right (w,h) - size of window
Interface cords are from bottom-left (0,0) to top-right (1,1) - and do not depend on window size */
Math::Point WindowToInterfaceCoords(Math::IntPoint pos);
//! Converts interface coords to window coords
Math::IntPoint InterfaceToWindowCoords(Math::Point pos);
//@}
//! Converts window size to interface size
Math::Size WindowToInterfaceSize(Math::IntSize size);
//! Converts interface size to window size
Math::IntSize InterfaceToWindowSize(Math::Size size);
//@{
//! Conversion functions between window and interface sizes
/** Unlike coordinate conversions, this is only scale conversion, not translation and scale. */
Math::Point WindowToInterfaceSize(Math::IntPoint size);
Math::IntPoint InterfaceToWindowSize(Math::Point size);
//@}
//! Returns the name of directory with textures
std::string GetTextureDir();
@ -1062,46 +1053,48 @@ protected:
//! Whether to show stats (FPS, etc)
bool m_showStats;
int m_blackSrcBlend[2];
int m_blackDestBlend[2];
int m_whiteSrcBlend[2];
int m_whiteDestBlend[2];
int m_diffuseSrcBlend[2];
int m_diffuseDestBlend[2];
int m_alphaSrcBlend[2];
int m_alphaDestBlend[2];
Math::Matrix m_matProj;
Math::Matrix m_matLeftView;
Math::Matrix m_matRightView;
Math::Matrix m_matView;
float m_focus;
Math::Matrix m_matWorldInterface;
Math::Matrix m_matProjInterface;
Math::Matrix m_matViewInterface;
long m_baseTime;
long m_stopTime;
float m_absTime;
float m_lastTime;
//! Speed of animation
float m_speed;
//! Pause mode
bool m_pause;
//! Rendering enabled?
bool m_render;
//! Lock for duration of movie?
bool m_movieLock;
//! Current size of viewport window
Math::IntSize m_size;
//! Previous size of viewport window
Math::IntSize m_lastSize;
//! Projection matrix for 3D scene
Math::Matrix m_matProj;
//! View matrix for 3D scene
Math::Matrix m_matView;
//! Camera angle for 3D scene
float m_focus;
//! World matrix for 2D interface
Math::Matrix m_matWorldInterface;
//! Projection matrix for 2D interface
Math::Matrix m_matProjInterface;
//! View matrix for 2D interface
Math::Matrix m_matViewInterface;
//! Current size of viewport window
Math::IntPoint m_size;
//! Previous size of viewport window
Math::IntPoint m_lastSize;
//! Root of tree object structure (level 1 list)
std::vector<Gfx::EngineObjLevel1> m_objectTree;
//! Object parameters
std::vector<Gfx::EngineObject> m_objects;
std::vector<Gfx::EngineShadow> m_shadow;
std::vector<Gfx::EngineGroundSpot> m_groundSpot;
//! Shadow list
std::vector<Gfx::EngineShadow> m_shadows;
//! Ground spot list
std::vector<Gfx::EngineGroundSpot> m_groundSpots;
//! Ground mark
Gfx::EngineGroundMark m_groundMark;
//! Location of camera
Math::Vector m_eyePt;
//! Camera target
Math::Vector m_lookatPt;
float m_eyeDirH;
float m_eyeDirV;
@ -1156,28 +1149,47 @@ protected:
int m_editIndentValue;
float m_tracePrecision;
//! Ranks of highlighted objects
int m_highlightRank[100];
//! Highlight visible?
bool m_highlight;
//@{
//! Highlight rectangle points
Math::Point m_highlightP1;
Math::Point m_highlightP2;
//@}
int m_lastState;
Gfx::Color m_lastColor;
char m_lastTexture[2][50];
Gfx::Material m_lastMaterial;
//! Texture directory name
std::string m_texPath;
//! Default texture create params
Gfx::TextureCreateParams m_defaultTexParams;
//! Map of loaded textures (by name)
std::map<std::string, Gfx::Texture> m_texNameMap;
//! Reverse map of loaded textures (by texture)
std::map<Gfx::Texture, std::string> m_revTexNameMap;
//! Mouse cursor definitions
Gfx::EngineMouse m_mice[Gfx::ENG_MOUSE_COUNT];
//! Texture with mouse cursors
Gfx::Texture m_miceTexture;
//! Size of mouse cursor
Math::Point m_mouseSize;
//! Type of mouse cursor
Gfx::EngineMouseType m_mouseType;
//! Position of mouse in interface coords
Math::Point m_mousePos;
//! Is mouse visible?
bool m_mouseVisible;
//! Last engine render state (-1 at the beginning of frame)
int m_lastState;
//! Last color set with render state
Gfx::Color m_lastColor;
//! Last texture names for 2 used texture stages
std::string m_lastTexture[2];
//! Last material
Gfx::Material m_lastMaterial;
};
}; // namespace Gfx

View File

@ -245,10 +245,10 @@ float Gfx::CText::GetAscent(Gfx::FontType font, float size)
Gfx::CachedFont* cf = GetOrOpenFont(font, size);
assert(cf != nullptr);
Math::IntSize wndSize;
wndSize.h = TTF_FontAscent(cf->font);
Math::Size ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.h;
Math::IntPoint wndSize;
wndSize.y = TTF_FontAscent(cf->font);
Math::Point ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.y;
}
float Gfx::CText::GetDescent(Gfx::FontType font, float size)
@ -257,10 +257,10 @@ float Gfx::CText::GetDescent(Gfx::FontType font, float size)
Gfx::CachedFont* cf = GetOrOpenFont(font, size);
assert(cf != nullptr);
Math::IntSize wndSize;
wndSize.h = TTF_FontDescent(cf->font);
Math::Size ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.h;
Math::IntPoint wndSize;
wndSize.y = TTF_FontDescent(cf->font);
Math::Point ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.y;
}
float Gfx::CText::GetHeight(Gfx::FontType font, float size)
@ -269,10 +269,10 @@ float Gfx::CText::GetHeight(Gfx::FontType font, float size)
Gfx::CachedFont* cf = GetOrOpenFont(font, size);
assert(cf != nullptr);
Math::IntSize wndSize;
wndSize.h = TTF_FontHeight(cf->font);
Math::Size ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.h;
Math::IntPoint wndSize;
wndSize.y = TTF_FontHeight(cf->font);
Math::Point ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.y;
}
@ -315,10 +315,10 @@ float Gfx::CText::GetStringWidth(const std::string &text, Gfx::FontType font, fl
Gfx::CachedFont* cf = GetOrOpenFont(font, size);
assert(cf != nullptr);
Math::IntSize wndSize;
TTF_SizeUTF8(cf->font, text.c_str(), &wndSize.w, &wndSize.h);
Math::Size ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.w;
Math::IntPoint wndSize;
TTF_SizeUTF8(cf->font, text.c_str(), &wndSize.x, &wndSize.y);
Math::Point ifSize = m_engine->WindowToInterfaceSize(wndSize);
return ifSize.x;
}
float Gfx::CText::GetCharWidth(Gfx::UTF8Char ch, Gfx::FontType font, float size, float offset)
@ -339,7 +339,7 @@ float Gfx::CText::GetCharWidth(Gfx::UTF8Char ch, Gfx::FontType font, float size,
else
tex = CreateCharTexture(ch, cf);
return tex.charSize.w;
return tex.charSize.x;
}
@ -539,9 +539,9 @@ void Gfx::CText::DrawString(const std::string &text, const std::vector<FontMetaC
Gfx::FontHighlight hl = static_cast<Gfx::FontHighlight>(format[fmtIndex] & Gfx::FONT_MASK_HIGHLIGHT);
if (hl != Gfx::FONT_HIGHLIGHT_NONE)
{
Math::Size charSize;
charSize.w = GetCharWidth(ch, font, size, offset);
charSize.h = GetHeight(font, size);
Math::Point charSize;
charSize.x = GetCharWidth(ch, font, size, offset);
charSize.y = GetHeight(font, size);
DrawHighlight(hl, pos, charSize);
}
@ -580,7 +580,7 @@ void Gfx::CText::DrawString(const std::string &text, Gfx::FontType font,
}
}
void Gfx::CText::DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Size size)
void Gfx::CText::DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Point size)
{
// Gradient colors
Gfx::Color grad[4];
@ -622,16 +622,16 @@ void Gfx::CText::DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Siz
return;
}
Math::IntSize vsize = m_engine->GetWindowSize();
Math::IntPoint vsize = m_engine->GetWindowSize();
float h = 0.0f;
if (vsize.h <= 768.0f) // 1024x768 or less?
h = 1.01f / vsize.h; // 1 pixel
if (vsize.y <= 768.0f) // 1024x768 or less?
h = 1.01f / vsize.y; // 1 pixel
else // more than 1024x768?
h = 2.0f / vsize.h; // 2 pixels
h = 2.0f / vsize.y; // 2 pixels
Math::Point p1, p2;
p1.x = pos.x;
p2.x = pos.x + size.w;
p2.x = pos.x + size.x;
if (hl == Gfx::FONT_HIGHLIGHT_LINK)
{
@ -641,7 +641,7 @@ void Gfx::CText::DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Siz
else
{
p1.y = pos.y;
p2.y = pos.y + size.h;
p2.y = pos.y + size.y;
}
m_device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, false);
@ -690,8 +690,8 @@ void Gfx::CText::DrawChar(Gfx::UTF8Char ch, Gfx::FontType font, float size, Math
m_device->SetRenderState(Gfx::RENDER_STATE_CULLING, false);
Math::Point p1(pos.x, pos.y + tex.charSize.h - tex.texSize.h);
Math::Point p2(pos.x + tex.texSize.w, pos.y + tex.charSize.h);
Math::Point p1(pos.x, pos.y + tex.charSize.y - tex.texSize.y);
Math::Point p2(pos.x + tex.texSize.x, pos.y + tex.charSize.y);
Math::Vector n(0.0f, 0.0f, -1.0f); // normal
@ -707,7 +707,7 @@ void Gfx::CText::DrawChar(Gfx::UTF8Char ch, Gfx::FontType font, float size, Math
m_device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4);
m_engine->AddStatisticTriangle(2);
pos.x += tex.charSize.w;
pos.x += tex.charSize.x;
}
Gfx::CachedFont* Gfx::CText::GetOrOpenFont(Gfx::FontType font, float size)
@ -797,8 +797,8 @@ Gfx::CharTexture Gfx::CText::CreateCharTexture(Gfx::UTF8Char ch, Gfx::CachedFont
}
texture.id = tex.id;
texture.texSize = m_engine->WindowToInterfaceSize(Math::IntSize(textureSurface->w, textureSurface->h));
texture.charSize = m_engine->WindowToInterfaceSize(Math::IntSize(textSurface->w, textSurface->h));
texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h));
texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h));
return texture;
}

View File

@ -20,7 +20,6 @@
#pragma once
#include "math/point.h"
#include "math/size.h"
#include <vector>
#include <map>
@ -168,8 +167,8 @@ struct UTF8Char
struct CharTexture
{
unsigned int id;
Math::Size texSize;
Math::Size charSize;
Math::Point texSize;
Math::Point charSize;
CharTexture() : id(0) {}
};
@ -277,7 +276,7 @@ protected:
float size, Math::Point pos, float width, int eol);
void DrawString(const std::string &text, Gfx::FontType font,
float size, Math::Point pos, float width, int eol);
void DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Size size);
void DrawHighlight(Gfx::FontHighlight hl, Math::Point pos, Math::Point size);
void DrawChar(Gfx::UTF8Char ch, Gfx::FontType font, float size, Math::Point &pos);
protected:

View File

@ -122,7 +122,7 @@ bool Gfx::CGLDevice::Create()
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, m_config.size.w, m_config.size.h);
glViewport(0, 0, m_config.size.x, m_config.size.y);
m_lights = std::vector<Gfx::Light>(GL_MAX_LIGHTS, Gfx::Light());
@ -390,8 +390,8 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
Gfx::Texture result;
result.valid = true;
result.size.w = data->surface->w;
result.size.h = data->surface->h;
result.size.x = data->surface->w;
result.size.y = data->surface->h;
// Use & enable 1st texture stage
glActiveTexture(GL_TEXTURE0);

View File

@ -1,70 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/** @defgroup MathIntSizeModule math/intsize.h
Contains the IntSize struct.
*/
#pragma once
#include "math/intpoint.h"
// Math module namespace
namespace Math
{
/* @{ */ // start of group
/** \struct IntSize math/size.h
\brief 2D size with integer dimensions */
struct IntSize
{
//! Width
int w;
//! Height
int h;
//! Constructs a zero size: (0,0)
inline IntSize()
{
LoadZero();
}
//! Constructs a size from given dimensions: (w,h)
inline explicit IntSize(int w, int h)
{
this->w = w;
this->h = h;
}
//! Sets the zero size: (0,0)
inline void LoadZero()
{
w = h = 0;
}
//! Converts Point to Size
inline static Math::IntSize FromIntPoint(Math::IntPoint p)
{
return Math::IntSize(p.x, p.y);
}
}; // struct Size
/* @} */ // end of group
}; // namespace Math

View File

@ -1,75 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/** @defgroup MathSizeModule math/size.h
Contains the Size struct.
*/
#pragma once
#include "math/point.h"
// Math module namespace
namespace Math
{
/* @{ */ // start of group
/** \struct Size math/size.h
\brief 2D size
Represents a 2D size (w, h).
Is separate from Math::Point to avoid confusion.
*/
struct Size
{
//! Width
float w;
//! Height
float h;
//! Constructs a zero size: (0,0)
inline Size()
{
LoadZero();
}
//! Constructs a size from given dimensions: (w,h)
inline explicit Size(float w, float h)
{
this->w = w;
this->h = h;
}
//! Sets the zero size: (0,0)
inline void LoadZero()
{
w = h = 0.0f;
}
//! Converts Point to Size
inline static Math::Size FromPoint(Math::Point p)
{
return Math::Size(p.x, p.y);
}
}; // struct Size
/* @} */ // end of group
}; // namespace Math