Results 1 to 3 of 3

Thread: Android SDK // Eclipse // OPENGL ES 2.0 -> Shader Question

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    2

    Android SDK // Eclipse // OPENGL ES 2.0 -> Shader Question

    hello...

    i try to use openGL ES 2.0 Shader ..but i am not able to load the vertex/fragment source

    opengl 2.0 is supported at my mobile phone ( info.getGlEsVersion() -> 2.0)

    i am using the android sdk (sdk manager) under Win7 with eclipse.

    testing at samsung galaxy s2 and the emulator



    i downloaded the NDK but i am not able to use it, because my english is not soo
    good to understand what to do.(downloading and extraction is not a problem)

    i open sample projekt (that i did understand in the manual..project from existing scource...) and build the apk..
    but when loading to mobile phone..it crashes..
    i think i need to link anything with anything i did not know where...
    maybe anything like libarys..etc...

    i hope and pray i did not need the ndk and opengl2 is working with the android sdk


    much greetings

    and thanks for all help i may get

    Code :
    public int createProgram() {
     
            	        String vertexSource =   "uniform mat4 u_mvpMatrix;"+
    			        	"attribute vec4 a_position;"+
    			        	"attribute vec4 a_color;"+
    			        	"varying vec4 v_color;"+
    			        	"void main() {"+
    			        	"gl_Position = u_mvpMatrix * a_position;"+
    			        	"v_color = a_color;"+
    			        	"}";
     
            		String fragmentSource = "precision mediump float;"+
    					    		 "varying vec4 v_color;"+
    					    "void main()\n {"+
    					    "gl_FragColor = v_color;";
     
     
     
     
    	is_error_text+="loading Shader / ";
     
    				int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
    				if (pixelShader == 0) {
    					is_error_text+=" FS error ";
    					return 0;
    				}
     
                    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
                    if (vertexShader == 0) {
                    	is_error_text+=" VS error ";
                        return 0;
                    }
    ...
    ...
    ...
     
     private int loadShader(int shaderType, String source) {
            	int shader = GLES20.glCreateShader(shaderType);
                    if (shader != 0) {
                        GLES20.glShaderSource(shader, source);
                        GLES20.glCompileShader(shader);
                        int[] compiled = new int[1];
                        GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
                        if (compiled[0] == 0) {
                            Log.e(TAG, "Could not compile shader " + shaderType + ":");
                            Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
                            GLES20.glDeleteShader(shader);
                            shader = 0;
                        }
                    }
                    return shader;
            }

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Android SDK // Eclipse // OPENGL ES 2.0 -> Shader Quest

    Your fragment shader seems to be lacking a closing }. That shouldn't cause a crash, though.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    1

    Re: Android SDK // Eclipse // OPENGL ES 2.0 -> Shader Quest

    try in Eclipse:Project->Clean..

Similar Threads

  1. Shader gives different results on different android phones!
    By dirhem in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 3
    Last Post: 07-16-2012, 12:22 AM
  2. Noob OpenGL ES Android Question
    By tttcowan in forum OpenGL ES general technical discussions
    Replies: 7
    Last Post: 01-06-2012, 08:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •