Ejemplo n.º 1
0
static void configureLightAndMaterial()
{
    static GLfixed light0Position[] = { -0x40000, 0x10000, 0x10000, 0 };
    static GLfixed light0Diffuse[] = { 0x10000, 0x6666, 0, 0x10000 };
    static GLfixed light1Position[] = { 0x10000, -0x20000, -0x10000, 0 };
    static GLfixed light1Diffuse[] = { 0x11eb, 0x23d7, 0x5999, 0x10000 };
    static GLfixed light2Position[] = { -0x10000, 0, -0x40000, 0 };
    static GLfixed light2Diffuse[] = { 0x11eb, 0x2b85, 0x23d7, 0x10000 };
    static GLfixed materialSpecular[] = { 0x10000, 0x10000, 0x10000, 0x10000 };

    glLightxv(GL_LIGHT0, GL_POSITION, light0Position);
    glLightxv(GL_LIGHT0, GL_DIFFUSE, light0Diffuse);
    glLightxv(GL_LIGHT1, GL_POSITION, light1Position);
    glLightxv(GL_LIGHT1, GL_DIFFUSE, light1Diffuse);
    glLightxv(GL_LIGHT2, GL_POSITION, light2Position);
    glLightxv(GL_LIGHT2, GL_DIFFUSE, light2Diffuse);
    glMaterialxv(GL_FRONT_AND_BACK, GL_SPECULAR, materialSpecular);

    glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, 60 << 16);
    glEnable(GL_COLOR_MATERIAL);
}
void glMaterialxvLogged(GLenum face, GLenum pname, const GLfixed *params) {
	printf("glMaterialxv(%s, %s, %p)\n", GLEnumName(face), GLEnumName(pname), params);
	glMaterialxv(face, pname, params);
}
Ejemplo n.º 3
0
/*!
* \brief	Updates the OpenGL ES state
* \param	width	Rendering width.
* \param	height	Rendering height.
*//*-------------------------------------------------------------------*/
static void updateOpenGLESState(int width, int height)
{
    /* Define lights and materials for the OpenGL ES scene */
    static const GLfixed light_position[]	= { F2F(-50.f), F2F(50.f), F2F(50.f), F2F(0.0f) };
    static const GLfixed light_ambient[]	= { F2F(0.125f), F2F(0.125f), F2F(0.125f), F2F(1.0f) };
    static const GLfixed light_diffuse[]	= { F2F(0.7f), F2F(0.7f), F2F(0.7f), F2F(1.0f) };
    static const GLfixed material_spec[]	= { F2F(0.7f), F2F(0.7f), F2F(0.7f), F2F(0.0f) };
    static const GLfixed zero_vec4[]		= { F2F(0.0f), F2F(0.0f), F2F(0.0f), F2F(0.0f) };

    /* Define the aspect ratio for the perpective calculations so that 
    no distortion happens when the screen is resized */
    float aspect		= height ? (float)width/(float)height : 1.0f;

    glViewport			(0, 0, width, height);
    glScissor			(0, 0, width, height);

    /* Set the matrix mode to world coordinates */
    glMatrixMode		(GL_MODELVIEW);
    glLoadIdentity		();

    /* Setup lights and materials with the values given above */
    glLightxv			(GL_LIGHT0, GL_POSITION, light_position);
    glLightxv			(GL_LIGHT0, GL_AMBIENT, light_ambient);
    glLightxv			(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightxv			(GL_LIGHT0, GL_SPECULAR, zero_vec4);
    glMaterialxv		(GL_FRONT_AND_BACK, GL_SPECULAR, material_spec);

    /* Enable ligting, materials, backface culling and textures */
    glDisable			(GL_NORMALIZE);
    glEnable			(GL_LIGHTING);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ZERO);
    
    glEnable			(GL_LIGHT0);
    glEnable			(GL_COLOR_MATERIAL);
    glEnable			(GL_CULL_FACE);
    glEnable			(GL_TEXTURE_2D);

    /* Tell OpenGL to use nicest perspective correction */
    glHint				(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    /* Use flat shading and disable dithering */
    glShadeModel		(GL_FLAT);
    glDisable			(GL_DITHER);

    /* Setup the clear color and the current color for the OpenGL context */
    glClearColorx		(F2F(0.1f), F2F(0.2f), F2F(0.4f), F2F(1.f));
    glColor4x			(0x10000, 0x10000, 0x10000, 0x10000);

    /* Enable the use of vertex, normal and texture coordinate arrays */
    glEnableClientState	(GL_VERTEX_ARRAY);
    glEnableClientState	(GL_NORMAL_ARRAY);
    glEnableClientState	(GL_TEXTURE_COORD_ARRAY);

    /* Mipmaps do not work on all BREW devices, so disable it */
/*    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);*/
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    /* Update the projection matrix */
    glMatrixMode		(GL_PROJECTION);
    glLoadIdentity		();
    setGLESperspective	(60.f, aspect, 0.1f, 100.f);
}