当前位置: 首页>>代码示例>>Java>>正文


Java GLES30.glCreateProgram方法代码示例

本文整理汇总了Java中android.opengl.GLES30.glCreateProgram方法的典型用法代码示例。如果您正苦于以下问题:Java GLES30.glCreateProgram方法的具体用法?Java GLES30.glCreateProgram怎么用?Java GLES30.glCreateProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.opengl.GLES30的用法示例。


在下文中一共展示了GLES30.glCreateProgram方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Square

import android.opengl.GLES30; //导入方法依赖的package包/类
/**
 * Sets up the drawing object data for use in an OpenGL ES context.
 */
public Square() {
    // initialize vertex byte buffer for shape coordinates
    ByteBuffer bb = ByteBuffer.allocateDirect(
    // (# of coordinate values * 4 bytes per float)
            squareCoords.length * 4);
    bb.order(ByteOrder.nativeOrder());
    vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(squareCoords);
    vertexBuffer.position(0);

    // initialize byte buffer for the draw list
    ByteBuffer dlb = ByteBuffer.allocateDirect(
            // (# of coordinate values * 2 bytes per short)
            drawOrder.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    drawListBuffer = dlb.asShortBuffer();
    drawListBuffer.put(drawOrder);
    drawListBuffer.position(0);

    // prepare shaders and OpenGL program
    int vertexShader = MyGLRenderer.loadShader(
            GLES30.GL_VERTEX_SHADER,
            vertexShaderCode);
    int fragmentShader = MyGLRenderer.loadShader(
            GLES30.GL_FRAGMENT_SHADER,
            fragmentShaderCode);

    mProgram = GLES30.glCreateProgram();             // create empty OpenGL Program
    GLES30.glAttachShader(mProgram, vertexShader);   // add the vertex shader to program
    GLES30.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program
    GLES30.glLinkProgram(mProgram);                  // create OpenGL program executables
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:36,代码来源:Square.java

示例2: Triangle

import android.opengl.GLES30; //导入方法依赖的package包/类
/**
 * Sets up the drawing object data for use in an OpenGL ES context.
 */
public Triangle() {
    // initialize vertex byte buffer for shape coordinates
    ByteBuffer bb = ByteBuffer.allocateDirect(
            // (number of coordinate values * 4 bytes per float)
            triangleCoords.length * 4);
    // use the device hardware's native byte order
    bb.order(ByteOrder.nativeOrder());

    // create a floating point buffer from the ByteBuffer
    vertexBuffer = bb.asFloatBuffer();
    // add the coordinates to the FloatBuffer
    vertexBuffer.put(triangleCoords);
    // set the buffer to read the first coordinate
    vertexBuffer.position(0);

    // prepare shaders and OpenGL program
    int vertexShader = MyGLRenderer.loadShader(
            GLES30.GL_VERTEX_SHADER, vertexShaderCode);
    int fragmentShader = MyGLRenderer.loadShader(
            GLES30.GL_FRAGMENT_SHADER, fragmentShaderCode);

    mProgram = GLES30.glCreateProgram();             // create empty OpenGL Program
    GLES30.glAttachShader(mProgram, vertexShader);   // add the vertex shader to program
    GLES30.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program
    GLES30.glLinkProgram(mProgram);                  // create OpenGL program executables

}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:31,代码来源:Triangle.java

示例3: loadProgram

import android.opengl.GLES30; //导入方法依赖的package包/类
public static int loadProgram ( String vertShaderSrc, String fragShaderSrc )
{
   int vertexShader;
   int fragmentShader;
   int programObject;
   int[] linked = new int[1];

   // Load the vertex/fragment shaders
   vertexShader = loadShader ( GLES30.GL_VERTEX_SHADER, vertShaderSrc );

   if ( vertexShader == 0 )
   {
      return 0;
   }

   fragmentShader = loadShader ( GLES30.GL_FRAGMENT_SHADER, fragShaderSrc );

   if ( fragmentShader == 0 )
   {
      GLES30.glDeleteShader ( vertexShader );
      return 0;
   }

   // Create the program object
   programObject = GLES30.glCreateProgram();

   if ( programObject == 0 )
   {
      return 0;
   }

   GLES30.glAttachShader ( programObject, vertexShader );
   GLES30.glAttachShader ( programObject, fragmentShader );

   // Link the program
   GLES30.glLinkProgram ( programObject );

   // Check the link status
   GLES30.glGetProgramiv ( programObject, GLES30.GL_LINK_STATUS, linked, 0 );

   if ( linked[0] == 0 )
   {
      Log.e ( "ESShader", "Error linking program:" );
      Log.e ( "ESShader", GLES30.glGetProgramInfoLog ( programObject ) );
      GLES30.glDeleteProgram ( programObject );
      return 0;
   }

   // Free up no longer needed shader resources
   GLES30.glDeleteShader ( vertexShader );
   GLES30.glDeleteShader ( fragmentShader );

   return programObject;
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:55,代码来源:ESShader.java

示例4: loadProgramFromAsset

import android.opengl.GLES30; //导入方法依赖的package包/类
public static int loadProgramFromAsset ( Context context, String vertexShaderFileName, String fragShaderFileName )
{
   int vertexShader;
   int fragmentShader;
   int programObject;
   int[] linked = new int[1];

   String vertShaderSrc = null;
   String fragShaderSrc = null;

   // Read vertex shader from assets
   vertShaderSrc = readShader ( context, vertexShaderFileName );

   if ( vertShaderSrc == null )
   {
      return 0;
   }

   // Read fragment shader from assets
   fragShaderSrc = readShader ( context, fragShaderFileName );

   if ( fragShaderSrc == null )
   {
      return 0;
   }

   // Load the vertex shader
   vertexShader = loadShader ( GLES30.GL_VERTEX_SHADER, vertShaderSrc );

   if ( vertexShader == 0 )
   {
      return 0;
   }

   // Load the fragment shader
   fragmentShader = loadShader ( GLES30.GL_FRAGMENT_SHADER, fragShaderSrc );

   if ( fragmentShader == 0 )
   {
      GLES30.glDeleteShader ( vertexShader );
      return 0;
   }

   // Create the program object
   programObject = GLES30.glCreateProgram();

   if ( programObject == 0 )
   {
      return 0;
   }

   GLES30.glAttachShader ( programObject, vertexShader );
   GLES30.glAttachShader ( programObject, fragmentShader );

   // Link the program
   GLES30.glLinkProgram ( programObject );

   // Check the link status
   GLES30.glGetProgramiv ( programObject, GLES30.GL_LINK_STATUS, linked, 0 );

   if ( linked[0] == 0 )
   {
      Log.e ( "ESShader", "Error linking program:" );
      Log.e ( "ESShader", GLES30.glGetProgramInfoLog ( programObject ) );
      GLES30.glDeleteProgram ( programObject );
      return 0;
   }

   // Free up no longer needed shader resources
   GLES30.glDeleteShader ( vertexShader );
   GLES30.glDeleteShader ( fragmentShader );

   return programObject;
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:75,代码来源:ESShader.java

示例5: Floor

import android.opengl.GLES30; //导入方法依赖的package包/类
public Floor() {
    // make a floor
    ByteBuffer bbFloorVertices = ByteBuffer.allocateDirect(FLOOR_COORDS.length * 4);
    bbFloorVertices.order(ByteOrder.nativeOrder());
    floorVertices = bbFloorVertices.asFloatBuffer();
    floorVertices.put(FLOOR_COORDS);
    floorVertices.position(0);

    ByteBuffer bbFloorNormals = ByteBuffer.allocateDirect(FLOOR_NORMALS.length * 4);
    bbFloorNormals.order(ByteOrder.nativeOrder());
    floorNormals = bbFloorNormals.asFloatBuffer();
    floorNormals.put(FLOOR_NORMALS);
    floorNormals.position(0);

    ByteBuffer bbFloorColors = ByteBuffer.allocateDirect(FLOOR_COLORS.length * 4);
    bbFloorColors.order(ByteOrder.nativeOrder());
    floorColors = bbFloorColors.asFloatBuffer();
    floorColors.put(FLOOR_COLORS);
    floorColors.position(0);

    //now setup the shaders and program object
    int vertexShader = myStereoRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, light_vertex);
    int gridShader = myStereoRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, grid_fragment);
    int programObject;
    int[] linked = new int[1];

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, gridShader);

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;
}
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:54,代码来源:Floor.java

示例6: Pyramid

import android.opengl.GLES30; //导入方法依赖的package包/类
public Pyramid() {
    //first setup the mVertices correctly.
    mVertices = ByteBuffer
            .allocateDirect(mVerticesData.length * 4)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(mVerticesData);
    mVertices.position(0);

    //setup the shaders
    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = myStereoRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = myStereoRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES30.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //now everything is setup and ready to draw.
}
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:52,代码来源:Pyramid.java

示例7: Cube

import android.opengl.GLES30; //导入方法依赖的package包/类
public Cube() {
    //first setup the mVertices correctly.
    mVertices = ByteBuffer
            .allocateDirect(mVerticesData.length * 4)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(mVerticesData);
    mVertices.position(0);

    //setup the shaders
    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = myStereoRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = myStereoRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES30.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //now everything is setup and ready to draw.
}
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:52,代码来源:Cube.java

示例8: Pyramid

import android.opengl.GLES30; //导入方法依赖的package包/类
public Pyramid() {
    //first setup the mVertices correctly.
    mVertices = ByteBuffer
            .allocateDirect(mVerticesData.length * 4)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(mVerticesData);
    mVertices.position(0);

    //setup the shaders
    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = myRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = myRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES30.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //now everything is setup and ready to draw.
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:52,代码来源:Pyramid.java

示例9: onSurfaceCreated

import android.opengl.GLES30; //导入方法依赖的package包/类
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    String vShaderStr =
            "#version 300 es 			  \n"
                    + "in vec4 vPosition;           \n"
                    + "void main()                  \n"
                    + "{                            \n"
                    + "   gl_Position = vPosition;  \n"
                    + "}                            \n";
    //a red ise 1.0, 0.0, 0.0, 1.0  but I prefer blue.
    String fShaderStr =
            "#version 300 es		 			          	\n"
                    + "precision mediump float;					  	\n"
                    + "out vec4 fragColor;	 			 		  	\n"
                    + "void main()                                  \n"
                    + "{                                            \n"
                    + "  fragColor = vec4 ( 0.0, 0.0, 1.0, 1.0 );	\n"
                    + "}                                            \n";

    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = LoadShader(GLES30.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = LoadShader(GLES30.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES30.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //set the clear buffer color to white.
    GLES30.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:60,代码来源:HelloTriangleRenderer.java

示例10: Cube

import android.opengl.GLES30; //导入方法依赖的package包/类
public Cube() {
    //first setup the mVertices correctly.
    mVertices = ByteBuffer
            .allocateDirect(mVerticesData.length * 4)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(mVerticesData);
    mVertices.position(0);

    //setup the shaders
    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = myRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = myRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES30.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES30.glAttachShader(programObject, vertexShader);
    GLES30.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES30.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES30.glLinkProgram(programObject);

    // Check the link status
    GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES30.glGetProgramInfoLog(programObject));
        GLES30.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //now everything is setup and ready to draw.
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:52,代码来源:Cube.java

示例11: glCreateProgram

import android.opengl.GLES30; //导入方法依赖的package包/类
@Override
public int glCreateProgram()
{
    return GLES30.glCreateProgram();
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:6,代码来源:AndroidGraphicsDevice.java


注:本文中的android.opengl.GLES30.glCreateProgram方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。