Beispiel #1
0
void	get_color(t_dot *dot)
{
	int		i;
	int		c[3];

	i = 0;
	if (dot->O_OPC == 18)
	{
		checker_pos(&c, dot);
		if (!((int)c[2] % 2))
		{
			if (!(((int)c[0] + (int)c[1]) % 2))
				apply_color(&dot->px_color, dot->O_COLOR);
			else
				apply_color(&dot->px_color, dot->obj->color2);
		}
		else
		{
			if (!(((int)c[0] + (int)c[1]) % 2))
				apply_color(&dot->px_color, dot->obj->color2);
			else
				apply_color(&dot->px_color, dot->O_COLOR);
		}
	}
	else
		apply_color(&dot->px_color, dot->O_COLOR);
}
Beispiel #2
0
void his_step() {
	chip damka;
	if (HisColor == White) damka = WDamka;
	else damka = BDamka;

	click_x = hishod[3 + 2*hishod_part] - 65;
	click_y = hishod[4 + 2*hishod_part] - 49;
	hishod_part++;

	if (board[click_y][click_x] == None) {
		byte step_status = do_step(click_x, click_y, HisColor);
		if (step_status > 0) {
			apply_select(selected_x, selected_y, 0);
			chip old_chip = board[selected_y][selected_x];
			board[selected_y][selected_x] = None;
			apply_color(selected_x, selected_y);
			board[click_y][click_x] = old_chip;
			if (step_status == 2 && can_eat(click_x, click_y, HisColor)) { // 2 - возможен повторный ход, т.к. предыдущий был рубкой.
				apply_color(click_x, click_y);
				apply_select(click_x, click_y, 1);
				if ((HisColor == White && click_y == 7) || (HisColor == Black && click_y == 0)) futureDamka = 1;
				if (hishod_part < hishod_len) {
					his_step();
				} else {
					debug_print("his_step error4", 15, 6);
					error();
				}
			} else {
				if (futureDamka || (HisColor == White && click_y == 7) || (HisColor == Black && click_y == 0))
					board[click_y][click_x] = damka;
				apply_color(click_x, click_y);
				forbidden_direction = DNone;
				if (hishod_part == hishod_len) {
					if (game_over()) {
						ggs = GGNEW;
					} else {
						if (HisColor == White) ggs = GGStartStepBlack;
						else ggs = GGStartStepWhite;
					}
					Mouse_Clc_Restart();
				} else {
					debug_print("his_step error3", 15, 6);
					error();
				}
			}
		} else {
			debug_print("his_step error2", 15, 6);
			error();
		}
	} else {
		debug_print("his_step error1", 15, 6);
		error();
	}
}
static gboolean apply_manipulation(manipulation man, image_output out) 
{
    gboolean success = TRUE;
    
    if (man->type == MANIP_RESIZE) {
        g_print("Applying RESIZE...\n");
        apply_resize((resize_settings)(bimp_list_get_manip(MANIP_RESIZE))->settings, out);
    }
    else if (man->type == MANIP_CROP) {
        g_print("Applying CROP...\n");
        apply_crop((crop_settings)(bimp_list_get_manip(MANIP_CROP))->settings, out);
    }
    else if (man->type == MANIP_FLIPROTATE) {
        g_print("Applying FLIP OR ROTATE...\n");
        success = apply_fliprotate((fliprotate_settings)(man->settings), out);
    }
    else if (man->type == MANIP_COLOR) {
        g_print("Applying COLOR CORRECTION...\n");
        success = apply_color((color_settings)(man->settings), out);
    }
    else if (man->type == MANIP_SHARPBLUR) {
        g_print("Applying SHARPBLUR...\n");
        success = apply_sharpblur((sharpblur_settings)(man->settings), out);
    }
    else if (man->type == MANIP_USERDEF && strstr(((userdef_settings)(man->settings))->procedure, "-save") == NULL) {
        g_print("Applying %s...\n", ((userdef_settings)(man->settings))->procedure);
        success = apply_userdef((userdef_settings)(man->settings), out);
    }
    
    return success;
}
Beispiel #4
0
void board_init() {
	for (int y=0; y<8; y++) {
		for (int x=0; x<8; x++) {
			if (y==1 || y==2) {
				board[y][x] = White;
				apply_color(x, y);
			} else if (y==5 || y==6) {
				board[y][x] = Black;
				apply_color(x, y);
			} else {
				board[y][x] = None;
				apply_color(x, y);
			}
			apply_select(x, y, 0);
		}
	}
	Mouse_Clc_Restart();
	ggs = GGStartStepWhite;
}
Beispiel #5
0
void apply_color(NodePath* node_path, Color color)
{
    switch(color)
    {
    case RED:
        apply_color(node_path, 1.,0.5,0.5,1.);
        break;
    case GREEN:
        apply_color(node_path, 0.5,1.,0.5,1.);
        break;
    case BLUE:
        apply_color(node_path, 0.5,0.5,1.0,1.);
        break;
    case NO_COLOR:
        node_path->clear_color();
        node_path->clear_color_scale();
        break;

    }
}
Beispiel #6
0
void  render_handler_nui::draw_bitmap(
                                      const gameswf::matrix& m,
                                      const gameswf::bitmap_info* bi,
                                      const gameswf::rect& coords,
                                      const gameswf::rect& uv_coords,
                                      gameswf::rgba color)
                                      // Draw a rectangle textured with the given bitmap, with the
                                      // given color.   Apply given transform; ignore any currently
                                      // set transforms.
                                      //
                                      // Intended for textured glyph rendering.
{
  assert(bi);
  const bitmap_info_nui* pbi = (bitmap_info_nui*)bi;

  apply_color(color);

  gameswf::point a, b, c, d;
  m.transform(&a, gameswf::point(coords.m_x_min, coords.m_y_min));
  m.transform(&b, gameswf::point(coords.m_x_max, coords.m_y_min));
  m.transform(&c, gameswf::point(coords.m_x_min, coords.m_y_max));
  d.m_x = b.m_x + c.m_x - a.m_x;
  d.m_y = b.m_y + c.m_y - a.m_y;

  mpContext->SetFillColor(nuiColor(color.m_r, color.m_g, color.m_b, color.m_a));
  mpContext->SetCurrentTexture(pbi->mpTexture);
  mpContext->EnableTexturing(true);
  nuiRect src(uv_coords.m_x_min, uv_coords.m_y_min, uv_coords.m_x_max, uv_coords.m_y_max, false);
  mpContext->DrawImageQuad(a.m_x, a.m_y, b.m_x, b.m_y, c.m_x, c.m_y, d.m_x, d.m_y, src);
/*
  glBindTexture(GL_TEXTURE_2D, bi->m_texture_id);
  glEnable(GL_TEXTURE_2D);
  glDisable(GL_TEXTURE_GEN_S);
  glDisable(GL_TEXTURE_GEN_T);

  glBegin(GL_TRIANGLE_STRIP);

  glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_min);
  glVertex2f(a.m_x, a.m_y);

  glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_min);
  glVertex2f(b.m_x, b.m_y);

  glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_max);
  glVertex2f(c.m_x, c.m_y);

  glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_max);
  glVertex2f(d.m_x, d.m_y);

  glEnd();
*/
}
Beispiel #7
0
void step(chip color) {
	chip damka;
	if (color == White) damka = WDamka;
	else damka = BDamka;

	if (mc == MCBoard) {
		if (board[click_y][click_x] == None) {
			byte step_status = do_step(click_x, click_y, color);
			if (step_status > 0) {
				write_hod(click_x, click_y);
				apply_select(selected_x, selected_y, 0);
				chip old_chip = board[selected_y][selected_x];
				board[selected_y][selected_x] = None;
				apply_color(selected_x, selected_y);
				board[click_y][click_x] = old_chip;
				if (step_status == 2 && can_eat(click_x, click_y, color)) { // 2 - возможен повторный ход, т.к. предыдущий был рубкой.
					apply_color(click_x, click_y);
					apply_select(click_x, click_y, 1);
					if ((color == White && click_y == 7) || (color == Black && click_y == 0)) futureDamka = 1;
				} else {
					if (futureDamka || (color == White && click_y == 7) || (color == Black && click_y == 0))
						board[click_y][click_x] = damka;
					apply_color(click_x, click_y);
					formalize_hod();
					debug_print(myhod, 3 + 2*myhod_len, Dmy);
					send_str(myhod, 3 + 2*myhod_len);
					forbidden_direction = DNone;
					if (game_over()) {
						ggs = GGNEW;
					} else {
						if (color == White) ggs = GGStartStepBlack;
						else ggs = GGStartStepWhite;
					}
				}
			}
		}
	}
}
	void	draw_bitmap(
		const gameswf::matrix& m,
		gameswf::bitmap_info* bi,
		const gameswf::rect& coords,
		const gameswf::rect& uv_coords,
		gameswf::rgba color)
	// Draw a rectangle textured with the given bitmap, with the
	// given color.	 Apply given transform; ignore any currently
	// set transforms.
	//
	// Intended for textured glyph rendering.
	{
		assert(bi);

		apply_color(color);

		gameswf::point a, b, c, d;
		m.transform(&a, gameswf::point(coords.m_x_min, coords.m_y_min));
		m.transform(&b, gameswf::point(coords.m_x_max, coords.m_y_min));
		m.transform(&c, gameswf::point(coords.m_x_min, coords.m_y_max));
		d.m_x = b.m_x + c.m_x - a.m_x;
		d.m_y = b.m_y + c.m_y - a.m_y;

		bi->layout();
//		glBindTexture(GL_TEXTURE_2D, bi->m_texture_id);
//		glEnable(GL_TEXTURE_2D);

		glDisable(GL_TEXTURE_GEN_S);
		glDisable(GL_TEXTURE_GEN_T);

		glBegin(GL_TRIANGLE_STRIP);

		glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_min);
		glVertex2f(a.m_x, a.m_y);

		glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_min);
		glVertex2f(b.m_x, b.m_y);

		glTexCoord2f(uv_coords.m_x_min, uv_coords.m_y_max);
		glVertex2f(c.m_x, c.m_y);

		glTexCoord2f(uv_coords.m_x_max, uv_coords.m_y_max);
		glVertex2f(d.m_x, d.m_y);

		glEnd();
	}
Beispiel #9
0
int		color(t_bunny_pixelarray **pix,
		      const int color)
{
  int		x;
  int		y;
  int		pos;

  y = 0;
  while (y < (*pix)->clipable.clip_height)
    {
      x = 0;
      while (x < (*pix)->clipable.clip_width)
	{
	  pos = x + y * (*pix)->clipable.clip_width;
	  apply_color(*pix, (unsigned int)color, pos, 0.2);
	  ++x;
	}
      ++y;
    }
  return (0);
}
	void	draw_bitmap(
		const gameswf::matrix& m,
		gameswf::bitmap_info* bi,
		const gameswf::rect& coords,
		const gameswf::rect& uv_coords,
		gameswf::rgba color)
	// Draw a rectangle textured with the given bitmap, with the
	// given color.	 Apply given transform; ignore any currently
	// set transforms.
	//
	// Intended for textured glyph rendering.
	{
		assert(bi);
		bi->layout();

		apply_color(color);

		gameswf::point a, b, c, d;
		m.transform(&a, gameswf::point(coords.m_x_min, coords.m_y_min));
		m.transform(&b, gameswf::point(coords.m_x_max, coords.m_y_min));
		m.transform(&c, gameswf::point(coords.m_x_min, coords.m_y_max));
		d.m_x = b.m_x + c.m_x - a.m_x;
		d.m_y = b.m_y + c.m_y - a.m_y;

		GLfloat squareVertices[8];
		squareVertices[0] = a.m_x;
		squareVertices[1] = a.m_y;
		squareVertices[2] = b.m_x;
		squareVertices[3] = b.m_y;
		squareVertices[4] = c.m_x;
		squareVertices[5] = c.m_y;
		squareVertices[6] = d.m_x;
		squareVertices[7] = d.m_y;
	
		GLfloat squareTextureCoords[8];
		squareTextureCoords[0] = uv_coords.m_x_min;
		squareTextureCoords[1] = uv_coords.m_y_min;
		squareTextureCoords[2] = uv_coords.m_x_max;
		squareTextureCoords[3] = uv_coords.m_y_min;
		squareTextureCoords[4] = uv_coords.m_x_min;
		squareTextureCoords[5] = uv_coords.m_y_max;
		squareTextureCoords[6] = uv_coords.m_x_max;
		squareTextureCoords[7] = uv_coords.m_y_max;

		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, 0, squareTextureCoords);

		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(2, GL_FLOAT, 0, squareVertices);

		glEnable(GL_LINE_SMOOTH);
		glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

		glDisable(GL_LINE_SMOOTH);

		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);

		glDisable(GL_TEXTURE_2D);
	}
Beispiel #11
0
void  render_handler_nui::fill_style::apply(/*const matrix& current_matrix*/) const
// Push our style into OpenGL.
{
  assert(m_mode != INVALID);

  if (m_mode == COLOR)
  {
    apply_color(m_color);
    glDisable(GL_TEXTURE_2D);
  }
  else if (m_mode == BITMAP_WRAP
    || m_mode == BITMAP_CLAMP)
  {
    assert(m_bitmap_info != NULL);

    apply_color(m_color);

    if (m_bitmap_info == NULL)
    {
      glDisable(GL_TEXTURE_2D);
    }
    else
    {
      // Set up the texture for rendering.

      {
        // Do the modulate part of the color
        // transform in the first pass.  The
        // additive part, if any, needs to
        // happen in a second pass.
        glColor4f(m_bitmap_color_transform.m_[0][0],
          m_bitmap_color_transform.m_[1][0],
          m_bitmap_color_transform.m_[2][0],
          m_bitmap_color_transform.m_[3][0]
          );
      }

      glBindTexture(GL_TEXTURE_2D, m_bitmap_info->m_texture_id);
      glEnable(GL_TEXTURE_2D);
      glEnable(GL_TEXTURE_GEN_S);
      glEnable(GL_TEXTURE_GEN_T);

      if (m_mode == BITMAP_CLAMP)
      {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      }
      else
      {
        assert(m_mode == BITMAP_WRAP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      }

      // Set up the bitmap matrix for texgen.

      float  inv_width = 1.0f / m_bitmap_info->m_original_width;
      float  inv_height = 1.0f / m_bitmap_info->m_original_height;

      const gameswf::matrix&  m = m_bitmap_matrix;
      glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
      float  p[4] = { 0, 0, 0, 0 };
      p[0] = m.m_[0][0] * inv_width;
      p[1] = m.m_[0][1] * inv_width;
      p[3] = m.m_[0][2] * inv_width;
      glTexGenfv(GL_S, GL_OBJECT_PLANE, p);

      glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
      p[0] = m.m_[1][0] * inv_height;
      p[1] = m.m_[1][1] * inv_height;
      p[3] = m.m_[1][2] * inv_height;
      glTexGenfv(GL_T, GL_OBJECT_PLANE, p);
    }
  }
}
	void	begin_display(
		gameswf::rgba background_color,
		int viewport_x0, int viewport_y0,
		int viewport_width, int viewport_height,
		float x0, float x1, float y0, float y1)
	// Set up to render a full frame from a movie and fills the
	// background.	Sets up necessary transforms, to scale the
	// movie to fit within the given dimensions.  Call
	// end_display() when you're done.
	//
	// The rectangle (viewport_x0, viewport_y0, viewport_x0 +
	// viewport_width, viewport_y0 + viewport_height) defines the
	// window coordinates taken up by the movie.
	//
	// The rectangle (x0, y0, x1, y1) defines the pixel
	// coordinates of the movie that correspond to the viewport
	// bounds.
	{
		m_display_width = fabsf(x1 - x0);
		m_display_height = fabsf(y1 - y0);

		glViewport(viewport_x0, viewport_y0, viewport_width, viewport_height);

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glOrtho(x0, x1, y0, y1, -1, 1);

		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	// GL_MODULATE

		glDisable(GL_TEXTURE_2D);

		// Clear the background, if background color has alpha > 0.
		if (background_color.m_a > 0)
		{
			// Draw a big quad.
			apply_color(background_color);
			glBegin(GL_QUADS);
			glVertex2f(x0, y0);
			glVertex2f(x1, y0);
			glVertex2f(x1, y1);
			glVertex2f(x0, y1);
			glEnd();
		}

		// Old unused code.  Might get revived someday.
		#if 0
				// See if we want to, and can, use multitexture
				// antialiasing.
				s_multitexture_antialias = false;
				if (m_enable_antialias)
				{
					int	tex_units = 0;
					glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &tex_units);
					if (tex_units >= 2)
					{
						s_multitexture_antialias = true;
					}

					// Make sure we have an edge texture available.
					if (s_multitexture_antialias == true
						&& s_edge_texture_id == 0)
					{
						// Very simple texture: 2 texels wide, 1 texel high.
						// Both texels are white; left texel is all clear, right texel is all opaque.
						unsigned char	edge_data[8] = { 255, 255, 255, 0, 255, 255, 255, 255 };

						ogl::active_texture(GL_TEXTURE1_ARB);
						glEnable(GL_TEXTURE_2D);
						glGenTextures(1, &s_edge_texture_id);
						glBindTexture(GL_TEXTURE_2D, s_edge_texture_id);

						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

						glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, edge_data);

						glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	// @@ should we use a 1D texture???

						glDisable(GL_TEXTURE_2D);
						ogl::active_texture(GL_TEXTURE0_ARB);
						glDisable(GL_TEXTURE_2D);
					}
				}
		#endif // 0
	}
Beispiel #13
0
byte damka_do_eat(byte x, byte y, chip color) {
	chip usual, damka; // Цвета противника
	if (color == White) {
		usual = Black;
		damka = BDamka;
	} else {
		usual = White;
		damka = WDamka;
	}
	byte xi, yi;
	byte enemy_x, enemy_y;
	byte enemy_count;

	if (y > selected_y && x == selected_x && forbidden_direction != DUp) {
		yi = selected_y + 1;
		enemy_count = 0;
		while (y > yi) {
			byte cell = board[yi][x];
			if (cell == None) {
				yi++; continue;
			}
			if ((cell == usual || cell == damka) && enemy_count == 0) {
				enemy_count = 1;
				enemy_x = x; enemy_y = yi;
				yi++; continue;
			}
			break;
		}
		if (yi == y && enemy_count == 1) {
			forbidden_direction = DDown;
			board[enemy_y][enemy_x] = None;
			apply_color(enemy_x, enemy_y);
			return 1;
		}
		return 0;
	}

	if (y < selected_y && x == selected_x && forbidden_direction != DDown) {
		yi = selected_y - 1;
		enemy_count = 0;
		while (y < yi) {
			byte cell = board[yi][x];
			if (cell == None) {
				yi--; continue;
			}
			if ((cell == usual || cell == damka) && enemy_count == 0) {
				enemy_count = 1;
				enemy_x = x; enemy_y = yi;
				yi--; continue;
			}
			break;
		}
		if (yi == y && enemy_count == 1) {
			forbidden_direction = DUp;
			board[enemy_y][enemy_x] = None;
			apply_color(enemy_x, enemy_y);
			return 1;
		}
		return 0;
	}

	if (x > selected_x && y == selected_y && forbidden_direction != DRight) {
		xi = selected_x + 1;
		enemy_count = 0;
		while (x > xi) {
			byte cell = board[y][xi];
			if (cell == None) {
				xi++; continue;
			}
			if ((cell == usual || cell == damka) && enemy_count == 0) {
				enemy_count = 1;
				enemy_x = xi; enemy_y = y;
				xi++; continue;
			}
			break;
		}
		if (xi == x && enemy_count == 1) {
			forbidden_direction = DLeft;
			board[enemy_y][enemy_x] = None;
			apply_color(enemy_x, enemy_y);
			return 1;
		}
		return 0;
	}

	if (x < selected_x && y == selected_y && forbidden_direction != DLeft) {
		xi = selected_x - 1;
		enemy_count = 0;
		while (x < xi) {
			byte cell = board[y][xi];
			if (cell == None) {
				xi--; continue;
			}
			if ((cell == usual || cell == damka) && enemy_count == 0) {
				enemy_count = 1;
				enemy_x = xi; enemy_y = y;
				xi--; continue;
			}
			break;
		}
		if (xi == x && enemy_count == 1) {
			forbidden_direction = DRight;
			board[enemy_y][enemy_x] = None;
			apply_color(enemy_x, enemy_y);
			return 1;
		}
		return 0;
	}

	return 0;
}
Beispiel #14
0
void usual_eat(byte x, byte y) {
	board[y][x] = None;
	apply_color(x, y);
	forbidden_direction = DNone;
}