umhhh, well, the idea is this, i've got a code, but i cant find the problem ..
Splash.h
Code: Select all
LRESULT CALLBACK DefaultWindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
switch (msg) /* manipulador del mensaje */
{
case WM_DESTROY:
PostQuitMessage(0); /* envía un mensaje WM_QUIT a la cola de mensajes */
break;
default: /* para los mensajes de los que no nos ocupamos */
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
typedef struct IrrEnviroment{
irr::scene::ISceneManager* SceneManager;
irr::video::IVideoDriver* Driver;
irr::IrrlichtDevice* Device;
irr::gui::IGUIEnvironment* Gui;
}IrrEnviroment;
// this thing of namespaces it's driving me crazy ..
class SplashScreen{
public:
SplashScreen();
~SplashScreen();
int Create(int X,int Y,int W,int H);
bool Show();
bool RenderLoop(bool* Render);
LRESULT CALLBACK (*WinProcedure)(HWND, UINT, WPARAM, LPARAM);
IrrEnviroment irrEnv;
private:
HWND hwnd,hRenderhWind;
MSG msg;
WNDCLASSEX wincl;
bool Error;
int W,H,X,Y;
irr::SIrrlichtCreationParameters IrrCreationParams;
};
/* usually, i'm not so smartypants with names, but this
isn't only irrlicht related, so, it could be a windows device
so, i make the names more "descriptive"
*/
SplashScreen::SplashScreen(){
Error^=Error;W^=W;H^=H;X^=X;Y^=Y; // Cleaning Up Or, setting to 0
WinProcedure = DefaultWindowProcedure;
}
int SplashScreen::Create(int X,int Y,int W,int H){
wincl.hInstance = NULL;
this->X = X;this->Y=Y;this->W=W;this->H=H;
wincl.lpszClassName = "SplashScreenClass";
wincl.lpfnWndProc = WinProcedure;
wincl.style = CS_HREDRAW | CS_VREDRAW;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = DLGWINDOWEXTRA;
wincl.hbrBackground = (HBRUSH)COLOR_WINDOWTEXT; /* as always is black ...
yeah, a nasty fashioned
way of saying black*/
if(!RegisterClassEx(&wincl)) Error = true;
if (!Error){
hwnd = CreateWindow(wincl.lpszClassName,"",WS_POPUP|SW_HIDE,X,Y,W,H,NULL, NULL,NULL, NULL);
if (hwnd==NULL) Error = true;
}
// empotremos el puto irrlich :@
hRenderhWind = CreateWindow("RenderWin", "", WS_CHILD | BS_OWNERDRAW | WS_VISIBLE ,X,Y,W,H, hwnd, NULL, NULL, NULL);
IrrCreationParams.WindowId = reinterpret_cast<irr::s32> (hRenderhWind );
IrrCreationParams.DriverType = irr::video::EDT_OPENGL;
irrEnv.Device = irr::createDeviceEx(IrrCreationParams);
irrEnv.SceneManager = irrEnv.Device->getSceneManager();
irrEnv.Driver = irrEnv.Device->getVideoDriver();
irrEnv.Gui = irrEnv.Device->getGUIEnvironment();
return !Error;
}
bool SplashScreen::Show(){
if (Error) return false;
ShowWindow(hwnd, SW_SHOWDEFAULT);
}
bool SplashScreen::RenderLoop(bool* Render){
while (irrEnv.Device->run()&& *Render==true ){
irrEnv.Driver->beginScene(true, true, 0);
irrEnv.SceneManager->drawAll();
irrEnv.Gui->drawAll();
irrEnv.Driver ->endScene();
}
}
// here we could use a Get() function to return the struct, umhh, but, its public xD
SplashScreen::~SplashScreen(){
}
Main.cpp
Code: Select all
#include <Windows.h>
#include <Irrlicht/Irrlicht.h>
#include "Splash.h"
#define ret return // dont gently caress with this xD
SplashScreen* Splash; // the splash itself
int DisplayH,DisplayW; // the Widht and height of screen
bool Render = true; // this is used for the rendering, the only way of broke RenderLoop is changing this value :roll:
void GetRes(); // using WinGDI for obtaining it ...
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
FreeConsole(); // funking console xD
GetRes(); // we fill the info ...
Splash = new SplashScreen(); // we create the splash screen
Splash->Create((DisplayW-400)/2,(DisplayH-200)/2,400,200); // here we create it with 400x200 size, centered on screen (W,H,X,Y)
Splash->Show(); // we show it ..
irr::gui::IGUIImage* Image = Splash->irrEnv.Gui->addImage(Splash->irrEnv.Driver->getTexture("Test.jpg"),irr::core::position2d<int>(1,1)); // just a nasty fashioned way of testing xD
Splash->RenderLoop(&Render); // the renderloop
ret 1;
}
void GetRes(){
// ignore this xD
HDC DisplayDC = GetDC(GetDesktopWindow());
DisplayW = GetDeviceCaps(DisplayDC,HORZRES);
DisplayH = GetDeviceCaps(DisplayDC,VERTRES);
DeleteDC(DisplayDC);
}
what part of CreateWindow() or CreateDeviceEx() doesn't understan that the second window is a child ?
damned xD
wel, i will se the problem ...
i forgot, once created the splash and with the struct, the user can do all the render work that he want ..
Au Revoir !