scummvm/backends/platform/ios7/ios7_video.h
Lars Sundström 208aa43d5b IOS7: Render openGLContext
Implement callbacks to set up OpenGL context, destroy context, get
scale factor and screen sizes. Implement rendering of graphics drawn
by the iOS graphicsManager.

This commit will enable graphics to be shown again. Screen rotation
and mouse movements are still to be adapted.
2023-07-03 21:50:32 +02:00

157 lines
3.8 KiB
Objective-C

/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BACKENDS_PLATFORM_IOS7_IOS7_VIDEO_H
#define BACKENDS_PLATFORM_IOS7_IOS7_VIDEO_H
#include <UIKit/UIKit.h>
#include <Foundation/Foundation.h>
#include <QuartzCore/QuartzCore.h>
#include <Accelerate/Accelerate.h>
#include <OpenGLES/EAGL.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#include "backends/platform/ios7/ios7_keyboard.h"
#include "backends/platform/ios7/ios7_common.h"
#include "backends/platform/ios7/ios7_game_controller.h"
#include "common/list.h"
typedef struct {
GLfloat x, y;
GLfloat u,v;
} GLVertex;
uint getSizeNextPOT(uint size);
@interface iPhoneView : UIView {
VideoContext _videoContext;
Common::List<InternalEvent> _events;
NSLock *_eventLock;
SoftKeyboard *_keyboardView;
Common::List<GameController*> _controllers;
UIBackgroundTaskIdentifier _backgroundSaveStateTask;
EAGLContext *_mainContext;
EAGLContext *_openGLContext;
GLuint _viewRenderbuffer;
GLuint _viewFramebuffer;
GLuint _screenTexture;
GLuint _overlayTexture;
GLuint _mouseCursorTexture;
GLuint _vertexShader;
GLuint _fragmentShader;
GLuint _vertexBuffer;
GLuint _screenSizeSlot;
GLuint _textureSlot;
GLuint _shakeXSlot;
GLuint _shakeYSlot;
GLuint _positionSlot;
GLuint _textureCoordSlot;
GLint _renderBufferWidth;
GLint _renderBufferHeight;
GLVertex _gameScreenCoords[4];
CGRect _gameScreenRect;
GLVertex _overlayCoords[4];
CGRect _overlayRect;
GLVertex _mouseCoords[4];
GLint _mouseHotspotX, _mouseHotspotY;
GLint _mouseWidth, _mouseHeight;
GLfloat _mouseScaleX, _mouseScaleY;
int _scaledShakeXOffset;
int _scaledShakeYOffset;
}
@property (nonatomic, assign) CGPoint pointerPosition;
@property (nonatomic, assign) BOOL isInGame;
- (id)initWithFrame:(struct CGRect)frame;
- (VideoContext *)getVideoContext;
- (uint)createOpenGLContext;
- (void)destroyOpenGLContext;
- (void)refreshScreen;
- (int)getScreenWidth;
- (int)getScreenHeight;
- (void)setGameScreenCoords;
- (void)initSurface;
- (void)setViewTransformation;
- (void)setGraphicsMode;
- (void)updateSurface;
- (void)updateMainSurface;
- (void)updateOverlaySurface;
- (void)updateMouseSurface;
- (void)clearColorBuffer;
- (void)notifyMouseMove;
- (void)updateMouseCursorScaling;
- (void)updateMouseCursor;
#if TARGET_OS_IOS
- (void)interfaceOrientationChanged:(UIInterfaceOrientation)orientation;
#endif
- (void)showKeyboard;
- (void)hideKeyboard;
- (BOOL)isKeyboardShown;
- (void)handleMainMenuKey;
- (void)applicationSuspend;
- (void)applicationResume;
- (void)saveApplicationState;
- (void)clearApplicationState;
- (void)restoreApplicationState;
- (void) beginBackgroundSaveStateTask;
- (void) endBackgroundSaveStateTask;
- (void)addEvent:(InternalEvent)event;
- (bool)fetchEvent:(InternalEvent *)event;
- (void)getMouseScaleFactorX:(CGFloat *)x andY:(CGFloat *)y;
- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y;
- (BOOL)isTouchControllerConnected;
- (BOOL)isMouseControllerConnected;
- (BOOL)isGamepadControllerConnected;
- (void)virtualController:(bool)connect;
@end
#endif