Results 1 to 2 of 2

Thread: Materials and blending question (blank screen)

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    3

    Materials and blending question (blank screen)

    Are materials affected differently than colors in blending?

    Something simple like this was producing a blank screen:

    Code :
            //init
     
    	glClearColor(100.0/256, 100.0/256, 100.0/256, 0);
    	glClearDepth(1.0f);
     
    	//lighting setup
    	glEnable (GL_DEPTH_TEST);
        glEnable (GL_LIGHTING); 
        glEnable (GL_LIGHT0); 
        glShadeModel (GL_SMOOTH); 
     
    	glViewport(0, 0, (GLsizei)width, (GLsizei)height);
     
     
    	glMatrixMode(GL_PROJECTION);
    	gluPerspective(fovy, (GLfloat)width/(GLfloat)height, 1, 100 );
     
            glMatrixMode(GL_MODELVIEW);
    	glEnable(GL_TEXTURE_2D);
     
    	glEnable( GL_BLEND );
    	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    Code :
            //render
     
            GLfloat blankMaterial[] = {0.0, 0.0, 0.0};
            GLfloat redDiffuseMaterial[] = {1.0f, 0.0f, 0.0f}; 
            GLfloat mShininess0[] = {0};
     
            //lighting
    	GLfloat DiffuseLight[] = {1.0f, 1.0f, 1.0f};
    	GLfloat LightPosition[] = {0.0f, 0.0f, 0.0f, 1.0f};
    	GLfloat AmbientLight[] = {0.0f, 0.0f, 0.0f};
    	GLfloat whiteSpecularLight[] = {1.0, 1.0, 1.0};
     
    	glLightfv (GL_LIGHT0, GL_AMBIENT, AmbientLight);
    	glLightfv(GL_LIGHT0, GL_SPECULAR, whiteSpecularLight);
    	glLightfv (GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
    	glLightfv (GL_LIGHT0, GL_POSITION, LightPosition);
     
    	//end lighting
     
    	GLfloat radius, height;
     
    	glPushMatrix();
    	glTranslatef(0.0f, 0.0f, -5.0f);
    	glRotatef( 140, 1.0f, 0.0f, 0.0f );
     
    	//Render inner Cylinder
    		radius = 1.f;
    		height = .2f;
    		quadratic=gluNewQuadric();
     
    		glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, redDiffuseMaterial);
    		glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, blankMaterial);
    		glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mShininess0);
    		gluQuadricOrientation(quadratic,GLU_OUTSIDE);
     
    		gluCylinder(quadratic, radius, radius, .2f, 1000, 1);
     
    		//cap
    		gluQuadricOrientation(quadratic,GLU_INSIDE);
    		gluDisk( quadratic, 0.0, radius, 1000, 1);
     
             glPopMatrix();

    but if i take out
    Code :
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    then I can see my objects

    I'm trying to place a texture on the top of the cylinder, so I have a transparent png being loaded as a texture. The texture works, but I can't seem to combine the two.

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Materials and blending question (blank screen)

    I'm trying to place a texture on the top of the cylinder, so I have a transparent png being loaded as a texture. The texture works, but I can't seem to combine the two.
    I don't see any texture binding in your code posted.
    We can't comment on what we can't see.

Similar Threads

  1. blank screen
    By sajis997 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-30-2014, 05:32 AM
  2. Blank Screen
    By imported_JoshKlint in forum OpenGL: Linux
    Replies: 1
    Last Post: 09-16-2013, 10:40 PM
  3. getting blank screen
    By marysowdha in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-07-2001, 01:39 PM
  4. getting blank screen
    By marysowdha in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-06-2001, 02:51 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