{"id":18269768,"url":"https://github.com/skyfe79/androidglkit","last_synced_at":"2025-10-24T09:51:20.273Z","repository":{"id":137746170,"uuid":"62943514","full_name":"skyfe79/AndroidGLKit","owner":"skyfe79","description":"AndroidGLKit provides OpenGL ES 2.0 boilerplate codes for Android.","archived":false,"fork":false,"pushed_at":"2018-07-15T14:47:32.000Z","size":239,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T20:18:15.214Z","etag":null,"topics":["android","glkit","glsl","opengl","opengl-es","opengles","shader"],"latest_commit_sha":null,"homepage":"https://github.com/skyfe79/AndroidGLKit","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skyfe79.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-09T10:02:25.000Z","updated_at":"2023-08-13T12:08:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"3fc54a0c-6eb6-45e0-8e04-efac90300bde","html_url":"https://github.com/skyfe79/AndroidGLKit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidGLKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidGLKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidGLKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidGLKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyfe79","download_url":"https://codeload.github.com/skyfe79/AndroidGLKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","glkit","glsl","opengl","opengl-es","opengles","shader"],"created_at":"2024-11-05T11:37:07.974Z","updated_at":"2025-10-24T09:51:15.235Z","avatar_url":"https://github.com/skyfe79.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AndroidGLKit\n\n[![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html)\n[![API](https://img.shields.io/badge/API-17%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=17)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://opensource.org/licenses/MIT)\n\nAndroidGLKit provides OpenGL ES 2.0 boilerplate codes for Android. You can implement OpenGL 2.0 things easily by using AndroidGLKit. \n\n## Setup Gradle\n\n```groovy\ndependencies {\n\t...\n\timplementation 'kr.pe.burt.android.lib:androidglkit:1.0.1'\n}\n```\n\n## How to Use\n\n### Extends Activity or Fragment\n\nAndroidGLKit provides GLKActivity or GLKFragments. Also it has  GLKAppCompatActivity and GLKSupportFragment. You can extends above activity or fragment like below.\n\n```java\npublic class TextureActivity extends GLKAppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n    }\n\n    @Override\n    protected void onStart() {\n        super.onStart();\n        glkView.setGLKRenderer(new TextureRenderer(this));\n    }\n}\n```\n\nNotice that above code does not have set layout code `setContentView(R.layout.texture_activity)`. Because AndroidGLKit provides default layout file as `common_glk_view.xml` like below:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003ckr.pe.burt.android.lib.androidglkit.GLKView\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/glkView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n\u003c/kr.pe.burt.android.lib.androidglkit.GLKView\u003e\n```\n\nIf you extends activity or fragment that GLKit provides, you don't need to have layout file. \n\n### Custom Layout file\n\nOf course, You don't like the above approach. Therefore, You can use custom layout file like below:\n\n```java\npublic class SquareActivity extends GLKAppCompatActivity {\n\n    @Override\n    protected int getLayoutFileResourceId() {\n        return R.layout.activity_square;\n    }\n\n    @Override\n    protected void onStart() {\n        super.onStart();\n        glkView.setGLKRenderer(new SquareRenderer(this));\n    }\n}\n```\n\nOverride `getLayoutFileResourceId` method and return resource id for your layout file. `R.layout.activity_square` looks like below:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cRelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    xmlns:glk=\"http://schemas.android.com/apk/res-auto\"\n    tools:context=\"kr.pe.burt.android.lib.androidglkit.app.SquareActivity\"\u003e\n\n\n    \u003ckr.pe.burt.android.lib.androidglkit.GLKView\n        android:id=\"@+id/glkView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        /\u003e\n\n\n\u003c/RelativeLayout\u003e\n```\n\nImportant thing is GLKView must have `android:id` as glkView. It is rule for using AndroidGLKit.\n\n### Implement GLKRenderer\n\nGLKRenderer takes responsibility for draw something on OpenGL ES Context. Maybe your opengl codes to be in here. The Simplest renderer is blank renderer like below:\n\n```java\npublic class BlankRenderer implements GLKRenderer {\n\n    @Override\n    public void init(GLKView view) {\n\n    }\n\n    @Override\n    public void onSizeChanged(GLKView view, int width, int height) {\n        GLES20.glViewport(0, 0, width, height);\n    }\n\n    @Override\n    public void update(GLKView view, long dt) {\n        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);\n        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);\n    }\n}\n```\n\n### Set Renderer to GLKView\n\nIf you have implemented GLKRenderer, you should set it to GLKView like below:\n\n```java\n@Override\npublic void onStart() {\n    super.onStart();\n    glkView.setGLKRenderer(new BlankRenderer());\n}\n```\n\nIt's all :) If you run the above code, You can see the result screen like below:\n\n![](art/img_01.png)\n\n## Examples \n\n### Square\n\n![](art/img_02.png)\n\n### Texture\n\n![](art/img_04.png)\n\n### Offscreen Rendering\n\n![](art/img_03.png)\n\nYou can get bitmap from OpenGL ES context easily like below:\n\n```java\n@Override\nprotected void onStart() {\n    super.onStart();\n\n    GLKPixelBuffer pb = new GLKPixelBuffer(300, 300);\n    Bitmap bitmap = pb.getBitmap(new SquareRenderer(this));\n    imageView.setImageBitmap(bitmap);\n    pb.destroy();\n}\n```\n\nEnjoy OpenGL ES 2.0 with AndroidGLKit!\n\n## MIT License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Sungcheol Kim, [https://github.com/skyfe79/AndroidGLKit](https://github.com/skyfe79/AndroidGLKit)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2Fandroidglkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyfe79%2Fandroidglkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2Fandroidglkit/lists"}