OpenGL3.0 android环境搭建

OpenGL3.0 android环境搭建,第1张

1.首先安装android studio。 2.新建项目->选择native c++ ->finish

3.项目加载完成后,先运行下看默认native代码是否生效。 4.查看目录结构,在src/main/cpp 下有CMakeList.txt文件,默认代码为这样:


cmake_minimum_required(VERSION 3.18.1)


project("testndk")


add_library( # Sets the name of the library.
        testndk

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp
       )





find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)


target_link_libraries( # Specifies the target library.
        testndk
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})
5.增加OpenGL相关的库依赖。在CMakeList.txt中的target_link_libraries模块中加入: EGL,GLESv3,android。或者直接粘下面的。


cmake_minimum_required(VERSION 3.18.1)


project("testndk")


add_library( # Sets the name of the library.
        testndk

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp//默认生成的cpp
       )





find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)


target_link_libraries( # Specifies the target library.
        testndk //你自己起的名字
        EGL
        GLESv3
        android
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})
6.编译项目,编译完后在默认的cpp里尝试引入openGL相关的库,如果有提示的话,那就证明成功喽。

#include 
#include 
#include 

如果一切顺利的话,你就可以开始android - openGL之路啦。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/733321.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存