LAMW OpenGLWallpaperService lazarus / 43-Android ---------------------------------------------------------------------- drugsound · 2020-06-25 14:25 Hello to all! I need to use OpenGL live wallpapers in my project. I found an implementation of this in Java. https://github.com/learnopengles/Learn-OpenGLES-Tutorials/blob/master/ android/AndroidOpenGLESLessons/app/src/main/java/com/learnopengles/and roid/livewallpaper/GLWallpaperService.java Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i import android.content.Context;import android.opengl.GLSurfaceView;import android.opengl.GLSurfaceView.Renderer;import android.os.Build;import android.service.wallpaper.WallpaperService;import android.util.Log;import android.view.SurfaceHolder; import com.learnopengles.android.util.LoggerConfig; public abstract class GLWallpaperService extends WallpaperService {         public class GLEngine extends Engine {                class WallpaperGLSurfaceView extends GLSurfaceView {                        private static final String TAG = "WallpaperGLSurfaceView";                         WallpaperGLSurfaceView(Context context) {                              super(context);                                 if (LoggerConfig.ON) {                                        Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")");                              }                        }                         @Override                      public SurfaceHolder getHolder() {                              if (LoggerConfig.ON) {                                      Log.d(TAG, "getHolder(): returning " + getSurfaceHolder());                              }                                 return getSurfaceHolder();                        }                         public void onDestroy() {                                if (LoggerConfig.ON) {                                        Log.d(TAG, "onDestroy()");                                }                               super.onDetachedFromWindow();                        }              }                 private static final String TAG = "GLEngine";                 private WallpaperGLSurfaceView glSurfaceView;                private boolean rendererHasBeenSet;                            @Override                public void onCreate(SurfaceHolder surfaceHolder) {                        if (LoggerConfig.ON) {                                Log.d(TAG, "onCreate(" + surfaceHolder + ")");                        }                       super.onCreate(surfaceHolder);                         glSurfaceView = new WallpaperGLSurfaceView(GLWallpaperService.this);              }                 @Override                public void onVisibilityChanged(boolean visible) {                        if (LoggerConfig.ON) {                                Log.d(TAG, "onVisibilityChanged(" + visible + ")");                        }                       super.onVisibilityChanged(visible);                       if (rendererHasBeenSet) {                                if (visible) {                                        glSurfaceView.onResume();                                } else {                                                                            glSurfaceView.onPause();                                                                                                                                            }                        }              }                                @Override                public void onDestroy() {                        if (LoggerConfig.ON) {                              Log.d(TAG, "onDestroy()");                        }                         super.onDestroy();                        glSurfaceView.onDestroy();                }                              protected void setRenderer(Renderer renderer) {                      if (LoggerConfig.ON) {                                Log.d(TAG, "setRenderer(" + renderer + ")");                        }                       glSurfaceView.setRenderer(renderer);                      rendererHasBeenSet = true;                }                              protected void setPreserveEGLContextOnPause(boolean preserve) {                      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {                                if (LoggerConfig.ON) {                                        Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")");                              }                                        glSurfaceView.setPreserveEGLContextOnPause(preserve);                      }                }                                protected void setEGLContextClientVersion(int version) {                        if (LoggerConfig.ON) {                                Log.d(TAG, "setEGLContextClientVersion(" + version + ")");                      }                         glSurfaceView.setEGLContextClientVersion(version);                }      }} and OpenGLES2 https://github.com/learnopengles/Learn-OpenGLES-Tutorials/blob/master/ android/AndroidOpenGLESLessons/app/src/main/java/com/learnopengles/and roid/livewallpaper/OpenGLES2WallpaperService.java Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i import android.app.ActivityManager;import android.content.Context;import android.content.pm.ConfigurationInfo;import android.opengl.GLSurfaceView.Renderer;import android.view.SurfaceHolder; public abstract class OpenGLES2WallpaperService extends GLWallpaperService {        @Override        public Engine onCreateEngine() {                return new OpenGLES2Engine();        }                class OpenGLES2Engine extends GLWallpaperService.GLEngine {                 @Override                public void onCreate(SurfaceHolder surfaceHolder) {                        super.onCreate(surfaceHolder);                                              // Check if the system supports OpenGL ES 2.0.                      final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);                        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();                        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;                                                if (supportsEs2)                         {                              // Request an OpenGL ES 2.0 compatible context.                              setEGLContextClientVersion(2);                                                              // On Honeycomb+ devices, this improves the performance when                                // leaving and resuming the live wallpaper.                                setPreserveEGLContextOnPause(true);                                 // Set the renderer to our user-defined renderer.                              setRenderer(getNewRenderer());                        }                       else                         {                              // This is where you could create an OpenGL ES 1.x compatible                              // renderer if you wanted to support both ES 1 and ES 2.                                return;                      }                                       }        }                     abstract Renderer getNewRenderer();} Is it possible to create a LAMW component from this? Are there any tutorials on creating "jComponent"? thank! ---------------------------------------------------------------------- jmpessoa · 2020-06-25 18:07 QuoteIs it possible to create a LAMW component from this? Are there any tutorials on creating "jComponent"? Yes! Go to Lazarus IDE: "Tools"  ---> "[LAMW] ......."   --->  "New jComponent...."   --->  [HELP] ---------------------------------------------------------------------- drugsound · 2021-12-28 12:39 I figured out how to create components. But what about WallpaperService? It is not launched from an application. And it doesn't start MainActivity (App.java and Controls.java). Or am I wrong? ---------------------------------------------------------------------- jmpessoa · 2021-12-28 21:38 QuoteOr am I wrong? No.  Here are some complete examples (and you can point up to others....) https://saltesta.com/android/android-live-wallpaper/ https://www.vogella.com/tutorials/AndroidLiveWallpaper/article.html https://www.pushing-pixels.org/2010/02/01/live-wallpapers-with- android-sdk-2-1.html Can you point out which of these examples (or others....) is closest to your needs? ---------------------------------------------------------------------- drugsound · 2022-01-02 12:15 QuoteCan you point out which of these examples (or others....) is closest to your needs? I think this https://www.vogella.com/tutorials/AndroidLiveWallpaper/article.html