void GraphicStore::LoadImages( CL_GraphicContext &gc )
{
	// Load the texture

/*
	CL_PixelBuffer test(1024, 768, cl_rgba8);
	unsigned int *dptr = (unsigned int *) test.get_data();
	for(int ypos = 0; ypos < 768; ypos++)
	{
		for(int xpos = 0; xpos < 1024; xpos++, dptr++)
		{
			*dptr = 0x777777ff;
			if ((xpos & 15) <= 3)
			{
				*dptr = 0xffffffff;
			}
			if ((ypos & 15) <= 3)
			{
				*dptr = 0xffffffff;
			}
		}
	}

	texture_underwater = CL_Texture(gc, 1024, 768, cl_rgba8);
	texture_underwater.set_subimage(0, 0, test, test.get_size());
	*/
	texture_underwater = CL_Texture(gc, "../../Game/SpritesRTS/Gfx/background.png");
	texture_underwater.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);

	texture_background = CL_Texture(gc, "../../Game/DiceWar/Resources/lobby_background1.png");
	texture_underwater.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);
}
/** Set new offset for the shown tracks. Offset 2 means
    that tracks 2-4 are shown.
    \param o New Offset.
*/
void
CASignUpScreen::setOffset( int offset ) 
{
    std::string trackPath = "tracks/";

    this->offset = offset;
    reset();

    for( int i=0; i<3; ++i ) 
    {
        if( i<numTracks ) 
        {
            try
            {
                image[i] = CL_Texture ( *CA_APP->graphicContext, trackPath + m_trackList[i] + "/thumb.tga" );
            }
            catch(CL_Exception err)
            {
                trackPath = "../resources/tracks/";
                image[i] = CL_Texture ( *CA_APP->graphicContext, trackPath + m_trackList[i] + "/thumb.tga" );
            }
            std::ostringstream oss;
            oss << "$" << (i==0 ? CA_PRIZE : (i==1 ? CA_PRIZE_MEDIUM : CA_PRIZE_HARD));
            racePreview[i] = new CAImageView( m_trackList[i], oss.str(), image[i], false );

            racePreview[i]->setImageSize( 150, 92 );
            racePreview[i]->move( left + 195*i, top + 50 );
        } 
        else 
        {
            image[i] = CL_Texture();
            racePreview[i] = 0;
        }
    }
}
Example #3
0
void GraphicStore::LoadImages( CL_GraphicContext &gc )
{
	// Load the texture
	texture_brick = CL_Texture(gc, "../Shadow/Resources/brick.png");
	texture_brick.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);

	normal_map = CL_Texture(gc, "Resources/normal_map.png");
	normal_map.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);

}
Example #4
0
Menu::Menu(World *world, CL_Rect viewPort) 
: GameObject(world), menuHeight(50), menuTowerLength(30), menuCoinsLength(45), menuTimeLength(45), menuLifeLength(40)
{
	//Viewport für die Positionierung des Menüs setzen
	this->viewPort = viewPort;

	//Textures setzen
	coinsTexture = CL_Texture("coinsTexture", &world->resources, world->get_gc());
	clockTexture = CL_Texture("clockTexture", &world->resources, world->get_gc());
	heartTexture = CL_Texture("heartTexture", &world->resources, world->get_gc());

	//Gibt die Breite des Menüinhaltes an
	menuWidth = -1;
}
GraphicStore::GraphicStore(CL_GraphicContext &gc) : shader_color_geometry(gc)
{
	// Create a depth buffer
	framebuffer_depth = CL_FrameBuffer(gc);
	texture_depth = CL_Texture(gc, gc.get_size(), cl_depth_component);
	texture_depth.set_wrap_mode(cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge);
	framebuffer_depth.attach_depth_buffer(texture_depth);

	// Load graphics
	texture_alpha_ball = CL_Texture(gc, "Resources/alpha_ball2.png");
	//texture_alpha_ball = CL_Texture(gc, "Resources/alpha_ball.png");
	texture_alpha_ball.set_wrap_mode(cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge);

}
Example #6
0
void ShaderImpl::begin(CL_GraphicContext &p_gc)
{
	G_ASSERT(m_initialized);
	G_ASSERT(!m_began);

	// new texture
	m_drawRect = m_parent->getDrawRect(m_boundRect);
	m_texture = CL_Texture(p_gc, m_drawRect.get_width(), m_drawRect.get_height());

	// attach frame buffer
	m_frameBuffer.attach_color_buffer(0, m_texture);
	p_gc.set_frame_buffer(m_frameBuffer);

	// clear to transparent
	p_gc.clear(CL_Colorf::transparent);

	// set proper matrix
	p_gc.push_modelview();

	// get scaling in count
	const CL_Mat4f &matrix = p_gc.get_modelview();
	const float scaleX = matrix[0];
	const float scaleY = matrix[5];

	p_gc.mult_translate(-m_drawRect.left / scaleX, -m_drawRect.top / scaleY);

	m_began = true;
}
void GraphicStore::LoadImages( CL_GraphicContext &gc, std::vector<CL_Collada_Image> &library_images )
{
	// Load the texture
	// TODO: Use library_images get the filename
	texture_brick = CL_Texture(gc, "../Shadow/Resources/brick.png");
	texture_brick.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);
}
Example #8
0
World::World(CL_DisplayWindow &display_window) : window(display_window), quit(false)
{
	CL_Slot slot_quit = window.sig_window_close().connect(this, &World::on_window_close);

	gc = window.get_gc();

	// Setup resources
	resources = CL_ResourceManager("resources.xml");

	background = CL_Texture("background", &resources, gc);
	
	// Receive mouse clicks
	slotKeyDown = window.get_ic().get_keyboard().sig_key_down().connect(this, &World::onKeyDown);
	slotMouseDown = window.get_ic().get_mouse().sig_key_down().connect(this, &World::onMouseDown);
	slotMouseUp = window.get_ic().get_mouse().sig_key_up().connect(this, &World::onMouseUp);
	slotMouseMove = window.get_ic().get_mouse().sig_pointer_move().connect(this, &World::onMouseMove);

	dragging = mouseDown = false;
	
	// Add some tanks
	initLevel();

	// Run the main loop
	run();
}
Example #9
0
Skybox::Skybox(CL_GraphicContext &gc)
{
/*
	CL_PixelBuffer pb_positive_x = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_RT.jpg");
	CL_PixelBuffer pb_negative_x = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_LF.jpg");
	CL_PixelBuffer pb_positive_y = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_UP.jpg");
	CL_PixelBuffer pb_negative_y = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_DN.jpg");
	CL_PixelBuffer pb_positive_z = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_BK.jpg");
	CL_PixelBuffer pb_negative_z = CL_ImageProviderFactory::load(L"Resources/Skybox/skybox_FR.jpg");
*/
	CL_PixelBuffer pb_positive_x = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_90.png");
	CL_PixelBuffer pb_negative_x = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_270.png");
	CL_PixelBuffer pb_positive_y = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_top.png");
	CL_PixelBuffer pb_negative_y = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_bottom.png");
	CL_PixelBuffer pb_positive_z = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_0.png");
	CL_PixelBuffer pb_negative_z = CL_ImageProviderFactory::load(L"Resources/Skybox/ice_field_180.png");

	CL_VirtualDirectory vd;
	program_object = CL_ProgramObject::load_and_link(gc, ("Resources/Skybox/skybox_vertex.glsl"), ("Resources/Skybox/skybox_fragment.glsl"), vd);

	skybox_texture = CL_Texture(gc, cl_texture_cube_map);
//	skybox_texture.set_generate_mipmap(true);
	skybox_texture.set_cube_map(
		pb_positive_x,
		pb_negative_x,
		pb_positive_y,
		pb_negative_y,
		pb_positive_z,
		pb_negative_z);
	skybox_texture.set_min_filter(cl_filter_linear);
	skybox_texture.set_mag_filter(cl_filter_linear);
	//skybox_texture.set_min_filter(cl_filter_linear_mipmap_linear);
	//skybox_texture.set_mag_filter(cl_filter_linear_mipmap_linear);
}
Example #10
0
CarType::CarType(const std::string& mainPath, CL_ResourceManager resources, CACarUpgrades* carUp, const bool debug)
     :
         m_motor (mainPath, resources, carUp),
         m_tires (mainPath, resources, carUp),
         m_armor (mainPath, resources, carUp)
{
    if(debug) std::cout << "  name" << std::endl;

    std::string path = mainPath + "name";
    name = resources.get_string_resource( path, "name" );

    if(debug) std::cout << "  surface" << std::endl;

    path = mainPath + "surface";
    surface = CL_Texture( *CA_APP->graphicContext, path, &resources );

    if(debug) std::cout << "  surface3d" << std::endl;

    path = mainPath + "surface3d";
    surface3d = CL_Texture( *CA_APP->graphicContext, path, &resources );

    path = mainPath + "length";
    length = resources.get_integer_resource( path, 0 );
    path = mainPath + "width";
    width = resources.get_integer_resource( path, 0 );
    path = mainPath + "minSpeed";
    minSpeed = 6 * resources.get_integer_resource( path, 1 );
    path = mainPath + "maxTurbo";
    maxTurbo = resources.get_integer_resource( path, 1000 );
    path = mainPath + "acceleration";
    deceleration = 6 * resources.get_integer_resource( path, 1000 );
    path = mainPath + "steeringPower";
    steeringPower = resources.get_integer_resource( path, 1 );
    path = mainPath + "price";
    price = resources.get_integer_resource( path, 0 );


    radius = std::sqrt( (double)width/2 * (double)width/2 + (double)length/2 * (double)length/2 );
    angle = atan( (double)(width/2) / (double)(length/2) ) * ARAD;
}
CL_TextureGroup_Impl::RootNode *CL_TextureGroup_Impl::add_new_root(CL_GraphicContext &context, const CL_Size &texture_size)
{
	CL_Rect rect(CL_Point(0, 0), texture_size);
	Node node(rect);

	active_root = new RootNode();
	active_root->texture = CL_Texture(context, texture_size);
	active_root->node = node;
	
	root_nodes.push_back(active_root);

	return active_root;
}
void CL_RenderBatch3D::flush(CL_GraphicContext &gc)
{
	if (position > 0)
	{
		gc.set_modelview(CL_Mat4f::identity());
		gc.set_program_object(cl_program_sprite);

		if (use_glyph_program)
		{
			CL_BlendMode old_blend_mode = gc.get_blend_mode();
			CL_BlendMode blend_mode;
			blend_mode.set_blend_color(constant_color);
			blend_mode.set_blend_function(cl_blend_constant_color, cl_blend_one_minus_src_color, cl_blend_zero, cl_blend_one);
			gc.set_blend_mode(blend_mode);

			for (int i = 0; i < num_current_textures; i++)
				gc.set_texture(i, current_textures[i]);
			CL_PrimitivesArray prim_array(gc);
			prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
			prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
			prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
			prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
			gc.draw_primitives(cl_triangles, position, prim_array);
			for (int i = 0; i < num_current_textures; i++)
				gc.reset_texture(i);

			gc.set_blend_mode(old_blend_mode);
		}
		else
		{
			for (int i = 0; i < num_current_textures; i++)
				gc.set_texture(i, current_textures[i]);
			CL_PrimitivesArray prim_array(gc);
			prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
			prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
			prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
			prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
			gc.draw_primitives(cl_triangles, position, prim_array);
			for (int i = 0; i < num_current_textures; i++)
				gc.reset_texture(i);
		}

		gc.reset_program_object();
		gc.set_modelview(modelview);
		position = 0;
		for (int i = 0; i < num_current_textures; i++)
			current_textures[i] = CL_Texture();
		num_current_textures = 0;
	}
}
/** Resets/destroys the images and previews.
*/
void
CASignUpScreen::reset() 
{
    for( int i=0; i<3; ++i ) 
    {
        if( racePreview[i] ) {
            delete racePreview[i];
            racePreview[i] = 0;
        }
        if( !image[i].is_null() ) {
            image[i] = CL_Texture();
        }
        // CAImageData doesn't delete image[i] !!
    }
}
Example #14
0
void SpriteResource::loadInMainThread(const std::string &fileName, CL_SharedPtr<Resource> &firstResource)
{
	FrameMap::iterator it = mFrames.find(fileName);
	GAME_ASSERT(it != mFrames.end());

	// convert previously loaded pixel buffer to the texture (only for the first resource)
	if (this == firstResource.get())
	{
		if (it->second.texture.is_null())
		{
			GAME_ASSERT(!it->second.pixelBuffer.is_null());
			it->second.texture = CL_Texture(Graphics::getSingleton().getWindow().get_gc(), it->second.pixelBuffer.get_size(), cl_rgba);
			it->second.texture.set_subimage(0, 0, it->second.pixelBuffer, CL_Rect(it->second.pixelBuffer.get_size()), 0);
			it->second.pixelBuffer = CL_PixelBuffer();
			CL_SharedGCData::add_texture(it->second.texture, it->second.fileName, mResource.get_manager().get_directory(mResource));
		}
	}
}
void HSVSpriteBatch::flush(CL_GraphicContext &gc)
{
	if (fill_position > 0)
	{
		CL_PrimitivesArray primarray(gc);
		primarray.set_attributes(0, positions);
		primarray.set_attributes(1, hue_offsets);
		primarray.set_attributes(2, tex1_coords);

		gc.set_texture(0, current_texture);
		gc.set_program_object(program, cl_program_matrix_modelview_projection);
		gc.draw_primitives(cl_triangles, fill_position, primarray);
		gc.reset_program_object();
		gc.reset_texture(0);

		fill_position = 0;
		current_texture = CL_Texture();
	}
}
void CL_GL1FrameBufferProvider::detach_all()
{
	stop();
	pbuffer = CL_PBuffer_GL1();
	selected_surface = CL_Texture();
}
/** Constructor.
*/
CASignUpScreen::CASignUpScreen(std::vector<Player*> player, std::vector<int> trackNumbers)
 : CAScreen(),
    m_Player(player)
{
    cursor = 0;
    offset = 0;
    title = "P R E S S   E N T E R   T O   S I G N   U P";
    help = "Use Arrow Keys to change selection and press Enter to\nconfirm";
    m_selected = false;

    left = (CA_APP->width - 640)/2;
    right = CA_APP->width - left;
    top = CA_APP->headerHeight + 30;
    bottom = top + 400;

    numTracks = CA_APP->trackList.size();

    for( int i=0; i<3; ++i )
    {
        image[i] = CL_Texture();
        racePreview[i] = 0;
    }

    //setOffset( 0 );
    std::sort(m_Player.begin(), m_Player.end(), RankPredicate()); // We sort player by points
    int beginRandom = m_Player.size()/2;
    int endRandom = m_Player.size() -1;
    for (int race=0; race<3; race++)
    {
        int rn = 0;
        if (trackNumbers.size() == 3)
            rn =  trackNumbers[race];
        else
        {
            std::vector<std::string>::const_iterator it = m_trackList.begin();
            do
            {
                rn = TrophyMath::getRandomNumber( 0, numTracks-1 );
                it = std::find(m_trackList.begin(), m_trackList.end(), CA_APP->trackList[rn]);
            }
            while (it != m_trackList.end());
        }
        m_trackList.push_back(CA_APP->trackList[rn]);
        m_trackNumbers.push_back(rn);

	    m_RacePlayer.push_back(std::vector<Player*>());
	    m_StringRacePlayer.push_back(std::vector<std::string>());

        for (int pl=0; pl<CA_RACEMAXPLAYERS; pl++)
        {
            std::vector<std::vector<Player*> >::const_iterator it;
            int rn = 0;
            do
            {
                rn = TrophyMath::getRandomNumber( beginRandom, endRandom );
                it = std::find_if(m_RacePlayer.begin(), m_RacePlayer.end(), std::bind2nd(FindPlayer(), m_Player[rn]));
            }
            while ( it != m_RacePlayer.end() || m_Player[rn] == CA_APP->player[0]);
            m_RacePlayer[race].push_back(m_Player[rn]);
            std::ostringstream oss;
            oss << rn+1 << ") " <<  m_Player[rn]->getName();
            m_StringRacePlayer[race].push_back(oss.str());
        }
        beginRandom -= m_Player.size()/4;
        endRandom -= m_Player.size()/4;
    }
    setOffset( 0 );
}
Example #18
0
CL_Texture HSV::create_texture(CL_GraphicContext &gc)
{
	return CL_Texture(gc, "../../Game/DiceWar/Resources/lobby_background2.png");
}