this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fixed missing shapes except for PolygonBlit. Added OpenGLv1 vertex code too.

+63 -75
+63 -75
SDL_gpu/OpenGL_common/SDL_gpuShapes_OpenGL.c
··· 100 100 } 101 101 102 102 103 + static inline void draw_vertices(GLfloat* glverts, int num_vertices, GLenum prim_type) 104 + { 105 + #ifdef SDL_GPU_USE_OPENGLv1 106 + glBegin(prim_type); 107 + int size = 3*num_vertices; 108 + for(int i = 0; i < size; i += 3) 109 + { 110 + glVertex3f(glverts[i], glverts[i+1], glverts[i+2]); 111 + } 112 + glEnd(); 113 + #else 114 + glVertexPointer(3, GL_FLOAT, 0, glverts); 115 + glEnableClientState(GL_VERTEX_ARRAY); 116 + glDrawArrays(prim_type, 0, num_vertices); 117 + glDisableClientState(GL_VERTEX_ARRAY); 118 + #endif 119 + } 120 + 103 121 104 122 static float SetThickness(GPU_ShapeRenderer* renderer, float thickness) 105 123 { ··· 121 139 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 122 140 123 141 GLfloat glverts[3]; 124 - glVertexPointer(3, GL_FLOAT, 0, glverts); 125 - glEnableClientState(GL_VERTEX_ARRAY); 126 142 127 143 glverts[0] = x; 128 144 glverts[1] = y; 129 145 glverts[2] = z; 130 - 131 - glDrawArrays(GL_POINTS, 0, 1); 132 - glDisableClientState(GL_VERTEX_ARRAY); 146 + 147 + draw_vertices(glverts, 1, GL_POINTS); 133 148 134 149 END; 135 150 } ··· 141 156 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 142 157 143 158 GLfloat glverts[6]; 144 - glVertexPointer(3, GL_FLOAT, 0, glverts); 145 - glEnableClientState(GL_VERTEX_ARRAY); 146 159 147 160 glverts[0] = x1; 148 161 glverts[1] = y1; ··· 151 164 glverts[4] = y2; 152 165 glverts[5] = z; 153 166 154 - glDrawArrays(GL_LINES, 0, 2); 155 - glDisableClientState(GL_VERTEX_ARRAY); 167 + draw_vertices(glverts, 2, GL_LINES); 156 168 157 169 END; 158 170 } ··· 238 250 glverts[i*3+1] = y+dy; 239 251 glverts[i*3+2] = z; 240 252 241 - glEnableClientState(GL_VERTEX_ARRAY); 242 - glVertexPointer(3, GL_FLOAT, 0, glverts); 243 - glDrawArrays(GL_LINE_STRIP, 0, numSegments+2); 244 - glDisableClientState(GL_VERTEX_ARRAY); 253 + draw_vertices(glverts, numSegments+2, GL_LINE_STRIP); 245 254 246 255 /*glBegin(GL_LINE_STRIP); 247 256 dx = radius*cos(t*RADPERDEG); ··· 344 353 glverts[i*3+1] = y+dy; 345 354 glverts[i*3+2] = z; 346 355 347 - glEnableClientState(GL_VERTEX_ARRAY); 348 - glVertexPointer(3, GL_FLOAT, 0, glverts); 349 - glDrawArrays(GL_TRIANGLE_FAN, 0, numSegments+3); 350 - glDisableClientState(GL_VERTEX_ARRAY); 356 + draw_vertices(glverts, numSegments+3, GL_TRIANGLE_FAN); 351 357 352 358 /*glBegin(GL_TRIANGLE_FAN); 353 359 glVertex3f(x, y, z); ··· 377 383 int numSegments = 360/dt+1; 378 384 379 385 GLfloat glverts[numSegments*3]; 380 - glVertexPointer(3, GL_FLOAT, 0, glverts); 381 - glEnableClientState(GL_VERTEX_ARRAY); 382 386 383 387 int i; 384 388 for(i = 0; i < numSegments; i++) ··· 391 395 t += dt; 392 396 } 393 397 394 - glDrawArrays(GL_LINE_LOOP, 0, numSegments); 395 - glDisableClientState(GL_VERTEX_ARRAY); 398 + draw_vertices(glverts, numSegments, GL_LINE_LOOP); 396 399 397 400 END; 398 401 } ··· 409 412 int numSegments = 360/dt+1; 410 413 411 414 GLfloat glverts[(1+numSegments)*3]; 412 - glVertexPointer(3, GL_FLOAT, 0, glverts); 413 - glEnableClientState(GL_VERTEX_ARRAY); 414 415 415 416 glverts[0] = x; 416 417 glverts[1] = y; ··· 426 427 t += dt; 427 428 } 428 429 429 - glDrawArrays(GL_TRIANGLE_FAN, 0, 1+numSegments); 430 - glDisableClientState(GL_VERTEX_ARRAY); 430 + draw_vertices(glverts, 1+numSegments, GL_TRIANGLE_FAN); 431 431 432 432 /*glBegin(GL_TRIANGLE_FAN); 433 433 dx = radius*cos(t*RADPERDEG); ··· 452 452 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 453 453 454 454 GLfloat glverts[9]; 455 - glVertexPointer(3, GL_FLOAT, 0, glverts); 456 - glEnableClientState(GL_VERTEX_ARRAY); 457 455 458 456 glverts[0] = x1; 459 457 glverts[1] = y1; ··· 465 463 glverts[7] = y3; 466 464 glverts[8] = z; 467 465 468 - glDrawArrays(GL_LINE_LOOP, 0, 3); 469 - glDisableClientState(GL_VERTEX_ARRAY); 466 + draw_vertices(glverts, 3, GL_LINE_LOOP); 470 467 471 468 END; 472 469 } ··· 478 475 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 479 476 480 477 GLfloat glverts[9]; 481 - glVertexPointer(3, GL_FLOAT, 0, glverts); 482 - glEnableClientState(GL_VERTEX_ARRAY); 483 478 484 479 glverts[0] = x1; 485 480 glverts[1] = y1; ··· 491 486 glverts[7] = y3; 492 487 glverts[8] = z; 493 488 494 - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); 495 - glDisableClientState(GL_VERTEX_ARRAY); 489 + draw_vertices(glverts, 3, GL_TRIANGLE_STRIP); 496 490 497 491 END; 498 492 } ··· 504 498 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 505 499 506 500 GLfloat glverts[12]; 507 - glVertexPointer(3, GL_FLOAT, 0, glverts); 508 - glEnableClientState(GL_VERTEX_ARRAY); 509 501 510 502 glverts[0] = x1; 511 503 glverts[1] = y1; ··· 520 512 glverts[10] = y1; 521 513 glverts[11] = z; 522 514 523 - glDrawArrays(GL_LINE_LOOP, 0, 4); 524 - glDisableClientState(GL_VERTEX_ARRAY); 515 + draw_vertices(glverts, 4, GL_LINE_LOOP); 525 516 526 517 END; 527 518 } ··· 533 524 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 534 525 535 526 GLfloat glverts[12]; 536 - glVertexPointer(3, GL_FLOAT, 0, glverts); 537 - glEnableClientState(GL_VERTEX_ARRAY); 538 527 539 528 glverts[0] = x1; 540 529 glverts[1] = y1; ··· 549 538 glverts[10] = y2; 550 539 glverts[11] = z; 551 540 552 - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 553 - glDisableClientState(GL_VERTEX_ARRAY); 541 + draw_vertices(glverts, 4, GL_TRIANGLE_STRIP); 554 542 555 543 END; 556 544 } ··· 573 561 BEGIN; 574 562 575 563 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 576 - 564 + 565 + //int numVerts = 8 + (int(M_PI*5)+1)*4; // 8 + (15.7 + 1)*4 566 + float glverts[120*3]; 567 + 577 568 float i; 578 - /*glBegin(GL_LINE_LOOP); 579 - glVertex3f(x1+radius,y1, z); 580 - glVertex3f(x2-radius,y1, z); 581 - for(i=(float)M_PI*1.5f;i<M_PI*2;i+=0.1f) 582 - glVertex3f(x2-radius+cos(i)*radius,y1+radius+sin(i)*radius, z); 583 - glVertex3f(x2,y1+radius, z); 584 - glVertex3f(x2,y2-radius, z); 585 - for(i=0;i<(float)M_PI*0.5f;i+=0.1f) 586 - glVertex3f(x2-radius+cos(i)*radius,y2-radius+sin(i)*radius, z); 587 - glVertex3f(x2-radius,y2, z); 588 - glVertex3f(x1+radius,y2, z); 589 - for(i=(float)M_PI*0.5f;i<M_PI;i+=0.1f) 590 - glVertex3f(x1+radius+cos(i)*radius,y2-radius+sin(i)*radius, z); 591 - glVertex3f(x1,y2-radius, z); 592 - glVertex3f(x1,y1+radius, z); 593 - for(i=(float)M_PI;i<M_PI*1.5f;i+=0.1f) 594 - glVertex3f(x1+radius+cos(i)*radius,y1+radius+sin(i)*radius, z); 595 - glEnd();*/ 569 + int n = 0; 570 + for(i=(float)M_PI*1.5f;i<M_PI*2;i+=0.1f) 571 + set_vertex(glverts, n++, x2-radius+cos(i)*radius,y1+radius+sin(i)*radius, z); 572 + for(i=0;i<(float)M_PI*0.5f;i+=0.1f) 573 + set_vertex(glverts, n++, x2-radius+cos(i)*radius,y2-radius+sin(i)*radius, z); 574 + for(i=(float)M_PI*0.5f;i<M_PI;i+=0.1f) 575 + set_vertex(glverts, n++, x1+radius+cos(i)*radius,y2-radius+sin(i)*radius, z); 576 + for(i=(float)M_PI;i<M_PI*1.5f;i+=0.1f) 577 + set_vertex(glverts, n++, x1+radius+cos(i)*radius,y1+radius+sin(i)*radius, z); 578 + 579 + draw_vertices(glverts, n, GL_LINE_LOOP); 596 580 597 581 END; 598 582 } ··· 618 602 619 603 //int numVerts = 8 + (int(M_PI*5)+1)*4; // 8 + (15.7 + 1)*4 620 604 float glverts[120*3]; 621 - glVertexPointer(3, GL_FLOAT, 0, glverts); 622 - glEnableClientState(GL_VERTEX_ARRAY); 623 605 624 606 float i; 625 607 int n = 0; ··· 640 622 for(i=(float)M_PI;i<M_PI*1.5f;i+=0.1f) 641 623 set_vertex(glverts, n++, x1+radius+cos(i)*radius,y1+radius+sin(i)*radius, z); 642 624 643 - glDrawArrays(GL_TRIANGLE_FAN, 0, n); 644 - glDisableClientState(GL_VERTEX_ARRAY); 625 + draw_vertices(glverts, n, GL_TRIANGLE_FAN); 645 626 646 627 END; 647 628 } ··· 651 632 BEGIN; 652 633 653 634 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 654 - 655 - int i; 656 - /*glBegin(GL_LINE_LOOP); 657 - for(i = 0; i < 2*n; i+=2) 635 + 636 + int numIndices = 2*n; 637 + float glverts[numIndices*3]; 638 + 639 + int i, j; 640 + for(i = 0, j = 0; i < numIndices; i+=2, j++) 658 641 { 659 - glVertex3f(vertices[i], vertices[i+1], z); 642 + set_vertex(glverts, j, vertices[i], vertices[i+1], z); 660 643 } 661 - glEnd();*/ 644 + 645 + draw_vertices(glverts, n, GL_LINE_LOOP); 662 646 663 647 END; 664 648 } ··· 668 652 BEGIN; 669 653 670 654 glColor4f(color.r/255.5f, color.g/255.5f, color.b/255.5f, color.unused/255.5f); 671 - int i; 672 - /*glBegin(GL_TRIANGLE_FAN); 673 - for(i = 0; i < 2*n; i+=2) 655 + 656 + int numIndices = 2*n; 657 + float glverts[numIndices*3]; 658 + 659 + int i, j; 660 + for(i = 0, j = 0; i < numIndices; i+=2, j++) 674 661 { 675 - glVertex3f(vertices[i], vertices[i+1], z); 662 + set_vertex(glverts, j, vertices[i], vertices[i+1], z); 676 663 } 677 - glEnd();*/ 664 + 665 + draw_vertices(glverts, n, GL_TRIANGLE_FAN); 678 666 679 667 END; 680 668 }