Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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>
18 
19 #ifndef BLAM
20 #define BLAM
21 #endif
22 
24 {
25  point,
26  linear,
28  none,
29 };
30 
31 
32 #pragma pack(push, 1)
33 struct bitmap
34 {
35  //filtering modes
36  /*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.
37 
38 
39 
40  * Point - Minimal filtering mode that preserves sharp edges. Ideal for pixel art or other similar cases.
41 
42  * 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.
43 
44  * Anisotropic - Best filtering mode. Performs the poorest but gives the best possible image quality.
45 
46  * None - No filtering is applied. Will often be identical to Point filtering.*/
51  //BITMAP DATA
52 
73  {
74  BF_RGBA8_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  ascii source_filename;
87  ascii source_file_format;
88  ascii source_pixel_format;
89  ascii 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  "UNUSED",
177  }),
178  new DataReferenceField("pixel data", "The raw pixel data for the bitmap."),
179  new Vector2Field("size", "The resolution of the bitmap."),
180  new Int16Field("bytes per line", "The amount of bytes needed for a single line/row of pixels for this bitmap."),
181  new BlockField(520, "import info", "",
182  {
183  new CommentField("IMPORT INFO",
184  "The fields listed below refer to data from the originally imported file, and are not used by the engine directly."),
185  new Int64Field("source filesize", "The file size of the original image, in bytes."),
186  new AsciiField("source filename", "The file name (or file path) of the original image."),
187  new AsciiField("source file format", "The format of the original image."),
188  new AsciiField("source pixel format", "The original pixel format of the source image."),
189  new AsciiField("parsed pixel format", "The pixel format of the interpreted image data during import."),
190  }),
191 
192  };
193  }
194 };
195 
197 {
198  BLAM bitmap* GetBitmapTag(std::string tag_path);
199 }
Int16Field
Class representing an int16 tag field.
Definition: int.h:59
font_map
BlamMap< std::string, BlamFontPackage * > font_map
Definition: fonts_new.cpp:18
BlamRendering::OGRE::Materials::CreateDefaultUnlitDatablockForPrimitives
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablockForPrimitives(std::string id)
Definition: materials.cpp:916
BlamRendering::RenderStack::Bitmap::resource_id
int resource_id
The resource ID of the bitmap.
Definition: render_stack.h:592
BlamRendering::RenderStack::StackObjectBase::visible
bool visible
Whether or not the object is visible.
Definition: render_stack.h:375
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:196
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:142
Blam::Content::Fonts::New::GetFontList
BLAM BlamMap< std::string, BlamFontPackage * > GetFontList()
Definition: fonts_new.cpp:652
font
io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels,...) font
Definition: README.txt:86
width
int width
Definition: bgfx.cpp:19
render_stack.h
logger.h
bitmap.h
glyph
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying glyph
Definition: ARPHICPL.TXT:16
AsciiField
Class representing an ascii tag field.
Definition: ascii.h:18
BlamFontPackage
Definition: fonts.h:57
Blam::Content::Fonts::New::LoadAllFonts
BLAM void LoadAllFonts()
Definition: fonts_new.cpp:64
ascii
char ascii[128]
Typedef for an ascii field, used in tag data definitions.
Definition: tags.h:353
BlamRendering::DirectX::Drawing::DrawBitmapFromResource
BLAM HRESULT DrawBitmapFromResource(int res_id, const char *res_type, D2D1_RECT_F area, int width, int height)
Draws a bitmap pulled from an application resource.
Definition: bitmap.cpp:6
imgui.h
Vector2Field
Class representing a vector2 tag field.
Definition: vector.h:34
ImGui::InputText
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
Definition: imgui_widgets.cpp:3068
resource_type_buffer
char resource_type_buffer[256]
Resource name buffer for ImGUI editor.
Definition: Bitmap.cpp:10
BlamRendering::DirectX::D2D::GetD2DRenderTarget
BLAM ID2D1DeviceContext * GetD2DRenderTarget()
Retrieves the Direct2D render target.
Definition: render_manage.cpp:598
DataReferenceField
Class representing a data reference, or dataref for short.
Definition: dataref.h:19
BitmapTagClass::BitmapTagClass
BitmapTagClass()
Definition: bitmap.h:97
BlamEngineDataFolder::Fonts
@ Fonts
Directory used for game engine fonts. Defaults to ./maps/fonts/
rendering.h
resolve_glyph_character
bool resolve_glyph_character(std::string xml_glyph, char *character)
Identify the character of the font glyph from the XML attribute.
Definition: fonts.cpp:755
drawing.h
Blam::Content::Fonts::New::GetFont
BLAM BlamFontPackage * GetFont(std::string id)
Definition: fonts_new.cpp:662
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
bitmap::TAG_BLOCK
TAG_BLOCK(import_info, { int64_t source_filesize;ascii source_filename;ascii source_file_format;ascii source_pixel_format;ascii parsed_pixel_format;})
Enum32Field
Definition: enum.h:46
glyph_attribute_test_int
int glyph_attribute_test_int(bool *out_result, std::string glyph_name, std::string font_name, std::string attribute_name, rapidxml::xml_attribute<> *attribute)
Definition: fonts_new.cpp:22
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:138
bitfield8
Typedef for a bitfield8 field, used in tag data definitions.
Definition: tags.h:275
BlamFontGlyph
Definition: fonts.h:35
errors.h
bitmap_filtering_mode::anisotropic
@ anisotropic
Blam::Content::Fonts::New::LoadFont
BLAM BlamResult LoadFont(std::string font_name)
Definition: fonts_new.cpp:647
bitmap::filtering_mode_mag
bitmap_filtering_mode filtering_mode_mag
Definition: bitmap.h:48
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:137
bitmap::size
vector2 size
The resolution of the bitmap.
Definition: bitmap.h:79
Blam::Content::Fonts::New::Cleanup
BLAM void Cleanup()
Definition: fonts_new.cpp:672
format
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting format
Definition: ARPHICPL.TXT:16
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:135
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:36
BlamFontPackageType::XMLBitmapAtlas
@ XMLBitmapAtlas
BlamRendering::DirectX::D2D::GetD2DFactory
BLAM ID2D1Factory * GetD2DFactory()
Retrieves the Direct2D factory.
Definition: render_manage.cpp:603
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:136
glyph_attribute_test_float
float glyph_attribute_test_float(bool *out_result, std::string glyph_name, std::string font_name, std::string attribute_name, rapidxml::xml_attribute<> *attribute)
Definition: fonts_new.cpp:43
Blam::Content::Fonts::New::LoadFontPackage
BLAM BlamResult LoadFontPackage(std::string file)
Definition: fonts_new.cpp:69
BlamRendering::OGRE::Materials::CreateDefaultUnlitDatablock
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablock(std::string id)
Definition: materials.cpp:905
bitmap::filtering_mode_mip
bitmap_filtering_mode filtering_mode_mip
Definition: bitmap.h:49
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:134
BlamRendering::RenderStack::Bitmap::ShowImPropertyEditor
void ShowImPropertyEditor()
Shows a set of ImGUI properties associated with the object.
Definition: Bitmap.cpp:28
int64_t
long long int64_t
Definition: stdint.h:14
BlamFontPackageType::XMLBitmap
@ XMLBitmap
Int64Field
Class representing an int64 tag field.
Definition: int.h:33
uint32_t
unsigned int uint32_t
Definition: stdint.h:17
Blam::Content::Tags::GetTagData
BLAM BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: tags.cpp:80
Blam::Content::Tags::GetBitmapTag
BLAM bitmap * GetBitmapTag(std::string tag_path)
Definition: bitmap.cpp:16
BlamRendering::DirectX::WIC::CreateD2DBitmapFromResource
BLAM HRESULT CreateD2DBitmapFromResource(int res_id, const char *res_type, ID2D1Bitmap **bitmap_pointer)
Creates a Direct2D bitmap from an application resource.
Definition: wic.cpp:262
BlamRendering::RenderStack::Bitmap::Draw
void Draw()
Draws the stack object.
Definition: Bitmap.cpp:13
bitmap_filtering_mode::none
@ none
IM_ARRAYSIZE
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:75
bitmap_filtering_mode::linear
@ linear
file
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current MUST include this txt file
Definition: chiropteraDM.txt:95
BlamRendering::RenderStack::StackObjectBase::area
D2D1_RECT_F area
The area of the object.
Definition: render_stack.h:369
fields.h
bitmap::pixel_data
data_reference pixel_data
The raw pixel data for the bitmap.
Definition: bitmap.h:78
BLAM
#define BLAM
Definition: bitmap.h:20
bitmap::flags
bitfield8 flags
Definition: bitmap.h:50
BlamRendering::RenderStack::StackObjectBase::width
float width
The width of the object.
Definition: render_stack.h:379
height
int height
Definition: bgfx.cpp:20
data_reference
Structure representing a data reference.
Definition: tags.h:261
BlamRendering::RenderStack::Bitmap::resource_type
const char * resource_type
The resource type of the bitmap.
Definition: render_stack.h:593
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:139
BlamFontPackageType::XMLTruetype
@ XMLTruetype
bitmap_filtering_mode
bitmap_filtering_mode
Definition: bitmap.h:23
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:356
bitmap
Definition: bitmap.h:33
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:71
tagclass.h
BlamRendering::RenderStack::StackObjectBase::height
float height
The height of the object.
Definition: render_stack.h:380
config.h
Blam::Error::GetStringFromHResult
BLAM std::string GetStringFromHResult(HRESULT hr)
Converts a result handle to a string.
Definition: errors.cpp:120
tags.h
tags.h
int16_t
short int16_t
Definition: stdint.h:12
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:68
fonts.h
BlamRendering::DirectX::Drawing::Widgets::DrawInvalidBitmapArea
BLAM void DrawInvalidBitmapArea(D2D1_RECT_F area)
A widget used to represent an invalid bitmap.
Definition: invalid_bitmap.cpp:7
BlamRendering::OGRE::Textures::LoadTexture2D
BLAM Ogre::TextureGpu * LoadTexture2D(std::string id, void *pixel_data, int width, int height, Ogre::PixelFormatGpu format, int bytes_per_line)
Definition: textures.cpp:117
bitmap::filtering_mode_min
bitmap_filtering_mode filtering_mode_min
Definition: bitmap.h:47
CommentField
Class representing a comment field.
Definition: comment.h:29
Blam::Content::Fonts::New::LoadFontDirectory
BLAM BlamResult LoadFontDirectory(std::string directory)
Definition: fonts_new.cpp:74
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:21
Blam::Content::Fonts::New::FontExists
BLAM bool FontExists(std::string id)
Definition: fonts_new.cpp:657
ImGui::InputInt
IMGUI_API bool InputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
Definition: imgui_widgets.cpp:3031
BlamTagClass
Class representing a tag class.
Definition: tags.h:131
bitmap::TAG_ENUM
TAG_ENUM(format, { BF_RGBA8_UNORM, BF_UNUSED, })
The fields below contain the raw bitmap data.
BitmapTagClass
Definition: bitmap.h:94
FONTINFO_FILENAME
#define FONTINFO_FILENAME
Definition: fonts.h:20
Bitfield8Field
Class representing a bitfield8 tag field.
Definition: bitfield.h:33