Hello all,
This is my first time posting on this forum. I have been having a peculiar problem on my TI-84 Plus CE regarding C++ programs. I am trying to create simple 3D graphics for a game I am working on, but the calculator is crashing when I attempt to run the program The code compiles without errors or warnings on the latest CE Toolchain.
My code is below:
main.cpp:
Code:
The calculator crashes when I run this program through Asmhook or Cesium. The line from (0, 0) to (100, 200) is drawn correctly, but the lines that I am trying to draw are not working. After I trigger GetCSC() to exit the program, the calculator goes entirely blank for about five seconds and then reboots, showing the "Validating OS" message. I have verified the line positions, and they are all within the screen's boundaries. I have also compiled all the non-graphical parts of the code on GCC, and they work as intended. Does anyone know why this may be happening?
Thank you,
srupuduflupudu
This is my first time posting on this forum. I have been having a peculiar problem on my TI-84 Plus CE regarding C++ programs. I am trying to create simple 3D graphics for a game I am working on, but the calculator is crashing when I attempt to run the program The code compiles without errors or warnings on the latest CE Toolchain.
My code is below:
main.cpp:
Code:
//#include <iostream>
#include <tice.h>
#include <graphx.h>
struct point2
{
int x;
int y;
};
struct point3
{
int x;
int y;
float z;
};
typedef point2 point2;
typedef point3 point3;
point2 p2from3(point3 p3_1);
class face3
{
public:
point3 p3_1;
point3 p3_2;
point3 p3_3;
point3 p3_4;
point2 p2_1 = p2from3(p3_1);
point2 p2_2 = p2from3(p3_2); // converting 3D points to 2D screen positions
point2 p2_3 = p2from3(p3_3);
point2 p2_4 = p2from3(p3_4);
void draw()
{
// gfx_FillTriangle(p2_1.x, p2_1.y, p2_2.x, p2_2.y, p2_3.x, p2_3.y); // 2 triangle generation
// gfx_FillTriangle(p2_2.x, p2_2.y, p2_3.x, p2_3.y, p2_4.x, p2_4.y);
gfx_Line(p2_1.x, p2_1.y, p2_2.x, p2_2.y); // drawing lines in the shape of the face outline
gfx_Line(p2_2.x, p2_2.y, p2_3.x, p2_3.y);
gfx_Line(p2_3.x, p2_3.y, p2_4.x, p2_4.y);
gfx_Line(p2_1.x, p2_1.y, p2_4.x, p2_4.y);
}
};
int main()
{
gfx_Begin();
face3 plate;
plate.p3_1.x = 50;
plate.p3_1.y = 100;
plate.p3_1.z = 2;
plate.p3_2.x = 120;
plate.p3_2.y = 100;
plate.p3_2.z = 2;
plate.p3_3.x = 120; // setting position and dimensions of the face "plate"
plate.p3_3.y = 120;
plate.p3_3.z = 1;
plate.p3_4.x = 100;
plate.p3_4.y = 120;
plate.p3_4.z = 1;
plate.draw();
gfx_Line(0, 0, 100, 200); // this line is drawn correctly, interestingly
while (!os_GetCSC())
{
}
gfx_End();
return 0;
}
point2 p2from3(point3 p3_1)
{
point2 p2_1;
p2_1.x = ((p3_1.x - 160) / p3_1.z) + 160;
p2_1.y = ((p3_1.x - 120) / p3_1.z) + 120;
return p2_1;
}
The calculator crashes when I run this program through Asmhook or Cesium. The line from (0, 0) to (100, 200) is drawn correctly, but the lines that I am trying to draw are not working. After I trigger GetCSC() to exit the program, the calculator goes entirely blank for about five seconds and then reboots, showing the "Validating OS" message. I have verified the line positions, and they are all within the screen's boundaries. I have also compiled all the non-graphical parts of the code on GCC, and they work as intended. Does anyone know why this may be happening?
Thank you,
srupuduflupudu