Made rendering slightly more efficient (Draw::Box is really not effective)
This commit is contained in:
@@ -234,10 +234,6 @@
|
||||
RelativePath=".\AudioPlayer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ButtonListener.cpp"
|
||||
>
|
||||
@@ -246,10 +242,6 @@
|
||||
RelativePath=".\CameraController.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Dialogs.rc"
|
||||
>
|
||||
@@ -258,14 +250,6 @@
|
||||
RelativePath=".\Globals.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
@@ -286,6 +270,25 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Instance"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.cpp"
|
||||
>
|
||||
@@ -299,6 +302,7 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
@@ -307,10 +311,6 @@
|
||||
RelativePath=".\AudioPlayer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ButtonListener.h"
|
||||
>
|
||||
@@ -319,10 +319,6 @@
|
||||
RelativePath=".\CameraController.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Demo.h"
|
||||
>
|
||||
@@ -331,6 +327,25 @@
|
||||
RelativePath=".\Globals.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\win32Defines.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Instance"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.h"
|
||||
>
|
||||
@@ -343,23 +358,16 @@
|
||||
RelativePath=".\PhysicalInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\win32Defines.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
|
||||
@@ -5,6 +5,7 @@ Vector3 size;
|
||||
Vector3 position;
|
||||
Vector3 velocity;
|
||||
Vector3 rotVelocity;
|
||||
GLfloat vertecies[96];
|
||||
CoordinateFrame cFrame;
|
||||
Color3 color;
|
||||
bool changed = true;
|
||||
@@ -89,13 +90,47 @@ Box PhysicalInstance::getBox()
|
||||
Box box = Box(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));
|
||||
CoordinateFrame c = getCFrameRenderBased();
|
||||
itemBox = c.toWorldSpace(box);
|
||||
Vector3 v0,v1,v2,v3;
|
||||
for (int f = 0; f < 6; f++) {
|
||||
itemBox.getFaceCorners(f, v0,v1,v2,v3);
|
||||
vertecies[f*16] = v0.x;
|
||||
vertecies[(f*16)+1] = v0.y;
|
||||
vertecies[(f*16)+2] = v0.z;
|
||||
vertecies[(f*16)+3] = v1.x;
|
||||
vertecies[(f*16)+4] = v1.y;
|
||||
vertecies[(f*16)+5] = v1.z;
|
||||
vertecies[(f*16)+6] = v2.x;
|
||||
vertecies[(f*16)+7] = v2.y;
|
||||
vertecies[(f*16)+8] = v2.z;
|
||||
vertecies[(f*16)+9] = v3.x;
|
||||
vertecies[(f*16)+10] = v3.y;
|
||||
vertecies[(f*16)+11] = v3.z;
|
||||
vertecies[(f*16)+12] = color.r;
|
||||
vertecies[(f*16)+13] = color.g;
|
||||
vertecies[(f*16)+14] = color.b;
|
||||
vertecies[(f*16)+15] = 1;
|
||||
}
|
||||
}
|
||||
return itemBox;
|
||||
}
|
||||
|
||||
void PhysicalInstance::render(RenderDevice* rd)
|
||||
{
|
||||
Draw::box(getBox(), rd, color, Color4::clear());
|
||||
if(changed)
|
||||
Box box = getBox();
|
||||
glColor(color);
|
||||
glBegin(GL_QUADS);
|
||||
for(int i = 0; i < 96; i+=16)
|
||||
{
|
||||
Vector3 v0 = Vector3(vertecies[i], vertecies[i+1], vertecies[i+2]), v1 = Vector3(vertecies[i+3], vertecies[i+4], vertecies[i+5]), v3 = Vector3(vertecies[i+9], vertecies[i+10], vertecies[i+11]);
|
||||
glNormal3fv((v1 - v0).cross(v3 - v0).direction());
|
||||
glVertex3fv(v0);
|
||||
glVertex3fv(v1);
|
||||
glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]);
|
||||
glVertex3fv(v3);
|
||||
}
|
||||
glEnd();
|
||||
glColor(Color3::white());
|
||||
if(!children.empty())
|
||||
{
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -997,9 +997,7 @@ void Demo::exitApplication()
|
||||
|
||||
void Demo::onGraphics(RenderDevice* rd) {
|
||||
|
||||
//Vector2 mousepos = dataModel->getMousePos();
|
||||
G3D::uint8 num = 0;
|
||||
//rd->window()->getRelativeMouseState(mousepos, num);
|
||||
POINT mousepos;
|
||||
bool mouseOnScreen = true;
|
||||
if (GetCursorPos(&mousepos))
|
||||
@@ -1514,6 +1512,7 @@ int main(int argc, char** argv) {
|
||||
MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
|
||||
ShowWindow(hwndMain, SW_SHOW);
|
||||
|
||||
Win32Window* win32Window = Win32Window::create(settings.window,hwndMain);
|
||||
|
||||
Reference in New Issue
Block a user