コード例 #1
0
ファイル: Particle.cpp プロジェクト: jmmemmol/boat-game
void Particle::Draw()
{
	// enable point
	glPushMatrix();
	glDepthMask( false );
	glEnable( GL_POINT_SMOOTH );
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

	// set up size of point
	double maxSize = 0.0;
	glGetDoublev( GL_POINT_SIZE_MAX, &maxSize );
	glPointSize( mSize );
	glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, 100.0 ); // ???
	glPointParameterf( GL_POINT_SIZE_MIN, 1.0 );
	glPointParameterf( GL_POINT_SIZE_MAX, maxSize );

	// size of points decreases
	//GLfloat constant[1] = {1.0};
	//GLfloat quadratic[3] = {1.0, 0.0, 0.1};
	//glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, constant);

	// draw particle
	glBegin( GL_POINTS );
	glColor4d( mColour.R(), mColour.G(), mColour.B(), 0.5 );
	glVertex3d( mPosition[0], mPosition[1], mPosition[2] );
	glEnd();

	// disable stuff
	glDisable( GL_POINT_SMOOTH );
	glDisable( GL_BLEND );
	glDepthMask( true );
	glPopMatrix();
}
コード例 #2
0
void SCE_RUsePointSprite (SCE_RPointSprite *point)
{
    if (point)
    {
        glPointSize (point->size); 
        /* TODO: manage ARB_point_parameters extensions :
           GL_ARB_point_parameters, GL_ARB_point_sprite,
           GL_EXT_point_parameters */
        glPointParameterfv (GL_POINT_DISTANCE_ATTENUATION, point->att);
        glPointParameterf (GL_POINT_SIZE_MAX, point->maxsize);
        glPointParameterf (GL_POINT_SIZE_MIN, point->minsize);

        if (point->smooth)
            glEnable (GL_POINT_SMOOTH);
        if (point->textured)
        {
            /* exige que la texture ait deja ete appliquee */
            glTexEnvf (GL_POINT_SPRITE, GL_COORD_REPLACE, SCE_TRUE);
            glEnable (GL_POINT_SPRITE);
        }
    }
    else
    {
        glTexEnvf (GL_POINT_SPRITE, GL_COORD_REPLACE, SCE_FALSE);
        glDisable (GL_POINT_SPRITE);
        glDisable (GL_POINT_SMOOTH);
    }
}
コード例 #3
0
void Particles::onPreRender(RenderView*, const RenderState&)
{
#if 0
	glEnable(GL_POINT_SPRITE);
	
	glPointSize(size);
	glPointParameterfv( GL_POINT_DISTANCE_ATTENUATION, &attenuation.x );
	glPointParameterf( GL_POINT_SIZE_MIN, minScale );
	glPointParameterf( GL_POINT_SIZE_MAX, maxScale );
	glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, fadeRate );
	//glTexEnvi( GL_POINT_SPRITE, GL_COORD_REPLACE, true );
#endif

	#pragma TODO("Enable point sprite extensions for the render")
}
コード例 #4
0
/**
 * @brief Renderer::initialize_pointsprites internally used to initialize point-sprite rendering
 */
void Renderer::initialize_pointsprites(){

    glEnable(GL_POINT_SPRITE); // needed so that fragment shader can use gl_PointCoord
    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); // needed so vertex stage can set point size
    glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
    glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 4);

    glGenBuffers(1, &pointsprites_vbo);
    glBindBuffer(GL_ARRAY_BUFFER, pointsprites_vbo);
    glBufferData(GL_ARRAY_BUFFER,
                 3 /* size of a vertex in elements */
                 * dataset.bodycount /* number of vertices */
                 * sizeof(float), /* lastly, convert to bytes */
                 dataset.type_adapter_get(),
                 GL_DYNAMIC_DRAW);

    glEnableVertexAttribArray(0); // xyz position
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float)*3 /* 3 components */, 0); // xyz positions

    if(use_fancy_shaders){
        pointsprites_shader = new Shader(SHADER_RESOURCE_PATH + "/pointsprite-fancier.vsh",
                                         SHADER_RESOURCE_PATH + "/pointsprite-fancier.fsh");
    }
    else {
        pointsprites_shader = new Shader(SHADER_RESOURCE_PATH + "/pointsprite.vsh",
                                         SHADER_RESOURCE_PATH + "/pointsprite-simple.fsh");
    }
}
コード例 #5
0
void StateSystem::RasterState::applyGL() const
{
  //glFrontFace(frontFace);
  glCullFace(cullFace);
  //glPolygonOffset(polyOffsetFactor,polyOffsetUnits);
  glPolygonMode(GL_FRONT_AND_BACK,polyMode);
  //glLineWidth(lineWidth);
  glPointSize(pointSize);
  glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE,pointFade);
  glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,pointSpriteOrigin);
}
コード例 #6
0
 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();
 }
コード例 #7
0
 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]);
     }
 }
コード例 #8
0
/*
 * Renders the tracked points
 */
void PointCloudApplication::render_point_cloud() {
	
    pointcloud_state state = pointcloud_get_state();
		     
    if (state == POINTCLOUD_INITIALIZING ||
		state == POINTCLOUD_TRACKING_SLAM_MAP) {
        
        pointcloud_point_cloud* points = pointcloud_get_points();
		
        if (points) {
			switch_to_camera();
			disable_lighting();

			glDisable(GL_DEPTH_TEST);

            glColor4f(0.9, 0.95, 1.0, 0.6);
            
            glEnable(GL_POINT_SPRITE_OES);
            glEnable(GL_TEXTURE_2D);
            
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			
			glBindTexture(GL_TEXTURE_2D, point_texture);

            glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
            
            glPointParameterf(GL_POINT_SIZE_MAX, 64.0f);
            
			glPointSize(32.0);
			glEnableClientState(GL_VERTEX_ARRAY);
            glVertexPointer(3,GL_FLOAT,0, (float *)points->points);
            glDrawArrays(GL_POINTS,0, points->size);
			
			glDisableClientState(GL_VERTEX_ARRAY);
            
            glColor4f(1, 1, 1, 1);
			
			glPointSize(1);

			glDisable(GL_BLEND);
			glDisable(GL_TEXTURE_2D);            
			glDisable(GL_POINT_SPRITE_OES);
			
			pointcloud_destroy_point_cloud(points);
			
			switch_to_ortho();
        }
    }    
}
コード例 #9
0
ファイル: myGL.cpp プロジェクト: sprunk/spring
void WorkaroundATIPointSizeBug()
{
	if (!globalRendering->atiHacks)
		return;

	GLboolean pointSpritesEnabled = false;
	glGetBooleanv(GL_POINT_SPRITE, &pointSpritesEnabled);
	if (pointSpritesEnabled)
		return;

	// force default params
	constexpr GLfloat atten[3] = {1.0f, 0.0f, 0.0f};
	glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, atten);
	glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 1.0f);
}
コード例 #10
0
ファイル: hdDrawingUtilities.cpp プロジェクト: cdave1/hdk
void SetupPointSprites()
{
#if TARGET_GL_OPENGL == 1
    GLfloat sizes[2];
    glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, sizes);
    glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, 32.0f );
    glPointParameterf( GL_POINT_SIZE_MIN, sizes[0] );
    glPointParameterf( GL_POINT_SIZE_MAX, sizes[1] );
#elif TARGET_GL_OPENGLES == 1
    GLfloat sizes[2];
    glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, sizes);
    glPointParameterf( GL_POINT_SIZE_MIN, sizes[0] );
    glPointParameterf( GL_POINT_SIZE_MAX, sizes[1] );
    glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
#else
    GLfloat sizes[2];
    glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, sizes);
    glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, 32.0f );
    glPointParameterf( GL_POINT_SIZE_MIN, sizes[0] );
    glPointParameterf( GL_POINT_SIZE_MAX, sizes[1] );
#endif
}
コード例 #11
0
void OpenGLRasterizerState::apply()
{
	if (changed_desc)
	{
		changed_desc = false;

		desc.get_culled() ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE);
		desc.get_enable_line_antialiasing() ? glEnable(GL_LINE_SMOOTH) : glDisable(GL_LINE_SMOOTH);
		switch (desc.get_face_cull_mode())
		{
			case cull_front:
				glCullFace(GL_FRONT);
				break;
			case cull_back:
				glCullFace(GL_BACK);
				break;
			case cull_front_and_back:
				glCullFace(GL_FRONT_AND_BACK);
				break;
		}
		if (glPolygonMode)
	        glPolygonMode(GL_FRONT_AND_BACK, OpenGL::to_enum(desc.get_face_fill_mode()));

		desc.get_front_face() == face_counter_clockwise ? glFrontFace(GL_CCW) : glFrontFace(GL_CW);

		// Note, enabled in GraphicContextProvider::set_scissor()
		if (!desc.get_enable_scissor())
			glDisable(GL_SCISSOR_TEST);

		if (glPointSize)
			glPointSize((GLfloat)desc.get_point_size());
		if (glPointParameterf)
			glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, (GLfloat)desc.get_point_fade_treshold_size());
		desc.is_point_size() ? glEnable(GL_VERTEX_PROGRAM_POINT_SIZE) : glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);

		if(glPointParameterf)
		{
			switch (desc.get_point_sprite_origin())
			{
			case origin_upper_left:
				glPointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
				break;
			case origin_lower_left:
				glPointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
				break;
			}
		}
#ifndef __ANDROID__
		desc.get_antialiased() ? glEnable(GL_POLYGON_SMOOTH) : glDisable(GL_POLYGON_SMOOTH);
		desc.get_offset_point() ? glEnable(GL_POLYGON_OFFSET_POINT) : glDisable(GL_POLYGON_OFFSET_POINT);
		desc.get_offset_line() ? glEnable(GL_POLYGON_OFFSET_LINE) : glDisable(GL_POLYGON_OFFSET_LINE);
#endif
		desc.get_offset_fill() ? glEnable(GL_POLYGON_OFFSET_FILL) : glDisable(GL_POLYGON_OFFSET_FILL);
		if (glPolygonOffset)
		{
			float factor,units;
			desc.get_polygon_offset(factor, units);
			glPolygonOffset(factor, units);
		}

	}

}
コード例 #12
0
 inline void VL_glPointParameterf( GLenum pname, GLfloat param)
 {
   glPointParameterf(pname,param);
 }
コード例 #13
0
ファイル: rfx_state.cpp プロジェクト: Booley/nbis
void RfxState::SetGLEnvironment()
{
	switch (state) {
	case GL_CurrentColor: {
		GLfloat *res = DecodeColor(value);
		glColor3f(res[0], res[1], res[2]);
		delete res;
	}

	case GL_SecondaryColor: {
		GLfloat *res = DecodeColor(value);
		glSecondaryColor3f(res[0], res[1], res[2]);
		delete res;
		break;
	}

	case GL_ClearColor: {
		GLfloat *res = DecodeColor(value);
		glClearColor(res[0], res[1], res[2], res[3]);
		delete res;
		break;
	}

	case GL_ClearDepth:
		glClearDepth(value);
		break;

	case GL_ShadeModel:
		glShadeModel((value == 1)? GL_FLAT : GL_SMOOTH);
		break;

	case GL_FrontFace:
		glFrontFace((value == 1)? GL_CCW : GL_CW);
		break;

	case GL_CullMode:
		if (value == 1) {
			glDisable(GL_CULL_FACE);
		} else {
			glEnable(GL_CULL_FACE);
			glCullFace((value == 2)? GL_FRONT :
			            ((value == 3)? GL_BACK : GL_FRONT_AND_BACK));
		}
		break;

	case GL_EdgeFlag:
		glEdgeFlag(value);
		break;

	case GL_DepthNear:
	case GL_DepthFar: {
		GLfloat range[2];
		glGetFloatv(GL_DEPTH_RANGE, range);
		if (state == GL_DepthNear)
			glDepthRange(value, range[1]);
		else
			glDepthRange(range[0], value);
		break;
	}

	case GL_FogColor: {
		glFogfv(GL_FOG_COLOR, DecodeColor(value));
		break;
	}

	case GL_FogDensity:
		glFogi(GL_FOG_DENSITY, value);
		break;

	case GL_FogStart:
		glFogi(GL_FOG_START, value);
		break;

	case GL_FogEnd:
		glFogi(GL_FOG_END, value);
		break;

	case GL_FogMode:
		glEnable(GL_FOG);
		switch ((GLint)value) {
		case 1: // NONE
			glDisable(GL_FOG);
			break;
		case 2: // LINEAR
			glFogi(GL_FOG_MODE, GL_LINEAR);
			break;
		case 3: // EXP
			glFogi(GL_FOG_MODE, GL_EXP);
			break;
		case 4: // EXP2
			glFogi(GL_FOG_MODE, GL_EXP2);
			break;
		default: // UNKNOWN
			break;
		}
		break;

	case GL_PointSize:
		glPointSize(value);
		break;

	case GL_PointMin:
		glPointParameterf(GL_POINT_SIZE_MIN, value);
		break;

	case GL_PointMax:
		glPointParameterf(GL_POINT_SIZE_MAX_ARB, value);
		break;

	case GL_PointSmooth:
		GLEnableDisable(GL_POINT_SMOOTH);
		break;

	case GL_LineWidth:
		glLineWidth(value);
		break;

	case GL_LineSmooth:
		GLEnableDisable(GL_LINE_SMOOTH);
		break;

	case GL_PolyFrontMode:
		glPolygonMode(GL_FRONT, (value == 1)? GL_POINT :
		                         ((value == 2)? GL_LINE : GL_FILL));
		break;

	case GL_PolyBackMode:
		glPolygonMode(GL_BACK, (value == 1)? GL_POINT :
                                ((value == 2)? GL_LINE : GL_FILL));
		break;

	case GL_PolySmooth:
		GLEnableDisable(GL_POLYGON_SMOOTH);
		break;

	case GL_PolyOffsetFactor: {
		GLfloat units;
		glGetFloatv(GL_POLYGON_OFFSET_UNITS, &units);
		glPolygonOffset(value, units);
		break;
	}

	case GL_PolyOffsetUnits: {
		GLfloat factor;
		glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &factor);
		glPolygonOffset(factor, value);
		break;
	}

	case GL_PolyOffsetPoint:
		GLEnableDisable(GL_POLYGON_OFFSET_POINT);
		break;

	case GL_PolyOffsetLine:
		GLEnableDisable(GL_POLYGON_OFFSET_LINE);
		break;

	case GL_PolyOffsetFill:
		GLEnableDisable(GL_POLYGON_OFFSET_FILL);
		break;

	case GL_AlphaEnable:
		GLEnableDisable(GL_ALPHA_TEST);
		break;

	case GL_AlphaFunction: {
		GLfloat ref;
		glGetFloatv(GL_ALPHA_TEST_REF, &ref);
		glAlphaFunc(GLFunctionMode(), ref);
		break;
	}

	case GL_AlphaReference: {
		GLint func;
		glGetIntegerv(GL_ALPHA_TEST_FUNC, &func);
		glAlphaFunc(func, value);
		break;
	}

	case GL_DepthEnable:
		GLEnableDisable(GL_DEPTH_TEST);
		break;

	case GL_DepthFunction:
		glDepthFunc(GLFunctionMode());
		break;

	case GL_BlendEnable:
		GLEnableDisable(GL_BLEND);
		break;

	case GL_BlendColor: {
		GLfloat *res = DecodeColor(value);
		glBlendColor(res[0], res[1], res[2], res[3]);
		delete res;
		break;
	}

	case GL_BlendSourceRGB:
	case GL_BlendDestRGB:
	case GL_BlendSourceAlpha:
	case GL_BlendDestAlpha: {
		GLint srcdst[4];
		glGetIntegerv(GL_BLEND_SRC_RGB, &srcdst[0]);
		glGetIntegerv(GL_BLEND_DST_RGB, &srcdst[1]);
		glGetIntegerv(GL_BLEND_SRC_ALPHA, &srcdst[2]);
		glGetIntegerv(GL_BLEND_DST_ALPHA, &srcdst[3]);

		glBlendFuncSeparate(
			((state == GL_BlendSourceRGB)?   GLColorMode() : srcdst[0]),
			((state == GL_BlendDestRGB)?     GLColorMode() : srcdst[1]),
			((state == GL_BlendSourceAlpha)? GLColorMode() : srcdst[2]),
			((state == GL_BlendDestAlpha)?   GLColorMode() : srcdst[3]));
		break;
	}

	case GL_BlendEquation:
		switch ((GLint)value) {
		case 1: // ADD
			glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
			break;
		case 2: // SUBTRACT
			glBlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_SUBTRACT);
			break;
		case 3: // REV_SUBTRACT
			glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT);
			break;
		case 4: // MIN
			glBlendEquationSeparate(GL_MIN, GL_MIN);
			break;
		case 5: // MAX
			glBlendEquationSeparate(GL_MAX, GL_MAX);
			break;
		}
		break;

	case GL_WriteMaskColor: {
		GLint val = (GLint)value;
		GLboolean par[4];
		par[3] = (val > 8)? GL_TRUE : GL_FALSE;
		par[2] = (val -= (8 * par[3]) > 4)? GL_TRUE : GL_FALSE;
		par[1] = (val -= (4 * par[2]) > 2)? GL_TRUE : GL_FALSE;
		par[0] = (val -= (2 * par[1]) > 1)? GL_TRUE : GL_FALSE;

		glColorMask(par[0], par[1], par[2], par[3]);
		break;
	}

	case GL_WriteMaskDepth:
		glDepthMask(value);
		break;

	case GL_VertexProgramTwoSideARB:
		GLEnableDisable(GL_VERTEX_PROGRAM_TWO_SIDE_ARB);
		break;

	case GL_StencilEnable:
		GLEnableDisable(GL_STENCIL_TEST);
		break;

	case GL_StencilFunction:
	case GL_StencilValueMask:
	case GL_StencilReference: {
		GLint StFun[3];
		glGetIntegerv(GL_STENCIL_FUNC, &StFun[0]);
		glGetIntegerv(GL_STENCIL_VALUE_MASK, &StFun[1]);
		glGetIntegerv(GL_STENCIL_REF, &StFun[2]);

		glStencilFunc(
			(state == GL_StencilFunction)? GLFunctionMode() : StFun[0],
			(state == GL_StencilValueMask)? value : StFun[1],
			(state == GL_StencilReference)? value : StFun[2]);
		break;
	}

	case GL_StencilFail:
	case GL_StencilPassDepthFail:
	case GL_StencilPassDepthPass: {
		GLint StOp[3];
		glGetIntegerv(GL_STENCIL_FAIL, &StOp[0]);
		glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &StOp[1]);
		glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &StOp[2]);

		// thanks god at least these values are equivalent to OpenGL ones,
		// no mapping needed.
		glStencilOp(
			(state == GL_StencilFail)?          value : StOp[0],
			(state == GL_StencilPassDepthFail)? value : StOp[1],
			(state == GL_StencilPassDepthPass)? value : StOp[2]);
		break;
	}

	case GL_WriteMaskStencil:
		glStencilMask(value);
		break;

	case GL_ClearStencil:
		glClearStencil(value);
		break;

	default:
		// do nothing, unsupported state
		break;
	}
}
コード例 #14
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL14_nglPointParameterf(JNIEnv *env, jclass clazz, jint pname, jfloat param, jlong function_pointer) {
	glPointParameterfPROC glPointParameterf = (glPointParameterfPROC)((intptr_t)function_pointer);
	glPointParameterf(pname, param);
}
コード例 #15
0
ファイル: property-bindings.c プロジェクト: dumbbell/piglit
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	float val[4];

	/* Material Property Bindings */
	for (int s = 0; s < 2; ++s) {
		for (int p = 0; p < 4; ++p) {
			const GLenum pname[] = {GL_EMISSION, GL_AMBIENT,
						GL_DIFFUSE, GL_SPECULAR};

			random_vec4(val);
			glMaterialfv(GL_FRONT + s, pname[p], val);
			pass = check_prg_param(val, "state.material.%s.%s",
					       s ? "back" : "front",
					       enum2program(pname[p])) &&
			       pass;

			/* The front material bindings are also accessible
			 * without ".front.".
			 */
			if (s == 0)
				pass = check_prg_param(
					       val, "state.material.%s",
					       enum2program(pname[p])) &&
				       pass;
		}

		val[0] = DRAND();
		val[1] = 0;
		val[2] = 0;
		val[3] = 1;
		glMaterialf(GL_FRONT + s, GL_SHININESS, val[0]);
		pass = check_prg_param(val, "state.material.%s.shininess",
				       s ? "back" : "front") && pass;

		if (s == 0)
			pass = check_prg_param(val,
					       "state.material.shininess") &&
			       pass;
	}

	/* Light Property Bindings */
	int max_lights;
	glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
	for (int l = 0; l < max_lights; ++l) {
		for (int p = 0; p < 4; ++p) {
			const GLenum pname[] = {GL_AMBIENT, GL_DIFFUSE,
						GL_SPECULAR, GL_POSITION};
			random_vec4(val);
			glLightfv(GL_LIGHT0 + l, pname[p], val);
			pass = check_prg_param(val, "state.light[%d].%s", l,
					       enum2program(pname[p])) &&
			       pass;
		}

		random_vec4(val);
		glLightf(GL_LIGHT0 + l, GL_CONSTANT_ATTENUATION, val[0]);
		glLightf(GL_LIGHT0 + l, GL_LINEAR_ATTENUATION, val[1]);
		glLightf(GL_LIGHT0 + l, GL_QUADRATIC_ATTENUATION, val[2]);
		glLightf(GL_LIGHT0 + l, GL_SPOT_EXPONENT, val[3]);
		pass = check_prg_param(val, "state.light[%d].attenuation",
				       l) && pass;

		random_vec4(val);
		glLightfv(GL_LIGHT0 + l, GL_SPOT_DIRECTION, val);
		glLightf(GL_LIGHT0 + l, GL_SPOT_CUTOFF, val[3]);
		val[3] = cosf(val[3] / 180 * M_PI);
		pass = check_prg_param(val, "state.light[%d].spot.direction",
				       l) && pass;

		for (int c = 0; c < 3; ++c)
			val[c] = DRAND();
		val[3] = 1;
		glLightfv(GL_LIGHT0 + l, GL_POSITION, val);
		normalize(val);
		val[2] += 1;
		normalize(val);
		pass = check_prg_param(val, "state.light[%d].half", l) &&
		       pass;
	}

	random_vec4(val);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, val);
	pass = check_prg_param(val, "state.lightmodel.ambient") && pass;

	for (int s = 0; s < 2; ++s) {
		float scene_color[4];

		for (int c = 0; c < 4; ++c)
			scene_color[c] = val[c] = DRAND();
		glMaterialfv(GL_FRONT + s, GL_AMBIENT, val);
		for (int c = 0; c < 4; ++c)
			scene_color[c] *= val[c] = DRAND();
		glLightModelfv(GL_LIGHT_MODEL_AMBIENT, val);
		for (int c = 0; c < 4; ++c)
			scene_color[c] += val[c] = DRAND();
		glMaterialfv(GL_FRONT + s, GL_EMISSION, val);

		/* Page 63 (77 of the PDF) of the OpenGL 2.0 spec says:
		 *
		 *      "The value of A produced by lighting is the alpha
		 *      value associated with d_{cm}."
		 *
		 * I'm not sure if this applies to the scene color, but both
		 * Mesa and the NVIDIA driver do this.
		 */
		random_vec4(val);
		glMaterialfv(GL_FRONT + s, GL_DIFFUSE, val);
		scene_color[3] = val[3];

		pass = check_prg_param(scene_color,
				       "state.lightmodel.%s.scenecolor",
				       s ? "back" : "front") && pass;

		if (s == 0)
			pass = check_prg_param(
				       scene_color,
				       "state.lightmodel.scenecolor") && pass;
	}

	for (int s = 0; s < 2; ++s) {
		for (int l = 0; l < max_lights; ++l) {
			const GLenum pname[] = {GL_AMBIENT, GL_DIFFUSE,
						GL_SPECULAR};
			for (int p = 0; p < 3; ++p) {
				float light_product[4];
				for (int c = 0; c < 4; ++c)
					light_product[c] = val[c] = DRAND();
				glLightfv(GL_LIGHT0 + l, pname[p], val);
				for (int c = 0; c < 4; ++c)
					light_product[c] *= val[c] = DRAND();
				glMaterialfv(GL_FRONT + s, pname[p], val);
				/* XXX: I have no Idea where the spec says the
				 * alpha value of the light product is the
				 * material's alpha value, but both Mesa and
				 * the NVIDIA driver do this.
				 */
				light_product[3] = val[3];

				pass = check_prg_param(
					       light_product,
					       "state.lightprod[%d].%s.%s", l,
					       s ? "back" : "front",
					       enum2program(pname[p])) &&
				       pass;

				if (s == 0)
					pass = check_prg_param(
						       light_product,
						       "state.lightprod[%d]."
						       "%s",
						       l,
						       enum2program(
							       pname[p])) &&
					       pass;
			}
		}
	}

	/* Texture Coordinate Generation Property Bindings */
	int max_texture_coords;
	glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);
	for (int t = 0; t < max_texture_coords; ++t) {
		const GLenum coord[] = {GL_S, GL_T, GL_R, GL_Q};
		glActiveTexture(GL_TEXTURE0 + t);

		for (int co = 0; co < 4; ++co) {
			const GLenum plane[] = {GL_EYE_PLANE,
						GL_OBJECT_PLANE};
			const char *plane_name[] = {"eye", "object"};
			for (int pl = 0; pl < 2; ++pl) {
				random_vec4(val);
				glTexGenfv(coord[co], plane[pl], val);
				pass = check_prg_param(
					       val, "state.texgen[%d].%s.%s",
					       t, plane_name[pl],
					       enum2program(coord[co])) &&
				       pass;
				if (t == 0)
					pass = check_prg_param(
						       val,
						       "state.texgen.%s.%s",
						       plane_name[pl],
						       enum2program(
							       coord[co])) &&
					       pass;
			}
		}
	}

	/* Fog Property Bindings */
	random_vec4(val);
	glFogfv(GL_FOG_COLOR, val);
	pass = check_prg_param(val, "state.fog.color") && pass;

	random_vec4(val);
	glFogf(GL_FOG_DENSITY, val[0]);
	glFogf(GL_FOG_START, val[1]);
	glFogf(GL_FOG_END, val[2]);
	val[3] = 1 / (val[2] - val[1]);
	pass = check_prg_param(val, "state.fog.params") && pass;

	/* Clip Plane Property Bindings */
	int max_clip_planes;
	glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
	for (int cp = 0; cp < max_clip_planes; ++cp) {
		double vald[4];
		for (int c = 0; c < 4; ++c)
			vald[c] = val[c] = DRAND();
		glClipPlane(GL_CLIP_PLANE0 + cp, vald);
		pass = check_prg_param(val, "state.clip[%d].plane", cp) &&
		       pass;
	}

	/* Point Property Bindings */
	random_vec4(val);
	glPointSize(val[0]);
	glPointParameterf(GL_POINT_SIZE_MIN, val[1]);
	glPointParameterf(GL_POINT_SIZE_MAX, val[2]);
	glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, val[3]);
	pass = check_prg_param(val, "state.point.size") && pass;

	random_vec4(val);
	val[3] = 1;
	glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, val);
	pass = check_prg_param(&val[0], "state.point.attenuation") && pass;

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
コード例 #16
0
ファイル: org_lwjgl_opengl_GL14C.c プロジェクト: LWJGL/lwjgl3
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL14C_glPointParameterf(JNIEnv *__env, jclass clazz, jint pname, jfloat param) {
    glPointParameterfPROC glPointParameterf = (glPointParameterfPROC)tlsGetFunction(428);
    UNUSED_PARAM(clazz)
    glPointParameterf(pname, param);
}
コード例 #17
0
void glPointParameterfLogged(GLenum pname, GLfloat param) {
	printf("glPointParameterf(%s, %.2f)\n", GLEnumName(pname), param);
	glPointParameterf(pname, param);
}
コード例 #18
0
ファイル: drawing.cpp プロジェクト: zeidrich/Quantree
void drawPoint(float x, float y, float z, float scale, float mx, float my, float mz, Image *image)
{
	UNREFERENCED_PARAMETER(image);
	UNREFERENCED_PARAMETER(scale);


	glPushMatrix();
	float distance;
	//glLoadIdentity();
	//glTranslatef(x,y,z);
	glTranslatef(x-0.5,y-0.5,z-0.5);
	distance = sqrt((mx-x)*(mx-x)+(my-y)*(my-y)+(mz-z)*(mz-z));
	//glPointSize(100000/(distance*distance));
	glPointParameterf(GL_POINT_SIZE_MAX, 1000.0f);
	glEnable(GL_POINT_SMOOTH);
	glPointSize(64);

	//glUseProgram(0);
	//glRotatef(180-angle,0,0,1);
	//glBindTexture(GL_TEXTURE_2D, objectID);
	glEnable(GL_POINT_SPRITE_ARB);
	glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);

	float distiterator = 0;
	float range = 0.35f;
	int type = 0;
	glBegin(GL_POINTS);
	glDisable(GL_TEXTURE_2D);
	//glBegin(GL_TRIANGLE_STRIP);
	if (distance < 20.0f)
	{
		for (distiterator = distance/5; distiterator < distance; distiterator = distiterator + distance/5)
		{
			if (type == 0)
			{
			range = 0.5f;
			if (distiterator > 1.0){
			glVertex3f(range/distiterator, range/distiterator, -range/distiterator);
			glVertex3f(-range/distiterator, -range/distiterator, -range/distiterator);
			glVertex3f(-range/distiterator, range/distiterator, -range/distiterator);
			glVertex3f(range/distiterator, -range/distiterator, -range/distiterator);

			glVertex3f(range/distiterator, range/distiterator, range/distiterator);
			glVertex3f(-range/distiterator, -range/distiterator, range/distiterator);
			glVertex3f(-range/distiterator, range/distiterator, range/distiterator);
			glVertex3f(range/distiterator, -range/distiterator, range/distiterator);
			type = 1;}
			}
			else 
			{
			//glVertex3f(0.0f/distiterator, 0.0f/distiterator, 0.0f/distiterator);
			range = 0.707f;
			if (distiterator > 1.0){
			glVertex3f(-range/distiterator, 0/distiterator, 0.0/distiterator);
			glVertex3f(range/distiterator, 0/distiterator, 0.0/distiterator);

			glVertex3f(0/distiterator, range/distiterator, 0.0f/distiterator);
			glVertex3f(0/distiterator, -range/distiterator, 0.0f/distiterator);
		
			glVertex3f(0/distiterator, 0/distiterator, range/distiterator);
			glVertex3f(0/distiterator, 0/distiterator, -range/distiterator);
			type = 0;}
			}
		}
	
	}
	else{
		glVertex3f(0, 0, 0);
	}
		 //glDrawPixels(100, 100, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
	glEnd();
	glPopMatrix();
}
コード例 #19
0
ファイル: r_part.c プロジェクト: DarthVador34/quake1-iphone
/* KJA: Particles seemed to be slowing things down; They were filling a lot of transparent pixels,
   and that's pretty expensive.  So I tried this version that does GL_POINTS instead.*/
void R_DrawParticles (void)
{
	particle_t		*p, *kill;
	float			grav;
	int				i;
	float			time2, time3;
	float			time1;
	float			dvel;
	float			frametime;
	
	frametime = cl.time - cl.oldtime;
	time3 = frametime * 15;
	time2 = frametime * 10; // 15;
	time1 = frametime * 5;
	grav = frametime * sv_gravity.value * 0.05;
	dvel = 4*frametime;
	
	for ( ;; ) 
	{
		kill = active_particles;
		if (kill && kill->die < cl.time)
		{
			active_particles = kill->next;
			kill->next = free_particles;
			free_particles = kill;
			continue;
		}
		break;
	}
	
	/* point parameters setup.  This seems to give a pretty good approximation of 
	   the original glquake particles */
	static const GLfloat pointSize = 10;
	static const GLfloat pointSizeMin = 2;
	static const GLfloat pointSizeMax = 20;
	static const GLfloat pointAttenuationCoefficients[3] = { 0, 0, 0.01 };
	glPointSize(pointSize);
	glEnable(GL_POINT_SMOOTH);
	glPointParameterf(GL_POINT_SIZE_MIN, pointSizeMin);
	glPointParameterf(GL_POINT_SIZE_MAX, pointSizeMax);
	glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, pointAttenuationCoefficients);
	
	// have to disable texturing; otherwise point color does not appear!
	glDisable(GL_TEXTURE_2D);
	
	glEnableClientState(GL_VERTEX_ARRAY);
	GLfloat partVerts[340*3];
	glVertexPointer(3, GL_FLOAT, sizeof(GLfloat)*3, partVerts);
	GLfloat * verts = partVerts;
	GLubyte partColors[(sizeof(partVerts)/sizeof(GLfloat)/3)*4];
	glEnableClientState(GL_COLOR_ARRAY);
	glColorPointer(4, GL_UNSIGNED_BYTE, 0, partColors);
	GLubyte * colors = partColors;
	
	for (p = active_particles; p ; p=p->next)
	{
		for ( ;; )
		{
			kill = p->next;
			if (kill && kill->die < cl.time)
			{
				p->next = kill->next;
				kill->next = free_particles;
				free_particles = kill;
				continue;
			}
			break;
		}
		
		byte * pcolor = (byte *)&d_8to24table[(int)p->color];
		*colors++ = pcolor[0]; *colors++ = pcolor[1]; *colors++ = pcolor[2]; *colors++ = 255;
		*verts++ = p->org[0]; *verts++ = p->org[1]; *verts++ = p->org[2];
		if (verts - partVerts >= sizeof(partVerts)/sizeof(GLfloat) - 3*sizeof(GLfloat))
		{
			glDrawArrays(GL_POINTS, 0, (verts-partVerts)/3);
			verts = partVerts;
			colors = partColors;
		}
		
		p->org[0] += p->vel[0]*frametime;
		p->org[1] += p->vel[1]*frametime;
		p->org[2] += p->vel[2]*frametime;
		
		switch (p->type)
		{
			case pt_static:
				break;
			case pt_fire:
				p->ramp += time1;
				if (p->ramp >= 6)
					p->die = -1;
				else
					p->color = ramp3[(int)p->ramp];
				p->vel[2] += grav;
				break;
				
			case pt_explode:
				p->ramp += time2;
				if (p->ramp >=8)
					p->die = -1;
				else
					p->color = ramp1[(int)p->ramp];
				for (i=0 ; i<3 ; i++)
					p->vel[i] += p->vel[i]*dvel;
				p->vel[2] -= grav;
				break;
				
			case pt_explode2:
				p->ramp += time3;
				if (p->ramp >=8)
					p->die = -1;
				else
					p->color = ramp2[(int)p->ramp];
				for (i=0 ; i<3 ; i++)
					p->vel[i] -= p->vel[i]*frametime;
				p->vel[2] -= grav;
				break;
				
			case pt_blob:
				for (i=0 ; i<3 ; i++)
					p->vel[i] += p->vel[i]*dvel;
				p->vel[2] -= grav;
				break;
				
			case pt_blob2:
				for (i=0 ; i<2 ; i++)
					p->vel[i] -= p->vel[i]*dvel;
				p->vel[2] -= grav;
				break;
				
			case pt_grav:
				break;
			case pt_slowgrav:
				p->vel[2] -= grav;
				break;
		}
	}
	if (verts > partVerts)
	{
		glDrawArrays(GL_POINTS, 0, (verts-partVerts)/3);
	}
	
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisable(GL_POINT_SMOOTH);
	glEnable(GL_TEXTURE_2D);
}
コード例 #20
0
ファイル: Particle.cpp プロジェクト: GALICSOFT/glc220
void CParticle::Render()
{
	int		hr = 0;

	// set up projection matrix in 3d pipeline
	float	temp[16]={0};
	float	w, h;
	glGetFloatv(GL_VIEWPORT, temp);		// get viewport to set the screen width and height.
	w = temp[2];
	h = temp[3];


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	glOrthof( 0.F,   w
			,   h, 0.F
			, 0.F, 1.F);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	hr = glGetError();
	hr = glGetError();

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, m_TexID);

	glEnable(GL_BLEND);
	glDisable(GL_CULL_FACE);

	//glBlendFunc(GL_ONE, GL_ONE);
	glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);


	//Setup point sprites coordinate generation
	glEnable(GL_POINT_SPRITE_OES);

	glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
	glPointParameterf ( GL_POINT_SIZE_MAX , 135);
	glPointSize(24);



	char* pVtx = (char*)m_Ptc;
	glEnableClientState(GL_VERTEX_ARRAY);	glVertexPointer(2, GL_FLOAT, sizeof(CParticle::Tptc), pVtx);	pVtx += sizeof(Tvector2) * 2;
	glEnableClientState(GL_COLOR_ARRAY);	glColorPointer (4, GL_FLOAT, sizeof(CParticle::Tptc), pVtx);


	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


	glDrawArrays(GL_POINTS, 0, m_PtcN);


	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);


	glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_FALSE);


	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	glDisable(GL_POINT_SPRITE_OES);

	
	glDisable(GL_BLEND);

	glColor4f(1, 1, 1, 1);

	glBindTexture(GL_TEXTURE_2D, 0);
	glDisable(GL_TEXTURE_2D);
}