- added ability to change background color and take screenshots (see file and Custom Color menus)
This commit is contained in:
parent
66261ad662
commit
685c338f97
|
@ -82,6 +82,7 @@ MainWindow::MainWindow(const string &modelPath)
|
||||||
menuFile->Append(miFileLoadProjectileParticleXML, wxT("Load P&rojectile Particle XML"), wxT("Press ctrl before menu for keeping current projectile particles"));
|
menuFile->Append(miFileLoadProjectileParticleXML, wxT("Load P&rojectile Particle XML"), wxT("Press ctrl before menu for keeping current projectile particles"));
|
||||||
menuFile->Append(miFileLoadSplashParticleXML, wxT("Load &Splash Particle XML"), wxT("Press ctrl before menu for keeping current splash particles"));
|
menuFile->Append(miFileLoadSplashParticleXML, wxT("Load &Splash Particle XML"), wxT("Press ctrl before menu for keeping current splash particles"));
|
||||||
menuFile->Append(miFileClearAll, wxT("&Clear All"));
|
menuFile->Append(miFileClearAll, wxT("&Clear All"));
|
||||||
|
menuFile->Append(miFileSaveScreenshot, wxT("Sa&ve a Screenshot"));
|
||||||
menuFile->AppendSeparator();
|
menuFile->AppendSeparator();
|
||||||
menuFile->Append(wxID_EXIT);
|
menuFile->Append(wxID_EXIT);
|
||||||
menu->Append(menuFile, wxT("&File"));
|
menu->Append(menuFile, wxT("&File"));
|
||||||
|
@ -103,6 +104,7 @@ MainWindow::MainWindow(const string &modelPath)
|
||||||
|
|
||||||
//custom color
|
//custom color
|
||||||
menuCustomColor= new wxMenu();
|
menuCustomColor= new wxMenu();
|
||||||
|
menuCustomColor->AppendCheckItem(miChangeBackgroundColor, wxT("Change Background Color"));
|
||||||
menuCustomColor->AppendCheckItem(miColorRed, wxT("&Red\t0"));
|
menuCustomColor->AppendCheckItem(miColorRed, wxT("&Red\t0"));
|
||||||
menuCustomColor->AppendCheckItem(miColorBlue, wxT("&Blue\t1"));
|
menuCustomColor->AppendCheckItem(miColorBlue, wxT("&Blue\t1"));
|
||||||
menuCustomColor->AppendCheckItem(miColorGreen, wxT("&Green\t2"));
|
menuCustomColor->AppendCheckItem(miColorGreen, wxT("&Green\t2"));
|
||||||
|
@ -257,6 +259,30 @@ void MainWindow::onMouseMove(wxMouseEvent &event){
|
||||||
lastY= y;
|
lastY= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnChangeColor(wxCommandEvent &event) {
|
||||||
|
//wxColour color = colorPicker->GetColour();
|
||||||
|
wxColourData data;
|
||||||
|
data.SetChooseFull(true);
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
wxColour colour(i*16, i*16, i*16);
|
||||||
|
data.SetCustomColour(i, colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColourDialog dialog(this, &data);
|
||||||
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
|
wxColourData retData = dialog.GetColourData();
|
||||||
|
wxColour col = retData.GetColour();
|
||||||
|
|
||||||
|
renderer->setBackgroundColor(col.Red()/255.0f, col.Green()/255.0f, col.Blue()/255.0f, col.Alpha()/255.0f);
|
||||||
|
//wxBrush brush(col, wxSOLID);
|
||||||
|
//myWindow->SetBackground(brush);
|
||||||
|
//myWindow->Clear();
|
||||||
|
//myWindow->Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
|
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
|
||||||
string fileName;
|
string fileName;
|
||||||
|
|
||||||
|
@ -326,7 +352,29 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
|
||||||
} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method?
|
} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method?
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onMenuFileClearAll(wxCommandEvent &event){
|
void MainWindow::onMenuFileSaveScreenshot(wxCommandEvent &event) {
|
||||||
|
string path = "screens/";
|
||||||
|
if(isdir(path.c_str()) == true) {
|
||||||
|
//Config &config= Config::getInstance();
|
||||||
|
//string fileFormat = config.getString("ScreenShotFileType","png");
|
||||||
|
string fileFormat = "png";
|
||||||
|
|
||||||
|
for(int i=0; i < 1000; ++i) {
|
||||||
|
path = "screens/";
|
||||||
|
path += string("screen") + intToStr(i) + string(".") + fileFormat;
|
||||||
|
FILE *f= fopen(path.c_str(), "rb");
|
||||||
|
if(f == NULL) {
|
||||||
|
renderer->saveScreen(path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
||||||
modelPathList.clear();
|
modelPathList.clear();
|
||||||
particlePathList.clear();
|
particlePathList.clear();
|
||||||
particleProjectilePathList.clear();
|
particleProjectilePathList.clear();
|
||||||
|
@ -927,6 +975,7 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||||
EVT_MENU(miFileLoadProjectileParticleXML, MainWindow::onMenuFileLoadProjectileParticleXML)
|
EVT_MENU(miFileLoadProjectileParticleXML, MainWindow::onMenuFileLoadProjectileParticleXML)
|
||||||
EVT_MENU(miFileLoadSplashParticleXML, MainWindow::onMenuFileLoadSplashParticleXML)
|
EVT_MENU(miFileLoadSplashParticleXML, MainWindow::onMenuFileLoadSplashParticleXML)
|
||||||
EVT_MENU(miFileClearAll, MainWindow::onMenuFileClearAll)
|
EVT_MENU(miFileClearAll, MainWindow::onMenuFileClearAll)
|
||||||
|
EVT_MENU(miFileSaveScreenshot, MainWindow::onMenuFileSaveScreenshot)
|
||||||
EVT_MENU(wxID_EXIT, MainWindow::onMenuFileExit)
|
EVT_MENU(wxID_EXIT, MainWindow::onMenuFileExit)
|
||||||
|
|
||||||
EVT_MENU(miModeWireframe, MainWindow::onMenuModeWireframe)
|
EVT_MENU(miModeWireframe, MainWindow::onMenuModeWireframe)
|
||||||
|
@ -945,6 +994,8 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||||
EVT_MENU(miColorCyan, MainWindow::onMenuColorCyan)
|
EVT_MENU(miColorCyan, MainWindow::onMenuColorCyan)
|
||||||
EVT_MENU(miColorOrange, MainWindow::onMenuColorOrange)
|
EVT_MENU(miColorOrange, MainWindow::onMenuColorOrange)
|
||||||
EVT_MENU(miColorMagenta, MainWindow::onMenuColorMagenta)
|
EVT_MENU(miColorMagenta, MainWindow::onMenuColorMagenta)
|
||||||
|
|
||||||
|
EVT_MENU(miChangeBackgroundColor, MainWindow::OnChangeColor)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include <wx/glcanvas.h>
|
#include <wx/glcanvas.h>
|
||||||
|
//#include <wx/clrpicker.h>
|
||||||
|
#include <wx/colordlg.h>
|
||||||
|
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -36,12 +38,14 @@ public:
|
||||||
miFileLoadProjectileParticleXML,
|
miFileLoadProjectileParticleXML,
|
||||||
miFileLoadSplashParticleXML,
|
miFileLoadSplashParticleXML,
|
||||||
miFileClearAll,
|
miFileClearAll,
|
||||||
|
miFileSaveScreenshot,
|
||||||
miModeWireframe,
|
miModeWireframe,
|
||||||
miModeNormals,
|
miModeNormals,
|
||||||
miModeGrid,
|
miModeGrid,
|
||||||
miSpeedSlower,
|
miSpeedSlower,
|
||||||
miSpeedFaster,
|
miSpeedFaster,
|
||||||
miRestart,
|
miRestart,
|
||||||
|
miChangeBackgroundColor,
|
||||||
miColorRed,
|
miColorRed,
|
||||||
miColorBlue,
|
miColorBlue,
|
||||||
miColorGreen,
|
miColorGreen,
|
||||||
|
@ -65,6 +69,8 @@ private:
|
||||||
wxMenu *menuCustomColor;
|
wxMenu *menuCustomColor;
|
||||||
wxFileDialog *fileDialog;
|
wxFileDialog *fileDialog;
|
||||||
|
|
||||||
|
wxColourDialog *colorPicker;
|
||||||
|
|
||||||
Model *model;
|
Model *model;
|
||||||
|
|
||||||
std::vector<string> modelPathList;
|
std::vector<string> modelPathList;
|
||||||
|
@ -108,6 +114,7 @@ public:
|
||||||
void onMenuFileLoadProjectileParticleXML(wxCommandEvent &event);
|
void onMenuFileLoadProjectileParticleXML(wxCommandEvent &event);
|
||||||
void onMenuFileLoadSplashParticleXML(wxCommandEvent &event);
|
void onMenuFileLoadSplashParticleXML(wxCommandEvent &event);
|
||||||
void onMenuFileClearAll(wxCommandEvent &event);
|
void onMenuFileClearAll(wxCommandEvent &event);
|
||||||
|
void onMenuFileSaveScreenshot(wxCommandEvent &event);
|
||||||
void onMenuFileExit(wxCommandEvent &event);
|
void onMenuFileExit(wxCommandEvent &event);
|
||||||
void onMenuModeNormals(wxCommandEvent &event);
|
void onMenuModeNormals(wxCommandEvent &event);
|
||||||
void onMenuModeWireframe(wxCommandEvent &event);
|
void onMenuModeWireframe(wxCommandEvent &event);
|
||||||
|
@ -115,6 +122,7 @@ public:
|
||||||
void onMenuSpeedSlower(wxCommandEvent &event);
|
void onMenuSpeedSlower(wxCommandEvent &event);
|
||||||
void onMenuSpeedFaster(wxCommandEvent &event);
|
void onMenuSpeedFaster(wxCommandEvent &event);
|
||||||
void onMenuRestart(wxCommandEvent &event);
|
void onMenuRestart(wxCommandEvent &event);
|
||||||
|
void OnChangeColor(wxCommandEvent &event);
|
||||||
void onMenuColorRed(wxCommandEvent &event);
|
void onMenuColorRed(wxCommandEvent &event);
|
||||||
void onMenuColorBlue(wxCommandEvent &event);
|
void onMenuColorBlue(wxCommandEvent &event);
|
||||||
void onMenuColorGreen(wxCommandEvent &event);
|
void onMenuColorGreen(wxCommandEvent &event);
|
||||||
|
|
|
@ -71,7 +71,7 @@ void MeshCallbackTeamColor::execute(const Mesh *mesh){
|
||||||
// class Renderer
|
// class Renderer
|
||||||
// ===============================================
|
// ===============================================
|
||||||
|
|
||||||
Renderer::Renderer(){
|
Renderer::Renderer() {
|
||||||
normals= false;
|
normals= false;
|
||||||
wireframe= false;
|
wireframe= false;
|
||||||
grid= true;
|
grid= true;
|
||||||
|
@ -79,9 +79,15 @@ Renderer::Renderer(){
|
||||||
textureManager = NULL;
|
textureManager = NULL;
|
||||||
particleRenderer = NULL;
|
particleRenderer = NULL;
|
||||||
modelManager = NULL;
|
modelManager = NULL;
|
||||||
|
width=0;
|
||||||
|
height=0;
|
||||||
|
red = 0.3f;
|
||||||
|
green = 0.3f;
|
||||||
|
blue = 0.3f;
|
||||||
|
alpha = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer(){
|
Renderer::~Renderer() {
|
||||||
delete modelRenderer;
|
delete modelRenderer;
|
||||||
delete textureManager;
|
delete textureManager;
|
||||||
delete particleRenderer;
|
delete particleRenderer;
|
||||||
|
@ -91,12 +97,12 @@ Renderer::~Renderer(){
|
||||||
delete modelManager;
|
delete modelManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer * Renderer::getInstance(){
|
Renderer * Renderer::getInstance() {
|
||||||
static Renderer * renderer = new Renderer();
|
static Renderer * renderer = new Renderer();
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::transform(float rotX, float rotY, float zoom){
|
void Renderer::transform(float rotX, float rotY, float zoom) {
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
@ -109,11 +115,9 @@ void Renderer::transform(float rotX, float rotY, float zoom){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::checkGlCaps(){
|
void Renderer::checkGlCaps() {
|
||||||
|
|
||||||
//opengl 1.3
|
//opengl 1.3
|
||||||
if(!isGlVersionSupported(1, 3, 0)){
|
if(!isGlVersionSupported(1, 3, 0)) {
|
||||||
|
|
||||||
string message;
|
string message;
|
||||||
|
|
||||||
message += "Your system supports OpenGL version \"";
|
message += "Your system supports OpenGL version \"";
|
||||||
|
@ -125,13 +129,13 @@ void Renderer::checkGlCaps(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//opengl 1.4 or extension
|
//opengl 1.4 or extension
|
||||||
if(!isGlVersionSupported(1, 4, 0)){
|
if(isGlVersionSupported(1, 4, 0) == false) {
|
||||||
checkExtension("GL_ARB_texture_env_crossbar", "MegaGlest");
|
checkExtension("GL_ARB_texture_env_crossbar", "MegaGlest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::checkExtension(const string &extension, const string &msg){
|
void Renderer::checkExtension(const string &extension, const string &msg) {
|
||||||
if(!isGlExtensionSupported(extension.c_str())){
|
if(isGlExtensionSupported(extension.c_str()) == false) {
|
||||||
string str= "OpenGL extension not supported: " + extension + ", required for " + msg;
|
string str= "OpenGL extension not supported: " + extension + ", required for " + msg;
|
||||||
throw runtime_error(str);
|
throw runtime_error(str);
|
||||||
}
|
}
|
||||||
|
@ -147,11 +151,19 @@ Model * Renderer::getNewModel() {
|
||||||
return newModel;
|
return newModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::init(){
|
void Renderer::setBackgroundColor(float red, float green, float blue, float alpha) {
|
||||||
assertGl();
|
this->red = red;
|
||||||
|
this->green = green;
|
||||||
|
this->blue = blue;
|
||||||
|
this->alpha= alpha;
|
||||||
|
glClearColor(red, green, blue, alpha); //backgroundcolor constant 0.3
|
||||||
|
//glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
//glFlush();
|
||||||
|
//SwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
//!!!glInitNames();
|
void Renderer::init() {
|
||||||
//!!!checkGlCaps();
|
assertGl();
|
||||||
|
|
||||||
GraphicsFactory *gf= new GraphicsFactoryGl();
|
GraphicsFactory *gf= new GraphicsFactoryGl();
|
||||||
GraphicsInterface::getInstance().setFactory(gf);
|
GraphicsInterface::getInstance().setFactory(gf);
|
||||||
|
@ -206,7 +218,7 @@ void Renderer::init(){
|
||||||
customTextureMagenta->getPixmap()->init(1, 1, 3);
|
customTextureMagenta->getPixmap()->init(1, 1, 3);
|
||||||
customTextureMagenta->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 1.f));
|
customTextureMagenta->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 1.f));
|
||||||
|
|
||||||
glClearColor(0.3f, 0.3f, 0.3f, 1.0f); //backgroundcolor constant 0.3
|
glClearColor(red, green, blue, alpha); //backgroundcolor constant 0.3
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glFrontFace(GL_CW);
|
glFrontFace(GL_CW);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
@ -230,9 +242,12 @@ void Renderer::init(){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::reset(int w, int h, PlayerColor playerColor){
|
void Renderer::reset(int w, int h, PlayerColor playerColor) {
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
|
width=w;
|
||||||
|
height=h;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
@ -243,7 +258,7 @@ void Renderer::reset(int w, int h, PlayerColor playerColor){
|
||||||
glTranslatef(0, -1.5, -5);
|
glTranslatef(0, -1.5, -5);
|
||||||
|
|
||||||
Texture2D *customTexture;
|
Texture2D *customTexture;
|
||||||
switch(playerColor){
|
switch(playerColor) {
|
||||||
case pcRed:
|
case pcRed:
|
||||||
customTexture= customTextureRed;
|
customTexture= customTextureRed;
|
||||||
break;
|
break;
|
||||||
|
@ -273,13 +288,13 @@ void Renderer::reset(int w, int h, PlayerColor playerColor){
|
||||||
}
|
}
|
||||||
meshCallbackTeamColor.setTeamTexture(customTexture);
|
meshCallbackTeamColor.setTeamTexture(customTexture);
|
||||||
|
|
||||||
if(wireframe){
|
if(wireframe) {
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glDisable(GL_LIGHT0);
|
glDisable(GL_LIGHT0);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
|
@ -289,10 +304,9 @@ void Renderer::reset(int w, int h, PlayerColor playerColor){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderGrid(){
|
void Renderer::renderGrid() {
|
||||||
if(grid){
|
if(grid) {
|
||||||
|
float i=0;
|
||||||
float i;
|
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
|
@ -302,11 +316,11 @@ void Renderer::renderGrid(){
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(1.0f, 1.0f, 1.0f); // gridcolor constant
|
glColor3f(1.0f, 1.0f, 1.0f); // gridcolor constant
|
||||||
for(i=-10.0f; i<=10.0f; i+=1.0f){
|
for(i=-10.0f; i<=10.0f; i+=1.0f) {
|
||||||
glVertex3f(i, 0.0f, 10.0f);
|
glVertex3f(i, 0.0f, 10.0f);
|
||||||
glVertex3f(i, 0.0f, -10.0f);
|
glVertex3f(i, 0.0f, -10.0f);
|
||||||
}
|
}
|
||||||
for(i=-10.0f; i<=10.0f; i+=1.0f){
|
for(i=-10.0f; i<=10.0f; i+=1.0f) {
|
||||||
glVertex3f(10.f, 0.0f, i);
|
glVertex3f(10.f, 0.0f, i);
|
||||||
glVertex3f(-10.f, 0.0f, i);
|
glVertex3f(-10.f, 0.0f, i);
|
||||||
}
|
}
|
||||||
|
@ -318,32 +332,32 @@ void Renderer::renderGrid(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::toggleNormals(){
|
void Renderer::toggleNormals() {
|
||||||
normals= normals? false: true;
|
normals= normals? false: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::toggleWireframe(){
|
void Renderer::toggleWireframe() {
|
||||||
wireframe= wireframe? false: true;
|
wireframe= wireframe? false: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::toggleGrid(){
|
void Renderer::toggleGrid() {
|
||||||
grid= grid? false: true;
|
grid= grid? false: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::loadTheModel(Model *model, string file){
|
void Renderer::loadTheModel(Model *model, string file) {
|
||||||
model->setTextureManager(textureManager);
|
model->setTextureManager(textureManager);
|
||||||
model->loadG3d(file);
|
model->loadG3d(file);
|
||||||
textureManager->init();
|
textureManager->init();
|
||||||
modelManager->init();
|
modelManager->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderTheModel(Model *model, float f){
|
void Renderer::renderTheModel(Model *model, float f) {
|
||||||
if(model != NULL){
|
if(model != NULL){
|
||||||
modelRenderer->begin(true, true, !wireframe, &meshCallbackTeamColor);
|
modelRenderer->begin(true, true, !wireframe, &meshCallbackTeamColor);
|
||||||
model->updateInterpolationData(f, true);
|
model->updateInterpolationData(f, true);
|
||||||
modelRenderer->render(model);
|
modelRenderer->render(model);
|
||||||
|
|
||||||
if(normals){
|
if(normals) {
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@ -356,15 +370,15 @@ void Renderer::renderTheModel(Model *model, float f){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::manageParticleSystem(ParticleSystem *particleSystem){
|
void Renderer::manageParticleSystem(ParticleSystem *particleSystem) {
|
||||||
particleManager->manage(particleSystem);
|
particleManager->manage(particleSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::updateParticleManager(){
|
void Renderer::updateParticleManager() {
|
||||||
particleManager->update();
|
particleManager->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderParticleManager(){
|
void Renderer::renderParticleManager() {
|
||||||
glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
particleRenderer->renderManager(particleManager, modelRenderer);
|
particleRenderer->renderManager(particleManager, modelRenderer);
|
||||||
|
@ -420,4 +434,17 @@ void Renderer::end() {
|
||||||
modelManager->end();
|
modelManager->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::saveScreen(const string &path) {
|
||||||
|
//const Metrics &sm= Metrics::getInstance();
|
||||||
|
|
||||||
|
//Pixmap2D pixmap(sm.getScreenW(), sm.getScreenH(), 3);
|
||||||
|
Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 3);
|
||||||
|
glFinish();
|
||||||
|
glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(),
|
||||||
|
GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels());
|
||||||
|
|
||||||
|
pixmapScreenShot->save(path);
|
||||||
|
delete pixmapScreenShot;
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -79,6 +79,9 @@ private:
|
||||||
bool normals;
|
bool normals;
|
||||||
bool grid;
|
bool grid;
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
ModelRenderer *modelRenderer;
|
ModelRenderer *modelRenderer;
|
||||||
TextureManager *textureManager;
|
TextureManager *textureManager;
|
||||||
ParticleRenderer *particleRenderer;
|
ParticleRenderer *particleRenderer;
|
||||||
|
@ -96,6 +99,11 @@ private:
|
||||||
Texture2D *customTextureMagenta;
|
Texture2D *customTextureMagenta;
|
||||||
MeshCallbackTeamColor meshCallbackTeamColor;
|
MeshCallbackTeamColor meshCallbackTeamColor;
|
||||||
|
|
||||||
|
float red;
|
||||||
|
float green;
|
||||||
|
float blue;
|
||||||
|
float alpha;
|
||||||
|
|
||||||
Renderer();
|
Renderer();
|
||||||
void checkGlCaps();
|
void checkGlCaps();
|
||||||
void checkExtension(const string &extension, const string &msg);
|
void checkExtension(const string &extension, const string &msg);
|
||||||
|
@ -135,6 +143,9 @@ public:
|
||||||
void initModelManager();
|
void initModelManager();
|
||||||
|
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
|
void setBackgroundColor(float red, float green, float blue, float alpha);
|
||||||
|
void saveScreen(const string &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
Loading…
Reference in New Issue