{"id":199396,"date":"2013-10-28T19:12:02","date_gmt":"2013-10-28T15:12:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=199396"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=199396","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 OpenGL ES 2.0 \u0432 Visual Studio \u0421++<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h5>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0417\u0430\u0447\u0435\u043c?<\/h5>\n<p>  \u041e\u0442\u043b\u0430\u0434\u043a\u0430 Android NDK \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0432 Xcode \u0440\u0435\u0448\u0430\u0435\u0442 90% \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u0433\u0440\u044b \u0432 Win32. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u0431\u044b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440 \u043c\u043e\u0433 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432 \u0438\u0433\u0440\u0435 \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043b\u0438, \u0447\u0442\u043e \u0431\u044b \u0441\u043d\u044f\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0438\u0433\u0440\u044b \u0438\u043b\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 \u0441 \u0438\u0433\u0440\u043e\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OpenGL ES 2.0 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f, \u0438\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 Xcode \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b \u0444\u0430\u043d Visual Studio.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>\u041a\u0430\u043a?<\/h5>\n<p>  AngleProject <a href=\"https:\/\/code.google.com\/p\/angleproject\/\">code.google.com\/p\/angleproject\/<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 OpenGL ES 2.0 API \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f DirectX. \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 ANGLE \u043d\u0443\u0436\u0435\u043d DirectX SDK. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 DirectX SDK June 2010 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0412\u044b\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 S1023. \u041f\u0435\u0440\u0435\u0434 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u0438\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c Visual C++ 2010 Redistributable Package  <\/p>\n<pre><code class=\"bash\">MsiExec.exe \/passive \/X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5} MsiExec.exe \/passive \/X{1D8E6291-B0D5-35EC-8441-6616F567A0F7} <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u043f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c DirectX SDK, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c ANGLE \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c OpenGL ES 2.0 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 libEGL.dll, libGLESv2.dll<\/p>\n<p>  \u0412 Linker \u2014 Input \u2014 Additional Dependencies \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c  <\/p>\n<pre><code class=\"bash\">esUtil.lib libEGL.lib libGLESv2.lib <\/code><\/pre>\n<p>  libEGL.dll, libGLESv2.dll \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0438 Debug, Release<\/p>\n<p>  esUtil.lib \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 OpenGL ES 2.0 \u043f\u0440\u0438\u043c\u0435\u0440\u044b ANGLE. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d\u0430 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<h5>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0435 \u043b\u044e\u0434\u044f\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 <a href=\"https:\/\/drive.google.com\/file\/d\/0By3tpQMnuHz-M1RtVll1ejFjdWM\/edit?usp=sharing\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c<\/a> \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 OpenGL ES 2.0 \u043a\u043e\u0434 \u0438\u0437 Visual Studion 2010 \u0432 \u0412\u0438\u043d\u0434\u0435 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 DirectX SDK \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u043a\u043d\u043e \u0441 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u043c<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8bf\/9cf\/8a9\/8bf9cf8a95db82564e29bf32f94fdb31.jpg\"\/><\/p>\n<p>  \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 OpenGL ES 2.0 \u0440\u0438\u0441\u0443\u0435\u0442 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/\/ \/\/ Book:      OpenGL(R) ES 2.0 Programming Guide \/\/ Authors:   Aaftab Munshi, Dan Ginsburg, Dave Shreiner \/\/ ISBN-10:   0321502795 \/\/ ISBN-13:   9780321502797 \/\/ Publisher: Addison-Wesley Professional \/\/ URLs:      http:\/\/safari.informit.com\/9780321563835 \/\/            http:\/\/www.opengles-book.com \/\/  \/\/ Hello_Triangle.c \/\/ \/\/    This is a simple example that draws a single triangle with \/\/    a minimal vertex\/fragment shader.  The purpose of this  \/\/    example is to demonstrate the basic concepts of  \/\/    OpenGL ES 2.0 rendering. #include &lt;stdlib.h&gt; #include &quot;esUtil.h&quot;  typedef struct {    \/\/ Handle to a program object    GLuint programObject;  } UserData;  \/\/\/ \/\/ Create a shader object, load the shader source, and \/\/ compile the shader. \/\/ GLuint LoadShader ( GLenum type, const char *shaderSrc ) {    GLuint shader;    GLint compiled;        \/\/ Create the shader object    shader = glCreateShader ( type );     if ( shader == 0 )    \treturn 0;     \/\/ Load the shader source    glShaderSource ( shader, 1, &shaderSrc, NULL );        \/\/ Compile the shader    glCompileShader ( shader );     \/\/ Check the compile status    glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );     if ( !compiled )     {       GLint infoLen = 0;        glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );              if ( infoLen &gt; 1 )       {          char* infoLog = malloc (sizeof(char) * infoLen );           glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );          esLogMessage ( &quot;Error compiling shader:\\n%s\\n&quot;, infoLog );                                free ( infoLog );       }        glDeleteShader ( shader );       return 0;    }     return shader;  }  \/\/\/ \/\/ Initialize the shader and program object \/\/ int Init ( ESContext *esContext ) {    UserData *userData = esContext-&gt;userData;    GLbyte vShaderStr[] =         &quot;attribute vec4 vPosition;    \\n&quot;       &quot;void main()                  \\n&quot;       &quot;{                            \\n&quot;       &quot;   gl_Position = vPosition;  \\n&quot;       &quot;}                            \\n&quot;;        GLbyte fShaderStr[] =         &quot;precision mediump float;\\n&quot;\\       &quot;void main()                                  \\n&quot;       &quot;{                                            \\n&quot;       &quot;  gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\\n&quot;       &quot;}                                            \\n&quot;;     GLuint vertexShader;    GLuint fragmentShader;    GLuint programObject;    GLint linked;     \/\/ Load the vertex\/fragment shaders    vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr );    fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fShaderStr );     \/\/ Create the program object    programObject = glCreateProgram ( );        if ( programObject == 0 )       return 0;     glAttachShader ( programObject, vertexShader );    glAttachShader ( programObject, fragmentShader );     \/\/ Bind vPosition to attribute 0       glBindAttribLocation ( programObject, 0, &quot;vPosition&quot; );     \/\/ Link the program    glLinkProgram ( programObject );     \/\/ Check the link status    glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );     if ( !linked )     {       GLint infoLen = 0;        glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );              if ( infoLen &gt; 1 )       {          char* infoLog = malloc (sizeof(char) * infoLen );           glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );          esLogMessage ( &quot;Error linking program:\\n%s\\n&quot;, infoLog );                                free ( infoLog );       }        glDeleteProgram ( programObject );       return FALSE;    }     \/\/ Store the program object    userData-&gt;programObject = programObject;     glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );    return TRUE; }  \/\/\/ \/\/ Draw a triangle using the shader pair created in Init() \/\/ void Draw ( ESContext *esContext ) {    UserData *userData = esContext-&gt;userData;    GLfloat vVertices[] = {  0.0f,  0.5f, 0.0f,                             -0.5f, -0.5f, 0.0f,                             0.5f, -0.5f, 0.0f };           \/\/ Set the viewport    glViewport ( 0, 0, esContext-&gt;width, esContext-&gt;height );        \/\/ Clear the color buffer    glClear ( GL_COLOR_BUFFER_BIT );     \/\/ Use the program object    glUseProgram ( userData-&gt;programObject );     \/\/ Load the vertex data    glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices );    glEnableVertexAttribArray ( 0 );     glDrawArrays ( GL_TRIANGLES, 0, 3 );     eglSwapBuffers ( esContext-&gt;eglDisplay, esContext-&gt;eglSurface ); }   int main ( int argc, char *argv[] ) {    ESContext esContext;    UserData  userData;     esInitContext ( &esContext );    esContext.userData = &userData;     esCreateWindow ( &esContext, TEXT(&quot;Hello Triangle&quot;), 320, 240, ES_WINDOW_RGB );        if ( !Init ( &esContext ) )       return 0;     esRegisterDrawFunc ( &esContext, Draw );        esMainLoop ( &esContext ); }  <\/code><\/pre>\n<p>  \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e OpenGL ES 2.0 \u043a\u043e\u0434\u0438\u043d\u0433\u0430!<\/p><\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/199396\/\"> http:\/\/habrahabr.ru\/post\/199396\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h5>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0417\u0430\u0447\u0435\u043c?<\/h5>\n<p>  \u041e\u0442\u043b\u0430\u0434\u043a\u0430 Android NDK \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0432 Xcode \u0440\u0435\u0448\u0430\u0435\u0442 90% \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u0433\u0440\u044b \u0432 Win32. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u0431\u044b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440 \u043c\u043e\u0433 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432 \u0438\u0433\u0440\u0435 \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043b\u0438, \u0447\u0442\u043e \u0431\u044b \u0441\u043d\u044f\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0438\u0433\u0440\u044b \u0438\u043b\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 \u0441 \u0438\u0433\u0440\u043e\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OpenGL ES 2.0 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f, \u0438\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 Xcode \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b \u0444\u0430\u043d Visual Studio.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-199396","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199396"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199396\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}