예제 #1
0
	void d3d9_prim2d_lines::render_segments(const vec2* points, unsigned int point_count, const color& color) {
		ASSERT(_is_rendering);

		if (point_count > 1) {
			static_assert(sizeof(solar::vec2) == sizeof(D3DXVECTOR2), "solar::vec2 cannot be casted to D3DXVECTOR2");
			auto d3dx_points = reinterpret_cast<const D3DXVECTOR2*>(points);

			if (_viewport.X != 0 || _viewport.Y != 0) {
				//NOTE: ID3DXLine will internally transform all the points by the viewport's top left position. This causes problems because
				//all clients expect the points to be in screen space, not in the current viewport space.
				D3DMATRIX old_projection;
				D3D9_VERIFY(_context.get_device()->GetTransform(D3DTS_PROJECTION, &old_projection));
				D3DXMATRIX new_projection;
				::D3DXMatrixTranslation(&new_projection, -uint_to_float(_viewport.X), -uint_to_float(_viewport.Y), 0.f);
				new_projection *= old_projection;
				D3D9_VERIFY(_context.get_device()->SetTransform(D3DTS_PROJECTION, &new_projection));
				D3D9_VERIFY(_d3dx_line->Draw(d3dx_points, point_count, color.to_argb32()));
				D3D9_VERIFY(_context.get_device()->SetTransform(D3DTS_PROJECTION, &old_projection));
			}
			else {
				D3D9_VERIFY(_d3dx_line->Draw(d3dx_points, point_count, color.to_argb32()));
			}
		}
	}
예제 #2
0
	void binary_archive_writer::write_color(const color& value) {
		write_atomic_value<uint32_t>(value.to_argb32());
	}