2013-09-22 19:05:33 -07:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "gfx_es2/glsl_program.h"
|
|
|
|
|
#include "Common/CommonWindows.h"
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
|
|
struct SimpleGLWindow {
|
|
|
|
|
static const PTCHAR windowClass;
|
|
|
|
|
|
2013-09-22 22:25:55 -07:00
|
|
|
enum Format {
|
2013-11-11 00:42:33 -08:00
|
|
|
FORMAT_565_REV = 0,
|
|
|
|
|
FORMAT_5551_REV = 1,
|
|
|
|
|
FORMAT_4444_REV = 2,
|
2013-09-22 22:25:55 -07:00
|
|
|
FORMAT_8888 = 3,
|
2013-11-11 00:42:33 -08:00
|
|
|
FORMAT_565 = 4,
|
|
|
|
|
FORMAT_5551 = 5,
|
|
|
|
|
FORMAT_4444 = 6,
|
2013-09-28 02:38:05 -07:00
|
|
|
|
|
|
|
|
FORMAT_FLOAT = 0x10,
|
|
|
|
|
FORMAT_16BIT = 0x11,
|
2013-10-06 17:11:42 -07:00
|
|
|
FORMAT_8BIT = 0x12,
|
2013-09-22 22:25:55 -07:00
|
|
|
};
|
|
|
|
|
|
2013-09-27 23:52:06 -07:00
|
|
|
enum Flags {
|
|
|
|
|
RESIZE_NONE = 0x00,
|
2013-10-05 18:14:29 -07:00
|
|
|
RESIZE_CENTER = 0x02,
|
2013-09-27 23:52:06 -07:00
|
|
|
RESIZE_SHRINK_FIT = 0x01,
|
2013-10-05 18:14:29 -07:00
|
|
|
RESIZE_SHRINK_CENTER = 0x03,
|
2013-09-27 23:52:06 -07:00
|
|
|
ALPHA_IGNORE = 0x00,
|
|
|
|
|
ALPHA_BLEND = 0x04,
|
2013-09-22 20:03:47 -07:00
|
|
|
};
|
|
|
|
|
|
2013-09-24 20:06:25 +02:00
|
|
|
SimpleGLWindow(HWND wnd);
|
2013-09-22 20:36:58 -07:00
|
|
|
~SimpleGLWindow();
|
2013-09-22 19:05:33 -07:00
|
|
|
|
|
|
|
|
void Clear();
|
2013-09-27 23:52:06 -07:00
|
|
|
void Draw(u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888);
|
2013-10-12 22:17:24 -07:00
|
|
|
void Redraw(bool andSwap = true);
|
2013-09-27 23:52:06 -07:00
|
|
|
void Initialize(u32 flags);
|
2013-09-27 22:41:44 -07:00
|
|
|
static SimpleGLWindow *GetFrom(HWND hwnd);
|
|
|
|
|
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
2013-09-22 19:05:33 -07:00
|
|
|
|
2013-10-12 22:17:24 -07:00
|
|
|
// To draw something custom.
|
|
|
|
|
void Begin();
|
|
|
|
|
void End();
|
|
|
|
|
|
2013-09-27 23:52:06 -07:00
|
|
|
void SetFlags(u32 flags) {
|
|
|
|
|
flags_ = flags;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-22 19:05:33 -07:00
|
|
|
void Swap() {
|
|
|
|
|
SwapBuffers(hDC_);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-13 20:47:52 -07:00
|
|
|
int Width() {
|
|
|
|
|
return w_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Height() {
|
|
|
|
|
return h_;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 15:05:11 -08:00
|
|
|
int TexWidth() {
|
|
|
|
|
return tw_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TexHeight() {
|
|
|
|
|
return th_;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-13 20:47:52 -07:00
|
|
|
void GetContentSize(float &x, float &y, float &fw, float &fh);
|
|
|
|
|
|
2013-09-27 22:41:44 -07:00
|
|
|
static void RegisterClass();
|
2013-09-22 20:36:58 -07:00
|
|
|
protected:
|
|
|
|
|
void SetupGL();
|
|
|
|
|
void ResizeGL(int w, int h);
|
|
|
|
|
void CreateProgram();
|
|
|
|
|
void GenerateChecker();
|
|
|
|
|
void DrawChecker();
|
2013-10-06 12:47:55 -07:00
|
|
|
bool DragStart(int mouseX, int mouseY);
|
|
|
|
|
bool DragContinue(int mouseX, int mouseY);
|
|
|
|
|
bool DragEnd(int mouseX, int mouseY);
|
|
|
|
|
bool ToggleZoom();
|
2013-09-22 20:36:58 -07:00
|
|
|
|
2013-09-22 19:05:33 -07:00
|
|
|
HWND hWnd_;
|
|
|
|
|
HDC hDC_;
|
|
|
|
|
HGLRC hGLRC_;
|
|
|
|
|
bool valid_;
|
2013-10-05 18:30:31 -07:00
|
|
|
// Width and height of the window.
|
2013-09-22 19:05:33 -07:00
|
|
|
int w_;
|
|
|
|
|
int h_;
|
2013-10-05 18:30:31 -07:00
|
|
|
// Last texture size/flipped for Redraw().
|
2013-10-05 18:14:29 -07:00
|
|
|
int tw_;
|
|
|
|
|
int th_;
|
|
|
|
|
bool tflipped_;
|
2013-09-22 19:05:33 -07:00
|
|
|
|
|
|
|
|
GLSLProgram *drawProgram_;
|
2013-09-22 20:36:58 -07:00
|
|
|
GLuint checker_;
|
2013-09-22 19:05:33 -07:00
|
|
|
GLuint tex_;
|
2013-09-27 23:52:06 -07:00
|
|
|
u32 flags_;
|
2013-10-05 18:30:31 -07:00
|
|
|
// Disable shrink (toggled by double click.)
|
2013-10-05 18:14:29 -07:00
|
|
|
bool zoom_;
|
2013-10-05 18:30:31 -07:00
|
|
|
bool dragging_;
|
|
|
|
|
int dragStartX_;
|
|
|
|
|
int dragStartY_;
|
|
|
|
|
u32 dragLastUpdate_;
|
|
|
|
|
// Offset to position the texture is drawn at.
|
|
|
|
|
int offsetX_;
|
|
|
|
|
int offsetY_;
|
2013-09-22 19:05:33 -07:00
|
|
|
};
|