Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/samples/gles1/HelloTriangle.cpp
2578 views
1
//
2
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
// Based on Hello_Triangle.c from
8
// Book: OpenGL(R) ES 2.0 Programming Guide
9
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
10
// ISBN-10: 0321502795
11
// ISBN-13: 9780321502797
12
// Publisher: Addison-Wesley Professional
13
// URLs: http://safari.informit.com/9780321563835
14
// http://www.opengles-book.com
15
16
#include "SampleApplication.h"
17
#include "util/shader_utils.h"
18
19
class GLES1HelloTriangleSample : public SampleApplication
20
{
21
public:
22
GLES1HelloTriangleSample(int argc, char **argv)
23
: SampleApplication("GLES1HelloTriangle", argc, argv, 1, 0)
24
{}
25
26
bool initialize() override
27
{
28
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
29
30
return true;
31
}
32
33
void draw() override
34
{
35
GLfloat vertices[] = {
36
0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f,
37
};
38
39
glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());
40
glClear(GL_COLOR_BUFFER_BIT);
41
42
glEnableClientState(GL_VERTEX_ARRAY);
43
glVertexPointer(3, GL_FLOAT, 0, vertices);
44
45
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
46
47
glDrawArrays(GL_TRIANGLES, 0, 3);
48
}
49
};
50
51
int main(int argc, char **argv)
52
{
53
GLES1HelloTriangleSample app(argc, argv);
54
return app.run();
55
}
56
57