blob: 3acfb598535089ba49254c3ffa60072083a57025 [file] [log] [blame]
Geoff Lang49be2ad2014-02-28 13:05:51 -05001//
2// Copyright (c) 2014 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#ifndef SAMPLE_UTIL_SAMPLE_APPLICATION_H
8#define SAMPLE_UTIL_SAMPLE_APPLICATION_H
9
Geoff Lange977efc2014-03-04 11:43:04 -050010#include <EGL/egl.h>
11#include <EGL/eglext.h>
Geoff Lang49be2ad2014-02-28 13:05:51 -050012
Jamie Madill1cfaaf82014-08-21 10:04:04 -040013#include "OSWindow.h"
Geoff Lang49be2ad2014-02-28 13:05:51 -050014#include "Timer.h"
15
16#include <string>
17#include <list>
18#include <cstdint>
19#include <memory>
20
Jamie Madill1cfaaf82014-08-21 10:04:04 -040021class EGLWindow;
22
Geoff Lang49be2ad2014-02-28 13:05:51 -050023class SampleApplication
24{
25 public:
Jamie Madill96e46cd2014-04-07 15:51:15 -040026 SampleApplication(const std::string& name, size_t width, size_t height,
Corentin Wallez98e7d072015-05-07 12:35:47 -070027 EGLint glesMajorVersion = 2, EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
Geoff Lang49be2ad2014-02-28 13:05:51 -050028 virtual ~SampleApplication();
29
30 virtual bool initialize();
31 virtual void destroy();
32
33 virtual void step(float dt, double totalTime);
34 virtual void draw();
35
Geoff Lange977efc2014-03-04 11:43:04 -050036 virtual void swap();
37
Jamie Madill1cfaaf82014-08-21 10:04:04 -040038 OSWindow *getWindow() const;
Geoff Lange977efc2014-03-04 11:43:04 -050039 EGLConfig getConfig() const;
Geoff Langf0955f12014-06-20 16:07:07 -040040 EGLDisplay getDisplay() const;
Geoff Lange977efc2014-03-04 11:43:04 -050041 EGLSurface getSurface() const;
42 EGLContext getContext() const;
Geoff Lang49be2ad2014-02-28 13:05:51 -050043
44 bool popEvent(Event *event);
45
46 int run();
47 void exit();
48
49 private:
Geoff Lang49be2ad2014-02-28 13:05:51 -050050 std::string mName;
Geoff Lang49be2ad2014-02-28 13:05:51 -050051 bool mRunning;
52
53 std::unique_ptr<Timer> mTimer;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040054 std::unique_ptr<EGLWindow> mEGLWindow;
Jamie Madill586666c2014-08-21 10:04:05 -040055 std::unique_ptr<OSWindow> mOSWindow;
Geoff Lang49be2ad2014-02-28 13:05:51 -050056};
57
58#endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H