6static constexpr int32_t
ONE_Q12 = 1 << 12;
23 return TEXTURE_SIZE_8;
25 return TEXTURE_SIZE_16;
27 return TEXTURE_SIZE_32;
29 return TEXTURE_SIZE_64;
31 return TEXTURE_SIZE_128;
33 return TEXTURE_SIZE_256;
35 return TEXTURE_SIZE_512;
37 return TEXTURE_SIZE_1024;
40 return TEXTURE_SIZE_8;
53 glViewport(0, 0, 255, 191);
54 glMatrixMode(GL_PROJECTION);
71 glFogShift(config.
shift);
73 glFogOffset(config.
depth);
77 for (uint8_t i = 0; i < 32; ++i)
79 glFogDensity(i, density);
81 density += (config.
mass * i) >> 2;
97 glClearColor(0, 0, 0, 31);
103 const GL_TEXTURE_TYPE_ENUM texType,
109 if (texture ==
nullptr)
115 if (textureID != -1 && textureID != 0)
117 glDeleteTextures(1, &textureID);
121 glGenTextures(1, &textureID);
122 glBindTexture(GL_TEXTURE_2D, textureID);
160 if (posX.raw_value() || posY.raw_value() || posZ.raw_value())
162 glTranslatef32(posX.raw_value(), posY.raw_value(), posZ.raw_value());
166 glRotatef32(rotX, 1, 0, 0);
170 glRotatef32(rotY, 0, 1, 0);
174 glRotatef32(rotZ, 0, 0, 1);
176 if (scale.raw_value() !=
ONE_Q12)
178 glScalef32(scale.raw_value(), scale.raw_value(), scale.raw_value());
197 BillboardData bb,
const int texture,
bool faceCamera, ae::q20_12_t camX, ae::q20_12_t camY, ae::q20_12_t camZ)
201 glBindTexture(GL_TEXTURE_2D, texture);
206 ae::q4_12_t rX{1}, rY{0}, rZ{0};
207 ae::q4_12_t uX{0}, uY{1}, uZ{0};
212 ae::q20_12_t bx = ae::q20_12_t::from_raw_value(
static_cast<int32_t
>(bb.
x.raw_value()));
213 ae::q20_12_t bz = ae::q20_12_t::from_raw_value(
static_cast<int32_t
>(bb.
z.raw_value()));
215 ae::q20_12_t dx = camX - bx;
216 ae::q20_12_t dz = camZ - bz;
219 ae::q20_12_t dist =
math.length(dx, dz, ae::q20_12_t{0});
221 if (dist > ae::q20_12_t{0.001})
223 dx =
math.div(dx, dist);
224 dz =
math.div(dz, dist);
228 rX = ae::q4_12_t::from_raw_value(
static_cast<int16_t
>(dz.raw_value()));
229 rZ = ae::q4_12_t::from_raw_value(
static_cast<int16_t
>((-dx).raw_value()));
240 glTexCoord2t16(bb.
u0.raw_value(), bb.
v1.raw_value());
241 glVertex3v16((bb.
x - rx - ux).raw_value(), (bb.
y - ry - uy).raw_value(), (bb.
z - rz - uz).raw_value());
243 glTexCoord2t16(bb.
u1.raw_value(), bb.
v1.raw_value());
244 glVertex3v16((bb.
x + rx - ux).raw_value(), (bb.
y + ry - uy).raw_value(), (bb.
z + rz - uz).raw_value());
246 glTexCoord2t16(bb.
u1.raw_value(), bb.
v0.raw_value());
247 glVertex3v16((bb.
x + rx + ux).raw_value(), (bb.
y + ry + uy).raw_value(), (bb.
z + rz + uz).raw_value());
249 glTexCoord2t16(bb.
u0.raw_value(), bb.
v0.raw_value());
250 glVertex3v16((bb.
x - rx + ux).raw_value(), (bb.
y - ry + uy).raw_value(), (bb.
z - rz + uz).raw_value());
264 glBindTexture(GL_TEXTURE_2D, texture);
268 glCallList(displayList);
275 glDeleteTextures(1, &texture);
static constexpr int32_t ONE_Q12
static int textureSizeEnum(int size)
Converts a raw texture dimension in pixels to the corresponding libnds TEXTURE_SIZE_* enum value.
Manager for hardware specific rendering functionse.
void cleanup3DView()
Cleans up the 3D view, resetting the state.
void renderTexturedBillboard(BillboardData bb, const int texture, bool faceCamera, ae::q20_12_t camX, ae::q20_12_t camY, ae::q20_12_t camZ)
Renders a textured billboard.
bool uploadTexture(int &textureID, const GL_TEXTURE_TYPE_ENUM texType, const int sizeX, const int sizeY, int param, const void *bitmap)
Uploads a texture to the GPU.
void initialize3DView(View3DConfig config)
Initialize a new 3D view.
void renderDisplayList(const void *displayList, const int texture)
Renders a textured model.
void renderModelComponent(MDL3Model &model)
Renders a MDL3 model.
void deleteTexture(int &texture)
Deletes a texture from the GPU and resets its ID.
static const ae::q20_12_t DEGREE_MODIFIER
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Util to handle error logging.
Represents a 3D model with nodes, textures, and animations.
etl::vector< MDL3Texture, 8 > textures
etl::vector< Node, 64 > nodes
Represents a node in the 3D model.
etl::vector< SubList_N, 64 > subLists
Represents a sublist of a node in the 3D model.
const uint32_t * displayList
Data structure to store 3D view configuration parameters.
uint8_t mass
How thick (translucent) the fog is.
rgb outlineColor
Outline color in RGB15 format. If -1, outline will not be enabled.
int settings
This is a bitmask of various settings, which will be passed to glEnable().
int farPlane
Defines how far the camera can see.
ae::q20_12_t nearPlane
Defines how close the cmaera can see.
RGBA fogColor
RGBA values for the foh color. If the r value is -1, fog will not be enabled.
uint32_t polyParams
This is a bitmask of various polygon parameters, which will be passed to glPolyFmt().
uint16_t depth
How far the fog is (0x0000 to 0x8000).