about summary refs log tree commit diff
path: root/src/game/client/components/maplayers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/components/maplayers.cpp')
-rw-r--r--src/game/client/components/maplayers.cpp56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp
index 847350e6..75f91521 100644
--- a/src/game/client/components/maplayers.cpp
+++ b/src/game/client/components/maplayers.cpp
@@ -1,3 +1,5 @@
+#include <engine/client/graphics.h>
+
 #include <game/layers.hpp>
 #include <game/client/gameclient.hpp>
 #include <game/client/component.hpp>
@@ -6,6 +8,7 @@
 #include <game/client/components/camera.hpp>
 #include <game/client/components/mapimages.hpp>
 
+
 #include "maplayers.hpp"
 
 MAPLAYERS::MAPLAYERS(int t)
@@ -14,16 +17,17 @@ MAPLAYERS::MAPLAYERS(int t)
 }
 
 
-static void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group)
+void MAPLAYERS::mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group)
 {
 	float points[4];
-	mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f,
-		group->offset_x, group->offset_y, gfx_screenaspect(), 1.0f, points);
-	gfx_mapscreen(points[0], points[1], points[2], points[3]);
+	RenderTools()->mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f,
+		group->offset_x, group->offset_y, Graphics()->ScreenAspect(), 1.0f, points);
+	Graphics()->MapScreen(points[0], points[1], points[2], points[3]);
 }
 
-static void envelope_eval(float time_offset, int env, float *channels)
+void MAPLAYERS::envelope_eval(float time_offset, int env, float *channels, void *user)
 {
+	MAPLAYERS *pThis = (MAPLAYERS *)user;
 	channels[0] = 0;
 	channels[1] = 0;
 	channels[2] = 0;
@@ -45,7 +49,7 @@ static void envelope_eval(float time_offset, int env, float *channels)
 		return;
 	
 	MAPITEM_ENVELOPE *item = (MAPITEM_ENVELOPE *)map_get_item(start+env, 0, 0);
-	render_eval_envelope(points+item->start_point, item->num_points, 4, client_localtime()+time_offset, channels);
+	pThis->RenderTools()->render_eval_envelope(points+item->start_point, item->num_points, 4, client_localtime()+time_offset, channels);
 }
 
 void MAPLAYERS::on_render()
@@ -53,8 +57,8 @@ void MAPLAYERS::on_render()
 	if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK)
 		return;
 	
-	RECT screen;
-	gfx_getscreen(&screen.x, &screen.y, &screen.w, &screen.h);
+	CUIRect screen;
+	Graphics()->GetScreen(&screen.x, &screen.y, &screen.w, &screen.h);
 	
 	vec2 center = gameclient.camera->center;
 	//float center_x = gameclient.camera->center.x;
@@ -71,14 +75,14 @@ void MAPLAYERS::on_render()
 			// set clipping
 			float points[4];
 			mapscreen_to_group(center.x, center.y, layers_game_group());
-			gfx_getscreen(&points[0], &points[1], &points[2], &points[3]);
+			Graphics()->GetScreen(&points[0], &points[1], &points[2], &points[3]);
 			float x0 = (group->clip_x - points[0]) / (points[2]-points[0]);
 			float y0 = (group->clip_y - points[1]) / (points[3]-points[1]);
 			float x1 = ((group->clip_x+group->clip_w) - points[0]) / (points[2]-points[0]);
 			float y1 = ((group->clip_y+group->clip_h) - points[1]) / (points[3]-points[1]);
 			
-			gfx_clip_enable((int)(x0*gfx_screenwidth()), (int)(y0*gfx_screenheight()),
-				(int)((x1-x0)*gfx_screenwidth()), (int)((y1-y0)*gfx_screenheight()));
+			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),
+				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
 		}		
 		
 		mapscreen_to_group(center.x, center.y, group);
@@ -121,43 +125,43 @@ void MAPLAYERS::on_render()
 				{
 					MAPITEM_LAYER_TILEMAP *tmap = (MAPITEM_LAYER_TILEMAP *)layer;
 					if(tmap->image == -1)
-						gfx_texture_set(-1);
+						Graphics()->TextureSet(-1);
 					else
-						gfx_texture_set(gameclient.mapimages->get(tmap->image));
+						Graphics()->TextureSet(gameclient.mapimages->get(tmap->image));
 						
 					TILE *tiles = (TILE *)map_get_data(tmap->data);
-					gfx_blend_none();
-					render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
-					gfx_blend_normal();
-					render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
+					Graphics()->BlendNone();
+					RenderTools()->render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
+					Graphics()->BlendNormal();
+					RenderTools()->render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
 				}
 				else if(layer->type == LAYERTYPE_QUADS)
 				{
 					MAPITEM_LAYER_QUADS *qlayer = (MAPITEM_LAYER_QUADS *)layer;
 					if(qlayer->image == -1)
-						gfx_texture_set(-1);
+						Graphics()->TextureSet(-1);
 					else
-						gfx_texture_set(gameclient.mapimages->get(qlayer->image));
+						Graphics()->TextureSet(gameclient.mapimages->get(qlayer->image));
 
 					QUAD *quads = (QUAD *)map_get_data_swapped(qlayer->data);
 					
-					gfx_blend_none();
-					render_quads(quads, qlayer->num_quads, envelope_eval, LAYERRENDERFLAG_OPAQUE);
-					gfx_blend_normal();
-					render_quads(quads, qlayer->num_quads, envelope_eval, LAYERRENDERFLAG_TRANSPARENT);
+					Graphics()->BlendNone();
+					RenderTools()->render_quads(quads, qlayer->num_quads, LAYERRENDERFLAG_OPAQUE, envelope_eval, this);
+					Graphics()->BlendNormal();
+					RenderTools()->render_quads(quads, qlayer->num_quads, LAYERRENDERFLAG_TRANSPARENT, envelope_eval, this);
 				}
 				
 				//layershot_end();	
 			}
 		}
 		if(!config.gfx_noclip)
-			gfx_clip_disable();
+			Graphics()->ClipDisable();
 	}
 	
 	if(!config.gfx_noclip)
-		gfx_clip_disable();
+		Graphics()->ClipDisable();
 	
 	// reset the screen like it was before
-	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
+	Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h);
 }