Results 1 to 3 of 3

Thread: Transparent object Problem

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Augsburg, Bayern, Germany
    Posts
    6

    Transparent object Problem

    I tried to display something but it always seems to be transparent. Please help me to show everything solid.

    Heres my code:


    void GLSetupRC(void *pData)
    {

    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glEnable(GL_CULL_FACE);
    glFrontFace(GL_CCW);

    GLfloat ambientLight[] = { 0.1f, 0.1f, 0.1f, 1.0f };
    GLfloat diffuseLight[] = { 0.6f, 0.6f, 0.6f, 1.0f };
    GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f};
    GLfloat lightPos[] = { 0.0f, -30.0f, 150.0f, 1.0f };
    GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };

    glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
    glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
    glLightfv(GL_LIGHT0,GL_SPECULAR,specular);
    glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
    glEnable(GL_LIGHTING);

    glEnable(GL_COLOR_MATERIAL);


    glEnable(GL_LIGHT0);
    BuildFont();
    }

    void GLRenderScene(void *pData)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    GLfloat specular2[] = { 1.0f, 1.0f, 1.0f, 0.0f};
    GLfloat specular1[] = { 0.0f, 0.0f, 0.0f, 0.0f};
    glPushMatrix();
    i+= 1.0 ;
    glTranslatef(0,0,15);
    glRotated(i, 0.0, 1.0, 0.0);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,specula r1);
    glColor3f(0.95f, 0.49f, 0.0f);
    obj1_mat1();
    obj2_mat2();
    obj3_mat3();
    obj4_mat4();

    glPopMatrix();

    glPushMatrix();
    glMaterialfv(GL_FRONT,GL_EMISSION,specular2);
    glColor3f(1.0f, 1.0f, 1.0f);
    glTranslatef(0.0f,0.0f,-3.0f);
    glPrint(0,11,"So verstehen wir uns...");

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Transparent object Problem

    Some questions that might help:
    Do you need the emissive materials? They have alpha = 0.
    Does that work as you expect it in conjunction with GL_COLOR_MATERIAL enabled?
    Why do you clear the color buffer with alpha = 0.5? Do you have some destination alpha blending in the program? Is it enabled/disabled properly when you draw your objects?

    I forgot one: Do you have depth test enabled?
    Maybe the face culling alone doesn't do the job with your objects.


    [This message has been edited by Relic (edited 06-27-2000).]

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Augsburg, Bayern, Germany
    Posts
    6

    Re: Transparent object Problem

    Thank You that you tried to help me.
    Ill try to answer your questions.

    I need emissive Materials because otherways the text that Im drawing is not white, but grey.
    Im a beginner an I dont know exactly why Im using some thins in the code. Im learning by doing, but sometimes that doesnt work.

Similar Threads

  1. Stripes on a transparent object
    By bliss in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-22-2011, 06:34 PM
  2. Problem of transparent.object (overlapping part)
    By HanWu in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-03-2010, 06:44 AM
  3. How to render a transparent textured object
    By lucafr in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-05-2008, 12:49 PM
  4. transparent object
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-09-2003, 04:13 AM
  5. the transparent object with light
    By ding in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-25-2002, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean