antispam-bee domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/ruwritingagame/public_html/wp-includes/functions.php on line 6131\u0414\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0445\u043e\u0442\u0435\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0441 “\u0431\u0435\u043b\u044b\u043c \u0448\u0443\u043c\u043e\u043c” \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0443\u0437\u043d\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0420\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b – \u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f – RGBA. \u041f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: BMP \u0438 TGA. BMP – \u043f\u043e\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0435\u0439, TGA – \u043f\u043e\u043f\u0440\u043e\u0449\u0435. \u041f\u0440\u0430\u0432\u0434\u0430, Photoshop \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 4 bytes BMPs, Windows Paint \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 TGAs, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0431\u0430 (\u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Texture)<\/strong>.<\/p>\n\n\n\n 1.\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c VS, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c C:\\CPP\\a997modeler<\/em>\\p_windows\\p_windows.sln<\/em>.<\/p>\n\n\n\n 2. \u0417\u0430\u043c\u0435\u043d\u0438\u043c Texture.h<\/em> \u043a\u043e\u0434 \u043d\u0430:<\/p>\n\n\n <\/p>\n\n\n\n 3. \u0417\u0430\u043c\u0435\u043d\u0438\u043c Texture.cpp<\/em> \u043a\u043e\u0434 \u043d\u0430: <\/p>\n\n\n <\/p>\n\n\n\n \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u0432\u044b\u0448\u0435, \u0432\u0440\u043e\u0434\u0435 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041f\u0440\u043e\u0441\u0442\u043e header \u0438 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f BGRA<\/strong>, \u0430 \u043d\u0435 RGBA.<\/p>\n\n\n\n \u0422\u0435\u043f\u0435\u0440\u044c, \u0431\u0435\u043b\u044b\u0439 \u0448\u0443\u043c<\/strong>. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 64×64 RGBA \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u043d\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 4-\u0445\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439). \u041f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0432\u0441\u0435 4 \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 255, \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 4-\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 TheGame::run()<\/em>. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 2 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n\n\n\n \u041f\u0435\u0440\u0432\u043e\u0435 – \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 <\/em>\u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (0 \u0438\u043b\u0438 <\/strong>255):<\/p>\n\n\n\n \u0412\u0442\u043e\u0440\u043e\u0435 – \u0441 \u0441\u0435\u0440\u044b\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043e\u043c (\u043e\u0442 0 \u0434\u043e 255):<\/p>\n\n\n\n \u0418 \u0442\u0430\u043a \u0434\u043b\u044f \u0432\u0441\u0435\u0445 4-\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a<\/p>\n\n\n\n \u0438<\/p>\n\n\n\n \u041e\u0431\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 BMP.<\/p>\n\n\n\n \u041a\u043e\u0434:<\/p>\n\n\n <\/p>\n\n\n\n 4. \u041e\u0442\u043a\u0440\u043e\u0435\u043c TheGame.cpp<\/em> \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u041d\u0415<\/strong> \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e run()<\/em> \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n\n\n\n 5. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a. <\/p>\n\n\n\n \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435<\/p>\n\n\n\n C:\\CPP\\a997modeler\\p_windows\\Debug\\dt\\out<\/strong><\/em><\/p>\n\n\n\n 6. \u0412 Windows File Explorer<\/strong>-\u0435 \u043f\u043e\u0434 C:\\CPP\\engine\\dt<\/em> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433<\/p>\n\n\n\n C:\\CPP\\engine\\dt\\common\\img\\whitenoise<\/strong><\/em><\/p>\n\n\n\n 7. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0430 BMP \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 C:\\CPP\\a997modeler\\p_windows\\Debug\\dt\\out<\/em> <\/p>\n\n\n\n \u0432 C:\\CPP\\engine\\dt\\common\\img\\whitenoise <\/em><\/p>\n\n\n\n 9. \u041a\u0430\u0442\u0430\u043b\u043e\u0433 C:\\CPP\\a997modeler\\p_windows\\Debug\\dt\\out<\/em> \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n\n\n\n \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438 \u0432\u0435\u0441\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 dt <\/strong>( C:\\CPP\\a997modeler\\p_windows\\Debug\\dt<\/strong><\/em>) \u0442\u043e\u0436\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435-\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 xcopy <\/em>\u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u0438\u043b\u0434\u0435.<\/p>\n\n\n\n <\/p>\n","protected":false},"excerpt":{"rendered":" \u0414\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0445\u043e\u0442\u0435\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0441 “\u0431\u0435\u043b\u044b\u043c \u0448\u0443\u043c\u043e\u043c” \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0443\u0437\u043d\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0420\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b – \u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f – RGBA. \u041f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: BMP \u0438 TGA. BMP – \u043f\u043e\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0435\u0439, TGA – \u043f\u043e\u043f\u0440\u043e\u0449\u0435. \u041f\u0440\u0430\u0432\u0434\u0430, […]<\/p>\n","protected":false},"author":1,"featured_media":1223,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-762","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cross-platform-3d"],"_links":{"self":[{"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/comments?post=762"}],"version-history":[{"count":5,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":1405,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts\/762\/revisions\/1405"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/media\/1223"}],"wp:attachment":[{"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/media?parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/categories?post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/tags?post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Windows<\/h2>\n\n\n\n
\n\n\n\n\n #pragma once\n#include <string>\n#include <vector>\n\nclass Texture\n{\npublic:\n \/\/texture's individual descriptor:\n unsigned int GLid = -1; \/\/ GL texture id\n int size[2] = { 0,0 }; \/\/ image size\n std::string source; \/\/file name\n \/\/end of descriptor\n\n \/\/static array (vector) of all loaded textures\n static std::vector<Texture*> textures;\n\npublic:\n static int loadTexture(std::string filePath);\n static int findTexture(std::string filePath);\n static int cleanUp();\n static unsigned int getGLid(int texN) { return textures.at(texN)->GLid; };\n\n static int saveBMP(std::string filePath, unsigned char* buff, int w, int h, int bytesPerPixel=4);\n static int saveTGA(std::string filePath, unsigned char* buff, int w, int h, int bytesPerPixel=4);\n};\n\n<\/pre><\/div>\n\n\n
\n\n\n\n\n#include "Texture.h"\n#define STB_IMAGE_IMPLEMENTATION \/\/required by stb_image.h\n#include "stb_image.h"\n#include "platform.h"\n#include "utils.h"\n\n\/\/static array (vector) of all loaded textures\nstd::vector<Texture*> Texture::textures;\n\nint Texture::loadTexture(std::string filePath) {\n int texN = findTexture(filePath);\n if (texN >= 0)\n return texN;\n \/\/if here - texture wasn't loaded\n \/\/create Texture object\n Texture* pTex = new Texture();\n textures.push_back(pTex);\n pTex->source.assign(filePath);\n \/\/ load an image\n int nrChannels;\n unsigned char* imgData = stbi_load(filePath.c_str(),\n &pTex->size[0], &pTex->size[1], &nrChannels, 4); \/\/"4"-convert to 4 channels -RGBA\n if (imgData == NULL) {\n mylog("ERROR in Texture::loadTexture loading image %s\\n", filePath.c_str());\n }\n \/\/ generate texture\n glGenTextures(1, &pTex->GLid);\n glBindTexture(GL_TEXTURE_2D, pTex->GLid);\n \/\/ set the texture wrapping\/filtering options (on the currently bound texture object)\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n \/\/ attach\/load image data\n glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pTex->size[0], pTex->size[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, imgData);\n glGenerateMipmap(GL_TEXTURE_2D);\n \/\/ release image data\n stbi_image_free(imgData);\n\n return (textures.size() - 1);\n}\nint Texture::findTexture(std::string filePath) {\n int texturesN = textures.size();\n if (texturesN < 1)\n return -1;\n for (int i = 0; i < texturesN; i++) {\n Texture* pTex = textures.at(i);\n if (pTex->source.compare(filePath) == 0)\n return i;\n }\n return -1;\n}\nint Texture::cleanUp() {\n int texturesN = textures.size();\n if (texturesN < 1)\n return -1;\n \/\/detach all textures\n glActiveTexture(GL_TEXTURE0); \/\/ activate the texture unit first before binding texture\n glBindTexture(GL_TEXTURE_2D, 0);\n glActiveTexture(GL_TEXTURE1);\n glBindTexture(GL_TEXTURE_2D, 0);\n glActiveTexture(GL_TEXTURE2);\n glBindTexture(GL_TEXTURE_2D, 0);\n glActiveTexture(GL_TEXTURE3);\n glBindTexture(GL_TEXTURE_2D, 0);\n \/\/release all textures\n for (int i = 0; i < texturesN; i++) {\n Texture* pTex = textures.at(i);\n glDeleteTextures(1, &pTex->GLid);\n delete pTex;\n }\n textures.clear();\n return 1;\n}\nint Texture::saveBMP(std::string filePath, unsigned char* buff, int w, int h, int bytesPerPixel) {\n std::string fullPath = getFullPath(filePath);\n std::string inAppPath = getInAppPath(fullPath);\n makeDirs(inAppPath);\n FILE* outFile;\n myFopen_s(&outFile, fullPath.c_str(), "wb");\n if (outFile == NULL) {\n mylog("ERROR in Texture::saveBMP: Can't create file %s\\n", filePath.c_str());\n return -1;\n }\n struct {\n char chars2skip[2]; \/\/\n \/\/BMP Header\n char bm[2] = { 0x42, 0x4D }; \/\/\t"BM"\n myUint32 fileSize = 0; \/\/ Size of the BMP file, little-endian\n myUint32 unused = 0;\n myUint32 dataOffset = 0; \/\/ Offset where the pixel array (bitmap data) can be found, little-endian\n \/\/DIB Header\n myUint32 dibHeaderSize = 0; \/\/ Number of bytes in the DIB header, little-endian\n myUint32 imgW = 0; \/\/ Width of the bitmap in pixels, little-endian\n myUint32 imgH = 0; \/\/ Height of the bitmap in pixels, little-endian\n char colorPlainsN[2] = { 1,0 };\n char bitsPerPixel[2] = { 32,0 };\n myUint32 compression = 0; \/\/0-BI_RGB\n myUint32 dataSize = 0; \/\/ Size of the raw bitmap data (including padding), little-endian\n myUint32 printResution[2] = { 2835 ,2835 }; \/\/ Print resolution of the image,\n \/\/72 DPI \u00d7 39.3701 inches per metre yields 2834.6472, little-endian\n myUint32 paletteColors = 0; \/\/ Number of colors in the palette\n myUint32 importantColors = 0; \/\/0 means all colors are important\n } bmpHeader;\n int rowSize = w * bytesPerPixel;\n int rowPadding = (4 - rowSize % 4) % 4;\n int rowSizeWithPadding = rowSize + rowPadding;\n int dataSize = rowSizeWithPadding * h;\n int headerSize = sizeof(bmpHeader) - 2; \/\/-chars2skip\n bmpHeader.fileSize = dataSize + headerSize;\n bmpHeader.dataOffset = headerSize;\n bmpHeader.dibHeaderSize = headerSize - 14; \/\/-BMP Header size\n bmpHeader.imgW = w;\n bmpHeader.imgH = h;\n if (bytesPerPixel != 4)\n bmpHeader.bitsPerPixel[0] = bytesPerPixel * 8;\n bmpHeader.dataSize = dataSize;\n fwrite(&bmpHeader.bm, 1, headerSize, outFile);\n \/\/data, from bottom to top\n unsigned char zero[4] = { 0,0,0,0 };\n unsigned char bgra[4];\n for (int y = h - 1; y >= 0; y--) {\n for (int x = 0; x < w; x++) {\n int pixelOffset = y * rowSize + x * 4;\n bgra[0] = buff[pixelOffset + 2];\n bgra[1] = buff[pixelOffset + 1];\n bgra[2] = buff[pixelOffset + 0];\n bgra[3] = buff[pixelOffset + 3];\n fwrite(bgra, 1, bytesPerPixel, outFile);\n }\n if (rowPadding != 0)\n fwrite(zero, 1, rowPadding, outFile);\n }\n fflush(outFile);\n fclose(outFile);\n\n return 1;\n}\n\nint Texture::saveTGA(std::string filePath, unsigned char* buff, int w, int h, int bytesPerPixel) {\n std::string fullPath = getFullPath(filePath);\n std::string inAppPath = getInAppPath(fullPath);\n makeDirs(inAppPath);\n FILE* outFile;\n myFopen_s(&outFile, fullPath.c_str(), "wb");\n if (outFile == NULL) {\n mylog("ERROR in Texture::saveBMP: Can't create file %s\\n", filePath.c_str());\n return -1;\n }\n unsigned char tgaHeader[18] = { 0,0,2,0,0,0,0,0,0,0,0,0, (unsigned char)(w % 256), (unsigned char)(w \/ 256),\n (unsigned char)(h % 256), (unsigned char)(h \/ 256), (unsigned char)(bytesPerPixel * 8), 0x20 };\n fwrite(tgaHeader, 1, 18, outFile);\n \/\/data\n unsigned char bgra[4];\n for (int i = 0; i < w * h; i++) {\n int pixelOffset = i * 4;\n bgra[0] = buff[pixelOffset + 2];\n bgra[1] = buff[pixelOffset + 1];\n bgra[2] = buff[pixelOffset + 0];\n bgra[3] = buff[pixelOffset + 3];\n fwrite(bgra, 1, bytesPerPixel, outFile);\n }\n fflush(outFile);\n fclose(outFile);\n\n return 1;\n}\n\n<\/pre><\/div>\n\n\n
\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n\nint TheGame::run() {\n \/*\n getReady();\n while (!bExitGame) {\n drawFrame();\n }\n cleanUp();\n *\/\n int wh[2] = { 64,64 };\n int bytesPerPixel = 4;\n unsigned char* buff = new unsigned char[wh[1] * wh[0] * 4];\n std::string fileName = "wn64_2";\n for (int y = 0; y < wh[1]; y++)\n for (int x = 0; x < wh[0]; x++) {\n int idx = (y * wh[1] + x) * bytesPerPixel;\n for (int i = 0; i < 4; i++)\n buff[idx + i] = getRandom(0, 1) * 255;\n }\n Texture::saveBMP("\/dt\/out\/" + fileName + ".bmp", (unsigned char*)buff, wh[0], wh[1]);\n\n fileName = "wn64_256";\n for (int y = 0; y < wh[1]; y++)\n for (int x = 0; x < wh[0]; x++) {\n int idx = (y * wh[1] + x) * bytesPerPixel;\n for (int i = 0; i < 4; i++)\n buff[idx + i] = getRandom(0, 255);\n }\n Texture::saveBMP("\/dt\/out\/" + fileName + ".bmp", (unsigned char*)buff, wh[0], wh[1]);\n\n delete[] buff;\n mylog("Ready\\n");\n return 1;\n}\n\n<\/pre><\/div>\n\n\n
\n\n\n\n
\n\n\n\n
\n\n\n\n
\n\n\n\n
\n\n\n\n