OpenGL3.0 android环境搭建

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 <GLES3/gl3.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值