Path: blob/main_old/samples/gles1/HelloTriangle.cpp
2578 views
//1// Copyright 2018 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56// Based on Hello_Triangle.c from7// Book: OpenGL(R) ES 2.0 Programming Guide8// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner9// ISBN-10: 032150279510// ISBN-13: 978032150279711// Publisher: Addison-Wesley Professional12// URLs: http://safari.informit.com/978032156383513// http://www.opengles-book.com1415#include "SampleApplication.h"16#include "util/shader_utils.h"1718class GLES1HelloTriangleSample : public SampleApplication19{20public:21GLES1HelloTriangleSample(int argc, char **argv)22: SampleApplication("GLES1HelloTriangle", argc, argv, 1, 0)23{}2425bool initialize() override26{27glClearColor(0.0f, 0.0f, 0.0f, 0.0f);2829return true;30}3132void draw() override33{34GLfloat vertices[] = {350.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f,36};3738glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());39glClear(GL_COLOR_BUFFER_BIT);4041glEnableClientState(GL_VERTEX_ARRAY);42glVertexPointer(3, GL_FLOAT, 0, vertices);4344glColor4f(1.0f, 0.0f, 0.0f, 1.0f);4546glDrawArrays(GL_TRIANGLES, 0, 3);47}48};4950int main(int argc, char **argv)51{52GLES1HelloTriangleSample app(argc, argv);53return app.run();54}555657