Пример #1
0
void gluLookAt(
    GLfloat eyex, 
    GLfloat eyey, 
    GLfloat eyez, 
    GLfloat centerx, 
    GLfloat centery, 
    GLfloat centerz, 
    GLfloat upx, 
    GLfloat upy, 
    GLfloat upz)
{
	//ref: http://www.manpagez.com/man/3/gluLookAt/
	//ref: http://www.opengl.org/wiki/GluLookAt_code

	float matrix[16], 
		eyePosition3D[3] = {eyex, eyey, eyez }, 
		center3D[3] = {centerx, centery, centerz }, 
		upVector3D[3] = {upx, upy, upz };
#ifdef BUILD_USE_GLHLIB
	glhLoadIdentityf2(matrix);
	glhLookAtf2(matrix, eyePosition3D, center3D, upVector3D);
	glMultMatrixf(matrix);
#else
	glhLookAtf2(matrix, eyePosition3D, center3D, upVector3D);
#endif
}
Пример #2
0
RENDERING_SERVICE_API int rs_render_simple_obj(const SimpleStaticObject* obj, const SimpleTransform* xform)
{
    if (!IsValidStaticObject(obj) || !xform)
    {
        return -1;
    }

    CLSALIGN16 float m[16], rot44[16];
    CLSALIGN16 float xyzw[4] = { xform->x, xform->y, xform->z, 1.0f };
    CLSALIGN16 float scale[4] = { 3.0f, 3.0f, 5.0f/2, 1.0f };
    CLSALIGN16 float zaxis[4] = { 0.0f, 0.0f, 1.0f, 0.0f };

    glhLoadIdentityf2(m);
    glhTranslatef2_SSE_Aligned(m, xyzw);
    glhScalef2_SSE_Aligned(m, scale);
    //glhMultMatrixf2_SSE_Aligned(m, rot44);
    glhRotatef2_SSE_Aligned(m, (float)M_PI, zaxis);

    float uvx[9];
    glhLoadIdentity3f2(uvx);
    glUniformMatrix3fv(xform->uniUvx, 1, GL_FALSE, (GLfloat*)uvx);

    //SetUniMvp(m, v, p);

    glBindTexture(GL_TEXTURE_2D, obj->texId);
    glBindVertexArray(obj->vb.varray);
    glDrawArrays(GL_TRIANGLES, 0, obj->vb.len);
    glBindVertexArray(0);

    return 0;
}
Пример #3
0
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
	//glPushMatrix();
	//glTranslatef(translation.x, translation.y, 0);
    CLSALIGN16 float mat[16];
    CLSALIGN16 float xyzw[] = { translation.x, translation.y, 0, 1 };
    glhLoadIdentityf2(mat);
    glhTranslatef2_SSE_Aligned(mat, xyzw);
    rs_set_rocket_model_matrix(mat);

    Draw2DElementsParam param;
    param.num_vertices = num_vertices;
    param.vertex = &vertices[0].position;
    param.color = &vertices[0].colour;
    param.texCoord = &vertices[0].tex_coord;
    param.stride = sizeof(Rocket::Core::Vertex);
    param.texture = texture;
    param.num_indices = num_indices;
    param.indices = indices;

    rs_draw_2d_elements(&param);

	//glVertexPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].position);
	//glEnableClientState(GL_COLOR_ARRAY);
	//glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rocket::Core::Vertex), &vertices[0].colour);

	//if (!texture)
	//{
	//	glDisable(GL_TEXTURE_2D);
	//	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	//}
	//else
	//{
	//	glEnable(GL_TEXTURE_2D);
	//	glBindTexture(GL_TEXTURE_2D, (GLuint) texture);
	//	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	//	glTexCoordPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].tex_coord);
	//}

	//glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);

	//glPopMatrix();
}