Permalink
Browse files

3D Shapes Drawing Test (#1350)

  • Loading branch information...
RobertBColton committed Aug 7, 2018
1 parent 1ca0e67 commit 42b7d98efe9930acb3ade71205b3778108892730
@@ -0,0 +1,23 @@
#include "TestHarness.hpp"

#include <gtest/gtest.h>

TEST(Regression, draw_3d_shapes_test) {
if (!TestHarness::windowing_supported()) return;
auto test_harness = LAUNCH_HARNESS_FOR_GAME(TestConfig(), "gmx");
if (!test_harness) FAIL() << "Game could not be run.";

test_harness->wait(); // Let the game render a frame first.
ASSERT_TRUE(test_harness->game_is_running())
<< "Game stopped running unexpectedly";

test_harness->screen_save("./test-harness-out/enigma_draw_3d_shapes_test.png");

test_harness->close_window();
bool game_running = test_harness->game_is_running();
for (int i = 0; game_running && i < 10; ++i) {
test_harness->wait();
game_running = test_harness->game_is_running();
}
ASSERT_FALSE(game_running) << "Game did not exit after window was closed!";
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<background>
<istileset>0</istileset>
<tilewidth>16</tilewidth>
<tileheight>16</tileheight>
<tilexoff>0</tilexoff>
<tileyoff>0</tileyoff>
<tilehsep>0</tilehsep>
<tilevsep>0</tilevsep>
<HTile>0</HTile>
<VTile>0</VTile>
<For3D>0</For3D>
<width>64</width>
<height>64</height>
<data>images\bkg_test.png</data>
</background>
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<assets>
<Configs name="configs"/>
<sprites name="sprites"/>
<sounds name="sound"/>
<backgrounds name="background">
<background>background\bkg_test</background>
</backgrounds>
<paths name="paths"/>
<scripts name="scripts">
<script>scripts\d3d_draw_shape.gml</script>
</scripts>
<shaders name="shaders"/>
<fonts name="fonts"/>
<timelines name="timelines"/>
<objects name="objects">
<object>objects\obj_0</object>
</objects>
<rooms name="rooms">
<room>rooms\rm_0</room>
</rooms>
<constants number="0"/>
<help/>
</assets>
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<object>
<spriteName>&lt;undefined&gt;</spriteName>
<solid>0</solid>
<visible>-1</visible>
<depth>0</depth>
<persistent>0</persistent>
<maskName>&lt;undefined&gt;</maskName>
<parentName>&lt;undefined&gt;</parentName>
<events>
<event enumb="0" eventtype="0">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<useapplyto>-1</useapplyto>
<isquestion>0</isquestion>
<exetype>2</exetype>
<functionname/>
<codestring/>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>test_texture = background_get_texture(bkg_test);&#13;
d3d_start();&#13;
d3d_set_hidden(true);&#13;
d3d_set_culling(false);&#13;
size = 20;</string>
</argument>
</arguments>
</action>
</event>
<event enumb="0" eventtype="8">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<useapplyto>-1</useapplyto>
<isquestion>0</isquestion>
<exetype>2</exetype>
<functionname/>
<codestring/>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>d3d_set_projection_ortho(0, 0, room_width, room_height, 0);&#13;
&#13;
for (var y = 0; y &lt; 6; y += 1) {&#13;
var yy = 25 + y * 45;&#13;
&#13;
for (var i = 0; i &lt; 4; i += 1) {&#13;
// Show all sides around the x-axis&#13;
d3d_transform_set_rotation_x(i * 90);&#13;
d3d_transform_add_translation(25 + i * 45, yy, 0);&#13;
d3d_draw_shape(y, size, test_texture);&#13;
// Show all sides around the y-axis&#13;
d3d_transform_set_rotation_y(i * 90);&#13;
d3d_transform_add_translation(30 + (i + 4) * 45, yy, 0);&#13;
d3d_draw_shape(y, size, test_texture);&#13;
}&#13;
}&#13;
&#13;
d3d_transform_set_identity();</string>
</argument>
</arguments>
</action>
</event>
</events>
<PhysicsObject>0</PhysicsObject>
<PhysicsObjectSensor>0</PhysicsObjectSensor>
<PhysicsObjectShape>0</PhysicsObjectShape>
<PhysicsObjectDensity>0.5</PhysicsObjectDensity>
<PhysicsObjectRestitution>0.1</PhysicsObjectRestitution>
<PhysicsObjectGroup>0</PhysicsObjectGroup>
<PhysicsObjectLinearDamping>0.1</PhysicsObjectLinearDamping>
<PhysicsObjectAngularDamping>0.1</PhysicsObjectAngularDamping>
<PhysicsObjectFriction>0.2</PhysicsObjectFriction>
<PhysicsObjectAwake>-1</PhysicsObjectAwake>
<PhysicsObjectKinematic>0</PhysicsObjectKinematic>
<PhysicsShapePoints/>
</object>
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<room>
<caption/>
<width>640</width>
<height>480</height>
<hsnap>16</hsnap>
<vsnap>16</vsnap>
<isometric>0</isometric>
<speed>30</speed>
<persistent>0</persistent>
<colour>16764006</colour>
<showcolour>-1</showcolour>
<code/>
<enableViews>0</enableViews>
<clearViewBackground>-1</clearViewBackground>
<makerSettings>
<isSet>-1</isSet>
<w>1024</w>
<h>640</h>
<showGrid>-1</showGrid>
<showObjects>-1</showObjects>
<showTiles>-1</showTiles>
<showBackgrounds>-1</showBackgrounds>
<showForegrounds>-1</showForegrounds>
<showViews>0</showViews>
<deleteUnderlyingObj>0</deleteUnderlyingObj>
<deleteUnderlyingTiles>0</deleteUnderlyingTiles>
<page>0</page>
<xoffset>0</xoffset>
<yoffset>0</yoffset>
</makerSettings>
<backgrounds>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
<background foreground="0" hspeed="0" htiled="-1" name="" stretch="0" visible="0" vspeed="0" vtiled="-1" x="0" y="0"/>
</backgrounds>
<views>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
<view hborder="32" hport="480" hspeed="-1" hview="480" objName="&lt;undefined&gt;" vborder="32" visible="0" vspeed="-1" wport="640" wview="640" xport="0" xview="0" yport="0" yview="0"/>
</views>
<instances>
<instance code="" colour="4294967295" id="100001" locked="0" name="inst_5593AEC4" objName="obj_0" rotation="0.0" scaleX="1.0" scaleY="1.0" x="0" y="0"/>
</instances>
<tiles/>
<PhysicsWorld>0</PhysicsWorld>
<PhysicsWorldTop>0</PhysicsWorldTop>
<PhysicsWorldLeft>0</PhysicsWorldLeft>
<PhysicsWorldRight>640</PhysicsWorldRight>
<PhysicsWorldBottom>480</PhysicsWorldBottom>
<PhysicsWorldGravityX>0.0</PhysicsWorldGravityX>
<PhysicsWorldGravityY>10.0</PhysicsWorldGravityY>
<PhysicsWorldPixToMeters>0.1</PhysicsWorldPixToMeters>
</room>
@@ -0,0 +1,59 @@
// argument0 = shape type
// 0 = d3d_draw_block
// 1 = d3d_draw_cylinder
// 2 = d3d_draw_cone
// 3 = d3d_draw_ellipsoid
// 4 = d3d_draw_wall
// 5 = d3d_draw_floor
// argument1 = size
// argument2 = texture id
var shape = argument0,
size = argument1,
tex = argument2;

switch (shape) {
case 0:
d3d_draw_block(
-size, -size, -size,
size, size, size,
tex, 1, 1
);
return 0;
case 1:
d3d_draw_cylinder(
-size, -size, -size,
size, size, size,
tex, 1, 1,
true, 8
);
return 0;
case 2:
d3d_draw_cone(
-size, -size, -size,
size, size, size,
tex, 1, 1,
true, 8
);
return 0;
case 3:
d3d_draw_ellipsoid(
-size, -size, -size,
size, size, size,
tex, 1, 1, 8
);
return 0;
case 4:
d3d_draw_wall(
-size, 0, -size,
size, 0, size,
tex, 1, 1
);
return 0;
case 5:
d3d_draw_floor(
-size, -size, 0,
size, size, 0,
tex, 1, 1
);
return 0;
}

0 comments on commit 42b7d98

Please sign in to comment.