~ppsspp/ppsspp/ppsspp-1.1.1

« back to all changes in this revision

Viewing changes to Windows/GEDebugger/SimpleGLWindow.h

  • Committer: Sérgio Benjamim
  • Date: 2015-10-17 01:37:55 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20151017013755-avrlz2pt37kwt43x
PPSSPP 1.1.1 source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2012- PPSSPP Project.
 
2
 
 
3
// This program is free software: you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation, version 2.0 or later versions.
 
6
 
 
7
// This program is distributed in the hope that it will be useful,
 
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
// GNU General Public License 2.0 for more details.
 
11
 
 
12
// A copy of the GPL 2.0 should have been included with the program.
 
13
// If not, see http://www.gnu.org/licenses/
 
14
 
 
15
// Official git repository and contact information can be found at
 
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
 
17
 
 
18
#pragma once
 
19
 
 
20
#include "base/functional.h"
 
21
#include "gfx_es2/glsl_program.h"
 
22
#include "Common/CommonWindows.h"
 
23
#include "Globals.h"
 
24
 
 
25
struct SimpleGLWindow {
 
26
        static const PTCHAR windowClass;
 
27
 
 
28
        enum Format {
 
29
                FORMAT_565_REV = 0x00,
 
30
                FORMAT_5551_REV = 0x01,
 
31
                FORMAT_4444_REV = 0x02,
 
32
                FORMAT_8888 = 0x03,
 
33
                FORMAT_565 = 0x04,
 
34
                FORMAT_5551 = 0x05,
 
35
                FORMAT_4444 = 0x06,
 
36
                FORMAT_5551_BGRA_REV = 0x09,
 
37
                FORMAT_4444_BGRA_REV = 0x0A,
 
38
                FORMAT_8888_BGRA = 0x0B,
 
39
 
 
40
                FORMAT_FLOAT = 0x10,
 
41
                FORMAT_16BIT = 0x11,
 
42
                FORMAT_8BIT = 0x12,
 
43
                FORMAT_24BIT_8X = 0x13,
 
44
                FORMAT_24X_8BIT = 0x14,
 
45
        };
 
46
 
 
47
        enum Flags {
 
48
                RESIZE_NONE = 0x00,
 
49
                RESIZE_CENTER = 0x02,
 
50
                RESIZE_SHRINK_FIT = 0x01,
 
51
                RESIZE_SHRINK_CENTER = 0x03,
 
52
                ALPHA_IGNORE = 0x00,
 
53
                ALPHA_BLEND = 0x04,
 
54
        };
 
55
 
 
56
        SimpleGLWindow(HWND wnd);
 
57
        ~SimpleGLWindow();
 
58
 
 
59
        void Clear();
 
60
        void Draw(const u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888);
 
61
        void Redraw(bool andSwap = true);
 
62
        void Initialize(u32 flags);
 
63
        static SimpleGLWindow *GetFrom(HWND hwnd);
 
64
        static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
 
65
 
 
66
        // To draw something custom.
 
67
        void Begin();
 
68
        void End();
 
69
 
 
70
        void SetFlags(u32 flags) {
 
71
                flags_ = flags;
 
72
        }
 
73
 
 
74
        void Swap() {
 
75
                SwapBuffers(hDC_);
 
76
        }
 
77
 
 
78
        int Width() {
 
79
                return w_;
 
80
        }
 
81
 
 
82
        int Height() {
 
83
                return h_;
 
84
        }
 
85
 
 
86
        bool HasTex() {
 
87
                return tw_ > 0 && th_ > 0;
 
88
        }
 
89
 
 
90
        int TexWidth() {
 
91
                return tw_;
 
92
        }
 
93
 
 
94
        int TexHeight() {
 
95
                return th_;
 
96
        }
 
97
 
 
98
        void GetContentSize(float &x, float &y, float &fw, float &fh);
 
99
 
 
100
        void SetHoverCallback(std::function<void(int, int)> hoverCallback) {
 
101
                hoverCallback_ = hoverCallback;
 
102
        }
 
103
 
 
104
        static void RegisterClass();
 
105
protected:
 
106
        void SetupGL();
 
107
        void ResizeGL(int w, int h);
 
108
        void CreateProgram();
 
109
        void GenerateChecker();
 
110
        void DrawChecker();
 
111
        bool DragStart(int mouseX, int mouseY);
 
112
        bool DragContinue(int mouseX, int mouseY);
 
113
        bool DragEnd(int mouseX, int mouseY);
 
114
        bool Hover(int mouseX, int mouseY);
 
115
        bool Leave();
 
116
        bool ToggleZoom();
 
117
        const u8 *Reformat(const u8 *data, Format fmt, u32 numPixels);
 
118
 
 
119
        HWND hWnd_;
 
120
        HDC hDC_;
 
121
        HGLRC hGLRC_;
 
122
        bool valid_;
 
123
        // Width and height of the window.
 
124
        int w_;
 
125
        int h_;
 
126
        // Last texture size/flipped for Redraw().
 
127
        int tw_;
 
128
        int th_;
 
129
        bool tflipped_;
 
130
 
 
131
        GLSLProgram *drawProgram_;
 
132
        GLuint checker_;
 
133
        GLuint tex_;
 
134
        u32 flags_;
 
135
        // Disable shrink (toggled by double click.)
 
136
        bool zoom_;
 
137
        bool dragging_;
 
138
        int dragStartX_;
 
139
        int dragStartY_;
 
140
        u32 dragLastUpdate_;
 
141
        // Offset to position the texture is drawn at.
 
142
        int offsetX_;
 
143
        int offsetY_;
 
144
        u32 *reformatBuf_;
 
145
        u32 reformatBufSize_;
 
146
 
 
147
        std::function<void(int, int)> hoverCallback_;
 
148
};
 
 
b'\\ No newline at end of file'