Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.blamite
The core library for the Blamite Game Engine.
bitmap.h
Go to the documentation of this file.
1 // bitmap [bitm] - Tag Definition //
3 // -------- //
4 // Author: haloman30 //
5 // Revision: 5 //
6 // -------- //
7 // Part of the Blamite Game Engine //
8 // Copyright (c) Elaztek Studios 2013 - 2023 //
10 
11 
12 #pragma once
13 
14 #include <string>
15 #include <blam/api/v1/types/tags.h>
17 
18 #ifndef BLAM
19 #define BLAM
20 #endif
21 
23 {
24  point,
25  linear,
27  none,
28 };
29 
30 
31 #pragma pack(push, 1)
32 struct bitmap
33 {
34  //filtering modes
35  /*The texture filtering mode adjusts how the bitmap is displayed in-game. Below is a list of all filtering modes and their ideal use cases.
36 
37 
38 
39  * Point - Minimal filtering mode that preserves sharp edges. Ideal for pixel art or other similar cases.
40 
41  * Linear - Balanced filtering mode that will attempt to blend pixels together to avoid a pixelated appearance, with a minimal performance impact. Ideal for most situations.
42 
43  * Anisotropic - Best filtering mode. Performs the poorest but gives the best possible image quality.
44 
45  * None - No filtering is applied. Will often be identical to Point filtering.*/
50  //BITMAP DATA
51 
71  TAG_ENUM(format,
72  {
73  BF_RGBA8_UNORM,
74  BF_RGB8_UNORM,
75  BF_UNUSED,
76  });
77 
81  TAG_BLOCK(import_info,
82  {
83  //IMPORT INFO
84  /*The fields listed below refer to data from the originally imported file, and are not used by the engine directly.*/
85  int64_t source_filesize;
86  data_reference source_filename;
87  data_reference source_file_format;
88  data_reference source_pixel_format;
89  data_reference parsed_pixel_format;
90  });
91 };
92 #pragma pack(pop)
93 
95 {
96 public:
98  {
99  class_name_long = "bitmap";
100  class_name_short = "bitm";
101  version = 5;
102 
103  revisions = {
104  {1, "haloman30", "Initial implementation."},
105  {2, "haloman30", "Add test datarefs and tagrefs"},
106  {3, "haloman30", "Remove all test fields, actual initial implementation"},
107  {4, "haloman30", "Add multiple filtering enums for min, mag, mip, and allow bitmap filter mode to override material filter mode"},
108  {5, "haloman30", "Add support for RGBA8_UNORM pixel formats, move format_temp to import info block as parsed_pixel_format"},
109 
110  };
111 
112  tag_size = 91;
113 
114  fields =
115  {
116  new CommentField("filtering modes",
117  "The texture filtering mode adjusts how the bitmap is displayed in-game. Below is a list of all filtering modes and their ideal use cases.\n"
118  "\n"
119  "\n"
120  "\n"
121  "* Point - Minimal filtering mode that preserves sharp edges. Ideal for pixel art or other similar cases.\n"
122  "\n"
123  "* Linear - Balanced filtering mode that will attempt to blend pixels together to avoid a pixelated appearance, with a minimal performance impact. Ideal for most situations.\n"
124  "\n"
125  "* Anisotropic - Best filtering mode. Performs the poorest but gives the best possible image quality.\n"
126  "\n"
127  "* None - No filtering is applied. Will often be identical to Point filtering."),
128  new Enum32Field("filtering mode (min)", "The texture filtering mode for minification. See comment above for details.",
129  {
130  "point",
131  "linear",
132  "anisotropic",
133  "none",
134  }),
135  new Enum32Field("filtering mode (mag)", "The texture filtering mode for magnification. See comment above for details.",
136  {
137  "point",
138  "linear",
139  "anisotropic",
140  "none",
141  }),
142  new Enum32Field("filtering mode (mip)", "The texture filtering mode for mip-mapping. See comment above for details.",
143  {
144  "point",
145  "linear",
146  "anisotropic",
147  "none",
148  }),
149  new Bitfield8Field("flags", "",
150  {
151  "force mip filtering mode",
152  "force min filtering mode",
153  "force mag filtering mode",
154  }),
155  new CommentField("BITMAP DATA",
156  "***************************************************************************************************************************\n"
157  "\n"
158  "\n"
159  "\n"
160  "The fields below contain the raw bitmap data. It is updated when you reimport the bitmap.\n"
161  "\n"
162  "\n"
163  "\n"
164  "Any changes you make below will be lost in the next import, and may even cause 'bad things' to happen - such as invalid textures or crashes.\n"
165  "\n"
166  "\n"
167  "\n"
168  "If you wish to make any changes to a bitmap, you should simply re-import the image from its source. If the source image filehas been lost, consult the documentation for methods to export a bitmap tag back into a source image file.\n"
169  "\n"
170  "\n"
171  "\n"
172  "***************************************************************************************************************************"),
173  new Enum32Field("format", "The pixel format of the bitmap data.",
174  {
175  "RGBA8_UNORM",
176  "RGB8_UNORM",
177  "UNUSED",
178  }),
179  new DataReferenceField("pixel data", "The raw pixel data for the bitmap."),
180  new Vector2Field("size", "The resolution of the bitmap."),
181  new Int16Field("bytes per line", "The amount of bytes needed for a single line/row of pixels for this bitmap."),
182  new BlockField(136, "import info", "",
183  {
184  new CommentField("IMPORT INFO",
185  "The fields listed below refer to data from the originally imported file, and are not used by the engine directly."),
186  new Int64Field("source filesize", "The file size of the original image, in bytes."),
187  new DataReferenceField("source filename", "The file name (or file path) of the original image."),
188  new DataReferenceField("source file format", "The format of the original image."),
189  new DataReferenceField("source pixel format", "The original pixel format of the source image."),
190  new DataReferenceField("parsed pixel format", "The pixel format of the interpreted image data during import."),
191  }),
192 
193  };
194  }
195 };
196 
198 {
199  BLAM bitmap* GetBitmapTag(std::string tag_path);
200 }
Int16Field
Class representing an int16 tag field.
Definition: int.h:59
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:197
bitmap.h
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:34
DataReferenceField
Class representing a data reference, or dataref for short.
Definition: dataref.h:19
BitmapTagClass::BitmapTagClass
BitmapTagClass()
Definition: bitmap.h:97
bitmap_filtering_mode::point
@ point
bitmap::bytes_per_line
int16_t bytes_per_line
The amount of bytes needed for a single line/row of pixels for this bitmap.
Definition: bitmap.h:80
Enum32Field
Definition: enum.h:46
Blam::API::v1::Tags::GetTagData
BLAM_EXT_API BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: api.cpp:197
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:200
bitfield8
Typedef for a bitfield8 field, used in tag data definitions.
Definition: tags.h:344
bitmap_filtering_mode::anisotropic
@ anisotropic
bitmap::filtering_mode_mag
bitmap_filtering_mode filtering_mode_mag
Definition: bitmap.h:47
BlamTagClass::revisions
std::vector< BlamTagClassRevision > revisions
List of all tag class revisions. Does not get written to tags, but is included in plugin files.
Definition: tags.h:199
bitmap::size
vector2 size
The resolution of the bitmap.
Definition: bitmap.h:79
plugins.h
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:197
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:198
bitmap::filtering_mode_mip
bitmap_filtering_mode filtering_mode_mip
Definition: bitmap.h:48
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:196
int64_t
long long int64_t
Definition: stdint.h:14
Int64Field
Class representing an int64 tag field.
Definition: int.h:33
uint32_t
unsigned int uint32_t
Definition: stdint.h:17
Blam::Content::Tags::GetBitmapTag
BLAM bitmap * GetBitmapTag(std::string tag_path)
Definition: bitmap.cpp:16
bitmap_filtering_mode::none
@ none
bitmap_filtering_mode::linear
@ linear
bitmap::TAG_BLOCK
TAG_BLOCK(import_info, { int64_t source_filesize;data_reference source_filename;data_reference source_file_format;data_reference source_pixel_format;data_reference parsed_pixel_format;})
bitmap::pixel_data
data_reference pixel_data
The raw pixel data for the bitmap.
Definition: bitmap.h:78
BLAM
#define BLAM
Definition: bitmap.h:19
bitmap::flags
bitfield8 flags
Definition: bitmap.h:49
data_reference
Structure representing a data reference.
Definition: tags.h:323
bitmap::TAG_ENUM
TAG_ENUM(format, { BF_RGBA8_UNORM, BF_RGB8_UNORM, BF_UNUSED, })
The fields below contain the raw bitmap data.
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:201
bitmap_filtering_mode
bitmap_filtering_mode
Definition: bitmap.h:22
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:425
bitmap
Definition: bitmap.h:32
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:130
tags.h
int16_t
short int16_t
Definition: stdint.h:12
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:124
bitmap::filtering_mode_min
bitmap_filtering_mode filtering_mode_min
Definition: bitmap.h:46
CommentField
Class representing a comment field.
Definition: comment.h:29
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:19
BlamTagClass
Class representing a tag class.
Definition: tags.h:193
BitmapTagClass
Definition: bitmap.h:94
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33
api.h