Ejemplo n.º 1
0
//------------------------------------------------------------------------------
void NBodyWnd::DrawH2()
{
    glBindTexture(GL_TEXTURE_2D, m_texStar);

    float maxSize = 0.0f;
    glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
    glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
    glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
    glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);

    glEnable(GL_POINT_SPRITE_ARB);
    glEnable(GL_TEXTURE_2D);       // point sprite texture support
    glEnable(GL_BLEND);            // soft blending of point sprites
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);


    Star *pH2 = m_galaxy.GetH2();
    int num = m_galaxy.GetNumH2();

    glPointSize(maxSize); //*(double)rand()/(double)RAND_MAX);


    for (int i=0; i<num; ++i)
    {
        int k1 = 2*i;
        int k2 = 2*i+1;

        const Vec2D &p1 = pH2[k1].m_pos;
        const Vec2D &p2 = pH2[k2].m_pos;

        double dst = sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
        double size = ((1000-dst) / 10) - 50;
        if (size<1)
            continue;

        glPointSize(2*size);
        glBegin(GL_POINTS);
        const Color &col = ColorFromTemperature(pH2[k1].m_temp);
        glColor3f(col.r * pH2[i].m_mag * 2,
                  col.g * pH2[i].m_mag,
                  col.b * pH2[i].m_mag);
        glVertex3f(p1.x, p1.y, 0.0f);
        glEnd();

        glPointSize(size/6);
        glBegin(GL_POINTS);
        glColor3f(1,1,1);
        glVertex3f(p1.x, p1.y, 0.0f);
        glEnd();
    }


    glDisable(GL_POINT_SPRITE_ARB);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);
}
Ejemplo n.º 2
0
void SimpleSparkle::draw() {
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    
    glColor3f(1.0, 1.0, 1.0);
    glEnable(GL_TEXTURE_2D);
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE );
        // This is how will our point sprite's size will be modified by 
    // distance from the viewer
    float quadratic[] =  { 1.0f, 0.0f, 0.01f };
    glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );

    // Query for the max point size supported by the hardware
    float maxSize = 0.0f;
    glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );

    // Clamp size to 100.0f or the sprites could get a little too big on some  
    // of the newer graphic cards. My ATI card at home supports a max point 
    // size of 1024.0f!
    if( maxSize > 100.0f )
        maxSize = 100.0f;

    glPointSize( pointSize );

    // The alpha of a point is calculated to allow the fading of points 
    // instead of shrinking them past a defined threshold size. The threshold 
    // is defined by GL_POINT_FADE_THRESHOLD_SIZE_ARB and is not clamped to 
    // the minimum and maximum point sizes.
    //glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );

    glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f );
    glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, maxSize );

    // Specify point sprite texture coordinate replacement mode for each 
    // texture unit
    glTexEnvf( 0x8861, 0x8862, GL_TRUE );

    glEnable( 0x8861 );


    glDrawArrays(GL_POINTS, 0, count);
//     glBegin(GL_POINTS);
//       glVertex2f(vertexArray[1], 0.0);
//     glEnd();
    glDisable( 0x8861 );
    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);

}
Ejemplo n.º 3
0
/*********************************************
 Figure out and set the dynamic scaling factor 
**********************************************/
float PSSprites::setSizeScale(){
	float scale = (1.0f/(float)iNumActive) * 150000;	
	if(scale < 5.0f){ scale = 5.0f; }
	else if(scale > MAX_SIZE){	
		scale = MAX_SIZE;
	}	
	scale *= App::S()->fParticleSizeScale;	
				
	//Set a default size here
	glPointSize(scale); 	
	glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, App::S()->fParticleSizeScale );
	glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, fMaxSize );
	
	return scale;
}
EXTERN_C_ENTER

JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBPointParameters_glPointParameterfARB(JNIEnv *__env, jclass clazz, jint pname, jfloat param) {
    glPointParameterfARBPROC glPointParameterfARB = (glPointParameterfARBPROC)tlsGetFunction(1256);
    UNUSED_PARAM(clazz)
    glPointParameterfARB(pname, param);
}
Ejemplo n.º 5
0
/*********************************************
	Set up the point sprites
**********************************************/
bool PSSprites::init(){
	if (!glewIsSupported("GL_VERSION_1_4  GL_ARB_point_sprite")){
		ERR("No point sprite support!\n");
	  	return false;
	}
	glGetFloatv( GL_POINT_SIZE_MAX_ARB, &fMaxSize );
			
	glPointSize( fMaxSize );
	glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
	glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f );
	glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, fMaxSize );
	glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
	glEnable( GL_POINT_SPRITE_ARB );

	return PSClassic::init();
}
Ejemplo n.º 6
0
Archivo: g_render.c Proyecto: aosm/X11
void __glXDisp_PointParameterfARB(GLbyte *pc)
{
	glPointParameterfARB(
		*(GLenum *)(pc + 0),
		*(GLfloat *)(pc + 4)
	);
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
void NBodyWnd::DrawStars()
{
    glBindTexture(GL_TEXTURE_2D, m_texStar);

    float maxSize = 0.0f;
    glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
    glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
    glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
    glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);

    glEnable(GL_POINT_SPRITE_ARB);
    glEnable(GL_TEXTURE_2D);       // point sprite texture support
    glEnable(GL_BLEND);            // soft blending of point sprites
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);


    int num = m_galaxy.GetNumStars();
    Star *pStars = m_galaxy.GetStars();


    glPointSize(4); //pStars[i].m_mag*10);
    glBegin(GL_POINTS);

    if (m_starRenderType==2)
        glColor3f(1, 1, 1);
    for (int i=1; i<num; ++i)
    {
        const Vec2D &pos = pStars[i].m_pos;
        const Color &col = ColorFromTemperature(pStars[i].m_temp);
        if (m_starRenderType==1)
        {
            glColor3f(col.r * pStars[i].m_mag,
                      col.g * pStars[i].m_mag,
                      col.b * pStars[i].m_mag);
        }
        glVertex3f(pos.x, pos.y, 0.0f);

    }
    glEnd();

    glDisable(GL_POINT_SPRITE_ARB);
    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);

}
Ejemplo n.º 8
0
void PointParticle::render(){
	
	//TODO alguams dessas funcoes sao de inicializacao do opengl
	//e devem ficar em outro local
	float quadratic[] =  { 1.0f, 0.0f, 0.01f };
	glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );
    glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
    glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f );
    glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f );

    glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
    glEnable( GL_POINT_SPRITE_ARB );
    glPointSize( size );
	
	glBegin( GL_POINTS );
		glColor4f( color[0], color[1], color[2], 1 - fade / life);
		glVertex3f( position[0], position[1], position[2] );
	glEnd();

	glDisable( GL_POINT_SPRITE_ARB );

};
 inline void VL_glPointParameterf( GLenum pname, GLfloat param)
 {
   if (glPointParameterf)
     glPointParameterf(pname,param);
   else
   if (glPointParameterfARB)
     glPointParameterfARB(pname,param);
   else
   if (glPointParameterfEXT)
     glPointParameterfEXT(pname,param);
   else
     VL_UNSUPPORTED_FUNC();
 }
 void GLStateCacheManagerImp::setPointParameters(GLfloat *attenuation, float minSize, float maxSize)
 {
     if (minSize != mPointSizeMin)
     {
         mPointSizeMin = minSize;
         const Ogre::RenderSystemCapabilities* caps = dynamic_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem())->getCapabilities();
         if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS))
             glPointParameterf(GL_POINT_SIZE_MIN, mPointSizeMin);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_ARB))
             glPointParameterfARB(GL_POINT_SIZE_MIN, mPointSizeMin);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_EXT))
             glPointParameterfEXT(GL_POINT_SIZE_MIN, mPointSizeMin);
     }
     if (maxSize != mPointSizeMax)
     {
         mPointSizeMax = maxSize;
         const Ogre::RenderSystemCapabilities* caps = dynamic_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem())->getCapabilities();
         if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS))
             glPointParameterf(GL_POINT_SIZE_MAX, mPointSizeMax);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_ARB))
             glPointParameterfARB(GL_POINT_SIZE_MAX, mPointSizeMax);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_EXT))
             glPointParameterfEXT(GL_POINT_SIZE_MAX, mPointSizeMax);
     }
     if (attenuation[0] != mPointAttenuation[0] || attenuation[1] != mPointAttenuation[1] || attenuation[2] != mPointAttenuation[2])
     {
         mPointAttenuation[0] = attenuation[0];
         mPointAttenuation[1] = attenuation[1];
         mPointAttenuation[2] = attenuation[2];
         const Ogre::RenderSystemCapabilities* caps = dynamic_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem())->getCapabilities();
         if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS))
             glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, &mPointAttenuation[0]);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_ARB))
             glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION, &mPointAttenuation[0]);
         else if (caps->hasCapability(RSC_POINT_EXTENDED_PARAMETERS_EXT))
             glPointParameterfvEXT(GL_POINT_DISTANCE_ATTENUATION, &mPointAttenuation[0]);
     }
 }
Ejemplo n.º 11
0
//------------------------------------------------------------------------------
void NBodyWnd::DrawDust()
{
    glBindTexture(GL_TEXTURE_2D, m_texStar);

    float maxSize = 0.0f;
    glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
    glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
    glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
    glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);

    glEnable(GL_POINT_SPRITE_ARB);
    glEnable(GL_TEXTURE_2D);       // point sprite texture support
    glEnable(GL_BLEND);            // soft blending of point sprites
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);


    Star *pDust = m_galaxy.GetDust();
    int num = m_galaxy.GetNumDust();

    glPointSize(maxSize); //*(double)rand()/(double)RAND_MAX);
    glBegin(GL_POINTS);

    for (int i=0; i<num; ++i)
    {
        const Vec2D &pos = pDust[i].m_pos;
        const Color &col = ColorFromTemperature(pDust[i].m_temp);
        glColor3f(col.r * pDust[i].m_mag,
                  col.g * pDust[i].m_mag,
                  col.b * pDust[i].m_mag);
        glVertex3f(pos.x, pos.y, 0.0f);

    }
    glEnd();

    glDisable(GL_POINT_SPRITE_ARB);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);
}
Ejemplo n.º 12
0
CatchSparksEffect::CatchSparksEffect(EffectSettings *conf)
    : Effect()
{
  flowerCount = conf->getIntegerOrDefault("flowercount", 30);
  blossomCount = conf->getIntegerOrDefault("blossomcount", 3);
  sparkCount = conf->getIntegerOrDefault("sparkcount", 30);
  blossomsize = conf->getFloatOrDefault("blossomsize", 12.0);
  sparksize = conf->getFloatOrDefault("sparksize", 10.0);

  xd = 4.0 / env->getMatrixWidth();
  yd = 2.0 / env->getMatrixHeight();

  Flower::setSparkCount(sparkCount);
  Flower::setBlossomCount(blossomCount);
  Flower::setAreaDetector(&detector);
  Flower::setxyd(xd, yd);
  flowers = new Flower[flowerCount];

  int verticesTotal = flowerCount * (blossomCount + sparkCount);
  vertices = new GLfloat[2 * verticesTotal];
  colors = new GLfloat[4 * verticesTotal];

  for ( int i = 0; i < verticesTotal; ++i) {
    vertices[2*i] = 0.0;
    vertices[2*i+1] = 0.0;
    colors[4*i] = 1.0;
    colors[4*i+1] = 1.0;
    colors[4*i+2] = 1.0;
    colors[4*i+3] = 1.0;
  }

  unsigned int sparkoffset = blossomCount * 2 * flowerCount; // sparks are stored behind blossoms
  for (unsigned int i = 0; i < flowerCount; ++i) {
    flowers[i].setBlossomPointers(vertices + i * 2 * blossomCount, colors + i * 4 * blossomCount);
    flowers[i].setSparksPointers(vertices + sparkoffset + i * 2 * sparkCount, colors + 2*sparkoffset + i * 4 * sparkCount);
    flowers[i].reset();
  }

  RGBAbmp *pic = loadBmp("data/blossom.bmp");

  glGenTextures(1, &blossomTex);
  glBindTexture(GL_TEXTURE_2D, blossomTex);
  int textureType = GL_RGB;
  if (pic->bpp == 32) 
  textureType = GL_RGBA ;
  gluBuild2DMipmaps(GL_TEXTURE_2D, pic->bpp/8, pic->width, 
                                    pic->height, textureType, GL_UNSIGNED_BYTE, pic->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
  delete pic->data;
  delete pic;

  pic = loadBmp("data/whiteflare.bmp");

  glGenTextures(1, &sparkTex);
  glBindTexture(GL_TEXTURE_2D, sparkTex);
  if (pic->bpp == 32) 
  textureType = GL_RGBA ;
  gluBuild2DMipmaps(GL_TEXTURE_2D, pic->bpp/8, pic->width, 
                                    pic->height, textureType, GL_UNSIGNED_BYTE, pic->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
  delete pic->data;
  delete pic;

  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);

  glVertexPointer(2, GL_FLOAT,0, vertices);
  glColorPointer(4, GL_FLOAT,0, colors);

  glColor3f(1.0, 1.0, 1.0);
  glEnable(GL_TEXTURE_2D);
  glEnable( GL_BLEND );
  glBlendFunc( GL_SRC_ALPHA, GL_DST_ALPHA );
  // This is how will our point sprite's size will be modified by 
  // distance from the viewer
  float quadratic[] =  { 1.0f, 0.0f, 0.01f };
  glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );

  glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f );
  glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f );

  // Specify point sprite texture coordinate replacement mode for each 
  // texture unit
  glTexEnvf( 0x8861, 0x8862, GL_TRUE );

    glEnable( 0x8861 );
}
Ejemplo n.º 13
0
static void
menu(int option)
{
  switch (option) {
  case 0:
    makePointList();
    break;
#ifdef GL_ARB_point_parameters
  case 1:
    glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
    break;
  case 2:
    glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, linear);
    break;
  case 3:
    glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
    break;
#endif
  case 4:
    blend = 1;
    break;
  case 5:
    blend = 0;
    break;
#ifdef GL_ARB_point_parameters
  case 6:
    glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
    break;
  case 7:
    glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 10.0);
    break;
#endif
  case 8:
    glEnable(GL_POINT_SMOOTH);
    smooth = 1;
    break;
  case 9:
    glDisable(GL_POINT_SMOOTH);
    smooth = 0;
    break;
  case 10:
    glPointSize(16.0);
    break;
  case 11:
    glPointSize(32.0);
    break;
  case 12:
    glPointSize(64.0);
    break;
  case 13:
    spin = 1 - spin;
    if (animate && (spin || motion)) {
      glutIdleFunc(idle);
    } else {
      glutIdleFunc(NULL);
    }
    break;
  case 14:
    numPoints = 200;
    break;
  case 15:
    numPoints = 500;
    break;
  case 16:
    numPoints = 1000;
    break;
  case 17:
    numPoints = 2000;
    break;
  case 666:
    exit(0);
  }
  glutPostRedisplay();
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBPointParameters_nglPointParameterfARB(JNIEnv *env, jclass clazz, jint pname, jfloat param, jlong function_pointer) {
	glPointParameterfARBPROC glPointParameterfARB = (glPointParameterfARBPROC)((intptr_t)function_pointer);
	glPointParameterfARB(pname, param);
}