Example #1
0
	GLvoid CMenuButton::draw()
	{	
		if (over)
		{
			push_state();
			GLfloat old_w = extent.width;
			GLfloat old_h = extent.height;
			scale(1.012f,1.12f);
			translate(-(extent.width-old_w)/2.0f,-(extent.height-old_h)/2.0f,0.0f);

			glPushMatrix();	
			set_color(red,0.0f,0.0f);
			red+=red_speed;
			if (red>1.0f || red<0.0f)
			{
				red_speed=-red_speed;
			}
			over=false;

			set_texture(effect_texture);
			CTexturedGUIButton::draw();
			glPopMatrix();

			pop_state();	
		}
		else
		{
			red=0.0f;
		}		

		set_color(1.0f,1.0f,1.0f);
		set_texture(normal_texture);
		CTexturedGUIButton::draw();
		set_caption_color(1.0f,0.0f,0.0f);
	}
Example #2
0
void		create_textures(t_env *e)
{
	set_texture(e, &(e->t[0]), "img/brick.xpm");
	set_texture(e, &(e->t[1]), "img/crate.xpm");
	set_texture(e, &(e->t[2]), "img/door.xpm");
	set_texture(e, &(e->t[3]), "img/grass.xpm");
	set_texture(e, &(e->t[4]), "img/wall.xpm");
}
Example #3
0
void UggWrongWay::SetTexture(void)
{
	if (isMoving)
	{		
		int rnd = rand() % 3;
		if ((MoveDirection == DIR_LEFTUP) || (MoveDirection == DIR_RIGHTDOWN))
		{
			if (rnd == 0)
				set_texture(0, &this->TexLeftJump1);
			else if (rnd == 1)
				set_texture(0, &this->TexLeftJump2);
			else
				set_texture(0, &this->TexLeftJump3);
		}
		else if ((MoveDirection == DIR_RIGHTUP) || (MoveDirection == DIR_LEFTDOWN))
		{
			if (rnd == 0)
				set_texture(0, &this->TexRightJump1);
			else if (rnd == 1)
				set_texture(0, &this->TexRightJump2);
			else
				set_texture(0, &this->TexRightJump3);
		}	
	}
	else
	{
		if ((MoveDirection == DIR_LEFTUP) || (MoveDirection == DIR_RIGHTDOWN))
			set_texture(0, &this->TexLeft);
		else if ((MoveDirection == DIR_RIGHTUP) || (MoveDirection == DIR_LEFTDOWN))
			set_texture(0, &this->TexRight);
	}
	return;
}
Example #4
0
void dialog_label::recalculate_texture()
{
	label::recalculate_texture();
	stages_ = current_text().size();
	int prog = progress_;
	if(prog < 0) prog = 0;
	if(prog > stages_) prog = stages_;
	std::string txt = current_text().substr(0, prog);

	if(prog > 0) {
		set_texture(font::render_text(txt, color(), size(), font()));
	} else {
		set_texture(graphics::texture());
	}
}
	void set_spriterator()
	{
		
		set_texture();		
		set_sprite_texture();
		
	}
bool RendCurve::render(unsigned long time) {
	if(!curve) return false;
	
	set_matrix(XFORM_WORLD, get_prs(time).get_xform_matrix());
	mat.set_glmaterial();

	if(mat.tex[TEXTYPE_DIFFUSE]) {
		set_texture(0, mat.tex[TEXTYPE_DIFFUSE]);
		enable_texture_unit(0);
		set_texture_coord_index(0, 0);
		set_texture_unit_color(0, TOP_MODULATE, TARG_TEXTURE, TARG_PREV);
		set_texture_unit_alpha(0, TOP_MODULATE, TARG_TEXTURE, TARG_PREV);
	}

	set_alpha_blending(true);
	set_zwrite(false);
	set_blend_func(src_blend, dst_blend);

	int line_count = curve->get_segment_count() * detail;
	scalar_t dx = 1.0 / (scalar_t)line_count;
	scalar_t t = dx;
	Vector3 prev_pos = (*curve)(0.0);
	for(int i=1; i<line_count; i++) {
		Vector3 pos = (*curve)(t);
		draw_line(Vertex(prev_pos, 0.0), Vertex(pos, 1.0), width, width);
		prev_pos = pos;
		t += dx;
	}
	
	set_alpha_blending(false);
	set_zwrite(true);
	disable_texture_unit(0);

	return true;
}
Example #7
0
	GLvoid CItemButton::on_mouse_over()
	{
		if (button_state>=BS_AVAILABLE_NOT_USED)
		{
			shape->set_z(1.0f);
			set_texture(mouse_over_texture);
		}
	}
void BasicEnemy::draw(I_GraphicsHandler& graphics) {
    if (texture_ == NULL) {
        printf("BasicEnemy graphics were null! Setting BasicEnemy graphic...\n");
        set_texture(graphics.load_image("assets/ships/BasicEnemy.png"));
    }

    graphics.draw(texture_, (int)x_pos(), (int)y_pos(), GraphicPriority::MIDDLE);
}
Example #9
0
void Panel::Parse_UIScript(std::istream &is, std::string &line) {
	if (line == "#create_end") {
		set_texture(tex_path, size.x, height);
	} else if (line == "Texture:") {
		Tim::String::get_line(is, tex_path, true, true);
		size.x=1.0f;height=0.0f;
	}else if(line == "Width:"){
		is >> size.x;
	}else if(line == "Height:"){
	target(const sf::Vector2f& position)
		: m_texture(), m_sprite()
	{
		
		set_texture();		
		set_sprite_texture();		
		set_origin();		
		set_position(position);		
		set_color();
		
	}
Example #11
0
	GLvoid CItemButton::on_mouse_down()
	{
		set_texture(mouse_down_texture);		

		if (!first_down)
		{
			push_state(&top_texture_extent);			
			scale(0.9f,0.9f,&top_texture_extent);
			first_down=true;
		}
	}
Example #12
0
	GLvoid CItemButton::on_mouse_out()
	{
		shape->set_z(0.0f);
		set_texture(normal_texture);

		if (first_down)
		{
			pop_state(&top_texture_extent);
			first_down=false;
		}
	}
Example #13
0
void resize(int w, int h)
{
	width = w;
	height = h;
 
	glViewport(0, 0, w, h);
	glLoadIdentity();
	glOrtho(0, w, 0, h, -1, 1);
 
	set_texture();
}
	gravitor(const float strength, const sf::Vector2f& position)
		: m_strength(strength), m_texture(), m_sprite()
	{
		
		set_texture();		
		set_sprite_texture();		
		set_origin();		
		set_position(position);		
		set_color();
		
	}
Example #15
0
void idle()
{
	scale *= 0.75;

	if (scale < 1e-14) {
		glFinish();
		glutDestroyWindow(gwin);
		return;
	}

	set_texture();
}
Example #16
0
void scene::set_location(const char *name)
{
    nya_render::texture::set_default_aniso(2);

    if (!m_curve.is_valid())
    {
        m_curve.create();
        load("postprocess.txt");
        set_texture("color_curve", m_curve);
        set_shader_param("screen_radius", nya_math::vec4(1.185185, 0.5 * 4.0 / 3.0, 0.0, 0.0));
        set_shader_param("damage_frame", nya_math::vec4(0.35, 0.5, 1.0, 0.1));
        m_flare.init(get_texture("main_color"), get_texture("main_depth"));
        m_cockpit_black.load("shaders/cockpit_black.nsh");
        m_cockpit_black_quad.init();
        m_missile_trails_renderer.init();
        m_particles_render.init();
    }

    if (is_native_location(name))
    {
        auto &zip = get_native_location_provider(name);
        auto tex = load_texture(zip, "tonecurve.tga");
        if (tex.get_width() > 0)
        {
            auto rtex = tex.internal().get_shared_data()->tex;
            rtex.set_wrap(nya_render::texture::wrap_clamp, nya_render::texture::wrap_clamp);
            m_curve.set(tex);
        }
        else
            m_curve.set(load_tonecurve("Map/tonecurve_default.tcb"));
    }
    else
    {
        if (m_location_name == "def" || m_location_name.empty())
            m_curve.set(load_tonecurve("Map/tonecurve_default.tcb"));
        else
            m_curve.set(load_tonecurve(("Map/tonecurve_" + m_location_name + ".tcb").c_str()));
    }

    world::set_location(name);

    for (auto &a: m_aircrafts)
        a->apply_location(m_location_name.c_str(), m_location.get_params());

    m_flare.apply_location(m_location.get_params());

    auto &p = m_location.get_params();
    set_shader_param("bloom_param", nya_math::vec4(p.hdr.bloom_threshold, p.hdr.bloom_offset, p.hdr.bloom_scale, 1.0));
    set_shader_param("saturation", nya_math::vec4(p.tone_saturation * 0.01, 0.0, 0.0, 0.0));
    m_luminance_speed = p.hdr.luminance_speed;
    m_fade_time = m_fade_max_time = 2000;
}
/**
 * @brief 読み込み簡略化関数
 * @param *obj : 対象のテクスチャ構造体ポインタ
 * @param filename : 対象の画像名
 * @param width : 横サイズ
 * @param height : 縦サイズ
 */
void runLoadTexture(texture_t * obj, char * filename, int width, int height)
{
  // 画像サイズの定義
  obj->imageWidth = width;
  obj->imageHeight = height;

  // テクスチャ画像用配列の確保(幅、高さ、RGBの3)(幅、高さ、RGBの3)
  obj->texture_Image = (GLubyte *)malloc(sizeof(GLubyte)* obj->imageWidth * obj->imageHeight * 3);
  // ファイルのロード
  LoadPPM_ascii(filename, obj->texture_Image, obj->imageWidth, obj->imageHeight);
  // ファイルをセットする
  set_texture(obj->texture_Image, &obj->texture_id, obj->imageWidth, obj->imageHeight);
}
Example #18
0
static void
free_screen_background (MetaScreenBackground *background)
{
  set_texture (background, COGL_INVALID_HANDLE);

  if (background->screen != NULL)
    {
      ClutterActor *stage = meta_get_stage_for_screen (background->screen);
      g_signal_handlers_disconnect_by_func (stage,
                                            (gpointer) on_notify_stage_color,
                                            background);
      background->screen = NULL;
    }
}
Example #19
0
	GLvoid CDKRoomInfoTexture::draw()
	{
		CGUIBackground::draw();

		if (blink)
		{
			blink_pos+=blink_speed*CV_GAME_MANAGER->getDeltaTime();
			if (blink_pos>=blink_time_out)
			{
				set_texture(textures[(GLint)(sel_tex=!sel_tex)]);
				blink_pos=0.0f;
			}
		}
	}
Example #20
0
void sfml2_renderer::draw(const rect& box, const texture& fill)
{
    auto& sftext = dynamic_cast<const sfml2_texture&>(*fill);
    set_primitive_type(sf::Triangles);
    set_texture(sftext.sf_texture());

    add_vertex(box.top_left(), sf::Vector2f{0, 0});
    add_vertex(box.top_right(), sf::Vector2f{1, 0});
    add_vertex(box.bottom_right(), sf::Vector2f{1, 1});

    add_vertex(box.top_left(), sf::Vector2f{0, 0});
    add_vertex(box.bottom_right(), sf::Vector2f{1, 1});
    add_vertex(box.bottom_left(), sf::Vector2f{0, 1});
}
Example #21
0
	GLvoid CDKRoomInfoTexture::set_selected(char *class_name, char leading)
	{
		char *info_texture_class_name=strdup(class_name);
		info_texture_class_name[0]=leading;
		info_texture_class_name[1]='E';
		textures[0]=texture_list->get_texture_by_name(info_texture_class_name);
		info_texture_class_name[1]='D';
		textures[1]=texture_list->get_texture_by_name(info_texture_class_name);
		delete info_texture_class_name;
		set_ready(true);

		blink=true;
		set_texture(textures[0]);		
	}	
Example #22
0
void init_gfx(int *c, char **v)
{
	glutInit(c, v);
	glutInitDisplayMode(GLUT_RGB);
	glutInitWindowSize(1024, 1024);
	glutDisplayFunc(render);
 
	gwin = glutCreateWindow("Mandelbrot");
 
	glutReshapeFunc(resize);
	glutIdleFunc(idle);
	glGenTextures(1, &texture);
	set_texture();
}
Example #23
0
void init(void){
  glClearColor(0.2,0.2,0.2,0.2);
  glGenTextures(3,TextureHandle);

  for (int i =0; i<3; i++){
    glBindTexture(GL_TEXTURE_2D, TextureHandle[i]);

    glPixelStorei(GL_UNPACK_ALIGNMENT,1);
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,TEXWIDTH,TEXHEIGHT,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

  }

  set_texture();
}
/** Inform Leafy of the number of fires. 
 For each config::leafy_mood_change_rate increment of fires, the
 mood of Leafy changes.
 @param number_of_fires 
 
 TODO: change to receive the vector of fires and make mood
 a function of the distance from fires.
 */
void Leafy::inform_fires_and_set_mood(const unsigned number_of_fires)
{
    Leafymood mood = static_cast<Leafymood>(number_of_fires / config::leafy_mood_change_rate);
    if (mood>skeleton) mood = skeleton;
    if(mood!=_mood)
    try {
        _mood = mood;
        set_texture(leafy_mood_filenames.at(mood));
    }
    catch(std::out_of_range &e)
    {
        /* The flow reaches this point if mood is greater than skeleton.
        */
        cocos2d::log("Leafy::inform_fires_and_set_mood(): %s", e.what());
    }
}
void init(int c, char **v) {
	mVar = malloc(sizeof(mainVar));
	mVar->zoomM = 1./128;
	mVar->zoomJ = 1./128;
	mVar->zoomF = 1./128;
	mVar->c = 0 + 0*I;
	mVar->z1 = 0 + 0*I;
	mVar->centerC = 0 + 0*I;
	mVar->function = MANDEL_AND_JULIA;
	mVar->color_rotate = 0;
	mVar->color_scheme = 0;
	mVar->max_iter = 128;

	mVar->tex = NULL;
	mVar->texIter = NULL;

	mVar->oldHeight = 0;
	mVar->oldWidth = 0;
	mVar->height = 400;
	mVar->width = 200;
	mVar->tex_h = 1;
	mVar->tex_w = 1;

	mVar->png_w = 1920;
	mVar->png_h = 1080;
	mVar->imgCount = 0;

	switch (c) {
		case 4: mVar->imgCount = atoi(v[3]);
		case 3: mVar->png_h = atoi(v[2]);
		case 2:	mVar->png_w = atoi(v[1]);
	}

	glutInit(&c, v);
	glutInitDisplayMode(GLUT_RGB);
	glutInitWindowSize(mVar->width, mVar->height);
	glutDisplayFunc(render);
 
	mVar->gwin = glutCreateWindow("Mandelbrot");
 
	glutKeyboardFunc(keypress);
	glutMouseFunc(mouseclick);
	glutReshapeFunc(resize);
	glGenTextures(1, &mVar->texture);

	set_texture();
}
Example #26
0
ui::menu::menu()
{
    set_position(window::center.x,window::center.y);
    fill_color=default_fillcolor;
    border_color=default_bordercolor;
    set_texture(default_texture);
    set_mask(default_mask);
    set_title("menu");
    title.set_font("helvetica",18);
    subtitle.set_font("helvetica",12);
    subtitle.hide();
    layout=default_layout;
    spacing=default_spacing;
    margin=default_margin;
    bordered=true;
    std::clog<<"object#"<<number<<"(menu)"<<" created.\n";
}
Example #27
0
/* Sets our material to paint with a 1x1 texture of the stage's background
 * color; doing this when we have no pixmap allows the application to turn
 * off painting the stage. There might be a performance benefit to
 * painting in this case with a solid color, but the normal solid color
 * case is a 1x1 root pixmap, so we'd have to reverse-engineer that to
 * actually pick up the (small?) performance win. This is just a fallback.
 */
static void
set_texture_to_stage_color (MetaScreenBackground *background)
{
  ClutterActor *stage = meta_get_stage_for_screen (background->screen);
  ClutterColor color;
  CoglHandle texture;

  clutter_stage_get_color (CLUTTER_STAGE (stage), &color);

  /* Slicing will prevent COGL from using hardware texturing for
   * the tiled 1x1 pixmap, and will cause it to draw the window
   * background in millions of separate 1x1 rectangles */
  texture = meta_create_color_texture_4ub (color.red, color.green,
                                           color.blue, 0xff,
                                           COGL_TEXTURE_NO_SLICING);
  set_texture (background, texture);
  cogl_handle_unref (texture);
}
Example #28
0
int main()
{
    auto engine = std::make_unique<yae::sdl_engine>();
    auto window = engine->create_simple_window();
    auto cv = yae::clipping_volume{ -8.0f, 8.0f, -6.0f, 6.0f, 1.0f, -1.0f };
    window->close_when_keydown();

    auto rwop = SDL_RWFromFile("smiley.png", "rb");
    auto hero_image = IMG_LoadPNG_RW(rwop);
    auto pixels = (GLubyte*)hero_image->pixels;
    auto width = hero_image->w;
    auto height = hero_image->h;
    auto hero_texture = std::make_shared<yae::texture>(pixels, width, height);

    yae::buffer_object_builder<float> b({ -50.0f, -50.0f, 50.0f, -50.0f, 50.0f, 50.0f, -50.0f, 50.0f });
    auto multi_hero = std::make_shared<yae::geometry<float>>(b.get_size() / 2, 2, GL_QUADS);
    multi_hero->set_vertex_positions(b.build());
    multi_hero->set_vertex_tex_coords(b.build());
    auto node = std::make_shared<yae::geometry_node<float>>(multi_hero);
    auto root = std::make_shared<yae::group>();
    root->add(node);
    auto prog = yae::texture_program::create();
    prog->set_texture(hero_texture);

    auto scene = std::make_shared<yae::rendering_scene>();
    auto cam = std::make_shared<yae::parallel_camera>(cv);
    auto bg_color = yae::color4f{ 0.0f, 0.0f, 0.0f, 0.0f };
    auto clear_viewport_cb = yae::clear_viewport_callback(bg_color, scene->get_viewport());
    auto cre = std::make_shared<yae::custom_rendering_element>("clear_viewport", clear_viewport_cb);
    auto nre = std::make_shared<yae::node_rendering_element>("smiley_canvas", root, prog, cam);
    scene->add_element(cre);
    scene->add_element(nre);
    scene->associate_camera<yae::rendering_scene::fit_all_adapter>(cam, window.get(), yae::viewport_relative{ 0.0f, 0.0f, 1.0f, 1.0f });

    window->set_render_callback([&](yae::rendering_context& ctx) {
        cam->rotate_z(0.5);
    });

    window->add_scene(scene);

    engine->run(window.get());

    return 0;
}
void mouseclick(int button, int state, int x, int y) {
	if(state != GLUT_UP) 
		return; 

	if (mVar->function == MANDEL_AND_JULIA) {
		if(y < mVar->height/2){ //Mandelbrot is clicked
			mVar->c += (x - mVar->width/2.) * mVar->zoomM - I*(y - mVar->height/4.) * mVar->zoomM;
			printf("c = %f + %fi\n", creal(mVar->c), cimag(mVar->c));
		}
		else{ // Julia Set was clicked
			mVar->z1 += (x - mVar->width/2.) * mVar->zoomJ - I*(y - 3*mVar->height/4.) * mVar->zoomJ;
			printf("z1 = %f + %fi\n", creal(mVar->z1), cimag(mVar->z1));
		}
	} else {
		mVar->centerC += (x - mVar->width/2.) * mVar->zoomM - I*(y - mVar->height/2.) * mVar->zoomM;
		printf("c = %f + %fi\n", creal(mVar->centerC), cimag(mVar->centerC));
	}

	set_texture();
}
Example #30
0
void UggWrongWay::InitGraphics(const char *TexName)
{
	D3DXMATRIX pos;
	D3DXMATRIX rota;
	D3DXMATRIX trans;
	CurNode.RelCube->get_transform(&pos);
	D3DXMatrixRotationY(&rota, -D3DX_PI/2.0f);
	D3DXMatrixTranslation(&trans, 0, 5.0f, 0);
	load("TriPrism.x", "myQBert/Models");
	std::stringstream ss;
	ss <<"myQBert/Textures/" <<TexName <<"-Left.png";
	TexLeft.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Left-Jump-1.png";
	TexLeftJump1.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Left-Jump-2.png";
	TexLeftJump2.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Left-Jump-3.png";
	TexLeftJump3.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Right.png";
	TexRight.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Right-Jump-1.png";
	TexRightJump1.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Right-Jump-2.png";
	TexRightJump2.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	ss <<"myQBert/Textures/" <<TexName <<"-Right-Jump-3.png";
	TexRightJump3.load((char*)ss.str().c_str());
	ss.str(std::string()); ss.clear();
	set_texture(0, &TexLeft);
	disable_reflections();
	add_transform(&rota);
	add_transform(&pos);
	add_transform(&trans);
	return;
}