mirror of
https://github.com/glest/glest-source.git
synced 2025-08-31 19:51:44 +02:00
Full transparency support is now added
This commit is contained in:
@@ -407,7 +407,8 @@ namespace Shared {
|
||||
menuCustomColor->AppendCheckItem(miColorWhite, wxT("&White\t4"));
|
||||
menuCustomColor->AppendCheckItem(miColorCyan, wxT("&Cyan\t5"));
|
||||
menuCustomColor->AppendCheckItem(miColorOrange, wxT("&Orange\t6"));
|
||||
menuCustomColor->AppendCheckItem(miColorMagenta, wxT("&Pink\t7")); // it is called Pink everywhere else so...
|
||||
menuCustomColor->AppendCheckItem(miColorMagenta, wxT("&Pink\t7"));
|
||||
menuCustomColor->AppendCheckItem(miColorTransparent, wxT("&Transparent\t8"));
|
||||
menu->Append(menuCustomColor, wxT("&Custom Color"));
|
||||
|
||||
menuMode->Check(miModeGrid, true);
|
||||
@@ -1388,8 +1389,7 @@ namespace Shared {
|
||||
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
|
||||
ups->setPos(vec);
|
||||
}
|
||||
//ups->setFactionColor(getFaction()->getTexture()->getPixmap()->getPixel3f(0,0));
|
||||
ups->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel3f(0, 0));
|
||||
ups->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel4f(0, 0));
|
||||
unitParticleSystems.push_back(ups);
|
||||
renderer->manageParticleSystem(ups);
|
||||
|
||||
@@ -1502,7 +1502,7 @@ namespace Shared {
|
||||
Vec3f vec2 = Vec3f(size * 2.f, height * 2.f, height * 2.f);
|
||||
ps->setPath(vec, vec2);
|
||||
}
|
||||
ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel3f(0, 0));
|
||||
ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel4f(0, 0));
|
||||
|
||||
projectileParticleSystems.push_back(ps);
|
||||
|
||||
@@ -1609,7 +1609,7 @@ namespace Shared {
|
||||
//Vec3f vec2 = Vec3f(size * 2.f, height * 2.f, height * 2.f); // <------- removed relative projectile
|
||||
//ps->setPath(vec, vec2); // <------- removed relative projectile
|
||||
}
|
||||
ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel3f(0, 0));
|
||||
ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel4f(0, 0));
|
||||
|
||||
splashParticleSystems.push_back(ps);
|
||||
|
||||
@@ -1706,6 +1706,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1723,6 +1724,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1740,6 +1742,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1757,6 +1760,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1774,6 +1778,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1791,6 +1796,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, true);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1808,6 +1814,7 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, true);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1825,6 +1832,25 @@ namespace Shared {
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, true);
|
||||
menuCustomColor->Check(miColorTransparent, false);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onMenuColorTransparent(wxCommandEvent &event) {
|
||||
try {
|
||||
playerColor = Renderer::pcTransparent;
|
||||
menuCustomColor->Check(miColorRed, false);
|
||||
menuCustomColor->Check(miColorBlue, false);
|
||||
menuCustomColor->Check(miColorGreen, false);
|
||||
menuCustomColor->Check(miColorYellow, false);
|
||||
menuCustomColor->Check(miColorWhite, false);
|
||||
menuCustomColor->Check(miColorCyan, false);
|
||||
menuCustomColor->Check(miColorOrange, false);
|
||||
menuCustomColor->Check(miColorMagenta, false);
|
||||
menuCustomColor->Check(miColorTransparent, true);
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||
@@ -1982,6 +2008,7 @@ namespace Shared {
|
||||
EVT_MENU(miColorCyan, MainWindow::onMenuColorCyan)
|
||||
EVT_MENU(miColorOrange, MainWindow::onMenuColorOrange)
|
||||
EVT_MENU(miColorMagenta, MainWindow::onMenuColorMagenta)
|
||||
EVT_MENU(miColorTransparent, MainWindow::onMenuColorTransparent)
|
||||
|
||||
EVT_MENU(miChangeBackgroundColor, MainWindow::OnChangeColor)
|
||||
END_EVENT_TABLE()
|
||||
|
@@ -71,7 +71,8 @@ namespace Shared {
|
||||
miColorWhite,
|
||||
miColorCyan,
|
||||
miColorOrange,
|
||||
miColorMagenta
|
||||
miColorMagenta,
|
||||
miColorTransparent
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -172,6 +173,7 @@ namespace Shared {
|
||||
void onMenuColorCyan(wxCommandEvent &event);
|
||||
void onMenuColorOrange(wxCommandEvent &event);
|
||||
void onMenuColorMagenta(wxCommandEvent &event);
|
||||
void onMenuColorTransparent(wxCommandEvent &event);
|
||||
void onMouseWheelDown(wxMouseEvent &event);
|
||||
void onMouseWheelUp(wxMouseEvent &event);
|
||||
void onMouseMove(wxMouseEvent &event);
|
||||
|
@@ -54,7 +54,7 @@ namespace Shared {
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
|
||||
|
||||
//set alpha to 1
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, hasAlpha ? GL_COMBINE : GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Shared {
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||
|
||||
//set alpha to 1
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, hasAlpha ? GL_COMBINE : GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace Shared {
|
||||
customTextureCyan = NULL;
|
||||
customTextureOrange = NULL;
|
||||
customTextureMagenta = NULL;
|
||||
customTextureTransparent = NULL;
|
||||
particleManager = NULL;
|
||||
}
|
||||
|
||||
@@ -239,43 +240,48 @@ namespace Shared {
|
||||
|
||||
//red tex
|
||||
customTextureRed = textureManager->newTexture2D();
|
||||
customTextureRed->getPixmap()->init(1, 1, 3);
|
||||
customTextureRed->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.f, 0.f));
|
||||
customTextureRed->getPixmap()->init(1, 1, 4);
|
||||
customTextureRed->getPixmap()->setPixel(0, 0, Vec4f(1.f, 0.f, 0.f, 1.0f));
|
||||
|
||||
//blue tex
|
||||
customTextureBlue = textureManager->newTexture2D();
|
||||
customTextureBlue->getPixmap()->init(1, 1, 3);
|
||||
customTextureBlue->getPixmap()->setPixel(0, 0, Vec3f(0.f, 0.f, 1.f));
|
||||
customTextureBlue->getPixmap()->init(1, 1, 4);
|
||||
customTextureBlue->getPixmap()->setPixel(0, 0, Vec4f(0.f, 0.f, 1.f, 1.0f));
|
||||
|
||||
//green tex
|
||||
customTextureGreen = textureManager->newTexture2D();
|
||||
customTextureGreen->getPixmap()->init(1, 1, 3);
|
||||
customTextureGreen->getPixmap()->setPixel(0, 0, Vec3f(0.f, 0.5f, 0.f));
|
||||
customTextureGreen->getPixmap()->init(1, 1, 4);
|
||||
customTextureGreen->getPixmap()->setPixel(0, 0, Vec4f(0.f, 0.5f, 0.f, 1.0f));
|
||||
|
||||
//yellow tex
|
||||
customTextureYellow = textureManager->newTexture2D();
|
||||
customTextureYellow->getPixmap()->init(1, 1, 3);
|
||||
customTextureYellow->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 0.f));
|
||||
customTextureYellow->getPixmap()->init(1, 1, 4);
|
||||
customTextureYellow->getPixmap()->setPixel(0, 0, Vec4f(1.f, 1.f, 0.f, 1.0f));
|
||||
|
||||
//white tex
|
||||
customTextureWhite = textureManager->newTexture2D();
|
||||
customTextureWhite->getPixmap()->init(1, 1, 3);
|
||||
customTextureWhite->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 1.f));
|
||||
customTextureWhite->getPixmap()->init(1, 1, 4);
|
||||
customTextureWhite->getPixmap()->setPixel(0, 0, Vec4f(1.f, 1.f, 1.f, 1.0f));
|
||||
|
||||
//cyan tex
|
||||
customTextureCyan = textureManager->newTexture2D();
|
||||
customTextureCyan->getPixmap()->init(1, 1, 3);
|
||||
customTextureCyan->getPixmap()->setPixel(0, 0, Vec3f(0.f, 1.f, 0.8f));
|
||||
customTextureCyan->getPixmap()->init(1, 1, 4);
|
||||
customTextureCyan->getPixmap()->setPixel(0, 0, Vec4f(0.f, 1.f, 0.8f, 1.0f));
|
||||
|
||||
//orange tex
|
||||
customTextureOrange = textureManager->newTexture2D();
|
||||
customTextureOrange->getPixmap()->init(1, 1, 3);
|
||||
customTextureOrange->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 0.f));
|
||||
customTextureOrange->getPixmap()->init(1, 1, 4);
|
||||
customTextureOrange->getPixmap()->setPixel(0, 0, Vec4f(1.f, 0.5f, 0.f, 1.0f));
|
||||
|
||||
//magenta tex
|
||||
customTextureMagenta = textureManager->newTexture2D();
|
||||
customTextureMagenta->getPixmap()->init(1, 1, 3);
|
||||
customTextureMagenta->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 1.f));
|
||||
customTextureMagenta->getPixmap()->init(1, 1, 4);
|
||||
customTextureMagenta->getPixmap()->setPixel(0, 0, Vec4f(1.f, 0.5f, 1.f, 1.0f));
|
||||
|
||||
//transparent tex
|
||||
customTextureTransparent = textureManager->newTexture2D();
|
||||
customTextureTransparent->getPixmap()->init(1, 1, 4);
|
||||
customTextureTransparent->getPixmap()->setPixel(0, 0, Vec4f(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
|
||||
glClearColor(red, green, blue, alpha); //backgroundcolor constant 0.3
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -332,6 +338,7 @@ namespace Shared {
|
||||
glTranslatef(0, -1.5, -5);
|
||||
|
||||
Texture2D *customTexture = NULL;
|
||||
bool hasAlpha = false;
|
||||
switch (playerColor) {
|
||||
case pcRed:
|
||||
customTexture = customTextureRed;
|
||||
@@ -357,11 +364,15 @@ namespace Shared {
|
||||
case pcMagenta:
|
||||
customTexture = customTextureMagenta;
|
||||
break;
|
||||
case pcTransparent:
|
||||
customTexture = customTextureTransparent;
|
||||
hasAlpha = true;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
meshCallbackTeamColor.setTeamTexture(customTexture);
|
||||
meshCallbackTeamColor.setTeamTexture(customTexture, hasAlpha);
|
||||
|
||||
if (wireframe) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
@@ -483,6 +494,9 @@ namespace Shared {
|
||||
case pcMagenta:
|
||||
customTexture = customTextureMagenta;
|
||||
break;
|
||||
case pcTransparent:
|
||||
customTexture = customTextureTransparent;
|
||||
break;
|
||||
default:
|
||||
throw megaglest_runtime_error("Unknown playercolor: " + intToStr(playerColor));
|
||||
break;
|
||||
|
@@ -55,13 +55,19 @@ namespace Shared {
|
||||
class MeshCallbackTeamColor : public MeshCallback {
|
||||
private:
|
||||
const Texture *teamTexture;
|
||||
bool hasAlpha;
|
||||
|
||||
public:
|
||||
MeshCallbackTeamColor() : MeshCallback() {
|
||||
teamTexture = NULL;
|
||||
hasAlpha = false;
|
||||
}
|
||||
void setTeamTexture(const Texture *teamTexture) {
|
||||
void setTeamTexture(const Texture *teamTexture, bool hasAlpha) {
|
||||
this->teamTexture = teamTexture;
|
||||
this->hasAlpha = hasAlpha;
|
||||
}
|
||||
bool getHasAlpha() {
|
||||
return hasAlpha;
|
||||
}
|
||||
virtual void execute(const Mesh *mesh);
|
||||
};
|
||||
@@ -86,7 +92,8 @@ namespace Shared {
|
||||
pcWhite,
|
||||
pcCyan,
|
||||
pcOrange,
|
||||
pcMagenta
|
||||
pcMagenta,
|
||||
pcTransparent
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -112,6 +119,7 @@ namespace Shared {
|
||||
Texture2D *customTextureCyan;
|
||||
Texture2D *customTextureOrange;
|
||||
Texture2D *customTextureMagenta;
|
||||
Texture2D *customTextureTransparent;
|
||||
MeshCallbackTeamColor meshCallbackTeamColor;
|
||||
|
||||
float red;
|
||||
|
Reference in New Issue
Block a user