Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 385705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:30:21+00:00 2026-05-12T15:30:21+00:00

I am just trying something with somebody else’s code. I have two functions: int

  • 0

I am just trying something with somebody else’s code.

I have two functions:

int Triangle(Render *render, int numParts, Token *nameList, Pointer *valueList) 
    int i;
    for (i=0; i<numParts; i++)
    {
        switch (nameList[i])
        {
        case GZ_NULL_TOKEN:
            break;

        case GZ_POSITION:
            return putTrianglePosition(render, (Coord *)valueList[i]);
            break;
        }
    }

    return SUCCESS;
}

int putTrianglePosition(Render *render, Coord vertexList[3]) /*vertexList[3][3:xyz]*/
{
    Coord *pv[3];
    int i,j;

    // sort verts by inc. y and inc. x
    pv[0] = &vertexList[0];
    pv[1] = &vertexList[1];
    pv[2] = &vertexList[2];
    for (i=0; i<2; i++)
        for (j=i+1; j<3; j++)
        {
            if ((*pv[i])[1]>(*pv[j])[1] || 
                (*pv[i])[1]==(*pv[j])[1] && (*pv[i])[0]>(*pv[j])[0]) {
                Coord *tmp;
                tmp = pv[i];
                pv[i] = pv[j];
                pv[j] = tmp;
            }
        }
    ;

    // all y the same?
    if ((*pv[0])[1] == (*pv[2])[1]) {
        drawHorizonLine(render, *pv[0], *pv[2]);
        return SUCCESS;  
    }

    // assign middle point
    Coord mid; 
    mid[1] = (*pv[1])[1];   // y
    float ratio = ((*pv[1])[1] - (*pv[0])[1]) / ((*pv[2])[1] - (*pv[0])[1]);
    mid[0] = (*pv[0])[0] + ratio * ((*pv[2])[0] - (*pv[0])[0]); // x
    mid[2] = (*pv[0])[2] + ratio * ((*pv[2])[2] - (*pv[0])[2]); // z

    if (mid[0]<=(*pv[1])[0]) {  // compare X
        drawTrapzoid(render, *pv[0], mid, *pv[0], *pv[1]); // upper tri
        drawTrapzoid(render, mid, *pv[2], *pv[1], *pv[2]); // lower tri
    }else{
        drawTrapzoid(render, *pv[0], *pv[1], *pv[0], mid); // upper tri
        drawTrapzoid(render, *pv[1], *pv[2], mid, *pv[2]); // lower tri
    }

    return SUCCESS;
}

I don’t want two functions here. I want to copy the putTrianglePosition() function into the Triangle() function.

I tried doing that, but I got a lot of errors.

Can somebody else show me how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:30:21+00:00Added an answer on May 12, 2026 at 3:30 pm

    If you just change the line

                return putTrianglePosition(render, (Coord *)valueList[i]);
    

    into:

    Coord* vertexList = (Coord*) valueList[i];
    

    followed by the whole body of what’s now putTrianglePosition from the opening { to the closing } included, I believe it should just work. If not, please edit your question to add the exact, complete, code as obtained by this edit and the exact, complete error messages you get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's a short example of how you would do it… May 13, 2026 at 1:46 am
  • Editorial Team
    Editorial Team added an answer How do I check that it is bare? As mentioned… May 13, 2026 at 1:46 am
  • Editorial Team
    Editorial Team added an answer notify only on true changes. Or use a flag to… May 13, 2026 at 1:46 am

Related Questions

I am just trying something with somebody else's code. I have two functions: int
I need to run Perl applications I develop on cygwin Windows on HP unix
I'm developing a facebook app right now all by my lonesome. I'm attempting to
I have been trying to design a WCF file upload service and am getting
I'm trying to figure out why my web app (I didn't write it, but

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.