Esempio n. 1
0
void DrawPoint ( vec2 coord, float width, colour col )
{
	SetShader("Primitive");
	DisableTexturing();
	if (col.alpha() < 1.0f)
	{
		EnableBlending();
	}
	else
	{
		DisableBlending();
	}
	SetColour(col);
	Matrices::SetViewMatrix(matrix2x3::Identity());
	Matrices::SetModelMatrix(matrix2x3::Identity());
	float quad[8] = { coord.X(), coord.Y(),
		coord.X(), coord.Y() - 2,
		coord.X() + 2, coord.Y() - 2,
		coord.X() + 2, coord.Y() };
	glVertexPointer ( 2, GL_FLOAT, 0, quad );
	glDrawArrays ( GL_QUADS, 0, 4 );
	/* ¡WARNING! IMMEDIATE MODE! ENTER AT YOUR OWN RISK */
//	glBegin(GL_POINTS);
//		glVertex2f(coord.X(), coord.Y());
//	glEnd();
}
Esempio n. 2
0
void SetCamera ( vec2 corner1, vec2 corner2, float rotation )
{
	matrix2x3 projection ( matrix2x3::Ortho(corner1.X(), corner2.X(), corner1.Y(), corner2.Y()) );
	if (fabs(rotation) > 0.00004f)
		projection *= matrix2x3::Rotation(rotation);
	Matrices::SetProjectionMatrix(projection);
	cameraCorner1 = corner1;
	cameraCorner2 = corner2;
}
Esempio n. 3
0
bool IsCulled ( vec2 position, float radius )
{
	if ((position.X() + radius) < cameraCorner1.X())
		return true;
	if ((position.X() - radius) > cameraCorner2.X())
		return true;
	if ((position.Y() + radius) < cameraCorner1.Y())
		return true;
	if ((position.Y() - radius) > cameraCorner2.Y())
		return true;
	return false;
}
Esempio n. 4
0
void SetListener(vec2 pos, vec2 vel)
{
	ALfloat fpos[] = {pos.X(), pos.Y(), 0.0f};
	ALfloat fvel[] = {vel.X(), vel.Y(), 0.0f};
	alListenerfv(AL_POSITION, fpos);
	alListenerfv(AL_VELOCITY, fvel);
	if (vel.ModulusSquared() > 0.2f)
	{
		forientation[0] = fvel[0];
		forientation[1] = fvel[1];
	}
	alListenerfv(AL_ORIENTATION, forientation);
}
Esempio n. 5
0
void PlaySoundPositional(const std::string& name, vec2 pos, vec2 vel, float gain)
{
	ALfloat fpos[] = {pos.X(), pos.Y(), 0.0f};
	ALfloat fvel[] = {vel.X(), vel.Y(), 0.0f};
	ALuint buf    = GetSound(name);
	ALuint source = GetFreeSource();
	alSourcei(source, AL_BUFFER, buf);
	alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
	alSourcefv(source, AL_POSITION, fpos);
	alSourcefv(source, AL_VELOCITY, fvel);
	alSourcef(source, AL_REFERENCE_DISTANCE, 50.0);
	alSourcef(source, AL_GAIN, gain);
	alSourcePlay(source);
}
Esempio n. 6
0
vec2 matrix2x3::operator* ( const vec2& srcv2 ) const
{
	float ix, iy, ox, oy;
	ix = srcv2.X();
	iy = srcv2.Y();
	ox = (ix * _m11) + (iy * _m12) + _tX;
	oy = (ix * _m21) + (iy * _m22) + _tY;
	return vec2(ox, oy);
}
Esempio n. 7
0
void DrawTriangle ( const vec2 point1, const vec2 point2, const vec2 point3, colour col )
{
	SetShader("Primitive");
	DisableTexturing();
	if (col.alpha() < 1.0f)
	{
		EnableBlending();
	}
	else
	{
		DisableBlending();
	}
	SetColour(col);
	Matrices::SetViewMatrix(matrix2x3::Identity());
	Matrices::SetModelMatrix(matrix2x3::Identity());
	float real_triangle[6] = { point1.X(), point1.Y(),
								point2.X(), point2.Y(),
								point3.X(), point3.Y() };
	glVertexPointer(2, GL_FLOAT, 0, real_triangle);
	glDrawArrays(GL_POLYGON, 0, 3);
} 
Esempio n. 8
0
void DrawLine ( vec2 coordinate1, vec2 coordinate2, float width, colour col )
{
	SetShader("Primitive");
	DisableTexturing();
	if (col.alpha() < 1.0f)
	{
		EnableBlending();
	}
	else
	{
		DisableBlending();
	}
	glLineWidth(width);
	Matrices::SetViewMatrix(matrix2x3::Identity());
	Matrices::SetModelMatrix(matrix2x3::Identity());
	SetColour(col);
	float vertices[4] = { coordinate1.X(), coordinate1.Y(),
						coordinate2.X(), coordinate2.Y() };
	glVertexPointer ( 2, GL_FLOAT, 0, vertices );
	glDrawArrays ( GL_LINES, 0, 2 );
}
Esempio n. 9
0
void PlaySoundPositional(const std::string& name, vec2 pos, vec2 vel, float gain)
{
	ALfloat fpos[] = {pos.X(), pos.Y(), 0.0f};
	ALfloat fvel[] = {vel.X(), vel.Y(), 0.0f};
	ALuint buf    = GetSound(name);
	ALuint source = GetFreeSource();
	alSourcei(source, AL_BUFFER, buf);
	alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
	alSourcefv(source, AL_POSITION, fpos);
	alSourcefv(source, AL_VELOCITY, fvel);
	alSourcef(source, AL_REFERENCE_DISTANCE, 50.0);
	alSourcef(source, AL_GAIN, gain);
	alSourcePlay(source);
#ifndef NDEBUG
    if (alGetError())
        LOG("Sound", LOG_ERROR, "OpenAL error");
    const ALchar* err = alureGetErrorString();
    if (strcmp(err, "No error"))
    {
        LOG("Sound", LOG_ERROR, "ALURE error: %s", err);
        exit(1);
    }
#endif
}
// Draw
void display ( void )
{
	int j=0;
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glLineWidth( GLfloat(lineWidth) );

	if (!useErrors)
	{
		// Bind and setup the shader
		draw->Enable();
		draw["xRange"] = vec2( 330.0f, 843.0f );
		draw["yRange"] = vec2( -0.13f, 2.05f );
		draw["useXYZ"]    = vec3( displayX ? 1.0f : 0.0f, 
								  displayY ? 1.0f : 0.0f, 
								  displayZ ? 1.0f : 0.0f );
			// For each curve, check if it's selected to be display, if so, draw it
			for (uint i=0; i<drawableCurves.Size(); i++)
			{
				// Check if this curve was selected to be drawn
				if ( curveSelection[i]->GetValue() )
				{
					draw["xColor"] = colorArr[j++];
					draw["yColor"] = colorArr[j++];
					draw["zColor"] = colorArr[j++];
					drawableCurves[i]->DrawArrays( GL_LINE_STRIP, 0, 471 );
				}
			}
		draw->Disable();

		// After drawing the curve, draw the axes
		drawAxes->Enable();
			axes->DrawArrays( GL_LINES, 0, 38 );
		drawAxes->Disable();
	}
	else
	{
		// Bind and setup the shader
		draw->Enable();
		draw["xRange"] = vec2( 330.0f, 843.0f );
		draw["yRange"] = vec2( -0.25f, 0.25f );
		draw["useXYZ"]    = vec3( displayX ? 1.0f : 0.0f, 
								  displayY ? 1.0f : 0.0f, 
								  displayZ ? 1.0f : 0.0f );
			// For each curve, check if it's selected to be display, if so, draw it
			for (uint i=0; i<errorCurves.Size(); i++)
			{
				// Check if this curve was selected to be drawn
				if ( curveSelection[i]->GetValue() )
				{
					draw["xColor"] = colorArr[j++];
					draw["yColor"] = colorArr[j++];
					draw["zColor"] = colorArr[j++];
					errorCurves[i]->DrawArrays( GL_LINE_STRIP, 0, 471 );
				}
			}
		draw->Disable();
	}

	// Draw the labels
	for (int i=0; i<10; i++)
		IGLUDraw::DrawColorText( IGLU_FONT_VARIABLE, 
		                         int(textOffsetFactor.X()*labels[i].x), 
								 int(textOffsetFactor.Y()*labels[i].y), 
								 color::Gray80, labels[i].name, textOffsetFactor.X() );
}