/* * Copyright © 2012 Linaro Limited * * This file is part of OpenGl ES2 test suite for piglit * * glmark2 is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * glmark2. If not, see . * * Authors: * Tom Gall */ #include "scene.h" #include "mat.h" #include "stack.h" #include "vec.h" #include "log.h" #include "program.h" #include "shader-source.h" #include "texture.h" #include "model.h" #include "util.h" #include using LibMatrix::vec3; using std::string; SceneSimpleTriangle::SceneSimpleTriangle(Canvas &pCanvas) : Scene(pCanvas, "simpletriangle"), radius_(0.0), orientModel_(false), orientationAngle_(0.0) { duration_=30; // set for 30 seconds } SceneSimpleTriangle::~SceneSimpleTriangle() { } bool SceneSimpleTriangle::load() { running_ = false; return true; } void SceneSimpleTriangle::unload() { } bool SceneSimpleTriangle::setup() { if (!Scene::setup()) return false; static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/basic-triangle.vert"); static const std::string frg_shader_filename(GLMARK_DATA_PATH"/shaders/basic-triangle.frag"); // Load shaders ShaderSource vtx_source; vtx_source.append_file(vtx_shader_filename); ShaderSource frg_source; frg_source.append_file(frg_shader_filename); if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { return false; } program_.start(); currentFrame_ = 0; running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; return true; } void SceneSimpleTriangle::teardown() { program_.stop(); program_.release(); Scene::teardown(); } void SceneSimpleTriangle::update() { Scene::update(); } void SceneSimpleTriangle::draw() { GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f }; // Set the viewport glViewport ( 0, 0, 320, 200 ); // Clear the color buffer glClear ( GL_COLOR_BUFFER_BIT ); //program_.start(); // Use the program object //glUseProgram ( userData->programObject ); // Load the vertex data glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); glEnableVertexAttribArray ( 0 ); glDrawArrays ( GL_TRIANGLES, 0, 3 ); } Scene::ValidationResult SceneSimpleTriangle::validate() { return Scene::ValidationSuccess; }