gl.h和放大器; glext.h未找到 [英] gl.h & glext.h not found

查看:292
本文介绍了gl.h和放大器; glext.h未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然试图通过NDK平台Android的运行基于C计划++编译是给错误gl.h和glext.h头文件都没有找到,我在包括他们两个我C ++ code。
    中号使用Android的NDK-R8和Cygwin的编译它。

While trying to execute a program based on C++ in android via NDK platform, the compilation is giving error that 'gl.h' and 'glext.h' header files are not found, as I have included both of them in my C++ code. M using android-ndk-r8 and compiling it with Cygwin.

here s my code:   
**ANDROID.MK**

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := NDK1
FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) 
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) 

include $(BUILD_SHARED_LIBRARY)

---
**APPLICATION.MK**

APP_STL := stlport_static
APP_ABI := armeabi armeabi-v7a 
APP_PLATFORM := android-3

---
**Viewer.cpp**

#include <iostream>

#import "OpenGLES/ES2/gl.h"
#import "OpenGLES/ES2/glext.h"

//#import <GLKit/GLKEffects.h>
#import <GLKit/GLKMath.h>

#include "Viewer.h"

void Viewer::render() {
    glClearColor(0.65f, 0.65f, 0.65f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBindVertexArrayOES( _vertexArray[0]);

    // Render the object with GLKit


    glDrawArrays(GL_TRIANGLES, 0, 36);

    /////////
    glBindVertexArrayOES(_vertexArray[1]);

    // Render the object with GLKit
    //[self.effect prepareToDraw];

    glDrawArrays(GL_TRIANGLES, 0, 36);
}

void Viewer::initialize() {
    sceneObj.constructDemoScene();

    glEnable( GL_DEPTH_TEST);

    ///////////////////////////////////
    glGenVertexArraysOES(1, &_vertexArray[0]);
    glBindVertexArrayOES( _vertexArray[0]);

    glGenBuffers(1, &_vertexBuffer[0]);
    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer[0]);
    H3DModel * model = sceneObj.get3DModel(0);
    float * vertices = model->vertexBuffObj.getVertices();
    for (int c = 0; c < 216; c++)
        printf("%f\t", vertices[c]);
    glBufferData(GL_ARRAY_BUFFER, 216 * 4, vertices, GL_STATIC_DRAW);

    glEnableVertexAttribArray( EVertexAttribPosition);
    glVertexAttribPointer(EVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24,
            (void*) offsetof(Vertex, position));
    glEnableVertexAttribArray( EVertexAttribNormal);
    glVertexAttribPointer(EVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24,
            (void*) offsetof(Vertex, normal));

    ///////////////////////////////////

    glGenVertexArraysOES(2, &_vertexArray[1]);
    glBindVertexArrayOES(_vertexArray[1]);

    glGenBuffers(2, &_vertexBuffer[1]);
    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer[1]);
    H3DModel * model1 = sceneObj.get3DModel(1);
    float * vertices1 = model1->vertexBuffObj.getVertices();
    for (int c = 0; c < 216; c++)
        printf("%f\t", vertices[c]);
    glBufferData(GL_ARRAY_BUFFER, 216 * 4, vertices1, GL_STATIC_DRAW);

    glEnableVertexAttribArray(EVertexAttribPosition);
    glVertexAttribPointer(EVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24,
            (void*) offsetof(Vertex, position));
    glEnableVertexAttribArray(EVertexAttribNormal);
    glVertexAttribPointer(EVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24,
            (void*) offsetof(Vertex, normal));

    glBindVertexArrayOES(0);
}

void Viewer::unInitialize() {
    glDeleteBuffers(1, &_vertexBuffer[0]);
    glDeleteBuffers(2, &_vertexBuffer[1]);
    glDeleteVertexArraysOES(1, &_vertexArray[0]);
    glDeleteVertexArraysOES(2, &_vertexArray[1]);

    if (_program) {
        glDeleteProgram( _program);
        _program = 0;
    }
}

GLKMatrix4 Viewer::update() {
    GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f,
            -4.0f);
    baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation,
            0.0f, 1.0f, 0.0f);

    // Compute the model view matrix for the object rendered with GLKit
    //GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -1.5f);
    //modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f);
    //modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);

    //self.effect.transform.modelviewMatrix = baseModelViewMatrix;

    /*// Compute the model view matrix for the object rendered with ES2
     modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f);
     modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f);
     modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);

     _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);

     _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);*/

    _rotation += 0.04f;
    return baseModelViewMatrix;
}

感谢advance..i想知道如何在Android的NDK使用OpenGL ES !!

Thanks in advance..i want to know how to use OPENGL ES in android ndk !!

推荐答案

不太清楚,但我相信,如果你寻找到由谷歌NDK提供的样品code,它可能是一个很大的帮助。

Not quite sure, but I believe if you looking into the sample code provided by google ndk, it could be a great help.

样品code

    android-ndk-r7b\samples\hello-gl2\jni\gl_code.cpp

如果比较Android.mk,你会发现你

If compare the Android.mk, you will find your

    LOCAL_LDLIBS    := -llog -lGLESv2

缺失。由谷歌提供了Android.mk看起来像如下:

is missing. The Android.mk provided by Google is looks like below:

    LOCAL_PATH:= $(call my-dir)

    include $(CLEAR_VARS)

    LOCAL_MODULE    := libgl2jni
    LOCAL_CFLAGS    := -Werror
    LOCAL_SRC_FILES := gl_code.cpp
    LOCAL_LDLIBS    := -llog -lGLESv2

    include $(BUILD_SHARED_LIBRARY)

和也,在CPP源$ C ​​$ C,Android是使用:

and also, in the cpp source code, android is using :

    #include <GLES2/gl2.h>
    #include <GLES2/gl2ext.h>

这篇关于gl.h和放大器; glext.h未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆