1v13d/src/main.c

215 lines
5.5 KiB
C
Raw Normal View History

2019-09-18 19:05:45 +02:00
/*
2019-07-19 21:55:17 +02:00
#include <gint/display.h>
#include <gint/keyboard.h>
2019-07-21 20:14:54 +02:00
#include <gint/std/stdio.h>
2019-07-23 18:30:27 +02:00
#include <gint/std/stdlib.h>
2019-07-21 21:27:02 +02:00
#include <gint/clock.h>
2019-09-17 18:57:38 +02:00
#include <fxengine/point.h>
2019-09-18 19:05:45 +02:00
*/
2019-09-17 18:57:38 +02:00
/*
int main(void)
{
//init_controls();
dclear(C_WHITE);
fe_integer_point point[4]={{{10,0,0},{0,0,0}},{{10,10,0},{0,0,0}},{{10,0,10},{0,0,0}},{{10,10,10},{0,0,0}}};
//FE_face face={&point[0],&point[1],&point[2],1,2};
//FE_face face2={&point[3],&point[1],&point[2],0,2};
while (1)
{
//FE_new_frame();
dclear(C_WHITE);
//reload_fps_displaying();
for (int i=0;i<4;i++)
{
fe_point_translate(&point[i]);
if (point[i].translated.z>0)
{
dpixel(point[i].translated.x,point[i].translated.y,C_BLACK);
}
}
dupdate();
//FE_draw_face(&face);
//FE_draw_face(&face2);
//display_fps(100,56);
}
getkey();
return 1;
}
*/
2019-07-20 16:03:28 +02:00
2019-07-23 18:30:27 +02:00
2019-09-17 18:57:38 +02:00
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/clock.h>
2019-09-18 19:05:45 +02:00
#include <fxengine/camera.h>
2019-09-17 18:57:38 +02:00
#include <fxengine/object.h>
2019-09-18 19:05:45 +02:00
#include <liblog.h>
2019-07-19 21:55:17 +02:00
int main(void)
{
2019-08-27 20:44:33 +02:00
//init_controls();
2019-07-19 21:55:17 +02:00
dclear(C_WHITE);
2019-09-17 18:57:38 +02:00
//render_integer_point point[4]={{{10,0,0},{0,0,0}},{{10,10,0},{0,0,0}},{{10,0,10},{0,0,0}},{{10,10,10},{0,0,0}}};
2019-08-27 20:44:33 +02:00
//FE_face face={&point[0],&point[1],&point[2],1,2};
//FE_face face2={&point[3],&point[1],&point[2],0,2};
2019-09-17 18:57:38 +02:00
uint32_t color[32] =
{
2019-09-17 18:57:38 +02:00
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11111111111111000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11000000000000000000000000000011,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111
};
fe_texture_rich * bmp = fe_texture_new_rich(32, 32, color, 0, 0, 0);
2019-09-18 19:05:45 +02:00
//fe_texture_debug(bmp);
fe_ivertex v[3]=
2019-09-17 18:57:38 +02:00
{
{
2019-09-18 19:05:45 +02:00
{1,1,2},
{0,0,0}
2019-09-17 18:57:38 +02:00
},
{
2019-09-18 19:05:45 +02:00
{2,1,3},
{0,0,0}
2019-09-17 18:57:38 +02:00
},
{
2019-09-18 19:05:45 +02:00
{1,4,2},
{0,0,0}
2019-09-17 18:57:38 +02:00
}
};
fe_object object;
fe_object_init(&object);
2019-09-18 19:05:45 +02:00
fe_object_set_points(&object, &v, 3, 0);
2019-09-17 18:57:38 +02:00
fe_triangle triangle =
{
2019-09-18 19:05:45 +02:00
fe_object_get_vertex(&object, 0),
fe_object_get_vertex(&object, 1),
fe_object_get_vertex(&object, 2),
2019-09-17 18:57:38 +02:00
bmp,
0,
0
};
fe_object_set_faces(&object, &triangle, 1, 0);
2019-09-18 19:05:45 +02:00
//fe_object_debug(&object);
fe_camera cam = {{0,0,0},{0,0,0},0,0,0};
while (1)
{
2019-09-17 18:57:38 +02:00
2019-09-18 19:05:45 +02:00
int key = getkey().key;
char str[40];
/* sprintf(str, "S1 %d %d %d",
fe_object_get_vertex(&object, 0)->x,
fe_object_get_vertex(&object, 0)->y,
fe_object_get_vertex(&object, 0)->z);
fe_log(str);
sprintf(str, "S2 %d %d %d",
fe_object_get_vertex(&object, 1)->x,
fe_object_get_vertex(&object, 1)->y,
fe_object_get_vertex(&object, 1)->z);
fe_log(str);
sprintf(str, "S3 %d %d %d",
fe_object_get_vertex(&object, 2)->x,
fe_object_get_vertex(&object, 2)->y,
fe_object_get_vertex(&object, 2)->z);
*/
sprintf(str, "cam %d %d %d",
cam.pos.x,
cam.pos.y,
cam.pos.z);
ll_log(str);
//ll_log(str);
if (key == KEY_LEFT)
cam.dh -= 0.1;
if (key == KEY_RIGHT)
cam.dh += 0.1;
cam.dh = fe_modulo_2pi(cam.dh);
if (key == KEY_UP)
cam.dv += 0.1;
if (key == KEY_DOWN)
cam.dv -= 0.1;
cam.dv = fe_modulo_2pi(cam.dv);
if (key == KEY_6)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_cos(cam.dh));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_sin(cam.dh));
}
if (key == KEY_4)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_cos(cam.dh+pi));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_sin(cam.dh+pi));
}
if (key == KEY_8)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_cos(cam.dh+pi_sur_2));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_sin(cam.dh+pi_sur_2));
}
if (key == KEY_2)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_cos(cam.dh-pi_sur_2));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_sin(cam.dh-pi_sur_2));
}
cam.dv = fe_modulo_2pi(cam.dv);
2019-09-17 18:57:38 +02:00
2019-09-18 19:05:45 +02:00
fe_view_set(&cam);
fe_object_display(&object);
2019-09-17 18:57:38 +02:00
2019-09-18 19:05:45 +02:00
if (key == KEY_EXIT)
break;
if (key==KEY_F1)
ll_display_log();
else
fe_render_update(1);
2019-09-17 18:57:38 +02:00
2019-09-18 19:05:45 +02:00
}
2019-09-17 18:57:38 +02:00
return 1;
}