mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 13:29:18 +02:00
basic renderer types. texture manager moved to renderer
This commit is contained in:
@@ -22,7 +22,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Timer.h"
|
||||
#include "MdlMngr.h"
|
||||
// McZapkie:
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
//---------------------------------------------------------------------------
|
||||
TAnimContainer *TAnimModel::acAnimList = NULL;
|
||||
|
||||
@@ -449,9 +449,9 @@ bool TAnimModel::Init(std::string const &asName, std::string const &asReplacable
|
||||
asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu
|
||||
else if (asReplacableTexture != "none")
|
||||
ReplacableSkinId[1] =
|
||||
TextureManager.GetTextureId( asReplacableTexture, "" );
|
||||
GfxRenderer.GetTextureId( asReplacableTexture, "" );
|
||||
if( ( ReplacableSkinId[ 1 ] != 0 )
|
||||
&& ( TextureManager.Texture( ReplacableSkinId[ 1 ] ).has_alpha ) ) {
|
||||
&& ( GfxRenderer.Texture( ReplacableSkinId[ 1 ] ).has_alpha ) ) {
|
||||
// tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
iTexAlpha = 0x31310031;
|
||||
}
|
||||
|
||||
34
DynObj.cpp
34
DynObj.cpp
@@ -21,7 +21,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Usefull.h"
|
||||
// McZapkie-260202
|
||||
#include "Globals.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
#include "AirCoupler.h"
|
||||
|
||||
#include "TractionPower.h"
|
||||
@@ -4389,7 +4389,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
Global::asCurrentTexturePath + ReplacableSkin; // skory tez z dynamic/...
|
||||
std::string x = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
||||
if (!x.empty())
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( Global::asCurrentTexturePath + "nowhere", "", 9);
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + "nowhere", "", 9);
|
||||
/*
|
||||
if ((i = ReplacableSkin.Pos("|")) > 0) // replacable dzielone
|
||||
{
|
||||
@@ -4452,21 +4452,21 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
*/
|
||||
if (iMultiTex > 0)
|
||||
{ // jeśli model ma 4 tekstury
|
||||
ReplacableSkinID[1] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[1] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin + ",1", "", Global::iDynamicFiltering);
|
||||
if (ReplacableSkinID[1])
|
||||
{ // pierwsza z zestawu znaleziona
|
||||
ReplacableSkinID[2] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[2] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin + ",2", "", Global::iDynamicFiltering);
|
||||
if (ReplacableSkinID[2])
|
||||
{
|
||||
iMultiTex = 2; // już są dwie
|
||||
ReplacableSkinID[3] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[3] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin + ",3", "", Global::iDynamicFiltering);
|
||||
if (ReplacableSkinID[3])
|
||||
{
|
||||
iMultiTex = 3; // a teraz nawet trzy
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin + ",4", "", Global::iDynamicFiltering);
|
||||
if (ReplacableSkinID[4])
|
||||
iMultiTex = 4; // jak są cztery, to blokujemy podmianę tekstury
|
||||
@@ -4477,14 +4477,14 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
else
|
||||
{ // zestaw nie zadziałał, próbujemy normanie
|
||||
iMultiTex = 0;
|
||||
ReplacableSkinID[1] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[1] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin, "", Global::iDynamicFiltering);
|
||||
}
|
||||
}
|
||||
else
|
||||
ReplacableSkinID[1] = TextureManager.GetTextureId(
|
||||
ReplacableSkinID[1] = GfxRenderer.GetTextureId(
|
||||
ReplacableSkin, "", Global::iDynamicFiltering);
|
||||
if (TextureManager.Texture(ReplacableSkinID[1]).has_alpha)
|
||||
if (GfxRenderer.Texture(ReplacableSkinID[1]).has_alpha)
|
||||
iAlpha = 0x31310031; // tekstura -1 z kanałem alfa - nie renderować w cyklu
|
||||
// nieprzezroczystych
|
||||
else
|
||||
@@ -4492,17 +4492,17 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
// renderować w
|
||||
// cyklu przezroczystych
|
||||
if (ReplacableSkinID[2])
|
||||
if (TextureManager.Texture(ReplacableSkinID[2]).has_alpha)
|
||||
if (GfxRenderer.Texture(ReplacableSkinID[2]).has_alpha)
|
||||
iAlpha |= 0x02020002; // tekstura -2 z kanałem alfa - nie renderować
|
||||
// w cyklu
|
||||
// nieprzezroczystych
|
||||
if (ReplacableSkinID[3])
|
||||
if (TextureManager.Texture(ReplacableSkinID[3]).has_alpha)
|
||||
if (GfxRenderer.Texture(ReplacableSkinID[3]).has_alpha)
|
||||
iAlpha |= 0x04040004; // tekstura -3 z kanałem alfa - nie renderować
|
||||
// w cyklu
|
||||
// nieprzezroczystych
|
||||
if (ReplacableSkinID[4])
|
||||
if (TextureManager.Texture(ReplacableSkinID[4]).has_alpha)
|
||||
if (GfxRenderer.Texture(ReplacableSkinID[4]).has_alpha)
|
||||
iAlpha |= 0x08080008; // tekstura -4 z kanałem alfa - nie renderować
|
||||
// w cyklu
|
||||
// nieprzezroczystych
|
||||
@@ -5831,13 +5831,13 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
|
||||
std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName);
|
||||
if (!x.empty())
|
||||
{
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
return;
|
||||
}
|
||||
x = TextureTest(asBaseDir + numer );
|
||||
if (!x.empty())
|
||||
{
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
return;
|
||||
}
|
||||
if (to.empty())
|
||||
@@ -5845,17 +5845,17 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
|
||||
x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD
|
||||
if (!x.empty())
|
||||
{
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
return;
|
||||
}
|
||||
x = TextureTest(asBaseDir + to); // na razie prymitywnie
|
||||
if (!x.empty())
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
|
||||
else
|
||||
{
|
||||
x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere
|
||||
if (!x.empty())
|
||||
ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9);
|
||||
ReplacableSkinID[4] = GfxRenderer.GetTextureId( x, "", 9);
|
||||
}
|
||||
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa
|
||||
// tekstury nr 4
|
||||
|
||||
48
Globals.h
48
Globals.h
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include "renderer.h"
|
||||
#include "opengl/glew.h"
|
||||
#include "dumb3d.h"
|
||||
|
||||
@@ -120,53 +121,6 @@ class cParser; // nowy (powolny!) parser
|
||||
class TEvent;
|
||||
class TTextSound;
|
||||
|
||||
// bare-bones render controller, in lack of anything better yet
|
||||
struct opengl_renderer {
|
||||
|
||||
GLenum static const sunlight{ GL_LIGHT0 };
|
||||
GLenum static const ambientlight{ GL_LIGHT1 };
|
||||
|
||||
enum class rendermode {
|
||||
color
|
||||
};
|
||||
|
||||
rendermode renderpass{ rendermode::color };
|
||||
};
|
||||
|
||||
struct opengl_light {
|
||||
|
||||
GLuint id{ -1 };
|
||||
Math3D::vector3 direction;
|
||||
GLfloat position[ 4 ]; // 4th parameter specifies directional(0) or omni-directional(1) light source
|
||||
GLfloat ambient[ 4 ];
|
||||
GLfloat diffuse[ 4 ];
|
||||
GLfloat specular[ 4 ];
|
||||
|
||||
opengl_light() {
|
||||
position[ 0 ] = position[ 1 ] = position[ 2 ] = 0.0f; position[ 3 ] = 1.0f;
|
||||
ambient[ 0 ] = ambient[ 1 ] = ambient[ 2 ] = ambient[ 3 ] = 1.0f;
|
||||
diffuse[ 0 ] = diffuse[ 1 ] = diffuse[ 2 ] = diffuse[ 3 ] = 1.0f;
|
||||
specular[ 0 ] = specular[ 1 ] = specular[ 2 ] = specular[ 3 ] = 1.0f;
|
||||
}
|
||||
|
||||
inline
|
||||
void apply_intensity() {
|
||||
|
||||
glLightfv( id, GL_AMBIENT, ambient );
|
||||
glLightfv( id, GL_DIFFUSE, diffuse );
|
||||
glLightfv( id, GL_SPECULAR, specular );
|
||||
}
|
||||
inline
|
||||
void apply_angle() {
|
||||
|
||||
glLightfv( id, GL_POSITION, position );
|
||||
if( position[ 3 ] == 1.0f ) {
|
||||
GLfloat directionarray[] = { direction.x, direction.y, direction.z };
|
||||
glLightfv( id, GL_SPOT_DIRECTION, directionarray );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class TTranscript
|
||||
{ // klasa obsługująca linijkę napisu do dźwięku
|
||||
public:
|
||||
|
||||
14
Ground.cpp
14
Ground.cpp
@@ -23,7 +23,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Logs.h"
|
||||
#include "usefull.h"
|
||||
#include "Timer.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
#include "Event.h"
|
||||
#include "EvLaunch.h"
|
||||
#include "TractionPower.h"
|
||||
@@ -276,7 +276,7 @@ void TGroundNode::RaRenderVBO()
|
||||
{ // renderowanie z domyslnego bufora VBO
|
||||
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
|
||||
if (TextureID)
|
||||
TextureManager.Bind(TextureID); // Ustaw aktywną teksturę
|
||||
GfxRenderer.Bind(TextureID); // Ustaw aktywną teksturę
|
||||
glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójkąty
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ void TGroundNode::Compile(bool many)
|
||||
#ifdef USE_VERTEX_ARRAYS
|
||||
glVertexPointer(3, GL_DOUBLE, sizeof(vector3), &Points[0].x);
|
||||
#endif
|
||||
TextureManager.Bind(0);
|
||||
GfxRenderer.Bind(0);
|
||||
#ifdef USE_VERTEX_ARRAYS
|
||||
glDrawArrays(iType, 0, iNumPts);
|
||||
#else
|
||||
@@ -478,7 +478,7 @@ void TGroundNode::Compile(bool many)
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(TGroundVertex), &tri->Vertices[0].tu);
|
||||
#endif
|
||||
glColor3ub(tri->Diffuse[0], tri->Diffuse[1], tri->Diffuse[2]);
|
||||
TextureManager.Bind(Global::bWireFrame ? 0 : tri->TextureID);
|
||||
GfxRenderer.Bind(Global::bWireFrame ? 0 : tri->TextureID);
|
||||
#ifdef USE_VERTEX_ARRAYS
|
||||
glDrawArrays(Global::bWireFrame ? GL_LINE_LOOP : tri->iType, 0, tri->iNumVerts);
|
||||
#else
|
||||
@@ -506,7 +506,7 @@ void TGroundNode::Compile(bool many)
|
||||
else if (iType == TP_MESH)
|
||||
{ // grupa ze wspólną teksturą - wrzucanie do wspólnego Display List
|
||||
if (TextureID)
|
||||
TextureManager.Bind(TextureID); // Ustaw aktywną teksturę
|
||||
GfxRenderer.Bind(TextureID); // Ustaw aktywną teksturę
|
||||
TGroundNode *n = nNode;
|
||||
while (n ? n->TextureID == TextureID : false)
|
||||
{ // wszystkie obiekty o tej samej testurze
|
||||
@@ -2133,8 +2133,8 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
tmp->PROBLEND = false;
|
||||
}
|
||||
#endif
|
||||
tmp->TextureID = TextureManager.GetTextureId( str, szTexturePath );
|
||||
tmp->iFlags = TextureManager.Texture(tmp->TextureID).has_alpha ? 0x220 : 0x210; // z usuwaniem
|
||||
tmp->TextureID = GfxRenderer.GetTextureId( str, szTexturePath );
|
||||
tmp->iFlags = GfxRenderer.Texture(tmp->TextureID).has_alpha ? 0x220 : 0x210; // z usuwaniem
|
||||
if (((tmp->iType == GL_TRIANGLES) && (tmp->iFlags & 0x10)) ?
|
||||
Global::pTerrainCompact->TerrainLoaded() :
|
||||
false)
|
||||
|
||||
36
Model3d.cpp
36
Model3d.cpp
@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "logs.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "Usefull.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "mtable.h"
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -411,12 +411,12 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
|
||||
TextureNameSet(texture.c_str());
|
||||
if (texture.find_first_of("/\\") == texture.npos)
|
||||
texture.insert(0, Global::asCurrentTexturePath.c_str());
|
||||
TextureID = TextureManager.GetTextureId( texture, szTexturePath );
|
||||
TextureID = GfxRenderer.GetTextureId( texture, szTexturePath );
|
||||
// TexAlpha=TTexturesManager::GetAlpha(TextureID);
|
||||
// iFlags|=TexAlpha?0x20:0x10; //0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||
if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity
|
||||
// 0!
|
||||
iFlags |= TextureManager.Texture(TextureID).has_alpha ?
|
||||
iFlags |= GfxRenderer.Texture(TextureID).has_alpha ?
|
||||
0x20 :
|
||||
0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||
else
|
||||
@@ -636,7 +636,7 @@ int TSubModel::TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri)
|
||||
m->AddTo(this, s);
|
||||
}
|
||||
// s->asTexture=AnsiString(TTexturesManager::GetName(tex).c_str());
|
||||
s->TextureNameSet(TextureManager.Texture(tex).name.c_str());
|
||||
s->TextureNameSet(GfxRenderer.Texture(tex).name.c_str());
|
||||
s->TextureID = tex;
|
||||
s->eType = GL_TRIANGLES;
|
||||
// iAnimOwner=0; //roboczy wskaźnik na wierzchołek
|
||||
@@ -714,7 +714,7 @@ void TSubModel::DisplayLists()
|
||||
{
|
||||
uiDisplayList = glGenLists(1);
|
||||
glNewList(uiDisplayList, GL_COMPILE);
|
||||
TextureManager.Bind(0);
|
||||
GfxRenderer.Bind(0);
|
||||
// if (eType==smt_FreeSpotLight)
|
||||
// {
|
||||
// if (iFarAttenDecay==0)
|
||||
@@ -737,7 +737,7 @@ void TSubModel::DisplayLists()
|
||||
{ // punkty świecące dookólnie
|
||||
uiDisplayList = glGenLists(1);
|
||||
glNewList(uiDisplayList, GL_COMPILE);
|
||||
TextureManager.Bind(0); // tekstury nie ma
|
||||
GfxRenderer.Bind(0); // tekstury nie ma
|
||||
glColorMaterial(GL_FRONT, GL_EMISSION);
|
||||
glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly
|
||||
glBegin(GL_POINTS);
|
||||
@@ -1100,11 +1100,11 @@ void TSubModel::RenderDL()
|
||||
{
|
||||
if (TextureID < 0) // && (ReplacableSkinId!=0))
|
||||
{ // zmienialne skóry
|
||||
TextureManager.Bind(ReplacableSkinId[-TextureID]);
|
||||
GfxRenderer.Bind(ReplacableSkinId[-TextureID]);
|
||||
// TexAlpha=!(iAlpha&1); //zmiana tylko w przypadku wymienej tekstury
|
||||
}
|
||||
else
|
||||
TextureManager.Bind(TextureID); // również 0
|
||||
GfxRenderer.Bind(TextureID); // również 0
|
||||
if (Global::fLuminance < fLight)
|
||||
{
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo
|
||||
@@ -1197,11 +1197,11 @@ void TSubModel::RenderAlphaDL()
|
||||
{
|
||||
if (TextureID < 0) // && (ReplacableSkinId!=0))
|
||||
{ // zmienialne skóry
|
||||
TextureManager.Bind(ReplacableSkinId[-TextureID]);
|
||||
GfxRenderer.Bind(ReplacableSkinId[-TextureID]);
|
||||
// TexAlpha=iAlpha&1; //zmiana tylko w przypadku wymienej tekstury
|
||||
}
|
||||
else
|
||||
TextureManager.Bind(TextureID); // również 0
|
||||
GfxRenderer.Bind(TextureID); // również 0
|
||||
if (Global::fLuminance < fLight)
|
||||
{
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo
|
||||
@@ -1278,11 +1278,11 @@ void TSubModel::RenderVBO()
|
||||
{
|
||||
if (TextureID < 0) // && (ReplacableSkinId!=0))
|
||||
{ // zmienialne skóry
|
||||
TextureManager.Bind(ReplacableSkinId[-TextureID]);
|
||||
GfxRenderer.Bind(ReplacableSkinId[-TextureID]);
|
||||
// TexAlpha=!(iAlpha&1); //zmiana tylko w przypadku wymienej tekstury
|
||||
}
|
||||
else
|
||||
TextureManager.Bind(TextureID); // również 0
|
||||
GfxRenderer.Bind(TextureID); // również 0
|
||||
glColor3fv(f4Diffuse); // McZapkie-240702: zamiast ub
|
||||
// glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,f4Diffuse); //to samo,
|
||||
// co glColor
|
||||
@@ -1349,7 +1349,7 @@ void TSubModel::RenderVBO()
|
||||
Distdimm=1;
|
||||
|
||||
*/
|
||||
TextureManager.Bind(0); // nie teksturować
|
||||
GfxRenderer.Bind(0); // nie teksturować
|
||||
// glColor3f(f4Diffuse[0],f4Diffuse[1],f4Diffuse[2]);
|
||||
// glColorMaterial(GL_FRONT,GL_EMISSION);
|
||||
float color[4] = {f4Diffuse[0] * Distdimm, f4Diffuse[1] * Distdimm,
|
||||
@@ -1378,7 +1378,7 @@ void TSubModel::RenderVBO()
|
||||
if (pRoot->StartColorVBO())
|
||||
{ // wyświetlanie kolorowych punktów zamiast
|
||||
// trójkątów
|
||||
TextureManager.Bind(0); // tekstury nie ma
|
||||
GfxRenderer.Bind(0); // tekstury nie ma
|
||||
glColorMaterial(GL_FRONT, GL_EMISSION);
|
||||
glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie
|
||||
// blendowaly
|
||||
@@ -1452,11 +1452,11 @@ void TSubModel::RenderAlphaVBO()
|
||||
{
|
||||
if (TextureID < 0) // && (ReplacableSkinId!=0))
|
||||
{ // zmienialne skory
|
||||
TextureManager.Bind(ReplacableSkinId[-TextureID]);
|
||||
GfxRenderer.Bind(ReplacableSkinId[-TextureID]);
|
||||
// TexAlpha=iAlpha&1; //zmiana tylko w przypadku wymienej tekstury
|
||||
}
|
||||
else
|
||||
TextureManager.Bind(TextureID); // również 0
|
||||
GfxRenderer.Bind(TextureID); // również 0
|
||||
if (Global::fLuminance < fLight)
|
||||
{
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo
|
||||
@@ -1624,14 +1624,14 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TS
|
||||
std::string tex = pTexture;
|
||||
if (tex.find_last_of("/\\") == std::string::npos)
|
||||
tex.insert(0, Global::asCurrentTexturePath);
|
||||
TextureID = TextureManager.GetTextureId( tex, szTexturePath );
|
||||
TextureID = GfxRenderer.GetTextureId( tex, szTexturePath );
|
||||
// TexAlpha=TTexturesManager::GetAlpha(TextureID); //zmienna robocza
|
||||
// ustawienie cyklu przezroczyste/nieprzezroczyste zależnie od własności
|
||||
// stałej tekstury
|
||||
// iFlags=(iFlags&~0x30)|(TTexturesManager::GetAlpha(TextureID)?0x20:0x10);
|
||||
// //0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||
if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity 0!
|
||||
iFlags |= TextureManager.Texture(TextureID).has_alpha ?
|
||||
iFlags |= GfxRenderer.Texture(TextureID).has_alpha ?
|
||||
0x20 :
|
||||
0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||
else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "PyInt.h"
|
||||
#include "renderer.h"
|
||||
#include "Train.h"
|
||||
#include "Logs.h"
|
||||
//#include <process.h>
|
||||
@@ -453,7 +454,7 @@ void TPythonScreens::init(cParser &parser, TModel3d *model, std::string const &n
|
||||
WriteLog( "Python Screen: submodel " + subModelName + " not found - Ignoring screen" );
|
||||
return; // nie ma takiego sub modelu w danej kabinie pomijamy
|
||||
}
|
||||
int textureId = TextureManager.Texture(subModel->GetTextureId()).id;
|
||||
int textureId = GfxRenderer.Texture(subModel->GetTextureId()).id;
|
||||
if (textureId <= 0)
|
||||
{
|
||||
WriteLog( "Python Screen: invalid texture id " + std::to_string(textureId) + " - Ignoring screen" );
|
||||
|
||||
@@ -641,7 +641,7 @@ void TSegment::RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *Shap
|
||||
void TSegment::Render()
|
||||
{
|
||||
vector3 pt;
|
||||
TextureManager.Bind(0);
|
||||
GfxRenderer.Bind(0);
|
||||
int i;
|
||||
if (bCurve)
|
||||
{
|
||||
|
||||
11
Texture.cpp
11
Texture.cpp
@@ -14,19 +14,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Texture.h"
|
||||
#include "texture.h"
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include "opengl/glew.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "usefull.h"
|
||||
#include "globals.h"
|
||||
#include "logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "TextureDDS.h"
|
||||
|
||||
texture_manager TextureManager;
|
||||
|
||||
texture_manager::texture_manager() {
|
||||
|
||||
|
||||
@@ -97,5 +97,3 @@ private:
|
||||
index_map m_texturemappings;
|
||||
size_type m_activetexture{ 0 }; // last i.e. currently bound texture
|
||||
};
|
||||
|
||||
extern texture_manager TextureManager;
|
||||
50
Track.cpp
50
Track.cpp
@@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "Ground.h"
|
||||
#include "parser.h"
|
||||
@@ -508,7 +508,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
|
||||
parser->getTokens();
|
||||
*parser >> token;
|
||||
str = token; // railtex
|
||||
TextureID1 = (str == "none" ? 0 : TextureManager.GetTextureId(
|
||||
TextureID1 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
||||
str, szTexturePath,
|
||||
(iCategoryFlag & 1) ? Global::iRailProFiltering :
|
||||
Global::iBallastFiltering));
|
||||
@@ -519,7 +519,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
|
||||
parser->getTokens();
|
||||
*parser >> token;
|
||||
str = token; // sub || railtex
|
||||
TextureID2 = (str == "none" ? 0 : TextureManager.GetTextureId(
|
||||
TextureID2 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
||||
str, szTexturePath,
|
||||
(eType == tt_Normal) ? Global::iBallastFiltering :
|
||||
Global::iRailProFiltering));
|
||||
@@ -579,12 +579,12 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
|
||||
if (TextureID1 && fTexLength)
|
||||
{ // dla drogi trzeba ustalić proporcje boków nawierzchni
|
||||
float w, h;
|
||||
TextureManager.Bind(TextureID1);
|
||||
GfxRenderer.Bind(TextureID1);
|
||||
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
||||
if (h != 0.0)
|
||||
fTexRatio1 = w / h; // proporcja boków
|
||||
TextureManager.Bind(TextureID2);
|
||||
GfxRenderer.Bind(TextureID2);
|
||||
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
||||
if (h != 0.0)
|
||||
@@ -1299,14 +1299,14 @@ void TTrack::Compile(GLuint tex)
|
||||
}
|
||||
}
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID2 );
|
||||
GfxRenderer.Bind( TextureID2 );
|
||||
Segment->RenderLoft(bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
||||
}
|
||||
if (TextureID1)
|
||||
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
||||
{ // szyny
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
Segment->RenderLoft(rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||
Segment->RenderLoft(rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||
}
|
||||
@@ -1345,7 +1345,7 @@ void TTrack::Compile(GLuint tex)
|
||||
// McZapkie-130302 - poprawione rysowanie szyn
|
||||
if (SwitchExtension->RightSwitch)
|
||||
{ // zwrotnica prawa
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
SwitchExtension->Segments[0]->RenderLoft(rpts1, nnumPts, fTexLength,
|
||||
2); // prawa szyna za iglicą
|
||||
SwitchExtension->Segments[0]->RenderSwitchRail(
|
||||
@@ -1354,7 +1354,7 @@ void TTrack::Compile(GLuint tex)
|
||||
SwitchExtension->Segments[0]->RenderLoft(
|
||||
rpts2, nnumPts, fTexLength); // lewa szyna normalnie cała
|
||||
if (TextureID2 != TextureID1) // nie wiadomo, czy OpenGL to optymalizuje
|
||||
TextureManager.Bind( TextureID2 );
|
||||
GfxRenderer.Bind( TextureID2 );
|
||||
SwitchExtension->Segments[1]->RenderLoft(
|
||||
rpts1, nnumPts, fTexLength); // prawa szyna normalna cała
|
||||
SwitchExtension->Segments[1]->RenderLoft(rpts2, nnumPts, fTexLength,
|
||||
@@ -1365,7 +1365,7 @@ void TTrack::Compile(GLuint tex)
|
||||
}
|
||||
else
|
||||
{ // lewa kiedyś działała lepiej niż prawa
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
SwitchExtension->Segments[0]->RenderLoft(
|
||||
rpts1, nnumPts, fTexLength); // prawa szyna normalna cała
|
||||
SwitchExtension->Segments[0]->RenderLoft(rpts2, nnumPts, fTexLength,
|
||||
@@ -1374,7 +1374,7 @@ void TTrack::Compile(GLuint tex)
|
||||
rpts2, rpts4, nnumPts, fTexLength, 2,
|
||||
-SwitchExtension->fOffset2); // lewa iglica
|
||||
if (TextureID2 != TextureID1) // nie wiadomo, czy OpenGL to optymalizuje
|
||||
TextureManager.Bind( TextureID2 );
|
||||
GfxRenderer.Bind( TextureID2 );
|
||||
SwitchExtension->Segments[1]->RenderLoft(rpts1, nnumPts, fTexLength,
|
||||
2); // prawa szyna za iglicą
|
||||
SwitchExtension->Segments[1]->RenderSwitchRail(
|
||||
@@ -1422,7 +1422,7 @@ void TTrack::Compile(GLuint tex)
|
||||
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
||||
{ // tworzenie trójkątów nawierzchni szosy
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
Segment->RenderLoft(bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
||||
}
|
||||
if (TextureID2)
|
||||
@@ -1430,7 +1430,7 @@ void TTrack::Compile(GLuint tex)
|
||||
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak
|
||||
// w Midtown Madness 2?)
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID2 );
|
||||
GfxRenderer.Bind( TextureID2 );
|
||||
vector6 rpts1[6],
|
||||
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
|
||||
if (fTexHeight1 >= 0.0)
|
||||
@@ -1610,7 +1610,7 @@ void TTrack::Compile(GLuint tex)
|
||||
// Midtown Madness 2?)
|
||||
if (TextureID2)
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID2 );
|
||||
GfxRenderer.Bind( TextureID2 );
|
||||
vector6 rpts1[6],
|
||||
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
|
||||
// Ra 2014-07: trzeba to przerobić na pętlę i pobierać profile (przynajmniej 2..4) z
|
||||
@@ -1755,7 +1755,7 @@ void TTrack::Compile(GLuint tex)
|
||||
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
||||
{
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
glBegin(GL_TRIANGLE_FAN); // takie kółeczko będzie
|
||||
glNormal3f(0, 1, 0);
|
||||
glTexCoord2f(0.5, 0.5); //środek tekstury na środku skrzyżowania
|
||||
@@ -1787,7 +1787,7 @@ void TTrack::Compile(GLuint tex)
|
||||
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
||||
{
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID1 );
|
||||
GfxRenderer.Bind( TextureID1 );
|
||||
Segment->RenderLoft(bpts1, numPts, fTexLength);
|
||||
}
|
||||
if (TextureID2)
|
||||
@@ -1799,7 +1799,7 @@ void TTrack::Compile(GLuint tex)
|
||||
vector6 rpts2[3] = {vector6(-fHTW, 0.0, 1.0), vector6(-fHTW - side, 0.0, 0.5),
|
||||
vector6(-rozp, -fTexHeight1, 0.0)}; // Ra: po kiego 0.1?
|
||||
if (!tex)
|
||||
TextureManager.Bind( TextureID2 ); // brzeg rzeki
|
||||
GfxRenderer.Bind( TextureID2 ); // brzeg rzeki
|
||||
Segment->RenderLoft(rpts1, 3, fTexLength);
|
||||
Segment->RenderLoft(rpts2, 3, fTexLength);
|
||||
}
|
||||
@@ -2473,7 +2473,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
if (TextureID1)
|
||||
if ((seg = SwitchExtension->Segments[0]->RaSegCount()) > 0)
|
||||
{
|
||||
TextureManager.Bind( TextureID1 ); // szyny +
|
||||
GfxRenderer.Bind( TextureID1 ); // szyny +
|
||||
for (i = 0; i < seg; ++i)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24);
|
||||
iPtr += 24 * seg; // pominięcie lewej szyny
|
||||
@@ -2484,7 +2484,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
if (TextureID2)
|
||||
if ((seg = SwitchExtension->Segments[1]->RaSegCount()) > 0)
|
||||
{
|
||||
TextureManager.Bind( TextureID2 ); // szyny -
|
||||
GfxRenderer.Bind( TextureID2 ); // szyny -
|
||||
for (i = 0; i < seg; ++i)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24);
|
||||
iPtr += 24 * seg; // pominięcie lewej szyny
|
||||
@@ -2498,14 +2498,14 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
{
|
||||
if (TextureID2)
|
||||
{
|
||||
TextureManager.Bind( TextureID2 ); // podsypka
|
||||
GfxRenderer.Bind( TextureID2 ); // podsypka
|
||||
for (i = 0; i < seg; ++i)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 8 * i, 8);
|
||||
iPtr += 8 * seg; // pominięcie podsypki
|
||||
}
|
||||
if (TextureID1)
|
||||
{
|
||||
TextureManager.Bind( TextureID1 ); // szyny
|
||||
GfxRenderer.Bind( TextureID1 ); // szyny
|
||||
for (i = 0; i < seg; ++i)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24);
|
||||
iPtr += 24 * seg; // pominięcie lewej szyny
|
||||
@@ -2520,7 +2520,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
{
|
||||
if (TextureID1)
|
||||
{
|
||||
TextureManager.Bind( TextureID1 ); // nawierzchnia
|
||||
GfxRenderer.Bind( TextureID1 ); // nawierzchnia
|
||||
for (i = 0; i < seg; ++i)
|
||||
{
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr, 4);
|
||||
@@ -2529,7 +2529,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
}
|
||||
if (TextureID2)
|
||||
{
|
||||
TextureManager.Bind( TextureID2 ); // pobocze
|
||||
GfxRenderer.Bind( TextureID2 ); // pobocze
|
||||
if (fTexHeight1 >= 0.0)
|
||||
{ // normalna droga z poboczem
|
||||
for (i = 0; i < seg; ++i)
|
||||
@@ -2558,7 +2558,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
{
|
||||
if (TextureID1)
|
||||
{
|
||||
TextureManager.Bind( TextureID1 ); // nawierzchnia
|
||||
GfxRenderer.Bind( TextureID1 ); // nawierzchnia
|
||||
for (i = 0; i < seg; ++i)
|
||||
{
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr, 4);
|
||||
@@ -2567,7 +2567,7 @@ void TTrack::RaRenderVBO(int iPtr)
|
||||
}
|
||||
if (TextureID2)
|
||||
{
|
||||
TextureManager.Bind( TextureID2 ); // pobocze
|
||||
GfxRenderer.Bind( TextureID2 ); // pobocze
|
||||
for (i = 0; i < seg; ++i)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6);
|
||||
iPtr += 6 * seg; // pominięcie lewego pobocza
|
||||
|
||||
@@ -18,7 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "logs.h"
|
||||
#include "mctools.h"
|
||||
#include "TractionPower.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
@@ -116,7 +116,7 @@ void TTraction::Optimize()
|
||||
uiDisplayList = glGenLists(1);
|
||||
glNewList(uiDisplayList, GL_COMPILE);
|
||||
|
||||
TextureManager.Bind(0);
|
||||
GfxRenderer.Bind(0);
|
||||
// glColor3ub(0,0,0); McZapkie: to do render
|
||||
|
||||
// glPushMatrix();
|
||||
@@ -469,7 +469,7 @@ void TTraction::RenderVBO(float mgn, int iPtr)
|
||||
{ // renderowanie z użyciem VBO
|
||||
if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana
|
||||
{
|
||||
TextureManager.Bind(0);
|
||||
GfxRenderer.Bind(0);
|
||||
glDisable(GL_LIGHTING); // aby nie używało wektorów normalnych do kolorowania
|
||||
glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste
|
||||
if (!Global::bSmoothTraction)
|
||||
|
||||
16
World.cpp
16
World.cpp
@@ -21,7 +21,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "MdlMngr.h"
|
||||
#include "Texture.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "mtable.h"
|
||||
#include "Sound.h"
|
||||
@@ -487,8 +487,8 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
||||
glColor3f( 1.0f, 1.0f, 1.0f );
|
||||
#endif
|
||||
|
||||
auto logo = TextureManager.GetTextureId( "logo", szTexturePath, 6 );
|
||||
TextureManager.Bind(logo); // Select our texture
|
||||
auto logo = GfxRenderer.GetTextureId( "logo", szTexturePath, 6 );
|
||||
GfxRenderer.Bind(logo); // Select our texture
|
||||
|
||||
glBegin(GL_QUADS); // Drawing using triangles
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
@@ -688,9 +688,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //{Texture blends with object
|
||||
// background}
|
||||
if (Global::bOldSmudge == true)
|
||||
light = TextureManager.GetTextureId( "smuga.tga", szTexturePath );
|
||||
light = GfxRenderer.GetTextureId( "smuga.tga", szTexturePath );
|
||||
else
|
||||
light = TextureManager.GetTextureId( "smuga2.tga", szTexturePath );
|
||||
light = GfxRenderer.GetTextureId( "smuga2.tga", szTexturePath );
|
||||
// Camera.Reset();
|
||||
Timer::ResetTimers();
|
||||
WriteLog( "Load time: " +
|
||||
@@ -1661,7 +1661,7 @@ TWorld::Render_Cab() {
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_LIGHTING );
|
||||
glDisable( GL_FOG );
|
||||
TextureManager.Bind( light ); // Select our texture
|
||||
GfxRenderer.Bind( light ); // Select our texture
|
||||
glBegin( GL_QUADS );
|
||||
float fSmudge =
|
||||
dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę
|
||||
@@ -1703,7 +1703,7 @@ TWorld::Render_Cab() {
|
||||
glDisable( GL_LIGHTING );
|
||||
glDisable( GL_FOG );
|
||||
//glColor4f(0.15f, 0.15f, 0.15f, 0.25f);
|
||||
TextureManager.Bind( light ); // Select our texture
|
||||
GfxRenderer.Bind( light ); // Select our texture
|
||||
//float ddl = (0.15*Global::diffuseDayLight[0]+0.295*Global::diffuseDayLight[1]+0.055*Global::diffuseDayLight[2]); //0.24:0
|
||||
glBegin( GL_QUADS );
|
||||
float fSmudge = dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę
|
||||
@@ -2011,7 +2011,7 @@ TWorld::Render_UI() {
|
||||
SetWindowText( hWnd, Controlled->MoverParameters->Name.c_str() );
|
||||
else
|
||||
SetWindowText( hWnd, Global::SceneryFile.c_str() ); // nazwa scenerii
|
||||
TextureManager.Bind( 0 );
|
||||
GfxRenderer.Bind( 0 );
|
||||
glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
|
||||
glLoadIdentity();
|
||||
glTranslatef( 0.0f, 0.0f, -0.50f );
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
<ClCompile Include="parser.cpp" />
|
||||
<ClCompile Include="PyInt.cpp" />
|
||||
<ClCompile Include="RealSound.cpp" />
|
||||
<ClCompile Include="renderer.cpp" />
|
||||
<ClCompile Include="ResourceManager.cpp" />
|
||||
<ClCompile Include="Segment.cpp" />
|
||||
<ClCompile Include="sky.cpp" />
|
||||
@@ -180,6 +181,7 @@
|
||||
<ClInclude Include="PyInt.h" />
|
||||
<ClInclude Include="python\include\Python.h" />
|
||||
<ClInclude Include="RealSound.h" />
|
||||
<ClInclude Include="renderer.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="ResourceManager.h" />
|
||||
<ClInclude Include="Segment.h" />
|
||||
|
||||
@@ -192,6 +192,9 @@
|
||||
<ClCompile Include="sun.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="opengl\glew.h">
|
||||
@@ -371,6 +374,9 @@
|
||||
<ClInclude Include="sun.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="maszyna.rc">
|
||||
|
||||
15
renderer.cpp
Normal file
15
renderer.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "renderer.h"
|
||||
|
||||
opengl_renderer GfxRenderer;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
99
renderer.h
Normal file
99
renderer.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opengl/glew.h"
|
||||
#include "texture.h"
|
||||
#include "dumb3d.h"
|
||||
|
||||
struct opengl_light {
|
||||
|
||||
GLuint id{ -1 };
|
||||
Math3D::vector3 direction;
|
||||
GLfloat position[ 4 ]; // 4th parameter specifies directional(0) or omni-directional(1) light source
|
||||
GLfloat ambient[ 4 ];
|
||||
GLfloat diffuse[ 4 ];
|
||||
GLfloat specular[ 4 ];
|
||||
|
||||
opengl_light() {
|
||||
position[ 0 ] = position[ 1 ] = position[ 2 ] = 0.0f; position[ 3 ] = 1.0f;
|
||||
ambient[ 0 ] = ambient[ 1 ] = ambient[ 2 ] = ambient[ 3 ] = 1.0f;
|
||||
diffuse[ 0 ] = diffuse[ 1 ] = diffuse[ 2 ] = diffuse[ 3 ] = 1.0f;
|
||||
specular[ 0 ] = specular[ 1 ] = specular[ 2 ] = specular[ 3 ] = 1.0f;
|
||||
}
|
||||
|
||||
inline
|
||||
void apply_intensity() {
|
||||
|
||||
glLightfv( id, GL_AMBIENT, ambient );
|
||||
glLightfv( id, GL_DIFFUSE, diffuse );
|
||||
glLightfv( id, GL_SPECULAR, specular );
|
||||
}
|
||||
inline
|
||||
void apply_angle() {
|
||||
|
||||
glLightfv( id, GL_POSITION, position );
|
||||
if( position[ 3 ] == 1.0f ) {
|
||||
GLfloat directionarray[] = { direction.x, direction.y, direction.z };
|
||||
glLightfv( id, GL_SPOT_DIRECTION, directionarray );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// encapsulates basic rendering setup.
|
||||
// for modern opengl this translates to a specific collection of glsl shaders,
|
||||
// for legacy opengl this is combination of blending modes, active texture units etc
|
||||
struct opengl_technique {
|
||||
|
||||
};
|
||||
|
||||
// a collection of parameters for the rendering setup.
|
||||
// for modern opengl this translates to set of attributes for the active shaders,
|
||||
// for legacy opengl this is basically just texture(s) assigned to geometry
|
||||
struct opengl_material {
|
||||
|
||||
};
|
||||
|
||||
// bare-bones render controller, in lack of anything better yet
|
||||
class opengl_renderer {
|
||||
|
||||
public:
|
||||
GLenum static const sunlight{ GL_LIGHT0 };
|
||||
// GLenum static const ambientlight{ GL_LIGHT1 };
|
||||
|
||||
texture_manager::size_type
|
||||
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true ) {
|
||||
|
||||
return m_textures.GetTextureId( Filename, Dir, Filter, Loadnow );
|
||||
}
|
||||
void
|
||||
Bind( texture_manager::size_type const Id ) {
|
||||
// temporary until we separate the renderer
|
||||
m_textures.Bind( Id );
|
||||
}
|
||||
opengl_texture &
|
||||
Texture( texture_manager::size_type const Id ) {
|
||||
|
||||
return m_textures.Texture( Id );
|
||||
}
|
||||
|
||||
private:
|
||||
enum class rendermode {
|
||||
color
|
||||
};
|
||||
|
||||
rendermode renderpass{ rendermode::color };
|
||||
|
||||
texture_manager m_textures;
|
||||
};
|
||||
|
||||
extern opengl_renderer GfxRenderer;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user