--- a/branches/wings2/src/wings_draw.erl
+++ b/branches/wings2/src/wings_draw.erl
@@ -17,12 +17,17 @@
 
 -export([all/5, gl_send_bins/1]).
 %% For selection
--export([activate_vertices/1, activate_index/1, activate_face_ids/1]).
+-export([draw_selection/3, 
+	 %% For picking
+	 activate_vertices/1, 
+	 activate_index/1, 
+	 activate_face_ids/1]).
 
 %%-define(V_SZ, ?GL_DOUBLE).
 -define(V_SZ, ?GL_FLOAT).
 -define(INT_SZ, 4).
 -define(F32, 32/native-float).
+-define(UI32, 32/unsigned-native).
        
 %% @doc SelMode relevant is vertex, edge anything else is cared for
 %% ViewProp flat or smooth or wireframe
@@ -276,8 +281,39 @@
     Fn = bind_binary(Fn0, ?GL_ARRAY_BUFFER),
     Vn = bind_binary(Vn0, ?GL_ARRAY_BUFFER),
     Vc = bind_binary(Vc0, ?GL_ARRAY_BUFFER),
-    Fid = bind_binary(Fid0, ?GL_ARRAY_BUFFER),
+    Fid= bind_binary(Fid0, ?GL_ARRAY_BUFFER),
     Fi = bind_binary(Fi0, ?GL_ELEMENT_ARRAY_BUFFER),
     DC#dc{ev_bin=Ev,ei={Ei, HEO, HEN},vi={Vi,VsN},
 	  fv_bin=Fv,fn_bin=Fn,vn_bin=Vn,vc_bin=Vc,
 	  fi={Fi, TriN, MatL},fid=Fid}.
+
+draw_selection(_, #gs{sel=[]}, _) -> ok;
+draw_selection(face, #gs{sel=Selects,objects=Obs}, DC) ->
+    [draw_face_selection(Sel, Obs, DC) || Sel <- Selects],
+    ok.
+
+draw_face_selection({Obj, Faces}, Obs, DC) ->
+    #object{body=Body} = array:get(Obj, Obs),
+    gl:pushMatrix(),
+    TransMat = e3d_mat:expand(wings_u:trans_mat(Obj,Obs)),
+    gl:multMatrixf(TransMat), 
+    #dc{fv_bin=VsBin,mirror=MM,fmap=Fmap} = array:get(Body,DC),
+    Fidx = build_face_idx(Faces, Fmap),
+    bind_binary(Fidx, ?GL_ELEMENT_ARRAY_BUFFER),
+    activate_vertices(VsBin),
+    gl:disableClientState(?GL_NORMAL_ARRAY),
+    gl:disableClientState(?GL_COLOR_ARRAY),
+    Count = size(Fidx) div ?INT_SZ,
+    gl:drawElements(?GL_TRIANGLES, Count, ?GL_UNSIGNED_INT,0),
+    gl:popMatrix().
+
+build_face_idx(Face, Fmap) when is_integer(Face) ->
+    {_,_,Vs} = array:get(Face, Fmap),
+    << << V:?UI32 >> || V <- Vs >>;
+build_face_idx(FaceSet, Fmap) ->
+    Fs = gb_sets:to_list(FaceSet),    
+    Vs = fun(Face) ->
+		 {_,_,Vs} = array:get(Face, Fmap),
+		 << << V:?UI32 >> || V <- Vs >>
+	 end,
+    << <<(Vs(Face))/binary>> || Face <- Fs>>.