Merge pull request #11 from andreja6/window

Now uses HWND rather than an SDL Window
This commit is contained in:
andreja6
2018-04-25 14:35:21 -07:00
committed by GitHub
23 changed files with 341 additions and 35 deletions

View File

@@ -4,6 +4,7 @@ bool floatBottom = false;
bool floatRight = false; bool floatRight = false;
bool floatCenter = false; bool floatCenter = false;
bool disabled = false; bool disabled = false;
bool selected = false;
ButtonListener* listener = NULL; ButtonListener* listener = NULL;
BaseButtonInstance::BaseButtonInstance(void) BaseButtonInstance::BaseButtonInstance(void)
@@ -16,6 +17,11 @@ BaseButtonInstance::~BaseButtonInstance(void)
delete listener; delete listener;
} }
void BaseButtonInstance::setButtonListener(ButtonListener* buttonListener)
{
listener = buttonListener;
}
void BaseButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown){} void BaseButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown){}
bool BaseButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd){return false;} bool BaseButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd){return false;}

View File

@@ -2,6 +2,7 @@
#include "instance.h" #include "instance.h"
#pragma once #pragma once
#include "ButtonListener.h" #include "ButtonListener.h"
class ButtonListener;
class BaseButtonInstance : public Instance class BaseButtonInstance : public Instance
{ {
public: public:
@@ -10,10 +11,12 @@ public:
virtual void drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown); virtual void drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown);
virtual bool mouseInButton(float, float, RenderDevice* rd); virtual bool mouseInButton(float, float, RenderDevice* rd);
virtual void onMouseClick(); virtual void onMouseClick();
void setButtonListener(ButtonListener*);
bool floatBottom; bool floatBottom;
bool floatRight; bool floatRight;
bool floatCenter; bool floatCenter;
bool disabled; bool disabled;
bool selected;
protected: protected:
bool mouseInArea(float, float, float, float, float, float); bool mouseInArea(float, float, float, float, float, float);
class ButtonListener* listener; class ButtonListener* listener;

Binary file not shown.

View File

@@ -46,6 +46,37 @@ END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_TOOLBOX DIALOGEX 0, 0, 398, 64
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
CONTROL "",IDC_TOOLBOX_BROWSER,
"{A8F8E829-06DA-11D2-8D70-00A0C98B28E2}",WS_TABSTOP,0,0,398,64
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
IDD_TOOLBOX DLGINIT
BEGIN
IDC_TOOLBOX_BROWSER, 0x376, 76, 0
0x0000, 0x0000, 0xb293, 0x0000, 0x0048, 0x0000, 0x0003, 0x0008, 0xf20b,
0x4757, 0x0020, 0x0000, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e,
0x0074, 0x0078, 0x3db4, 0x0000, 0x0003, 0x0008, 0xf20a, 0x4757, 0xffe0,
0xffff, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x0074, 0x0079,
0x0ac0, 0x0000,
0
END
#endif // English (U.S.) resources #endif // English (U.S.) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -92,6 +123,15 @@ BEGIN
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "icon1.ico"
#endif // English (Canada) resources #endif // English (Canada) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@@ -316,6 +316,10 @@
Name="Resource Files" Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
> >
<File
RelativePath=".\icon1.ico"
>
</File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>

View File

@@ -49,6 +49,7 @@ ImageButtonInstance::~ImageButtonInstance(void)
image_dn = NULL; image_dn = NULL;
delete listener; delete listener;
listener = NULL; listener = NULL;
selected = false;
} }
bool ImageButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd) bool ImageButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
@@ -93,7 +94,11 @@ void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouse
positionRelative = Vector2(rd->getWidth() + position.x, position.y); positionRelative = Vector2(rd->getWidth() + position.x, position.y);
} }
int renderimage = openGLID; int renderimage = openGLID;
if(disabled) if(selected == true && !image_dn.isNull())
{
renderimage = openGLID_dn;
}
else if(disabled)
{ {
if(!image_ds.isNull()) if(!image_ds.isNull())
renderimage = openGLID_ds; renderimage = openGLID_ds;
@@ -134,6 +139,6 @@ void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouse
rd->popState(); rd->popState();
if(drawDisabledBox) if(drawDisabledBox)
{ {
Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7,0.7,0.7,0.3), Color4::clear()); Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7F,0.7F,0.7F,0.3F), Color4::clear());
} }
} }

View File

@@ -11,6 +11,7 @@ public:
void drawObj(RenderDevice*, Vector2, bool); void drawObj(RenderDevice*, Vector2, bool);
Vector2 size; Vector2 size;
Vector2 position; Vector2 position;
G3D::TextureRef image; G3D::TextureRef image;
int openGLID; int openGLID;
G3D::TextureRef image_ovr; G3D::TextureRef image_ovr;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

After

Width:  |  Height:  |  Size: 576 B

BIN
content/cursor2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 792 B

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

306
main.cpp
View File

@@ -54,6 +54,7 @@ static bool forwards = false;
static bool backwards = false; static bool backwards = false;
static bool left = false; static bool left = false;
static bool right = false; static bool right = false;
static bool centerCam = false;
static const int CURSOR = 0; static const int CURSOR = 0;
static const int ARROWS = 1; static const int ARROWS = 1;
static const int RESIZE = 2; static const int RESIZE = 2;
@@ -66,6 +67,11 @@ Instance* selectedInstance = NULL;
This simple demo applet uses the debug mode as the regular This simple demo applet uses the debug mode as the regular
rendering mode so you can fly around the scene. rendering mode so you can fly around the scene.
*/ */
class Demo : public GApplet { class Demo : public GApplet {
public: public:
@@ -76,6 +82,8 @@ public:
class App* app; class App* app;
virtual void exitApplication();
Demo(App* app); Demo(App* app);
virtual ~Demo() {} virtual ~Demo() {}
@@ -98,7 +106,7 @@ public:
class App : public GApp { /*class App : public GApp {
protected: protected:
void main(); void main();
public: public:
@@ -109,7 +117,44 @@ public:
App(const GAppSettings& settings, GWindow* wnd); App(const GAppSettings& settings, GWindow* wnd);
~App(); ~App();
};*/
class App : public GApp {
protected:
void main();
public:
SkyRef sky;
Demo* applet;
App(const GAppSettings& settings, GWindow* wnd,HWND tempMainHWnd, SDLWindow*);
~App();
HWND getHWND();
HWND getPropertyHWND();
HWND getMainHWND();
//void addHWND(HWND hwnd);
private:
HWND hwnd;
HWND propertyHWnd;
HWND mainHWnd;
}; };
App *usableApp = NULL;
HWND App::getHWND()
{
return hwnd;
}
HWND App::getPropertyHWND()
{
return propertyHWnd;
}
HWND App::getMainHWND()
{
return mainHWnd;
}
Demo::Demo(App* _app) : GApplet(_app), app(_app) { Demo::Demo(App* _app) : GApplet(_app), app(_app) {
@@ -188,6 +233,53 @@ ImageButtonInstance* makeImageButton(G3D::TextureRef newImage = NULL, G3D::Textu
} }
class CameraButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
if(button->name == "CenterCam")
centerCam = true;
else if(button->name == "ZoomIn")
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.lookVector()*2;
else if(button->name == "ZoomOut")
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) - frame.lookVector()*2;
}
class ModeSelectionListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
{
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(instances_2D.at(i)->name == "Cursor" || instances_2D.at(i)->name == "Resize" || instances_2D.at(i)->name == "Arrows")
{
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
button->selected = false;
}
}
button->selected = true;
if(button->name == "Cursor")
mode = CURSOR;
else if(button->name == "Resize")
mode = RESIZE;
else if(button->name == "Arrows")
mode = ARROWS;
}
void initGUI() void initGUI()
{ {
TextButtonInstance* button = makeTextButton(); TextButtonInstance* button = makeTextButton();
@@ -316,6 +408,7 @@ void initGUI()
button->setAllColorsSame(); button->setAllColorsSame();
ImageButtonInstance* instance = makeImageButton(go, go_ovr, go_dn); ImageButtonInstance* instance = makeImageButton(go, go_ovr, go_dn);
instance->name = "go";
instance->size = Vector2(65,65); instance->size = Vector2(65,65);
instance->position = Vector2(6.5, 25); instance->position = Vector2(6.5, 25);
instance->parent = dataModel; instance->parent = dataModel;
@@ -330,11 +423,15 @@ void initGUI()
instance->size = Vector2(50,50); instance->size = Vector2(50,50);
instance->position = Vector2(15, 90); instance->position = Vector2(15, 90);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "Cursor";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png"))); instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
instance->size = Vector2(40,40); instance->size = Vector2(40,40);
instance->position = Vector2(0, 140); instance->position = Vector2(0, 140);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "Resize";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton( instance = makeImageButton(
@@ -345,6 +442,8 @@ void initGUI()
instance->size = Vector2(40,40); instance->size = Vector2(40,40);
instance->position = Vector2(40, 140); instance->position = Vector2(40, 140);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "Arrows";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")), Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
@@ -392,7 +491,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-77, -90); instance->position = Vector2(-77, -90);
instance->parent = dataModel; instance->parent = dataModel;
instance->disabled = true; instance->name = "ZoomIn";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")), Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
@@ -403,6 +503,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-77, -31); instance->position = Vector2(-77, -31);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "ZoomOut";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")), Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
@@ -413,6 +515,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-110, -50); instance->position = Vector2(-110, -50);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "PanLeft";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")), Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
@@ -423,6 +527,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-45, -50); instance->position = Vector2(-45, -50);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "PanRight";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")), Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
@@ -433,6 +539,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-77, -60); instance->position = Vector2(-77, -60);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "CenterCam";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")), Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
@@ -443,6 +551,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-105, -75); instance->position = Vector2(-105, -75);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "TiltUp";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton( instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")), Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
@@ -453,6 +563,8 @@ void initGUI()
instance->floatRight = true; instance->floatRight = true;
instance->position = Vector2(-40, -75); instance->position = Vector2(-40, -75);
instance->parent = dataModel; instance->parent = dataModel;
instance->name = "TiltDown";
instance->setButtonListener(new CameraButtonListener());
} }
@@ -594,7 +706,8 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
if(dataModel->name != title) if(dataModel->name != title)
{ {
title = dataModel->name; title = dataModel->name;
app->renderDevice->setCaption("Game \"" + title + "\""); std::string text = "Game \"" + title + "\"";
SetWindowText(app->getMainHWND(), text.c_str());
} }
CoordinateFrame frame = app->debugCamera.getCoordinateFrame(); CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
@@ -619,6 +732,17 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.rightVector()*moveRate; cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.rightVector()*moveRate;
} }
app->debugCamera.setPosition(cameraPos); app->debugCamera.setPosition(cameraPos);
if(centerCam)
{
CoordinateFrame frame = CoordinateFrame(app->debugCamera.getCoordinateFrame().translation);
if(selectedInstance == NULL)
frame.lookAt(Vector3(0,0,0));
else
frame.lookAt(((PhysicalInstance*)selectedInstance)->getPosition());
app->debugController.setCoordinateFrame(frame);
centerCam = false;
}
} }
@@ -723,7 +847,6 @@ void Demo::onUserInput(UserInput* ui) {
mousex = ui->getMouseX(); mousex = ui->getMouseX();
mousey = ui->getMouseY(); mousey = ui->getMouseY();
mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY); mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY);
messageTime = System::time();
if(ui->keyDown(SDLK_UP)) if(ui->keyDown(SDLK_UP))
{ {
forwards = true; forwards = true;
@@ -738,11 +861,13 @@ void Demo::onUserInput(UserInput* ui) {
} }
else if(ui->keyDown(SDLK_RIGHT)) else if(ui->keyDown(SDLK_RIGHT))
{ {
right = true; right = true;
} }
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY)) if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
{ {
for(size_t i = 0; i < instances_2D.size(); i++) for(size_t i = 0; i < instances_2D.size(); i++)
{ {
if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton") if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton")
@@ -767,6 +892,7 @@ void Demo::onUserInput(UserInput* ui) {
void makeFlag(Vector3 &vec, RenderDevice* &rd) void makeFlag(Vector3 &vec, RenderDevice* &rd)
{ {
Vector3 up = Vector3(vec.x, vec.y+3, vec.z); Vector3 up = Vector3(vec.x, vec.y+3, vec.z);
//Draw::lineSegment(G3D::LineSegment::fromTwoPoints(vec, up), rd, Color3::blue(), 3); //Draw::lineSegment(G3D::LineSegment::fromTwoPoints(vec, up), rd, Color3::blue(), 3);
rd->setColor(Color3::blue()); rd->setColor(Color3::blue());
@@ -822,30 +948,28 @@ void drawButtons(RenderDevice* rd)
} }
} }
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos) void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
{ {
//rd->setLight(0, NULL); //rd->setLight(0, NULL);
//rd->setAmbientLightColor(Color3(1,1,1)); //rd->setAmbientLightColor(Color3(1,1,1));
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F); Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
float offsetSize = 0.05F; float offsetSize = 0.05F;
//X //X
Draw::box(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
//Y //Y
Draw::box(Box(Vector3(from.x + offsetSize, from.y - offsetSize, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize, from.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(to.x + offsetSize, from.y - offsetSize, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize, from.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(to.x + offsetSize, from.y - offsetSize, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize, to.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.1, to.z - offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(from.x + offsetSize, from.y - offsetSize, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize, to.z - offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, to.z - offsetSize))), rd, outline, Color4::clear());
//Z //Z
Draw::box(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.y - offsetSize, to.z + offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
Draw::box(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize)), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
mode = RESIZE;
if(mode == ARROWS) if(mode == ARROWS)
{ {
@@ -894,6 +1018,12 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
} }
void Demo::exitApplication()
{
endApplet = true;
app->endProgram = true;
}
void Demo::onGraphics(RenderDevice* rd) { void Demo::onGraphics(RenderDevice* rd) {
@@ -916,6 +1046,7 @@ void Demo::onGraphics(RenderDevice* rd) {
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera); app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera);
@@ -958,7 +1089,7 @@ void Demo::onGraphics(RenderDevice* rd) {
Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear()); Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear());
if(selectedInstance == part) if(selectedInstance == part)
{ {
drawOutline(pos2, pos3, rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2)); drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), c);
} }
} }
@@ -1083,13 +1214,14 @@ void Demo::onGraphics(RenderDevice* rd) {
void App::main() { void App::main() {
usableApp = this;
setDebugMode(false); setDebugMode(false);
debugController.setActive(false); debugController.setActive(false);
// Load objects here // Load objects here
go = Texture::fromFile(GetFileInPath("/content/images/Run.png")); go = Texture::fromFile(GetFileInPath("/content/images/Run.png"));
go_ovr = Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")); go_ovr = Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png"));
go_dn = Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")); go_dn = Texture::fromFile(GetFileInPath("/content/images/Run_dn.png"));
cursor = Texture::fromFile(GetFileInPath("/content/cursor.png")); cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png"));
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt")); fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt")); fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
sky = Sky::create(NULL, ExePath() + "/content/sky/"); sky = Sky::create(NULL, ExePath() + "/content/sky/");
@@ -1099,8 +1231,21 @@ void App::main() {
App::App(const GAppSettings& settings, GWindow* wnd) : GApp(settings, wnd) { //App::App(const GAppSettings& settings, GWindow* wnd) : GApp(settings, wnd) {
// applet = new Demo(this);
//}
App::App(const GAppSettings& settings, GWindow* wnd,HWND tempMainHWnd, SDLWindow* wndSDL) : GApp(settings, wnd) {
applet = new Demo(this); applet = new Demo(this);
hwnd = wndSDL->win32HWND();
mainHWnd = tempMainHWnd;
propertyHWnd = CreateWindowEx(
WS_EX_TOOLWINDOW,
"ToolWindowClass", "ToolWindow",
WS_SYSMENU | WS_THICKFRAME | WS_VISIBLE | WS_CHILD,
200, 700, 400, 64,
mainHWnd, NULL, GetModuleHandle(0), NULL
);
} }
@@ -1111,16 +1256,41 @@ App::~App() {
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
App *app = (App *)GetWindowLongPtr(hwnd, GWL_USERDATA);
switch(msg) switch(msg)
{ {
case WM_CLOSE: case WM_CLOSE:
DestroyWindow(hwnd); if (app != 0)
{
HWND g3DWind = app->getHWND();
app->applet->exitApplication();
//DestroyWindow(hwnd);
}
//DestroyWindow(hwnd);
break; break;
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WM_SIZE:
if(app != 0)
{
HWND g3DWind = app->getHWND();
int width = 640;
int height = 480;
RECT rect;
if(GetClientRect(hwnd, &rect))
{
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}
SetWindowPos(g3DWind, NULL, 0, 0, width, height, NULL);
}
break;
default: default:
{
return DefWindowProc(hwnd, msg, wParam, lParam); return DefWindowProc(hwnd, msg, wParam, lParam);
}
} }
return 0; return 0;
} }
@@ -1130,21 +1300,95 @@ int main(int argc, char** argv) {
//_CrtSetBreakAlloc(1279); //_CrtSetBreakAlloc(1279);
GAppSettings settings; GAppSettings settings;
if(getOSVersion() > 5.0)
settings.window.defaultIconFilename = GetFileInPath("/content/images/rico.png");
else
settings.window.defaultIconFilename = GetFileInPath("/content/images/rico256c.png");
settings.window.resizable = true; settings.window.resizable = true;
settings.window.fsaaSamples = 8;
settings.writeLicenseFile = false; settings.writeLicenseFile = false;
settings.window.width = 841; settings.window.center = true;
settings.window.height = 639;
//Using the damned SDL window now //Using the damned SDL window now
SDLWindow* wnd = new SDLWindow(settings.window); SDLWindow* wnd = new SDLWindow(settings.window);
//wnd->setInputCaptureCount(200); //wnd->setInputCaptureCount(200);
wnd->setMouseVisible(false); wnd->setMouseVisible(false);
App app = App(settings, wnd);
HWND hwnd = wnd->win32HWND();
WNDCLASSEX wc;
HINSTANCE hInstance = GetModuleHandle(NULL);
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "containerHWND";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx (&wc))
return false;
HMODULE hThisInstance = GetModuleHandle(NULL);
HWND hwnd = wnd->win32HWND();
HWND hwndMain = CreateWindowEx(
WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE,
"containerHWND",
"Main test",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
800,
600,
NULL, // parent
NULL, // menu
hThisInstance,
NULL
);
ShowWindow(hwndMain, SW_SHOW);
if(hwndMain == NULL)
{
MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK);
return 0;
}
SetParent(hwnd, hwndMain);
App app = App(settings, wnd, hwndMain, wnd);
RECT rect;
int width = 640;
int height = 480;
if(GetClientRect(hwndMain, &rect))
{
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}
SetWindowPos(hwnd, NULL, 0, 0, width, height, NULL);
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
SetWindowLong(hwnd, GWL_STYLE, lStyle);
LONG lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
//SetWindowLong(hwnd, GWL_STYLE, WS_VISIBLE | WS_CHILD);
SetWindowLongPtr(hwndMain, GWL_USERDATA, (LONG)&app);
HICON hicon = (HICON)LoadImage(GetModuleHandleW(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
SendMessage(hwndMain, WM_SETICON, ICON_BIG, (LPARAM)hicon);
SetWindowPos(hwndMain, NULL, 0, 0, 800, 600, NULL);
HMONITOR monitor = MonitorFromWindow(hwndMain, MONITOR_DEFAULTTONEAREST);
MONITORINFO lpmi;
GetMonitorInfo( monitor, &lpmi);
int widthMON = lpmi.rcMonitor.bottom;
int heightMON = lpmi.rcMonitor.right;
//message = Convert(widthMON) + ", " + Convert(heightMON);
//messageTime = G3D::System::time();
app.run(); app.run();
return 0; return 0;
} }

View File

@@ -3,14 +3,17 @@
// Used by Dialogs.rc // Used by Dialogs.rc
// //
#define IDD_ABOUT_DIALOG 102 #define IDD_ABOUT_DIALOG 102
#define IDD_TOOLBOX 103
#define IDI_ICON1 106
#define IDC_TOOLBOX_BROWSER 1001
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40004 #define _APS_NEXT_COMMAND_VALUE 40004
#define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif