{"id":161775,"date":"2012-12-07T14:44:03","date_gmt":"2012-12-07T10:44:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=161775"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=161775","title":{"rendered":"<span class=\"post_title\">\u0414\u0435\u043b\u0430\u0435\u043c OpenGL ES LiveWallpaper \u043d\u0430 Linderdaum Engine \u043f\u043e\u0434 Android<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440!<\/p>\n<p>  \u0422\u0435\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f LiveWallpaper \u043f\u043e\u0434 Android \u0443\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u0431\u043a\u0430\u0442\u0430\u043d\u0430: \u0435\u0441\u0442\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u0439 Java, \u0435\u0441\u0442\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043d\u0430 Java \u0441 OpenGL ES 1.0\/2.0, \u0435\u0441\u0442\u044c\u2026 \u0434\u0430 \u0447\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0442!<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c LiveWallpaper \u043f\u043e\u0434 Android \u043d\u0430 \u0421++ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/www.linderdaum.com\">Linderdaum Engine<\/a> \u0438 GLSL.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 <a href=\"http:\/\/www.linderdaum.com\">Linderdaum Engine<\/a>. \u041f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0431\u044b\u043b \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435: <a href=\"http:\/\/habrahabr.ru\/post\/121062\/\">http:\/\/habrahabr.ru\/post\/121062\/<\/a><\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0430\u0439\u0442\u043e\u043c: <a href=\"http:\/\/www.chromeexperiments.com\/webgl\">http:\/\/www.chromeexperiments.com\/webgl<\/a> \u0422\u0430\u043c \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u044b image-space \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 WebGL, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0437\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (\u0448\u0435\u0439\u0434\u0435\u0440\u044b WebGL \u0438 OpenGL ES 2 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b).<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0432\u043e\u0442 \u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 \u0421++, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0451 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">#include &quot;Linderdaum.h&quot;  sEnvironment* Env = NULL;  clPtr&lt;clRenderState&gt; Background = NULL;  void DrawOverlay(LEvent Event, const LEventArgs& Args) { \tEnv-&gt;Renderer-&gt;GetCanvas()-&gt;FullscreenRect( Background ); }  APPLICATION_ENTRY_POINT { \tEnv = new sEnvironment(); \tEnv-&gt;DeployDefaultEnvironment( NULL, &quot;..\\\\..\\\\CommonMedia&quot; ); \tEnv-&gt;Connect( L_EVENT_DRAWOVERLAY, Utils::Bind( &DrawOverlay ) ); \tBackground = Env-&gt;Resources-&gt;LoadShader( &quot;Background.shader&quot; ); \tEnv-&gt;RunApplication( DEFAULT_CONSOLE_AUTOEXEC ); \tAPPLICATION_EXIT_POINT( Env ); }  APPLICATION_SHUTDOWN { \tBackground = NULL; } <\/code><\/pre>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u041f\u043e\u043b\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u0432 <b>Test_LiveWallpaper.cpp<\/b> \u0438 \u0441 \u0421++ \u043d\u0430 \u044d\u0442\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0451 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u043e.<\/p>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c <b>Background.shader<\/b>:<\/p>\n<pre><code class=\"cpp\">Object(&quot;clRenderState&quot;) {    ShaderProgram &quot;Plane.sp&quot; } <\/code><\/pre>\n<p>  \u0438 <b>Plane.sp<\/b>:<\/p>\n<pre><code class=\"cpp\">\/*VERTEX_PROGRAM*\/ #include Layout.sp in vec4 in_Vertex; in vec4 in_TexCoord; out vec2 Coord; void main() {    gl_Position = in_ModelViewProjectionMatrix * in_Vertex;    Coord = in_TexCoord.xy; }  \/*FRAGMENT_PROGRAM*\/ in vec2 Coord; uniform float ENGINE_TIME; out vec4 out_FragColor; \/\/ Plane deformations by Anton Platonov &lt;platosha@gmail.com&gt; twitter.com\/platosha const float TAU = 5.2832; void main( void )  { \tvec2 position = Coord; \tvec2 p = -1.0 + 2.0 * position; \tfloat alpha = -ENGINE_TIME * 0.13; \tfloat sinA = sin(alpha), cosA = cos(alpha); \tp = vec2(cosA*p.x+sinA*p.y, -sinA*p.x+cosA*p.y); \tvec2 q = p; \tfloat zr = 1.0\/length(q); \tfloat zp = 1.0\/abs(q.y); \tfloat mc = sin(ENGINE_TIME*0.16)*.5 + .5; \tfloat z = mix(zr, zp, mc); \tfloat ur = 5.0*atan(q.x*sign(q.y), abs(q.y))\/TAU + cos(0.2*z*TAU+ENGINE_TIME*1.37) * 1.2 * sin( ENGINE_TIME * 0.21 ); \tfloat up = q.x*z; \tfloat u = mix(ur, up, mc); \tvec2 uv = vec2(u, (1.0+mc*2.0)*z); \tfloat mv = sin(ENGINE_TIME * 0.55); \tuv = mix(uv, q, 0.0); \tfloat color = 0.0; \tcolor = cos(uv.x*TAU) * cos(uv.y*TAU + ENGINE_TIME*7.7); \tcolor = pow(abs(cos(color*TAU)), 3.0); \tfloat color2 = 0.0; \tcolor2 = cos(uv.x*TAU*2.0); \tcolor2 -= 0.25; \tfloat shadow = 1.0\/(z*z); \tvec3 rc = vec3(0.9, 1.0, 0.8)*color + vec3(0.3, 0.7, 0.6)*color2; \trc *= shadow; \tout_FragColor = vec4( rc, 1.0 ); } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 \u0432\u0438\u043d\u0434\u043e\u0439. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432. \u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/www.linderdaum.com\/Tutorials\/shot0000.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043d\u0430 Android, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u0440\u0430\u0432\u0434\u0430 \u043d\u0430 Java \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0442\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435. <b>Test_LiveWallpaperService.java<\/b>:<\/p>\n<pre><code class=\"java\">package com.linderdaum.engine.Test_LiveWallpaper;  import com.linderdaum.engine.LinderdaumEngineService;  public class Test_LiveWallpaperService extends LinderdaumEngineService { \t@Override \tpublic LinderdaumEngineService.GLEngine onCreateEngine() \t{ \t\treturn new LinderdaumEngineService.GLEngine(); \t} } <\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442 <b>AndroidManifest.xml<\/b>:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;       package=&quot;com.linderdaum.engine.Test_LiveWallpaper&quot;       android:versionCode=&quot;1&quot;       android:versionName=&quot;1.0.0&quot;&gt; \t&lt;supports-screens         android:smallScreens=&quot;false&quot;         android:normalScreens=&quot;true&quot;         android:largeScreens=&quot;true&quot;         android:anyDensity=&quot;true&quot; \/&gt;     &lt;uses-sdk android:minSdkVersion=&quot;7&quot; \/&gt;     &lt;uses-feature android:glEsVersion=&quot;0x00020000&quot;\/&gt;     &lt;uses-feature android:name=&quot;android.software.live_wallpaper&quot;\/&gt;     &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;\/&gt;     &lt;application android:label=&quot;Test_LiveWallpaper&quot;                  android:icon=&quot;@drawable\/icon&quot;                  android:installLocation=&quot;preferExternal&quot;                  android:debuggable=&quot;false&quot;&gt; \t\t  &lt;service android:name=&quot;com.linderdaum.engine.Test_LiveWallpaper.Test_LiveWallpaperService&quot;                  android:label=&quot;Test_LiveWallpaper&quot;                  android:permission=&quot;android.permission.BIND_WALLPAPER&quot;&gt;             &lt;intent-filter&gt;                 &lt;action android:name=&quot;android.service.wallpaper.WallpaperService&quot; \/&gt;             &lt;\/intent-filter&gt;             &lt;meta-data android:name=&quot;android.service.wallpaper&quot; android:resource=&quot;@xml\/wallpaper&quot; \/&gt;         &lt;\/service&gt;      &lt;\/application&gt; &lt;\/manifest&gt;  <\/code><\/pre>\n<p>  \u0412\u0441\u0451! \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0435\u0441\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 Linderdaum \u0434\u043b\u044f Android. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <b>ndk-build<\/b> \u0438 <b>ant copy-common-media debug<\/b>. \u041c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c <b>Test_LiveWallpaper-debug.apk<\/b> \u043d\u0430 \u0434\u0435\u0432\u0430\u0439\u0441 \u2014 \u043d\u043e\u0432\u044b\u0435 \u0436\u0438\u0432\u044b\u0435 \u043e\u0431\u043e\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<p>  <b>P.S.<\/b> \u0422\u0430\u043a\u043e\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0432\u0435\u0441\u044c\u043c\u0430 \u0442\u044f\u0436\u0451\u043b\u044b\u0439 \u0434\u043b\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e GPU, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0435\u0434\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435!    \t   \t<\/p>\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\/161775\/\"> http:\/\/habrahabr.ru\/post\/161775\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440!<\/p>\n<p>  \u0422\u0435\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f LiveWallpaper \u043f\u043e\u0434 Android \u0443\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u0431\u043a\u0430\u0442\u0430\u043d\u0430: \u0435\u0441\u0442\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u0439 Java, \u0435\u0441\u0442\u044c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043d\u0430 Java \u0441 OpenGL ES 1.0\/2.0, \u0435\u0441\u0442\u044c\u2026 \u0434\u0430 \u0447\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0442!<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c LiveWallpaper \u043f\u043e\u0434 Android \u043d\u0430 \u0421++ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/www.linderdaum.com\">Linderdaum Engine<\/a> \u0438 GLSL.<\/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-161775","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/161775","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=161775"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/161775\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}