小编And*_*our的帖子

带有片段着色器的 OpenGL 3.3 不同颜色

我正在尝试为 3 个圆圈着色,但只出现了 3 个白色圆圈。在此示例中,n 为 3。每个顶点有 5 个点,2 个用于位置,3 个用于颜色

这是我认为可能存在问题的地方:

    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glVertexAttribPointer(
        0,                  
        2,                 
        GL_FLOAT,           
        GL_FALSE,          
        5*sizeof(float), 
        (void*)0            
    );

    glEnableVertexAttribArray(1);
    glVertexAttribPointer(
        1, 
        3,
        GL_FLOAT,
        GL_FALSE, 
        5*sizeof(float), 
        (void*)(2*sizeof(float))
    );

    glDrawElements(GL_TRIANGLES, 20 * 3 * n, GL_UNSIGNED_INT, 0);

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
Run Code Online (Sandbox Code Playgroud)

我的着色器:

#version 330 core

in vec3 Color;

out vec4 outColor;

void main()
{
    outColor = vec4(Color, 1.0);
}


#version 330 core

layout(location = 0) in vec2 position;

layout(location = 1) in vec3 color
out vec3 Color

void main(){ …
Run Code Online (Sandbox Code Playgroud)

c++ opengl shader colors opengl-3

6
推荐指数
1
解决办法
1405
查看次数

从抛出FileNotFoundException的资产读取文件

我正在使用以下代码:

    public void readLevel(int line){
    AssetManager am = this.getAssets();
    InputStream is = null;
    try {
        is = am.open("levelinfo.txt");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Scanner scanner = new Scanner(is);
    scanner.useDelimiter(",");
    String skip;
    for(int i = 1; i < line; i++){
        skip = scanner.nextLine();
    }
    levelData = new ArrayList<Integer>();
    while(scanner.hasNextInt()){
        levelData.add(scanner.nextInt());
    }
}
Run Code Online (Sandbox Code Playgroud)

该代码给出了FileNotFoundException。我已经看到了一些类似的问题,但是我不确定如何解决。该文件是资产文件夹中的文本文件。任何帮助表示赞赏

安迪

android assets filenotfoundexception

5
推荐指数
1
解决办法
8803
查看次数