Project

General

Profile

« Previous | Next » 

Revision b6a5d557

Added by Leszek Koltunski over 7 years ago

Change in the API: we always have to create a DistortedFramebuffer to render to.

View differences:

src/main/java/org/distorted/library/Distorted.java
27 27
import android.content.Context;
28 28
import android.opengl.GLES20;
29 29
import android.os.Build;
30
import android.util.Log;
31 30

  
32 31
import org.distorted.library.exception.*;
33 32

  
......
82 81
   */
83 82
  public static final int CLONE_CHILDREN= 0x10;
84 83

  
85
  private static final String TAG = Distorted.class.getSimpleName();
86 84
  private static boolean mInitialized = false;
87 85

  
88 86
  static int mPositionH;       // model position information
89 87
  static int mNormalH;         // model normal information.
90 88
  static int mTextureCoordH;   // model texture coordinate information.
91 89

  
92
  static DistortedFramebuffer mFramebuffer = new DistortedFramebuffer(0); // output to the screen
93

  
94 90
///////////////////////////////////////////////////////////////////////////////////////////////////
95 91

  
96 92
  private Distorted()
......
110 106
    GLES20.glGetIntegerv(GLES20.GL_MAX_FRAGMENT_UNIFORM_VECTORS, param, 0);
111 107
    maxF = param[0];
112 108
    
113
    Log.d(TAG, "Max vectors in vertex shader: "+maxV);
114
    Log.d(TAG, "Max vectors in fragment shader: "+maxF);
109
    //Log.d("Distorted", "Max vectors in vertex shader: "+maxV);
110
    //Log.d("Distorted", "Max vectors in fragment shader: "+maxF);
115 111
    
116 112
    if( !Build.FINGERPRINT.contains("generic") )
117 113
      {
......
200 196
      final int[] numberOfUniforms = new int[1];
201 197
      GLES20.glGetProgramiv(programHandle, GLES20.GL_ACTIVE_UNIFORMS, numberOfUniforms, 0);
202 198

  
203
      android.util.Log.d(TAG, "number of active uniforms="+numberOfUniforms[0]);
199
      //android.util.Log.d("Distorted", "number of active uniforms="+numberOfUniforms[0]);
204 200
      }
205 201
 
206 202
    return programHandle;
......
278 274
    return readTextFileFromRawResource( c, R.raw.main_fragment_shader);
279 275
    }
280 276

  
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282
// Public API
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284
/**
285
 * Sets Vertical Field of View angle and the point the camera is looking at. This changes the Projection Matrix.
286
 *   
287
 * @param fov Vertical Field Of View angle, in degrees. If T is the middle of the top edge of the 
288
 *            screen, E is the eye point, and B is the middle of the bottom edge of the screen, then 
289
 *            fov = angle(TEB)
290
 * @param x   X-coordinate of the point the camera is looking at. -scrWidth/2 < x < scrWidth/2
291
 * @param y   Y-coordinate of the point the camera is looking at. -scrHeight/2 < y < scrHeight/2
292
 */
293
  public static void setProjection(float fov, float x, float y)
294
    {
295
    mFramebuffer.setProjection(fov,x,y);
296
    }
297
  
298 277
///////////////////////////////////////////////////////////////////////////////////////////////////
299 278
/**
300 279
 * When OpenGL context gets created, you need to call this method so that the library can initialise its internal data structures.
......
324 303
      
325 304
    int programH = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, new String[] {"a_Position",  "a_Color", "a_Normal", "a_TexCoordinate"});
326 305

  
327
    mFramebuffer.setProjection(60.0f,0.0f,0.0f);
328

  
329 306
    GLES20.glUseProgram(programH);
330 307

  
331 308
    int textureUniformH = GLES20.glGetUniformLocation(programH, "u_Texture");
......
354 331
    DistortedObjectTree.reset();
355 332
    EffectMessageSender.startSending();
356 333
    }
357
  
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359
/**
360
 * Call this when the physical size of the surface we are rendering to changes.
361
 * I.e. must be called from GLSurfaceView.onSurfaceChanged()  
362
 *   
363
 * @param surfaceWidth  new width of the surface.
364
 * @param surfaceHeight new height of the surface.
365
 */
366
  public static void onSurfaceChanged(int surfaceWidth, int surfaceHeight)
367
    {
368
    mFramebuffer.resize(surfaceWidth,surfaceHeight);
369
    }
370 334

  
371 335
///////////////////////////////////////////////////////////////////////////////////////////////////
372 336
/**

Also available in: Unified diff