Start 3D rendering

This commit is contained in:
Miloslav Ciz 2023-09-16 20:35:01 +02:00
parent 6e068eff2b
commit edcde03fa3
3 changed files with 74 additions and 0 deletions

View file

@ -1,11 +1,70 @@
#ifndef _LCR_RENDERER_H
#define _LCR_RENDERER_H
#define S3L_RESOLUTION_X LCR_SETTING_RESOLUTION_X
#define S3L_RESOLUTION_Y LCR_SETTING_RESOLUTION_Y
#define S3L_PIXEL_FUNCTION LCR_pixelFunc3D
#include "small3dlib.h"
struct LCR_Renderer
{
// TODO
};
S3L_Scene LCR_scene3D;
S3L_Model3D LCR_models3D[3]; // TODO
S3L_Unit LCR_vertices3D[LCR_SETTING_MAX_VERTICES * 3];
S3L_Index LCR_triangles3D[LCR_SETTING_MAX_TRIANGLES * 3];
void LCR_pixelFunc3D(S3L_PixelInfo *pixel)
{
LCR_drawPixelSafe(pixel->x,pixel->y,0xff00);
}
/** Builds an internal 3D model of the currently loaded map. Returns 1 on
success, otherwise 0 (e.g. not enough space). */
uint8_t LCR_buildMapModel(void)
{
// TODO
LCR_vertices3D[0] = -400;
LCR_vertices3D[1] = -100;
LCR_vertices3D[2] = 1000;
LCR_vertices3D[3] = 400;
LCR_vertices3D[4] = -100;
LCR_vertices3D[5] = 1000;
LCR_vertices3D[6] = 0;
LCR_vertices3D[7] = 400;
LCR_vertices3D[8] = 1000;
LCR_triangles3D[0] = 0;
LCR_triangles3D[1] = 1;
LCR_triangles3D[2] = 2;
return 1;
}
uint8_t LCR_rendererInit(void)
{
if (!LCR_buildMapModel())
return 0;
S3L_model3DInit(LCR_vertices3D,3,LCR_triangles3D,1,LCR_models3D);
S3L_sceneInit(LCR_models3D,1,&LCR_scene3D);
return 1;
}
void LCR_render(void)
{
S3L_newFrame();
S3L_drawScene(LCR_scene3D);
}
void LCR_drawBackground(int verticalOffset)
{
uint16_t color = LCR_skyImages[LCR_skyImages[256] & 0x00ff] ; // TODO