Project

General

Profile

« Previous | Next » 

Revision d6e94c84

Added by Leszek Koltunski over 7 years ago

progress with Postprocessing.

View differences:

src/main/java/org/distorted/library/Distorted.java
20 20
package org.distorted.library;
21 21

  
22 22
import android.content.Context;
23
import android.content.res.Resources;
23 24
import android.opengl.GLES20;
24 25
import org.distorted.library.program.*;
25 26

  
......
62 63
   * This way we can have two different DistortedEffects sharing the FRAGMENT queue.
63 64
   */
64 65
  public static final int CLONE_FRAGMENT= 0x8;
66
   /**
67
   * When creating an instance of a DistortedEffects from another instance, clone the PostProcess Effects.
68
   * <p>
69
   * This way we can have two different DistortedEffects sharing the POSTPROCESS queue.
70
   */
71
  public static final int CLONE_POSTPROCESS= 0x10;
65 72
  /**
66 73
   * When creating an instance of a DistortedTree from another instance, clone the children Nodes.
67 74
   * <p>
68 75
   * This is mainly useful for creating many similar sub-trees and rendering then at different places
69 76
   * on the screen with (optionally) different Effects.
70 77
   */
71
  public static final int CLONE_CHILDREN= 0x10;
78
  public static final int CLONE_CHILDREN= 0x20;
72 79

  
73 80
  static int[] mMainProgramAttributes;
81
  static int[] mPostProgramAttributes;
82

  
83
  static int mainProgramH, postProgramH;
74 84

  
75 85
///////////////////////////////////////////////////////////////////////////////////////////////////
76 86

  
......
102 112
 */
103 113
  public static void onCreate(final Context context)
104 114
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
105
    { 
106
    final InputStream vertexStream   = context.getResources().openRawResource(R.raw.main_vertex_shader);
107
    final InputStream fragmentStream = context.getResources().openRawResource(R.raw.main_fragment_shader);
115
    {
116
    final Resources resources = context.getResources();
108 117

  
109
    DistortedProgram mainProgram = new DistortedProgram(vertexStream,fragmentStream);
110
    int programH = mainProgram.getProgramHandle();
111
    GLES20.glUseProgram(programH);
118
    final InputStream mainVertexStream   = resources.openRawResource(R.raw.main_vertex_shader);
119
    final InputStream mainFragmentStream = resources.openRawResource(R.raw.main_fragment_shader);
120

  
121
    DistortedProgram mainProgram = new DistortedProgram(mainVertexStream,mainFragmentStream);
122
    mainProgramH = mainProgram.getProgramHandle();
123
    GLES20.glUseProgram(mainProgramH);
112 124
    mainProgram.bindAndEnableAttributes();
113 125
    mMainProgramAttributes = mainProgram.getAttributes();
114 126

  
......
119 131
    GLES20.glCullFace(GLES20.GL_BACK);
120 132
    GLES20.glFrontFace(GLES20.GL_CW);
121 133

  
122
    EffectQueueFragment.getUniforms(programH);
123
    EffectQueueVertex.getUniforms(programH);
124
    EffectQueueMatrix.getUniforms(programH);
125
    DistortedTexture.getUniforms(programH);
134
    EffectQueueFragment.getUniforms(mainProgramH);
135
    EffectQueueVertex.getUniforms(mainProgramH);
136
    EffectQueueMatrix.getUniforms(mainProgramH);
137
    DistortedTexture.getUniforms(mainProgramH);
138

  
139
    final InputStream postVertexStream   = resources.openRawResource(R.raw.post_vertex_shader);
140
    final InputStream postFragmentStream = resources.openRawResource(R.raw.post_fragment_shader);
141

  
142
    DistortedProgram postProgram = new DistortedProgram(postVertexStream,postFragmentStream);
143
    postProgramH = postProgram.getProgramHandle();
144
    GLES20.glUseProgram(postProgramH);
145
    postProgram.bindAndEnableAttributes();
146
    mPostProgramAttributes = postProgram.getAttributes();
147

  
148
    EffectQueuePostprocess.getUniforms(postProgramH);
126 149

  
127 150
    DistortedTree.reset();
128 151
    EffectMessageSender.startSending();

Also available in: Unified diff