Ejemplo n.º 1
0
void initScene() {
    // Clear
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Set drawing mode
    glMatrixMode(GL_MODELVIEW);

    // Draw scene
    glLoadIdentity();
    glTranslatef(0.0f,0.0f,-7.0f);

    // Draw lighting
	GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f}; //Color (0.2, 0.2, 0.2)
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

    //Add positioned light
	GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5)
	GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8)
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

	//Add directed light
	GLfloat lightColor1[] = {0.7f, 0.7f, 0.7f, 1.0f}; //Color (0.5, 0.2, 0.2)
	//Coming from the direction (-1, 0.5, 0.5)
	GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);

    // Draw the cube
    Cube.draw(_textureId);

    glutSwapBuffers();
}
Ejemplo n.º 2
0
Archivo: geom.cpp Proyecto: jokoon/eio
    void draw_indexed(){
        // render
        // ------
        glEnable(GL_DEPTH_TEST);
        glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // bind textures on corresponding texture units
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_1D, mi.texture);
        // glActiveTexture(GL_TEXTURE1);
        // glBindTexture(GL_TEXTURE_2D, geom::texture2);

        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

        // activate shader
        geom::shader_lowpoly.use();

        // pass projection matrix to shader (note that in this case it could change every frame)
        glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), float(SCR_WIDTH) / float(SCR_HEIGHT), 0.1f, 100.0f);
        geom::shader_lowpoly.setMat4("projection", projection);

        // camera/view transformation
        glm::mat4 view = fixed_cam?fixed_transform: camera.GetViewMatrix();
        geom::shader_lowpoly.setMat4("view", view);

        // render boxes
            // glBindVertexArray(geom::mi.VAO);
            // for (unsigned int i = 0; i < 10; i++)
            // {
            //     // calculate the model matrix for each object and pass it to shader before drawing
            //     glm::mat4 model;
            //     model = glm::translate(model, cubePositions[i]);
            //     float angle = 20.0f * i;
            //     model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
            //     geom::shader_lowpoly.setMat4("model", model);
            //     glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
            // }

        glm::mat4 model;// = glm::translate(model, cubePositions[i]);
        // model = glm::translate(model, {-5,-2,-5});
        geom::shader_lowpoly.setMat4("model", model);

        glBindVertexArray(geom::mi2.VAO);
        glDrawElements(GL_TRIANGLES, mi2.triangles, GL_UNSIGNED_INT, 0);

        cb.draw();
        for(auto&cb:cubes){ cb.draw(); }
        draw_mesh(wall);
        // physics::chtr.cb.draw();

        character_control::cb.draw();

        dlines.draw();
        character_control:: lines.draw();
        dpoints.draw();
        debug_spheres.draw();
        // dpoints.make_points(vector<vec3>(1000, { 0,0,0 }));


        }