@@ -60,6 +60,9 @@ static const GLuint VERTEX_SIZE = VERTEX_POS_SIZE + VERTEX_TEXCOORD_SIZE + VERTE
6060// ARRAYS OF PENDING DRAW CALLS (DrawCall _vgl_pending_calls[MAX_VERTICES];)
6161static char __vgl_repaint_inprog = 0 ;
6262
63+ // Filled by default
64+ static char _curBufferFillState [MAX_VERTICES ] = {1 };
65+
6366static DrawCall * _curBufferA ;
6467static DrawCall * _curBufferB ;
6568
@@ -241,29 +244,45 @@ _Vita_WriteVertices4xColor(DrawCall *drawCall,
241244 float rgba0 [4 ],
242245 float rgba1 [4 ],
243246 float rgba2 [4 ],
244- float rgba3 [4 ])
247+ float rgba3 [4 ],
248+ char filled )
245249{
246250 if (drawCall == nullptr ) return ;
247251
252+ // we haven't incremented until we call "Vita_DoneWithDrawCall()"
253+ // so we can set this here.
254+ _curBufferFillState [_vgl_pending_offset ] = filled ;
255+
256+ // filled order?
257+ // x, y
258+ //
259+ // v0
248260 drawCall -> verts [0 ].x = x ;
249261 drawCall -> verts [0 ].y = y ;
250262 drawCall -> verts [0 ].s = n_src_x ; // Tex Coord X
251263 drawCall -> verts [0 ].v = n_src_y ; // Tex Coord Y
252-
264+
265+ // v1
253266 drawCall -> verts [1 ].x = x ;
254267 drawCall -> verts [1 ].y = y + hDst ;
255- drawCall -> verts [1 ].s = n_src_x ; // Tex Coord X
268+ drawCall -> verts [1 ].s = n_src_x ; // Tex Coord X
256269 drawCall -> verts [1 ].v = n_src_y2 ; // Tex Coord Y
257-
258- drawCall -> verts [2 ].x = x + wDst ;
259- drawCall -> verts [2 ].y = y ;
260- drawCall -> verts [2 ].s = n_src_x2 ; // Tex Coord X
261- drawCall -> verts [2 ].v = n_src_y ; // Tex Coord Y
262270
263- drawCall -> verts [3 ].x = x + wDst ;
264- drawCall -> verts [3 ].y = y + hDst ;
265- drawCall -> verts [3 ].s = n_src_x2 ; // Tex Coord X
266- drawCall -> verts [3 ].v = n_src_y2 ; // Tex Coord Y
271+ // If we're not drawing filled, then we need to swap
272+ // the last two vertices to ensure proper draw order.
273+ const int c = filled ? 2 : 3 ,
274+ d = filled ? 3 : 2 ;
275+ // v2
276+ drawCall -> verts [c ].x = x + wDst ;
277+ drawCall -> verts [c ].y = y ;
278+ drawCall -> verts [c ].s = n_src_x2 ; // Tex Coord X
279+ drawCall -> verts [c ].v = n_src_y ; // Tex Coord Y
280+
281+ // v3
282+ drawCall -> verts [d ].x = x + wDst ;
283+ drawCall -> verts [d ].y = y + hDst ;
284+ drawCall -> verts [d ].s = n_src_x2 ; // Tex Coord X
285+ drawCall -> verts [d ].v = n_src_y2 ; // Tex Coord Y
267286
268287 drawCall -> verts [0 ]._r = rgba0 [0 ];
269288 drawCall -> verts [0 ]._g = rgba0 [1 ];
@@ -311,7 +330,7 @@ _Vita_WriteVertices(DrawCall *drawCall,
311330 _Vita_WriteVertices4xColor (drawCall ,
312331 x , y , wDst , hDst ,
313332 n_src_x , n_src_x2 , n_src_y , n_src_y2 ,
314- rgba0 , rgba0 , rgba0 , rgba0 );
333+ rgba0 , rgba0 , rgba0 , rgba0 , true );
315334}
316335
317336static inline GLuint Vita_GetVertexBufferID () { return _vertexBufferID ; }
@@ -387,14 +406,15 @@ void Vita_DrawRect4xColor(float x, float y,
387406 float rgba0 [4 ],
388407 float rgba1 [4 ],
389408 float rgba2 [4 ],
390- float rgba3 [4 ])
409+ float rgba3 [4 ],
410+ char filled )
391411{
392412 DrawCall * _curDrawCall = _Vita_GetAvailableDrawCall ();
393413
394414 for (int i = 0 ; i < 4 ; i ++ )
395415 _curDrawCall -> verts [i ].obj_ptr = 0 ;
396416
397- _Vita_WriteVertices4xColor (_curDrawCall , x , y , wDst , hDst , 0.f , 1.f , 0.f , 1.f , rgba0 , rgba1 , rgba2 , rgba3 );
417+ _Vita_WriteVertices4xColor (_curDrawCall , x , y , wDst , hDst , 0.f , 1.f , 0.f , 1.f , rgba0 , rgba1 , rgba2 , rgba3 , filled );
398418
399419 _Vita_DoneWithDrawCall ();
400420}
@@ -409,10 +429,11 @@ void Vita_DrawRectColor(float x, float y,
409429 float _r ,
410430 float _g ,
411431 float _b ,
412- float _a )
432+ float _a ,
433+ char filled )
413434{
414435 float rgba0 [4 ] = {_r , _g , _b , _a };
415- Vita_DrawRect4xColor (x , y , wDst , hDst , rgba0 , rgba0 , rgba0 , rgba0 );
436+ Vita_DrawRect4xColor (x , y , wDst , hDst , rgba0 , rgba0 , rgba0 , rgba0 , filled );
416437}
417438
418439/**
@@ -447,7 +468,7 @@ void Vita_DrawRectColorExData(float x, float y,
447468 // _curDrawCall->piv_x = x + (wDst * .5f);
448469 // _curDrawCall->piv_y = y + (hDst * .5f);
449470
450- _Vita_WriteVertices4xColor (_curDrawCall , x , y , wDst , hDst , 1.f , 1.f , 1.f , 1.f , rgba0 , rgba0 , rgba0 , rgba0 );
471+ _Vita_WriteVertices4xColor (_curDrawCall , x , y , wDst , hDst , 1.f , 1.f , 1.f , 1.f , rgba0 , rgba0 , rgba0 , rgba0 , true );
451472
452473 _Vita_DoneWithDrawCall ();
453474
@@ -840,6 +861,9 @@ int initGLAdv()
840861 memset (_curBufferA , 0 , _vgl_pending_total_size );
841862 memset (_curBufferB , 0 , _vgl_pending_total_size );
842863
864+ // 1 to indicate filled by default
865+ memset (_curBufferFillState , 1 , MAX_VERTICES );
866+
843867 _vgl_pending_calls = _curBufferA ;
844868 _vgl_current_write_buffer = _curBufferB ;
845869
@@ -1103,7 +1127,7 @@ void Vita_Repaint()
11031127 // This is a "hack around".
11041128 // Ideally, I'd be able to batch this all at once.
11051129 GLuint i ;
1106- GLuint _curBoundTex = -1 ;
1130+ GLuint _curBoundTex = 0 ;
11071131 GLuint _curReqTex = 0 ;
11081132 int totalTextureSwaps = 0 ;
11091133 DrawCall _curDrawCall ;
@@ -1182,7 +1206,7 @@ void Vita_Repaint()
11821206 }
11831207
11841208 // draw
1185- glDrawArrays (GL_TRIANGLE_STRIP , i * VERTICES_PER_PRIM , VERTICES_PER_PRIM );
1209+ glDrawArrays ( _curBufferFillState [ i ] == 1 ? GL_TRIANGLE_STRIP : GL_LINE_LOOP , i * VERTICES_PER_PRIM , VERTICES_PER_PRIM );
11861210 }
11871211#if DEBUG_BUILD
11881212 if (last_frame_time_s != 0 )
0 commit comments