Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.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 
22 #define tag_bitm "bitm"
23 
25 {
26  point,
27  linear,
29  none,
30 };
31 
32 
33 #pragma pack(push, 1)
34 struct bitmap
35 {
40  {
46  bool unused5 : 1;
47  bool unused6 : 1;
48  bool unused7 : 1;
49  };
50 
52 
55  TAG_ENUM(format,
56  {
57  BF_RGBA8_UNORM,
58  BF_RGB8_UNORM,
59  BF_UNUSED,
60  });
61 
65  TAG_BLOCK(import_info,
66  {
67  int64_t source_filesize;
68  data_reference source_filename;
69  data_reference source_file_format;
70  data_reference source_pixel_format;
71  data_reference parsed_pixel_format;
72  });
73 };
74 #pragma pack(pop)
75 
77 {
78 public:
80  {
81  class_name_long = "bitmap";
82  class_name_short = "bitm";
83  version = 5;
84 
85  revisions = {
86  {1, "haloman30", "Initial implementation."},
87  {2, "haloman30", "Add test datarefs and tagrefs"},
88  {3, "haloman30", "Remove all test fields, actual initial implementation"},
89  {4, "haloman30", "Add multiple filtering enums for min, mag, mip, and allow bitmap filter mode to override material filter mode"},
90  {5, "haloman30", "Add support for RGBA8_UNORM pixel formats, move format_temp to import info block as parsed_pixel_format"},
91 
92  };
93 
94  tag_size = 91;
95 
96  fields =
97  {
98  new CommentField("filtering modes",
99  "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"
100  "\n"
101  "\n"
102  "\n"
103  "* Point - Minimal filtering mode that preserves sharp edges. Ideal for pixel art or other similar cases.\n"
104  "\n"
105  "* 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"
106  "\n"
107  "* Anisotropic - Best filtering mode. Performs the poorest but gives the best possible image quality.\n"
108  "\n"
109  "* None - No filtering is applied. Will often be identical to Point filtering."),
110  new Enum32Field("filtering mode (min)", "The texture filtering mode for minification. See comment above for details.",
111  {
112  "point",
113  "linear",
114  "anisotropic",
115  "none",
116  }),
117  new Enum32Field("filtering mode (mag)", "The texture filtering mode for magnification. See comment above for details.",
118  {
119  "point",
120  "linear",
121  "anisotropic",
122  "none",
123  }),
124  new Enum32Field("filtering mode (mip)", "The texture filtering mode for mip-mapping. See comment above for details.",
125  {
126  "point",
127  "linear",
128  "anisotropic",
129  "none",
130  }),
131  new Bitfield8Field("flags", "",
132  {
133  "force mip filtering mode",
134  "force min filtering mode",
135  "force mag filtering mode",
136  "disable auto mipmap generation",
137  "skip srgb correction for auto mipmaps",
138  }),
139  new CommentField("BITMAP DATA",
140  "***************************************************************************************************************************\n"
141  "\n"
142  "\n"
143  "\n"
144  "The fields below contain the raw bitmap data. It is updated when you reimport the bitmap.\n"
145  "\n"
146  "\n"
147  "\n"
148  "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"
149  "\n"
150  "\n"
151  "\n"
152  "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"
153  "\n"
154  "\n"
155  "\n"
156  "***************************************************************************************************************************"),
157  new Enum32Field("format", "The pixel format of the bitmap data.",
158  {
159  "RGBA8_UNORM",
160  "RGB8_UNORM",
161  "UNUSED",
162  }),
163  new DataReferenceField("pixel data", "The raw pixel data for the bitmap."),
164  new Vector2Field("size", "The resolution of the bitmap."),
165  new Int16Field("bytes per line", "The amount of bytes needed for a single line/row of pixels for this bitmap."),
166  new BlockField(136, "import info", "",
167  {
168  new CommentField("IMPORT INFO",
169  "The fields listed below refer to data from the originally imported file, and are not used by the engine directly."),
170  new Int64Field("source filesize", "The file size of the original image, in bytes."),
171  new DataReferenceField("source filename", "The file name (or file path) of the original image."),
172  new DataReferenceField("source file format", "The format of the original image."),
173  new DataReferenceField("source pixel format", "The original pixel format of the source image."),
174  new DataReferenceField("parsed pixel format", "The pixel format of the interpreted image data during import."),
175  }),
176 
177  };
178  }
179 };
180 
182 {
183  BLAM bitmap* GetBitmapTag(std::string tag_path);
184 }
Int16Field
Class representing an int16 tag field.
Definition: int.h:59
tag_io.h
BlamTagInstance::parent_tag
BlamTagData * parent_tag
Definition: tags.h:238
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:181
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
bitmap::bitfield8_flags::force_mip_filtering_mode
bool force_mip_filtering_mode
Definition: bitmap.h:41
logger.h
bitmap.h
bitmap::bitfield8_flags::unused7
bool unused7
Definition: bitmap.h:48
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:34
blamscript.h
BlamTagData::path
char path[256]
The tag's path.
Definition: tags.h:145
DataReferenceField
Class representing a data reference, or dataref for short.
Definition: dataref.h:19
BlamTagData::GetPokeKey
int GetPokeKey()
Definition: BlamTagData.cpp:93
BitmapTagClass::BitmapTagClass
BitmapTagClass()
Definition: bitmap.h:79
BlamTagData::BlamTagData
BlamTagData()
Definition: BlamTagData.cpp:9
BlamTagData::Good
bool Good()
Definition: BlamTagData.cpp:114
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:64
Enum32Field
Definition: enum.h:45
Blam::API::v1::Tags::GetTagData
BLAM_EXT_API BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: api.cpp:208
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:209
BlamTagData::~BlamTagData
~BlamTagData()
Definition: BlamTagData.cpp:16
bitmap_filtering_mode::anisotropic
@ anisotropic
BlamTagData::instances
std::vector< BlamTagInstance * > instances
Definition: tags.h:149
BlamTagData::SetTagPath
bool SetTagPath(std::string new_path)
Updates the tag path.
Definition: BlamTagData.cpp:39
bitmap::filtering_mode_mag
bitmap_filtering_mode filtering_mode_mag
Definition: bitmap.h:37
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:208
bitmap::size
vector2 size
The resolution of the bitmap.
Definition: bitmap.h:63
plugins.h
Blam::Content::Tags::CloneTag
BLAM BlamTagData * CloneTag(BlamTagData *original_tag_data)
Creates a copy of a tag in memory.
Definition: tag_io.cpp:826
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:206
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:207
BlamTagData::GetInstance
BlamTagInstance * GetInstance(std::string identifier)
Definition: BlamTagData.cpp:80
tag_bitm
#define tag_bitm
Definition: bitmap.h:22
bitmap::filtering_mode_mip
bitmap_filtering_mode filtering_mode_mip
Definition: bitmap.h:38
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:205
int64_t
long long int64_t
Definition: stdint.h:14
Int64Field
Class representing an int64 tag field.
Definition: int.h:33
BlamTagInstance::identifier
std::string identifier
Definition: tags.h:239
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
BlamTagData::Poke
void Poke()
Definition: BlamTagData.cpp:98
bitmap_filtering_mode::linear
@ linear
BlamTagInstance
Definition: tags.h:236
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:62
BLAM
#define BLAM
Definition: bitmap.h:19
bitmap::bitfield8_flags
Definition: bitmap.h:39
data_reference
Structure representing a data reference.
Definition: tags.h:342
bitmap::TAG_ENUM
TAG_ENUM(format, { BF_RGBA8_UNORM, BF_RGB8_UNORM, BF_UNUSED, })
The pixel format of the bitmap data.
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:210
bitmap_filtering_mode
bitmap_filtering_mode
Definition: bitmap.h:24
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:444
BlamTagData::CreateNewInstance
BlamTagInstance * CreateNewInstance()
Definition: BlamTagData.cpp:67
bitmap
Definition: bitmap.h:34
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:132
bitmap::bitfield8_flags::disable_auto_mip_srgb_correction
bool disable_auto_mip_srgb_correction
Definition: bitmap.h:45
bitmap::flags
bitfield8_flags flags
Bitfield data for flags. See #bitfield8_flags for details.
Definition: bitmap.h:51
tags.h
int16_t
short int16_t
Definition: stdint.h:12
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
bitmap::bitfield8_flags::force_mag_filtering_mode
bool force_mag_filtering_mode
Definition: bitmap.h:43
bitmap::bitfield8_flags::unused6
bool unused6
Definition: bitmap.h:47
bitmap::filtering_mode_min
bitmap_filtering_mode filtering_mode_min
Definition: bitmap.h:36
CommentField
Class representing a comment field.
Definition: comment.h:29
BlamTagInstance::instance
BlamTagData * instance
Definition: tags.h:240
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:19
script
Definition: script.h:31
bitmap::bitfield8_flags::disable_auto_mipmaps
bool disable_auto_mipmaps
Definition: bitmap.h:44
BlamTagClass
Class representing a tag class.
Definition: tags.h:202
bitmap::bitfield8_flags::force_min_filtering_mode
bool force_min_filtering_mode
Definition: bitmap.h:42
BitmapTagClass
Definition: bitmap.h:76
BlamTagData::script
BlamTagScript * script
Definition: tags.h:154
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33
api.h
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:146
bitmap::bitfield8_flags::unused5
bool unused5
Definition: bitmap.h:46