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 134611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:38:41+00:00 2026-05-11T06:38:41+00:00

This is probably a silly mistake but I cant see it?! I have classes

  • 0

This is probably a silly mistake but I cant see it?! I have classes defining geometry and classes that render that geometry. Right now it is basic triangles and colours for each vertex.

Here is the code defining said geometry objects data:

CGeometry* g = new CGeometry(); g->vertexes = new double[3*3];  g->vertexes[0] = 0; g->vertexes[1] = 0; g->vertexes[2] = 0;  g->vertexes[3] = 100; g->vertexes[4] = 100; g->vertexes[5] = 0;  g->vertexes[6] = 100; g->vertexes[7] = 0; g->vertexes[8] = 0;  g->colors = new double[12];  g->colors[0] = 1; g->colors[1] = 1; g->colors[2] = 0; g->colors[3] = 1;  g->colors[4] = 1; g->colors[5] = 0; g->colors[6] = 1; g->colors[7] = 0;  g->colors[8] = 0; g->colors[9] = 1; g->colors[10] = 1; g->colors[11] = 0; 

And here is the code that renders said data:

CGeometry* g = object->geometry;  int j = object->endIndex - object->startIndex; double* vertexes = g->vertexes; double* colors = g->colors;  glBegin(GL_TRIANGLES); {     for(int i = 0; i < j; i++){         int coord = object->startIndex+i;         int colorind = coord*4;          double r,g,b,a;         r = colors[colorind];         g = colors[colorind+1];         b = colors[colorind+2];         a = colors[colorind+3];          glColor4d(  r,g,b,a);         glVertex3d( vertexes[coord*3],                     vertexes[coord*3+1],                     vertexes[coord*3+2]);     } } glEnd(); 

Yet regardless of what I put my triangle is always yellow, or the value of the first color in the colors array. I have gone into the debugger and checked the values on each individual loop iteration and the values of the r g b and a variables do infact change accordingly and are not always yellow, yet the result is a yellow triangle.

Yet if I put the following nabbed from the neheGL tutorials:

glClearColor(0.1f,0.1f,0.1f,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity();                                   // Reset The Current Modelview Matrix //glTranslatef(1.5f,0.0f,0.0f);                     // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_TRIANGLES);                              // Drawing Using Triangles     glColor3f(1.0f,0.0f,0.0f);                      // Set The Color To Red     glVertex3f( 0.0f, 1.0f, 0.0f);                  // Top     glColor3f(0.0f,1.0f,0.0f);                      // Set The Color To Green     glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left     glColor3f(0.0f,0.0f,1.0f);                      // Set The Color To Blue     glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right glEnd();                                            // Finished Drawing The Triangle glTranslatef(160.0f,0.0f,0.0f);                     // Move Right 3 Units glColor3f(0.5f,0.5f,1.0f);                          // Set The Color To Blue One Time Only glBegin(GL_QUADS);                                  // Draw A Quad     glVertex3f(-1.0f, 1.0f, 0.0f);                  // Top Left     glVertex3f( 1.0f, 1.0f, 0.0f);                  // Top Right     glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right     glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left glEnd(); 

I get a nice blended triangle with 3 colours from each vertex

  • 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. 2026-05-11T06:38:41+00:00Added an answer on May 11, 2026 at 6:38 am

    Actually, I think I got it: you’re only seeing a small portion of the bottom left corner of your triangle. You need to move away from it to view it entirely: your coordinates are too large.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Been there, done that. Since there is no continuity in… May 11, 2026 at 3:57 pm
  • added an answer Subversion (aka SVN) and http://tortoisesvn.net/ TortoiseSVN is an easy to… May 11, 2026 at 3:57 pm
  • added an answer Another way to protect against this is to use a… May 11, 2026 at 3:57 pm

Related Questions

This is probably a silly question, but curiosity has gotten the better of me.
Alright, this is probably a really silly question but I am new to Python/Django
In an answer to Is it safe to store objects of a class which
This is probably silly but very frustrating. Using VS2008 with a C++ project, when

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.