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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:29:08+00:00 2026-05-19T05:29:08+00:00

I have: float[,] nodesN = null; //indexes: //number of node; //value index 0->x, 1->y,

  • 0

I have:

float[,] nodesN = null; //indexes:
                        //number of node;
                        //value index 0->x, 1->y, 2->temperature
int[,] elements = null; //indexes:
                        //indexof element (triangle)
                        //1, 2, 3 - vertexes (from nodesN)
List<Pair> edges = null; //Pair is a class containing two int values which are
                         //indexes of nodesN

And function which is supposed do all elements and edges on SharpGL.OpenGLCtrl

    private void openGLCtrl1_Load(object sender, EventArgs e)
    {
        gl = this.glCtrl.OpenGL;
        gl.ClearColor(this.BackColor.R / 255.0f,
            this.BackColor.G / 255.0f,
            this.BackColor.B / 255.0f, 1.0f);
        gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);
    }

    private void openGLControl1_OpenGLDraw(object sender, PaintEventArgs e)
    {
        gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);
        gl.LoadIdentity();
        gl.Translate(0.0f, 0.0f, -6.0f);

        if (!draw) return;

        bool drawElements = false;

        if (drawElements)
        {
            gl.Begin(OpenGL.TRIANGLES);

            for (int i = 0; i < elementNo; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    float x, y, t;
                    x = nodesN[elements[i, j], 0];
                    y = nodesN[elements[i, j], 1];
                    t = nodesN[elements[i, j], 2];

                    gl.Color(t, 0.0f, 1.0f - t);
                    gl.Vertex(x, y, 0.0f);
                }
            }

            gl.End();
        }

        gl.Color(0f, 0f, 0f);            

        gl.Begin(OpenGL.LINES);

        //for(int i=edges.Count-1; i>=0; i--)
        for(int i=0; i<edges.Count; i++)
        {               

            float x1, y1, x2, y2;
            x1 = nodesN[edges[i].First, 0];
            y1 = nodesN[edges[i].First, 1];

            x2 = nodesN[edges[i].Second, 0];
            y2 = nodesN[edges[i].Second, 1];

            gl.Vertex(x1, y1, 0.0f);
            gl.Vertex(x2, y2, 0.0f);                
        }   

        gl.End();          
    }

But it doesn’t draw all the edges. If i change drawElements it draws different number of edges. Changing for(int i=0; i<edges.Count; i++) to for(int i=edges.Count-1; i>=0; i--) shows that esges are generated correctly, but they are not drawn.

Images:
for(int i=0; i<edges.Count; i++)
drawElements=false
http://img225.imageshack.us/img225/9295/noup.jpg

for(int i=edges.Count-1; i>=0; i--)
drawElements=false
http://img828.imageshack.us/img828/9595/nodown.jpg

for(int i=0; i<edges.Count; i++)
drawElements=true
http://img64.imageshack.us/img64/4929/withup.jpg

for(int i=edges.Count-1; i>=0; i--)
drawElements=true
http://img833.imageshack.us/img833/9167/withdown.jpg

What is wrong with this? How can I draw all edges?

EDIT:
Never mind, I dropped SharpGL and wrote exactly the same code in OpenTK. It works excelent without me wondering what was wrong. This was a good call because SharpGL uses enormously big amount of memory.

  • 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-19T05:29:09+00:00Added an answer on May 19, 2026 at 5:29 am

    Once I had a very similar problem.

    It was due to z-buffer. If you have a plane and want to draw it’s wireframe than the coordinates overlap and artifacts like those arise. It’s numerically undefined behavior – drawing two objects on the same depth. You never know which one comes on top.

    One solution is to offset the wireframe a bit. I noticed that in some 3d modelling packages. In game engines it’s also common to offset sprites on geometry (gunshot marks on a wall). Another might be disabling the z-buffer and manually occlude hidden lines.

    The case when you disable drawing of elements might be to another issue with z-buffer. It’s bounded by far and near clipping planes. Most probably you draw the lines exactly at the depth of one of them (my guess is far one).

    EDIT. I read Your code a bit. One I’d like to see is how You construct the projection matrix. If you didn’t touch it at all than (If I recall correctly) the near and far clipping planes are at -1.0 and 1.0 respectively. But, I might be wrong since You draw at z=-6.0…

    The other thing, try replacing:

    gl.Vertex(x1, y1, 0.0f);
    gl.Vertex(x2, y2, 0.0f);  
    

    With something along the lines of:

    gl.Vertex(x1, y1, 0.01f);
    gl.Vertex(x2, y2, 0.01f);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a float in MSSQLServer, to what do you map this in
I have double (or float) variables that might be empty, as in holding no
Both are mathematical values, however the float does have more precision. Is that the
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);
I have a function that returns a float from 0 to 255. I would
Mine would have to be the float and margin bugs... If you float an
So I have a function that looks something like this: float function(){ float x
I want to have two items on the same line using float: left for
I have a div with two nested divs inside, the (float:left) one is the
I have an annoying CSS layout problem. I'm trying to float images on a

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.