| 1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.3
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
|---|
| 10 | * copy of this software and associated documentation files (the "Software"),
|
|---|
| 11 | * to deal in the Software without restriction, including without limitation
|
|---|
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|---|
| 13 | * and/or sell copies of the Software, and to permit persons to whom the
|
|---|
| 14 | * Software is furnished to do so, subject to the following conditions:
|
|---|
| 15 | *
|
|---|
| 16 | * The above copyright notice and this permission notice shall be included
|
|---|
| 17 | * in all copies or substantial portions of the Software.
|
|---|
| 18 | *
|
|---|
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|---|
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|---|
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|---|
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|---|
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 25 | *
|
|---|
| 26 | *
|
|---|
| 27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
|---|
| 28 | * terms stated above.
|
|---|
| 29 | *
|
|---|
| 30 | * Thank you for your contribution, David!
|
|---|
| 31 | *
|
|---|
| 32 | * Please make note of the above copyright/license statement. If you
|
|---|
| 33 | * contributed code or bug fixes to this code under the previous (GNU
|
|---|
| 34 | * Library) license and object to the new license, your code will be
|
|---|
| 35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
|---|
| 36 | * for more information.
|
|---|
| 37 | *
|
|---|
| 38 | * Additional Mesa/3Dfx driver developers:
|
|---|
| 39 | * Daryll Strauss <daryll@precisioninsight.com>
|
|---|
| 40 | * Keith Whitwell <keith@precisioninsight.com>
|
|---|
| 41 | *
|
|---|
| 42 | * See fxapi.h for more revision/author details.
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | #ifdef HAVE_CONFIG_H
|
|---|
| 47 | #include "conf.h"
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | #if defined(FX)
|
|---|
| 53 | #include "fxdrv.h"
|
|---|
| 54 |
|
|---|
| 55 | /* I have found this quite useful in tracking down transformation &
|
|---|
| 56 | * clipping bugs. If you get a random graphics card freeze, running
|
|---|
| 57 | * your triangles through this will probably catch the problem.
|
|---|
| 58 | */
|
|---|
| 59 |
|
|---|
| 60 | #define WID 640
|
|---|
| 61 | #define HI 480
|
|---|
| 62 |
|
|---|
| 63 | #undef grDrawTriangle
|
|---|
| 64 |
|
|---|
| 65 | void fx_sanity_triangle( GrVertex *v1, GrVertex *v2, GrVertex *v3 )
|
|---|
| 66 | {
|
|---|
| 67 | GLuint rv = 1, print = 0;
|
|---|
| 68 |
|
|---|
| 69 | GLfloat area = ((v1->x - v3->x) * (v2->y - v3->y) -
|
|---|
| 70 | (v1->y - v3->y) * (v2->x - v3->x));
|
|---|
| 71 |
|
|---|
| 72 | if (v1->x < 0 || v1->y < 0 || v1->x > WID || v1->y > HI ||
|
|---|
| 73 | v2->x < 0 || v2->y < 0 || v2->x > WID || v2->y > HI ||
|
|---|
| 74 | v3->x < 0 || v3->y < 0 || v3->x > WID || v3->y > HI)
|
|---|
| 75 | {
|
|---|
| 76 | fprintf(stderr,"not clipped/set up!!!!!\n");
|
|---|
| 77 | rv = 0;
|
|---|
| 78 | print = 1;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | if (area > (WID*HI)) {
|
|---|
| 82 | fprintf(stderr,"too big\n");
|
|---|
| 83 | rv = 0;
|
|---|
| 84 | }
|
|---|
| 85 | if (v1->oow == 0 || v2->oow == 0 || v3->oow == 0) {
|
|---|
| 86 | fprintf(stderr,"zero oow\n");
|
|---|
| 87 | rv = 0;
|
|---|
| 88 | }
|
|---|
| 89 | if (0 && area == 0) {
|
|---|
| 90 | fprintf(stderr,"zero area %p %p %p\n", v1,v2,v3);
|
|---|
| 91 | rv =0;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | if (print) {
|
|---|
| 95 | fprintf(stderr,"v1: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
|
|---|
| 96 | v1->x, v1->y, v1->ooz, v1->oow,
|
|---|
| 97 | v1->r, v1->g, v1->b, v1->a,
|
|---|
| 98 | v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
|
|---|
| 99 | v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
|
|---|
| 100 | fprintf(stderr,"v2: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
|
|---|
| 101 | v2->x, v2->y, v2->ooz, v2->oow,
|
|---|
| 102 | v2->r, v2->g, v2->b, v2->a,
|
|---|
| 103 | v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
|
|---|
| 104 | v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
|
|---|
| 105 | fprintf(stderr,"v3: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
|
|---|
| 106 | v3->x, v3->y, v3->ooz, v3->oow,
|
|---|
| 107 | v3->r, v3->g, v3->b, v3->a,
|
|---|
| 108 | v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
|
|---|
| 109 | v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | if (1)
|
|---|
| 113 | FX_grDrawTriangle(v1,v2,v3);
|
|---|
| 114 | else
|
|---|
| 115 | fprintf(stderr, "\n\n\n");
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | #else
|
|---|
| 119 |
|
|---|
| 120 | void gl_fxsanity_dummy()
|
|---|
| 121 | {
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | #endif
|
|---|