Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


select mimap level?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 31 August 2012 - 01:45 PM

Hi,

I'm trying to sample a certain mipmap level of a mipmapped texture. How do I do that?

  //do the downsampling
  tex.bind();
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
  glGenerateMipmap( GL_TEXTURE_2D );

  //process the half res texture
  glViewport( 0, 0, o->conf.SCREEN_WIDTH / 2, o->conf.SCREEN_HEIGHT / 2 );

  half_fbo.bind();
  shader->bind();

  shader->pass_m4x4( o->ppl.get_projection_matrix(), "proj" );
  shader->pass_m4x4( o->ppl.get_model_view_matrix(), "modelview" );
  shader->pass_int( 0, "texture0" );

  tex.bind();
//how do I select the desired mipmap level here?
  quad.render();

  shader->unbind();
  half_fbo.unbind();

Best regards,
Yours3!f

Edited by Yours3!f, 31 August 2012 - 01:48 PM.


Sponsor:

#2 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 31 August 2012 - 01:47 PM

duplicate :D

Edited by Yours3!f, 31 August 2012 - 01:47 PM.


#3 dpadam450   Members   -  Reputation: 949

Like
1Likes
Like

Posted 31 August 2012 - 03:13 PM

http://www.opengl.org/sdk/docs/man/xhtml/glTexParameter.xml

MIN_LOD, MAX_LOD, BASE_LEVEL, MAX_LEVEL

Setting 2 of those should do it.

#4 mhagain   Crossbones+   -  Reputation: 8282

Like
1Likes
Like

Posted 31 August 2012 - 06:45 PM

Since you're using GLSL you don't need to respecify any glTexParameter stuff; just use textureLod to sample the specific level you want: http://www.opengl.org/wiki/GLSL_Sampler#Lod_texture_access

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 01 September 2012 - 02:46 AM

thank you both, I think I'll stick to the GLSL version, this seems more convenient.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS