Java Code Examples for com.jogamp.opengl.GL2#GL_RED

The following examples show how to use com.jogamp.opengl.GL2#GL_RED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DwOpticalFlow.java    From PixelFlow with MIT License 6 votes vote down vote up
public boolean resize(DwPixelFlow context_, int w, int h, boolean grayscale){
  int internalformat = grayscale ? GL2.GL_R16F : GL2.GL_RGBA16F;
  int format         = grayscale ? GL2.GL_RED  : GL2.GL_RGBA;
  int channels       = grayscale ? 1           : 4;

  this.context = context_;
  this.w = w;
  this.h = h;
    
  context.begin();
  boolean resized = false;
  resized |= frame   .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= sobelH  .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= sobelV  .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= velocity.resize(context, GL2.GL_RG16F  , w, h, GL2.GL_RG  , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, 2       , 2);
  resized |= tmp     .resize(context, GL2.GL_RGBA16F, w, h, GL2.GL_RGBA, GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, 4       , 2);
  context.end();
  return resized;
}
 
Example 2
Source File: DwFlowFieldParticles.java    From PixelFlow with MIT License 4 votes vote down vote up
public boolean resizeWorld(int w, int h){
    
    param.wh_scale_sum = Math.min(Math.min(param.wh_scale_col, param.wh_scale_coh), param.wh_scale_obs);
    
    float scale_obs = 1 << Math.abs(param.wh_scale_obs);
    float scale_col = 1 << Math.abs(param.wh_scale_col);
    float scale_coh = 1 << Math.abs(param.wh_scale_coh);
    float scale_sum = 1 << Math.abs(param.wh_scale_sum);
    
    if(param.wh_scale_obs < 0) scale_obs = 1f / scale_obs;
    if(param.wh_scale_col < 0) scale_col = 1f / scale_col;
    if(param.wh_scale_coh < 0) scale_coh = 1f / scale_coh;
    if(param.wh_scale_sum < 0) scale_sum = 1f / scale_sum;

//    int w_sum = w,                            h_sum = h;
    int w_sum = (int) Math.ceil(w/scale_sum), h_sum = (int) Math.ceil(h/scale_sum);
    int w_obs = (int) Math.ceil(w/scale_obs), h_obs = (int) Math.ceil(h/scale_obs);
    int w_col = (int) Math.ceil(w/scale_col), h_col = (int) Math.ceil(h/scale_col);
    int w_coh = (int) Math.ceil(w/scale_coh), h_coh = (int) Math.ceil(h/scale_coh);
    
    boolean resized = false;
    
    resized |= ff_obs.resize(w_obs, h_obs);
    resized |= ff_col.resize(w_col, h_col);
    resized |= ff_coh.resize(w_coh, h_coh);
    resized |= ff_sum.resize(w_sum, h_sum);
    
    resized |= tex_obs_FG.resize(context, GL2.GL_RGBA, w_obs, h_obs, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, GL2.GL_NEAREST, 4, 1);
    resized |= tex_obs   .resize(context, GL2.GL_RGBA, w_obs, h_obs, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, GL2.GL_NEAREST, 4, 1);
    
    boolean HIGHP_FLOAT = true;
    int format  = GL2.GL_RED;
    int filter  = GL2.GL_LINEAR;
    int wrap    = GL2.GL_CLAMP_TO_EDGE;
    int iformat = HIGHP_FLOAT ? GL2.GL_R32F : GL2.GL_R16F;
    int type    = HIGHP_FLOAT ? GL2.GL_FLOAT : GL2.GL_HALF_FLOAT;
    int bpc     = HIGHP_FLOAT ? 4 : 2;
    resized |= tex_obs_dist.resize(context, iformat, w_obs, h_obs, format, type, filter, wrap, 1, bpc);
    resized |= tex_col_dist.resize(context, iformat, w_col, h_col, format, type, filter, wrap, 1, bpc);
    resized |= tex_coh_dist.resize(context, iformat, w_coh, h_coh, format, type, filter, wrap, 1, bpc);
    resized |= tex_tmp_dist.resize(context, iformat, w_col, h_col, format, type, filter, wrap, 1, bpc);
    
    if(resized){
      tex_obs_dist.clear(0);
      tex_col_dist.clear(0);
      tex_coh_dist.clear(0);
      tex_tmp_dist.clear(0);
    }

    return resized;
  }