xcopy \"..\\dt\\*.*\" \"$(TargetDir)dt\\\" \/E \/R \/D \/y<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
\u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 2 xcopy \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n\n\n\n
Ok, Apply, Ok.<\/p>\n\n\n\n
\n\n\n\n5. \u041e\u0442\u043a\u0440\u043e\u0435\u043c TheGame.cpp<\/em>. \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0435-\u0447\u0442\u043e:<\/p>\n\n\n\n- \u041d\u0443\u0436\u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 stb_image.h<\/em>.<\/li>
- \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/li>
- \u041d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043e\u0432: 3D \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b + 2D \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442.<\/li>
- \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f 4 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0445 \u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 GL_TRIANGLE_STRIP \u0432\u043c\u0435\u0441\u0442\u043e GL_TRIANGLES.<\/li>
- \u0415\u0449\u0435 \u043d\u0443\u0436\u043d\u044b \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0435\u0433\u043e \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443.<\/li>
- \u0418 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 id \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u0443 \u0432 \u043d\u043e\u0432\u0443\u044e \u0448\u0435\u0439\u0434\u0435\u0440-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/li><\/ul>\n\n\n\n
\u0417\u0430\u043c\u0435\u043d\u0438\u043cTheGame.cpp<\/em> \u043a\u043e\u0434 \u043d\u0430:<\/p>\n\n\n\n#include "TheGame.h"\n#include "platform.h"\n#include "linmath.h"\n#include "utils.h"\n#include "Shader.h"\n\nextern std::string filesRoot;\n\n#define STB_IMAGE_IMPLEMENTATION \/\/required by stb_image.h\n#include "stb_image.h"\n\nstatic const struct\n{\n float x, y, z, tu, tv;\n} vertices[4] =\n{\n { -0.5f, 0.5f, 0.f, 0.f, 0.f }, \/\/top-left\n { -0.5f, -0.5f, 0.f, 0.f, 1.f }, \/\/bottom-left\n { 0.5f, 0.5f, 0.f, 1.f, 0.f }, \/\/top-right\n { 0.5f, -0.5f, 0.f, 1.f, 1.f } \/\/bottom-right\n};\nunsigned int vao_buffer, vertex_buffer, shaderProgramId, textureId;\nint umvp_location, apos_location, atuv_location;\nfloat angle_z = 0;\n\nint TheGame::getReady() {\n bExitGame = false;\n\n glGenVertexArrays(1, &vao_buffer);\n glBindVertexArray(vao_buffer);\n\n glGenBuffers(1, &vertex_buffer);\n glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);\n glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);\n\n shaderProgramId = Shader::linkShaderProgram((filesRoot + "\/dt\/shaders\/flat_tex_v.txt").c_str(), (filesRoot + "\/dt\/shaders\/flat_tex_f.txt").c_str());\n\n umvp_location = glGetUniformLocation(shaderProgramId, "uMVP");\n\n apos_location = glGetAttribLocation(shaderProgramId, "aPos");\n glEnableVertexAttribArray(apos_location);\n glVertexAttribPointer(apos_location, 3, GL_FLOAT, GL_FALSE,\n sizeof(vertices[0]), (void*)0);\n\n atuv_location = glGetAttribLocation(shaderProgramId, "aTuv");\n glEnableVertexAttribArray(atuv_location);\n glVertexAttribPointer(atuv_location, 2, GL_FLOAT, GL_FALSE,\n sizeof(vertices[0]), (void*)(sizeof(float) * 3));\n\n \/\/ loading an image\n int imgWidth, imgHeight, nrChannels;\n unsigned char* imgData = stbi_load((filesRoot + "\/dt\/sample_img.png").c_str(),\n &imgWidth, &imgHeight, &nrChannels, 4); \/\/"4"-convert to 4 channels -RGBA\n if (imgData == NULL) {\n mylog("ERROR loading image\\n");\n }\n \/\/ generate texture\n unsigned int textureId;\n glGenTextures(1, &textureId);\n glBindTexture(GL_TEXTURE_2D, textureId);\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, imgWidth, imgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, imgData);\n glGenerateMipmap(GL_TEXTURE_2D);\n \/\/ release image data\n stbi_image_free(imgData);\n\n \/\/pass textureId to shader program\n glActiveTexture(GL_TEXTURE0); \/\/ activate the texture unit first before binding texture\n glBindTexture(GL_TEXTURE_2D, textureId);\n\n return 1;\n}\nint TheGame::drawFrame() {\n myPollEvents();\n\n mat4x4 m, p, mvp;\n\n \/\/glClearColor(0.0, 0.0, 0.5, 1.0);\n glClear(GL_COLOR_BUFFER_BIT);\n angle_z += 0.01f;\n mat4x4_identity(m);\n mat4x4_rotate_Z(m, m, angle_z);\n mat4x4_scale_aniso(m, m, 2.0, 1.0, 1.0);\n mat4x4_ortho(p, -screenRatio, screenRatio, -1.f, 1.f, 1.f, -1.f);\n mat4x4_mul(mvp, p, m);\n\n glUseProgram(shaderProgramId);\n glUniformMatrix4fv(umvp_location, 1, GL_FALSE, (const GLfloat*)mvp);\n\n glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\n\n mySwapBuffers();\n return 1;\n}\nint TheGame::cleanUp() {\n return 1;\n}\nint TheGame::onScreenResize(int width, int height) {\n if (screenSize[0] == width && screenSize[1] == height)\n return 0;\n screenSize[0] = width;\n screenSize[1] = height;\n screenRatio = (float)width \/ (float)height;\n glViewport(0, 0, width, height);\n mylog(" screen size %d x %d\\n", width, height);\n return 1;\n}\nint TheGame::run() {\n getReady();\n while (!bExitGame) {\n drawFrame();\n }\n cleanUp();\n return 1;\n}\n\n<\/pre><\/div>\n\n\n<\/p>\n\n\n\n
\n\n\n\n- \u0418, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e\u0432\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b:<\/li><\/ol>\n\n\n\n
Vertex shader<\/strong>:<\/p>\n\n\n\n#version 320 es\nprecision lowp float;\nuniform mat4 uMVP; \/\/ transform matrix (Model-View-Projection)\nin vec3 aPos; \/\/attribute position (3D coordinates)\nin vec2 aTuv; \/\/attribute TUV (texture coordinates)\nout vec2 vTuv; \/\/varying TUV (pass to fragment shader)\nvoid main(){\n gl_Position = uMVP * vec4(aPos, 1.0);\n vTuv = aTuv;\n}\n\n<\/pre><\/div>\n\n\n<\/p>\n\n\n\n
\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/strong> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043a\u0430\u043a txt \u0444\u0430\u0439\u043b \u0432<\/p>\n\n\n\nC:\\CPP\\engine\\dt\\shaders\\flat_tex_v.txt<\/em><\/p>\n\n\n\nFragment shader<\/strong>:<\/p>\n\n\n\n#version 320 es\nprecision lowp float;\nuniform sampler2D uTex0; \/\/texture id\nin vec2 vTuv; \/\/varying TUV (passed from vertex shader)\nout vec4 FragColor; \/\/ output pixel color\nvoid main(){\n FragColor = texture(uTex0, vTuv);\n}\n\n<\/pre><\/div>\n\n\n<\/p>\n\n\n\n
\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/strong> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043a\u0430\u043a txt \u0444\u0430\u0439\u043b \u0432 <\/p>\n\n\n\nC:\\CPP\\engine\\dt\\shaders\\flat_tex_f.txt<\/p>\n\n\n\n
\n\n\n\n7. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
\n\n\n\n\u0422\u0435\u043f\u0435\u0440\u044c – \u043d\u0430<\/p>\n\n\n\n
\u0410\u043d\u0434\u0440\u043e\u0438\u0434\u0435<\/h2>\n\n\n\n
\u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0412\u0421\u0415 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043d\u0430 cross-platform-\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0434\u0430\u0436\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u2026 \u041a\u0440\u043e\u043c\u0435 stb_image.h<\/em> \u0438 xcopy<\/em> post-build \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n\n\n\n8. \u041f\u0435\u0440\u0435-\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Visual Studio. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c C:\\CPP\\a999hello\\p_android\\p_android.sln<\/em>.<\/p>\n\n\n\n
\n\n\n\n9. \u0418\u0434\u0435\u043c \u0432 p_android.NativeActivity<\/em> project Properties, All Configurations \/ ARM64, Build Events -> Post-Build Event -> Command Line -> Edit<\/em><\/p>\n\n\n\n\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n\n\n\n
xcopy \"..\\..\\dt\\*.*\" \"..\\$(RootNamespace).Packaging\\assets\\dt\\\" \/E \/R \/D \/y<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
Ok, Apply, Ok.<\/p>\n\n\n\n
\n\n\n\n9. \u0422\u0435\u043f\u0435\u0440\u044c, right-click \u043d\u0430 xEngine<\/em>, Add -> Existing <\/strong>Item,<\/p>\n\n\n\nC:\\CPP\\engine\\stb_image.h<\/em><\/p>\n\n\n\nAdd<\/strong>.<\/p>\n\n\n\n
\n\n\n\n10. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c Android, \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c. <\/p>\n\n\n\n
Re-build \u0438 \u0437\u0430\u043f\u0443\u0441\u043a. <\/p>\n\n\n\n
\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n\n\n\n
\n\n\n\n\u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0412\u044b – \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0440\u043e\u043c\u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u0440\u0435\u0437\u044e\u043c\u0435, \u0447\u0442\u043e \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0435 \u0432\u043b\u0430\u0434\u0435\u0435\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438:<\/p>\n\n\n\n
- C++<\/li>
- graphics<\/li>
- 3D<\/li>
- Visual Studio<\/li>
- Cross-platform<\/li>
- Android<\/li>
- Windows<\/li>
- OpenGL ES<\/li>
- GLSL<\/li><\/ul>\n\n\n\n
\u041d\u0443, “\u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0435” – \u043f\u043e\u043a\u0430, \u043c\u043e\u0436\u0435\u0442, \u0438 \u043f\u0440\u0435\u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 – \u0447\u0438\u0441\u0442\u0430\u044f \u043f\u0440\u0430\u0432\u0434\u0430<\/em>.<\/p>\n\n\n\n
\n","protected":false},"excerpt":{"rendered":"1. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041a\u0430\u043a\u0430\u044f-\u043d\u0438\u0431\u0443\u0434\u044c image-loading \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c stb_image.h \u043e\u0442 \u0428\u043e\u043d\u0430 \u0411\u0430\u0440\u0440\u0435\u0442\u0442\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e 1 h-\u0444\u0430\u0439\u043b, \u0430 \u043d\u0435 lib \u0438\u043b\u0438 dll. \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0435\u0435 \u0432 C:\\CPP\\engine folder (\u0442\u0430\u043c \u0436\u0435 \u0433\u0434\u0435 \u0438 linmath.h \u0440\u0430\u043d\u0435\u0435). 2. \u041f\u043e\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0430\u043c\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c […]<\/p>\n","protected":false},"author":1,"featured_media":1210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-505","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\/505","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=505"}],"version-history":[{"count":6,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":1384,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/posts\/505\/revisions\/1384"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/media\/1210"}],"wp:attachment":[{"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/media?parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/categories?post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/writingagame.ru\/index.php\/wp-json\/wp\/v2\/tags?post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}