| 1 |
/* |
| 2 |
* Copyright (C) 2005-2021 Team Kodi (https://kodi.tv) |
| 3 |
* Copyright (C) 2005 Joakim Eriksson <[email protected]> |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSE.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
/***************************** D E F I N E S *******************************/ |
| 12 |
/****************************** M A C R O S ********************************/ |
| 13 |
/***************************** C L A S S E S *******************************/ |
| 14 |
|
| 15 |
//////////////////////////////////////////////////////////////////////////// |
| 16 |
// |
| 17 |
|
| 18 |
#ifndef WIN32 |
| 19 |
#include <kodi/gui/gl/Shader.h> |
| 20 |
#include <glm/glm.hpp> |
| 21 |
#include <glm/gtc/type_ptr.hpp> |
| 22 |
#endif |
| 23 |
#include <kodi/AddonBase.h> |
| 24 |
|
| 25 |
typedef struct TRenderVertex |
| 26 |
{ |
| 27 |
CVector pos; |
| 28 |
CRGBA col; |
| 29 |
} TRenderVertex; |
| 30 |
|
| 31 |
//////////////////////////////////////////////////////////////////////////// |
| 32 |
// |
| 33 |
class CPaddel |
| 34 |
{ |
| 35 |
public: |
| 36 |
CVector m_Pos; |
| 37 |
CVector m_Size; |
| 38 |
CRGBA m_Col; |
| 39 |
|
| 40 |
CPaddel() |
| 41 |
{ |
| 42 |
m_Pos.Zero(); |
| 43 |
m_Size.Set(1.0f, 20.0f, 0.0f); |
| 44 |
m_Col.Set(1.0f, 1.0f, 1.0f, 1.0f); |
| 45 |
} |
| 46 |
}; |
| 47 |
|
| 48 |
//////////////////////////////////////////////////////////////////////////// |
| 49 |
// |
| 50 |
class CBall |
| 51 |
{ |
| 52 |
public: |
| 53 |
CVector m_Pos; |
| 54 |
CVector m_Vel; |
| 55 |
CVector m_Size; |
| 56 |
CRGBA m_Col; |
| 57 |
|
| 58 |
CBall() |
| 59 |
{ |
| 60 |
m_Pos.Set(300,300,0.0); |
| 61 |
m_Vel.Zero(); |
| 62 |
m_Size.Set(2.0f, 2.0f, 2.0f); |
| 63 |
m_Col.Set(1.0f, 1.0f, 1.0f, 1.0f); |
| 64 |
} |
| 65 |
}; |
| 66 |
|
| 67 |
//////////////////////////////////////////////////////////////////////////// |
| 68 |
// |
| 69 |
class ATTR_DLL_LOCAL CPingPong |
| 70 |
#ifndef WIN32 |
| 71 |
: kodi::gui::gl::CShaderProgram |
| 72 |
#endif |
| 73 |
{ |
| 74 |
public: |
| 75 |
CPingPong(); |
| 76 |
~CPingPong(); |
| 77 |
bool RestoreDevice(CRenderD3D* render); |
| 78 |
void InvalidateDevice(CRenderD3D* render); |
| 79 |
void Update(f32 dt); |
| 80 |
bool Draw(CRenderD3D* render); |
| 81 |
|
| 82 |
CPaddel m_Paddle[2]; |
| 83 |
CBall m_Ball; |
| 84 |
int topy; |
| 85 |
int bottomy; |
| 86 |
int m_Width = 0; |
| 87 |
int m_Height = 0; |
| 88 |
protected: |
| 89 |
TRenderVertex* AddQuad(TRenderVertex* vert, const CVector& pos, const CVector& size, const CRGBA& col); |
| 90 |
|
| 91 |
#ifndef WIN32 |
| 92 |
void OnCompiledAndLinked() override; |
| 93 |
bool OnEnabled() override; |
| 94 |
|
| 95 |
glm::mat4 m_projMat; |
| 96 |
GLuint m_vertexVBO; |
| 97 |
GLuint m_indexVBO; |
| 98 |
GLint m_uProjMatrix = -1; |
| 99 |
GLint m_aPosition = -1; |
| 100 |
GLint m_aColor = -1; |
| 101 |
#endif |
| 102 |
}; |