【问题标题】:NDK-build GLuint does not name a type when trying to compileNDK-build GLuint 在尝试编译时没有命名类型
【发布时间】:2015-07-18 05:57:49
【问题描述】:

显然我不太清楚如何在我的 SDL 应用程序中包含 Open GL

我有:

if _ANDROID_
#include <GLES2/gl2.h>
#include <GLES2/glext.h>

但是当我使用 GLUint 时,我得到了

GLuint 没有命名类型

我的 android.mk 包括

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog 

我正在为 android 平台 10 (** **) 构建

APP_PLATFORM := android-10 
APP_ABI := armeabi-v7a armeabi x86

所以我不太确定我做错了什么

(添加了有问题的文件的其余部分:)

#pragma once
#include <stdlib.h>
#include <iostream>
#include <random>
#include <cassert>

#include "vec2.h"
#include "vec3.h"
#include "vec4.h"
#include "mat4.h"
#include "transformations.h"

#if defined(_MSC_VER)
#include <windows.h>
#include <glew.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#include <SDL_opengl.h>
#include <stdio.h>
#include <string>
#endif

#if __APPLE__
#include <SDL2/SDL.h>
#include <SDL2_image/SDL_image.h>
#include <SDL2_ttf/SDL_ttf.h>
#include <SDL2_mixer/SDL_mixer.h>
#endif

#if __ANDROID__
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
#endif

// vec2 *screen;
/*const*/ // int sw;
/*const*/ // int sh;

#if __IPHONEOS__ || __ANDROID__
#define MOBILE 1
#endif

#if __MACOSX__ || __WINDOWS__ || __LINUX__
#define PC 1
#endif

#if __IPHONEOS__
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
inline void glBindVertexArray(GLuint id1) {
   glBindVertexArrayOES(id1);
}
inline void glGenVertexArrays(GLsizei n, GLuint *ids) {
   glGenVertexArraysOES(n, ids);
}
inline void glDeleteVertexArrays(GLsizei n, const GLuint *ids) {
   glDeleteVertexArraysOES(n, ids);
}
#elif TARGET_OS_MAC
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
inline void glBindVertexArray(GLuint id1) {
   glBindVertexArrayAPPLE(id1);
}
inline void glGenVertexArrays(GLsizei n, GLuint *ids) {
   glGenVertexArraysAPPLE(n, ids);
}
inline void glDeleteVertexArrays(GLsizei n, const GLuint *ids) {
   glDeleteVertexArraysAPPLE(n, ids);
}

#elif __ANDROID__
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
    inline void glBindVertexArray(GLuint id1) {
        glBindVertexArrayOES(id1);
    }
    inline void glGenVertexArrays(GLsizei n, GLuint *ids) {
        glGenVertexArraysOES(n, ids);
    }
    inline void glDeleteVertexArrays(GLsizei n, const GLuint *ids) {
        glDeleteVertexArraysOES(n, ids);
    }
#endif // ANDROID


inline string get_path(string filename) {
   char *base = SDL_GetBasePath();
   string path(base + filename);
   SDL_free(base);
   //cout << "getting path " << path << endl;
   return path;
}

using namespace std;

【问题讨论】:

  • _ANDROID_ 是错字吗?定义应为__ANDROID__。另外,#ifdef,而不是if...
  • C++ 区分大小写 - 如果您使用的是 GLUint,将找不到它,因为类型是 GLuint
  • 谢谢@DanAlbert 你是对的那个错误。但是现在我得到 'glDeleteVertexArraysOES 没有在这个范围内声明,并且该类型在 android 东西之后在同一个文件中使用并添加 gl2.h 和 gl2ext.h。我在某处读到 gl2 不支持这种类型,所以我尝试使用 GL3 并得到相同的错误。有什么想法吗?
  • 我添加了该文件的其余部分。它确实为 windows 和 IOS 正常编译,但我无法让它与 android 的 ndk 一起编译

标签: android opengl-es compilation android-ndk sdl-2


【解决方案1】:

我通过使用解决了它

APP_STL := c++_static

而不是

#APP_STL := gnustl_static 

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    • 2021-09-21
    相关资源
    最近更新 更多