Guest User

Untitled

a guest
Mar 15th, 2014
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1.         System.out.println("Load Shader");
  2.         char sep = File.separatorChar;
  3.         this.spriteVertexShaderID = loadShader("res" + sep + "shader" + sep + "sprite_white_vs.glsl" , GL2.GL_VERTEX_SHADER, gl);
  4.         this.spriteHueFragmentShaderID = loadShader("res" + sep + "shader" + sep + "sprite_white_fs.glsl", GL2.GL_FRAGMENT_SHADER, gl);
  5.        
  6.         this.spriteProgramID = gl.glCreateProgram();
  7.         gl.glAttachShader(this.spriteProgramID, this.spriteVertexShaderID);
  8.         gl.glAttachShader(this.spriteProgramID, this.spriteHueFragmentShaderID);
  9.        
  10.         gl.glLinkProgram(this.spriteProgramID);
  11.         gl.glValidateProgram(this.spriteProgramID);
  12.  
  13.         System.out.println("Error after validation: "+gl.glGetError());
  14.        
  15.         ByteBuffer cbuffer = ByteBuffer.allocate(512);
  16.         IntBuffer ibuffer = IntBuffer.allocate(16);
  17.         gl.glGetProgramInfoLog(this.spriteProgramID, 512, ibuffer, cbuffer);
  18.  
  19.         int c = 0;
  20.         boolean written = false;
  21.         for(int i = 0 ; i < 16 ; i++){
  22.             for(int j = ibuffer.get(i) ; j > 0 ; j--){
  23.                 char l = (char) cbuffer.get(c);
  24.                 c++;
  25.                 System.out.print(l);
  26.                 written = true;
  27.             }
  28.             if(written){
  29.                 System.out.println();  
  30.                 written = false;
  31.             }
  32.         }
  33.        
  34.         gl.glGetProgramiv(this.spriteProgramID, GL2.GL_VALIDATE_STATUS, VBO_VAO_ID_BUFFER);
  35.         System.out.println("Validate Status: " + VBO_VAO_ID_BUFFER.get(0));
  36.        
  37.         gl.glUseProgram(this.spriteProgramID);
  38.         this.positionLoc = gl.glGetUniformLocation(spriteProgramID, "position");
  39.         this.sizeLoc = gl.glGetUniformLocation(spriteProgramID, "size");
  40.         this.colorLoc = gl.glGetUniformLocation(spriteProgramID, "color");
  41.         System.out.println("Position Loc: " + this.positionLoc);
  42.         System.out.println("Size Loc: " + this.sizeLoc);
  43.         System.out.println("Color Loc: " + this.colorLoc);
  44.         System.out.println("Error after getting Uniform Locations: "+ gl.glGetError());
  45.        
  46.         int vertexLoc = gl.glGetAttribLocation(this.spriteProgramID, "vertex");
  47.         System.out.println("Vertex Loc: "+vertexLoc);
  48.         System.out.println("Error after getting attrib location: "+ gl.glGetError());
  49.        
  50.         gl.glBindAttribLocation(this.spriteProgramID, 0, "vertex");
Advertisement
Add Comment
Please, Sign In to add comment