Is there any option for programming irrlicht in a custom Oriented Object code ?
let me explain.
i know that irrlicht has a lot of functions for make anything i want, but in some moments the engine takes so much code that i lost myself.
I´m just wondering, it´s healthy for the code standards use the structure like i´m doing below ?
Code: Select all
#ifndef APP_H
#define APP_H
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
class app{
protected:
IrrlichtDevice *m_dispositivo;
private:
bool m_stencil;
bool m_vsync;
public:
/**largura,altura,pbits,fullscreen?*/
app(int,int,int,bool);
~app();
bool run();
IrrlichtDevice *dispositivo();
};
#endif
Code: Select all
#include "app.h"
using namespace irr;
app::app(int l_largura, int l_altura, int l_pbits, bool l_fullscreen){
this->m_stencil = false;
this->m_vsync = false;
this->m_dispositivo = createDevice(EDT_OPENGL,
dimension2d<s32>(l_largura,l_altura),
l_pbits,
l_fullscreen,
this->m_stencil,
this->m_vsync,
0
);
}
app::~app(){
delete(this->m_dispositivo);
}
IrrlichtDevice *app::dispositivo(){
return m_dispositivo;
}
bool app::run(){
return this->m_dispositivo->run();
}
i have another for video
Code: Select all
#ifndef VIDEO_H
#define VIDEO_H
#include <irrlicht.h>
#include "app.h"
using namespace irr;
using namespace video;
class Cvideo {
protected:
IVideoDriver *m_video;
private:
bool m_backbuffer;
bool m_zbuffer;
public:
Cvideo();
void clear(int,int,int,int);
void render();
};
#endif
Code: Select all
#include "video.h"
Cvideo::Cvideo(){
this->m_backbuffer = true;
this->m_zbuffer = true;
}
void Cvideo::clear(int l_r, int l_g, int l_b, int l_a){
this->m_video->beginScene(
m_backbuffer,
m_zbuffer,
SColor(l_a,l_r,l_g,l_b),0,0);
}
void Cvideo::render(){
this->m_video->endScene();
Code: Select all
#ifndef WORLD_H
#define WORLD_H
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace gui;
using namespace io;
using namespace scene;
class world {
private:
ISceneManager *m_cena;
IVideoDriver *m_video;
ICameraSceneNode *m_camera;
s32 cameraId;
public:
ISceneManager *cena();
world(IrrlichtDevice*);
void addCamera(vector3df,vector3df);
void SkyBox(char*,char*,char*,char*,char*,char*);
};
#endif
Code: Select all
#include "world.h"
class game;
world::world(IrrlichtDevice* l_dispositivo) {
this->m_cena = l_dispositivo->getSceneManager();
this->m_video = l_dispositivo->getVideoDriver();
cameraId = 0;
}
ISceneManager *world::cena(){
return this->m_cena;
}
void world::addCamera(vector3df l_posicao, vector3df l_target){
this->m_camera = m_cena->addCameraSceneNode(0,l_posicao,l_target,cameraId);
cameraId++;
}
void world::SkyBox(char *l_up,char * l_down,char * l_left,char * l_right,char * l_front ,char * l_back){
m_cena->addSkyBoxSceneNode(
m_video->getTexture(l_up),
m_video->getTexture(l_down),
m_video->getTexture(l_left),
m_video->getTexture(l_right),
m_video->getTexture(l_front),
m_video->getTexture(l_back));
}
Code: Select all
#ifndef GAME_H
#define GAME_H
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace gui;
using namespace io;
#include "app.h"
#include "video.h"
#include "world.h"
class game : public app, public Cvideo {
private:
int m_largura;
int m_altura;
int m_pbits;
bool m_fullscreen;
public:
game(int,int);
~game();
};
#endif
Code: Select all
#include "game.h"
game::game(int l_largura, int l_altura)
: app(l_largura,l_altura,32,false),
Cvideo() {
this->m_largura = l_largura;
this->m_altura = l_altura;
this->m_pbits = 32;
this->m_fullscreen = false;
this->m_video = dispositivo()->getVideoDriver();
}
game::~game(){
delete(m_video);
delete(m_dispositivo);
}
Now, i have de MAIN.CC that keep the things more cleaner.
Code: Select all
#include "game.h"
int main() {
game *jogo = new game(800,600);
world *mundo = new world(jogo->dispositivo());
mundo->SkyBox("1.jpg","1.jpg","1.jpg","1.jpg","1.jpg","1.jpg");
mundo->addCamera(vector3df(0,0,0),vector3df(0,0,100));
while(jogo->run()){
jogo->clear(150,150,150,255); //Limpa os buffers
mundo->cena()->drawAll();
jogo->render(); //Renderiza
}
return 0;
}
Am i getting clear in my doubt ? I hope you guys can help-me, i´m just a regular programmer trying to make the best way to non-pros or newbies understand irrlicht.
Thanx a lot
U rock!