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

  • Home
  • SEARCH
  • 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 6715987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:40:46+00:00 2026-05-26T08:40:46+00:00

i am rendering a 3d surface in opengl by drawing a bunch of triangles.

  • 0

i am rendering a 3d surface in opengl by drawing a bunch of triangles. some of my primitives are see through. i don’t simply mean that there is a blending of the color behind them, i mean that i can see completely through them. i have no idea why i am able to see through these primitives and would not like that to be the case (unless i specify alpha blending which i have not).

unfortunately i cannot link any code (there are ~1800 lines right now and i don’t know where the error would be!), but any help would be great.

i hope i have given enough information, if not, please feel free to ask for me to clarify!

EDIT: more info …

i call plotPrim(ix,iy,iz) which uses cube marching to plot a triangle (or a few) through the current cube of a rectangular grid.

myInit() is …

void myInit()
{
// initialize vectors
update_vectors();
// set initial color to white
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_BLEND | GL_DEPTH_TEST);
}

plotMesh() is where i do my work of going through each cube and plotting the primitives

void plotMesh()                             //
{
if(plot_prop)
{
    // do some stuff
}
else
{
    glBegin(GL_TRIANGLES);
    for(int ix = 0; ix < snx-1; ix++)
    {
        //x = surf_x[ix];
        for(int iy = 0; iy < sny-1; iy++)
        {
            //y = surf_y[iy];
            for(int iz = 0; iz < snz-1; iz++)
            {
                //z = surf_z[iz];

                // front face
                a = sv(ix+0, iy+0, iz+0);
                b = sv(ix+0, iy+1, iz+0);
                g = sv(ix+0, iy+0, iz+1);
                d = sv(ix+0, iy+1, iz+1);
                // back face
                al = sv(ix+1, iy+0, iz+0);
                be = sv(ix+1, iy+1, iz+0);
                ga = sv(ix+1, iy+0, iz+1);
                de = sv(ix+1, iy+1, iz+1);

                // test to see if a primitive needs to be plotted
                plotPrim(ix, iy, iz);

            }
        }
    }
    glEnd();
}

}

one example of a primitive being plotted in plotPrim() is ….

if(val>a && val<g && val<b && val<al || val<a && val>g && val>b && val>al) // "a" corner
{
    tx = (val-a)/(al-a);
    ty = (val-a)/(b-a);
    tz = (val-a)/(g-a);

    x1 = surf_x[ix] + tx*surf.dx;
    y1 = surf_y[iy];
    z1 = surf_z[iz];

    x2 = surf_x[ix];
    y2 = surf_y[iy] + ty*surf.dy;
    z2 = surf_z[iz];

    x3 = surf_x[ix];
    y3 = surf_y[iy];
    z3 = surf_z[iz] + tz*surf.dz;

    getColor( (1.0-tx)*sv(ix,iy,iz) + tx*sv(ix+1,iy,iz) );
    glVertex3f(x1,y1,z1);
    getColor( (1.0-ty)*sv(ix,iy,iz) + ty*sv(ix,iy+1,iz) );
    glVertex3f(x2,y2,z2);
    getColor( (1.0-tz)*sv(ix,iy,iz) + tz*sv(ix,iy,iz+1) );
    glVertex3f(x3,y3,z3);
}
  • 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-26T08:40:46+00:00Added an answer on May 26, 2026 at 8:40 am
    glEnable(GL_BLEND | GL_DEPTH_TEST);
    

    is wrong as glEnable only takes a single capability to enable, not a bitmask. You might have more errors, but you want to change the above to:

    glEnable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a platform using VCL TFrame as rendering surface for OpenGL. Using FireMonkey,
I have made a window with an NSOpenGLView that I am rendering openGL content
I want to make a custom VCL control that wraps a SDL rendering surface
While rendering the view page, based on some condition in the controller action I
I was wondering if there was any tutorial that introduces 3D Graphics theory while
I have some Qt applications rendered using OpenGL on surfaces provided by an EGL
I am rendering a scene to a texture, then using that texture and its
I'm looking for an API or some sort of solution to do 3d surface
My concern are quadratic bezier triangles which I'm trying to tesselate for rendering them.
I don't really have any problems with the way I'm rendering now, but I

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.