mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 15:01:16 +01:00
Big commit. Fix running the APK, I had missed a view in the manifest. Clean up the Android EGL context creation to fit more in line with how Dolphin works. This breaks input at the moment as well. Change the memarena from 768MB to 64MB to allow 1GB phones to potentially run it. Rename EGL_X11 back to EGL since this merge brings in some of soreau's changes to more easily allow different platforms like Wayland and Android. Not quite all of the code because some needs to be cleaned up still.
This commit is contained in:
parent
d11679a06e
commit
7034c79ab9
@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 2.6)
|
|||||||
|
|
||||||
option(ANDROID "Enables a build for Android" OFF)
|
option(ANDROID "Enables a build for Android" OFF)
|
||||||
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
|
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
|
||||||
|
option(USE_X11 "Enables X11 Support" ON)
|
||||||
|
option(USE_WAYLAND "Enables Wayland Support" OFF)
|
||||||
option(USE_GLES "Enables GLES And EGL, disables OGL" OFF)
|
option(USE_GLES "Enables GLES And EGL, disables OGL" OFF)
|
||||||
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
|
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
|
||||||
|
|
||||||
@ -263,16 +265,28 @@ if(USE_GLES)
|
|||||||
add_definitions(-DUSE_EGL=1)
|
add_definitions(-DUSE_EGL=1)
|
||||||
set(USE_EGL True)
|
set(USE_EGL True)
|
||||||
endif()
|
endif()
|
||||||
|
# For now Wayland and EGL are tied to each other.
|
||||||
|
# The alternative would be an shm path
|
||||||
|
if(USE_WAYLAND)
|
||||||
|
add_definitions(-DUSE_EGL)
|
||||||
|
set(USE_EGL 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(USE_EGL)
|
if(USE_EGL)
|
||||||
message("EGL OpenGL interface enabled")
|
message("EGL OpenGL interface enabled")
|
||||||
add_definitions(-DUSE_EGL=1)
|
add_definitions(-DUSE_EGL=1)
|
||||||
|
else()
|
||||||
|
# Using GLX
|
||||||
|
set(USE_X11 1)
|
||||||
|
set(USE_WAYLAND 0)
|
||||||
endif()
|
endif()
|
||||||
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
|
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
message("Building for Android")
|
message("Building for Android")
|
||||||
add_definitions(-DANDROID)
|
add_definitions(-DANDROID)
|
||||||
|
set(USE_X11 0)
|
||||||
|
set(USE_WAYLAND 0)
|
||||||
endif()
|
endif()
|
||||||
########################################
|
########################################
|
||||||
# Dependency checking
|
# Dependency checking
|
||||||
@ -348,29 +362,53 @@ if(NOT ANDROID)
|
|||||||
message("OpenAL NOT found, disabling OpenAL sound backend")
|
message("OpenAL NOT found, disabling OpenAL sound backend")
|
||||||
endif(OPENAL_FOUND)
|
endif(OPENAL_FOUND)
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
# Note: The convention is to check USE_X11 or USE_WAYLAND where needed.
|
||||||
|
# This is where we detect platforms and set the variables accordingly.
|
||||||
|
pkg_check_modules(WAYLAND wayland-egl wayland-client wayland-cursor)
|
||||||
|
if(USE_WAYLAND AND WAYLAND_FOUND)
|
||||||
|
pkg_check_modules(XKBCOMMON xkbcommon)
|
||||||
|
if(XKBCOMMON_FOUND)
|
||||||
|
set(USE_WAYLAND 1)
|
||||||
|
add_definitions(-DHAVE_WAYLAND)
|
||||||
|
include_directories(${WAYLAND_INCLUDE_DIR})
|
||||||
|
message("Wayland support enabled")
|
||||||
|
endif(XKBCOMMON_FOUND)
|
||||||
|
else()
|
||||||
|
set(USE_WAYLAND 0)
|
||||||
|
message("Wayland support disabled")
|
||||||
|
add_definitions(-DHAVE_WAYLAND=0)
|
||||||
|
endif(USE_WAYLAND AND WAYLAND_FOUND)
|
||||||
|
|
||||||
# Note: We do not need to explicitly check for X11 as it is done in the cmake
|
# Note: We do not need to explicitly check for X11 as it is done in the cmake
|
||||||
# FindOpenGL module on linux.
|
# FindOpenGL module on linux.
|
||||||
if(UNIX AND NOT APPLE)
|
if(USE_X11 AND X11_FOUND)
|
||||||
if(X11_FOUND)
|
set(USE_X11 1)
|
||||||
add_definitions(-DHAVE_X11=1)
|
add_definitions(-DHAVE_X11=1)
|
||||||
include_directories(${X11_INCLUDE_DIR})
|
include_directories(${X11_INCLUDE_DIR})
|
||||||
message("X11 found")
|
message("X11 support enabled")
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "X11 is required but not found")
|
|
||||||
endif(X11_FOUND)
|
|
||||||
else()
|
else()
|
||||||
|
set(USE_X11 0)
|
||||||
|
SET(X11_FOUND "")
|
||||||
|
message("X11 support disabled")
|
||||||
add_definitions(-DHAVE_X11=0)
|
add_definitions(-DHAVE_X11=0)
|
||||||
|
endif(USE_X11 AND X11_FOUND)
|
||||||
|
|
||||||
|
if (NOT USE_WAYLAND AND NOT USE_X11)
|
||||||
|
message(FATAL_ERROR "\n"
|
||||||
|
"No suitable display platform found\n"
|
||||||
|
"Requires wayland or x11 to run")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(X11_FOUND)
|
if(USE_X11)
|
||||||
check_lib(XRANDR Xrandr)
|
check_lib(XRANDR Xrandr)
|
||||||
endif()
|
|
||||||
if(XRANDR_FOUND)
|
if(XRANDR_FOUND)
|
||||||
add_definitions(-DHAVE_XRANDR=1)
|
add_definitions(-DHAVE_XRANDR=1)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DHAVE_XRANDR=0)
|
add_definitions(-DHAVE_XRANDR=0)
|
||||||
endif(XRANDR_FOUND)
|
endif(XRANDR_FOUND)
|
||||||
|
endif()
|
||||||
if(ENCODE_FRAMEDUMPS)
|
if(ENCODE_FRAMEDUMPS)
|
||||||
check_libav()
|
check_libav()
|
||||||
endif()
|
endif()
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".NativeListView"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@android:style/Theme"
|
||||||
|
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -18,7 +18,6 @@ import android.view.WindowManager;
|
|||||||
public class DolphinEmulator<MainActivity> extends Activity {
|
public class DolphinEmulator<MainActivity> extends Activity {
|
||||||
|
|
||||||
static private NativeGLSurfaceView GLview = null;
|
static private NativeGLSurfaceView GLview = null;
|
||||||
static private NativeRenderer Renderer = null;
|
|
||||||
static private boolean Running = false;
|
static private boolean Running = false;
|
||||||
|
|
||||||
private float screenWidth;
|
private float screenWidth;
|
||||||
@ -42,21 +41,21 @@ public class DolphinEmulator<MainActivity> extends Activity {
|
|||||||
{
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
if (Running)
|
if (Running)
|
||||||
Renderer.StopEmulation();
|
NativeGLSurfaceView.StopEmulation();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onPause()
|
public void onPause()
|
||||||
{
|
{
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (Running)
|
if (Running)
|
||||||
Renderer.PauseEmulation();
|
NativeGLSurfaceView.PauseEmulation();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (Running)
|
if (Running)
|
||||||
Renderer.UnPauseEmulation();
|
NativeGLSurfaceView.UnPauseEmulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@ -84,15 +83,10 @@ public class DolphinEmulator<MainActivity> extends Activity {
|
|||||||
screenWidth = displayMetrics.widthPixels;
|
screenWidth = displayMetrics.widthPixels;
|
||||||
screenHeight = displayMetrics.heightPixels;
|
screenHeight = displayMetrics.heightPixels;
|
||||||
|
|
||||||
|
|
||||||
String FileName = data.getStringExtra("Select");
|
String FileName = data.getStringExtra("Select");
|
||||||
Renderer = new NativeRenderer();
|
|
||||||
Renderer.setContext(getApplicationContext());
|
|
||||||
|
|
||||||
GLview = new NativeGLSurfaceView(this);
|
GLview = new NativeGLSurfaceView(this);
|
||||||
GLview.setEGLContextClientVersion(2);
|
|
||||||
GLview.setRenderer(Renderer);
|
|
||||||
|
|
||||||
|
GLview.SetDimensions(screenWidth, screenHeight);
|
||||||
GLview.SetFileName(FileName);
|
GLview.SetFileName(FileName);
|
||||||
setContentView(GLview);
|
setContentView(GLview);
|
||||||
Running = true;
|
Running = true;
|
||||||
@ -108,10 +102,10 @@ public class DolphinEmulator<MainActivity> extends Activity {
|
|||||||
Y = event.getY();
|
Y = event.getY();
|
||||||
Action = event.getActionMasked();
|
Action = event.getActionMasked();
|
||||||
|
|
||||||
int Button = Renderer.ButtonPressed(Action, ((X / screenWidth) * 2.0f) - 1.0f, ((Y / screenHeight) * 2.0f) - 1.0f);
|
//int Button = Renderer.ButtonPressed(Action, ((X / screenWidth) * 2.0f) - 1.0f, ((Y / screenHeight) * 2.0f) - 1.0f);
|
||||||
|
|
||||||
if (Button != -1)
|
//if (Button != -1)
|
||||||
SetKey(Action, Button);
|
//SetKey(Action, Button);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,21 @@ import android.opengl.GLSurfaceView;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
|
||||||
public class NativeGLSurfaceView extends GLSurfaceView {
|
public class NativeGLSurfaceView extends SurfaceView {
|
||||||
static private String FileName;
|
static private String FileName;
|
||||||
static private Thread myRun;
|
static private Thread myRun;
|
||||||
static private boolean Running = false;
|
static private boolean Running = false;
|
||||||
static private boolean Created = false;
|
static private boolean Created = false;
|
||||||
|
static private float width;
|
||||||
|
static private float height;
|
||||||
|
|
||||||
public static native void main(String File, Surface surf);
|
public static native void main(String File, Surface surf, int width, int height);
|
||||||
|
|
||||||
|
public static native void UnPauseEmulation();
|
||||||
|
public static native void PauseEmulation();
|
||||||
|
public static native void StopEmulation();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@ -35,20 +42,29 @@ public class NativeGLSurfaceView extends GLSurfaceView {
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
main(FileName, getHolder().getSurface());
|
main(FileName, getHolder().getSurface(), (int)width, (int)height);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Created = true;
|
getHolder().addCallback(new SurfaceHolder.Callback() {
|
||||||
}
|
|
||||||
|
|
||||||
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
myRun.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceCreated(SurfaceHolder holder)
|
public void surfaceChanged(SurfaceHolder arg0, int arg1,
|
||||||
{
|
int arg2, int arg3) {
|
||||||
super.surfaceCreated(holder);
|
// TODO Auto-generated method stub
|
||||||
if (!Running)
|
|
||||||
{
|
}
|
||||||
myRun.start();
|
|
||||||
Running = true;
|
public void surfaceDestroyed(SurfaceHolder arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Created = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +72,11 @@ public class NativeGLSurfaceView extends GLSurfaceView {
|
|||||||
{
|
{
|
||||||
FileName = file;
|
FileName = file;
|
||||||
}
|
}
|
||||||
|
public void SetDimensions(float screenWidth, float screenHeight)
|
||||||
|
{
|
||||||
|
width = screenWidth;
|
||||||
|
height = screenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,6 @@ public class NativeRenderer implements GLSurfaceView.Renderer {
|
|||||||
public static native void DrawButton(int GLTex, int ID);
|
public static native void DrawButton(int GLTex, int ID);
|
||||||
public static native void SetButtonCoords(float[] Coords);
|
public static native void SetButtonCoords(float[] Coords);
|
||||||
public static native void PrepareME();
|
public static native void PrepareME();
|
||||||
public static native void UnPauseEmulation();
|
|
||||||
public static native void PauseEmulation();
|
|
||||||
public static native void StopEmulation();
|
|
||||||
|
|
||||||
// Texture loading
|
// Texture loading
|
||||||
private static int buttonA = -1;
|
private static int buttonA = -1;
|
||||||
|
@ -153,7 +153,12 @@ u8* MemArena::Find4GBBase()
|
|||||||
}
|
}
|
||||||
return base;
|
return base;
|
||||||
#else
|
#else
|
||||||
void* base = mmap(0, 0x31000000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
#ifdef ANDROID
|
||||||
|
const u32 MemSize = 0x04000000;
|
||||||
|
#else
|
||||||
|
const u32 MemSize = 0x31000000;
|
||||||
|
#endif
|
||||||
|
void* base = mmap(0, MemSize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
if (base == MAP_FAILED) {
|
if (base == MAP_FAILED) {
|
||||||
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
|
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -7,10 +7,19 @@ set(LIBS core
|
|||||||
audiocommon
|
audiocommon
|
||||||
z
|
z
|
||||||
sfml-network
|
sfml-network
|
||||||
${GTK2_LIBRARIES}
|
${GTK2_LIBRARIES})
|
||||||
${XRANDR_LIBRARIES}
|
|
||||||
${X11_LIBRARIES})
|
|
||||||
if(NOT ANDROID)
|
if(NOT ANDROID)
|
||||||
|
if(USE_X11)
|
||||||
|
set(LIBS ${LIBS} ${X11_LIBRARIES}
|
||||||
|
${XRANDR_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if(USE_WAYLAND)
|
||||||
|
set(LIBS ${LIBS} ${WAYLAND_LIBRARIES}
|
||||||
|
${XKBCOMMON_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
link_directories(${CMAKE_PREFIX_PATH}/lib)
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
if(SDL2_FOUND)
|
||||||
# Using shared SDL2
|
# Using shared SDL2
|
||||||
set(LIBS ${LIBS} ${SDL2_LIBRARY})
|
set(LIBS ${LIBS} ${SDL2_LIBRARY})
|
||||||
@ -87,13 +96,17 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_EGL)
|
if(USE_EGL)
|
||||||
if(NOT ANDROID)
|
set(SRCS ${SRCS} Src/GLInterface/Platform.cpp
|
||||||
set(SRCS ${SRCS} Src/GLInterface/EGL_X11.cpp
|
Src/GLInterface/EGL.cpp)
|
||||||
Src/GLInterface/X11_Util.cpp)
|
if(USE_WAYLAND)
|
||||||
|
set(SRCS ${SRCS} Src/GLInterface/Wayland_Util.cpp)
|
||||||
|
endif()
|
||||||
|
if(USE_X11)
|
||||||
|
set(SRCS ${SRCS} Src/GLInterface/X11_Util.cpp)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SRCS ${SRCS} Src/GLInterface/GLW.cpp)
|
set(SRCS ${SRCS} Src/GLInterface/WGL.cpp)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
|
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
|
||||||
else()
|
else()
|
||||||
@ -127,10 +140,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||||||
list(APPEND SRCS ${RESOURCES})
|
list(APPEND SRCS ${RESOURCES})
|
||||||
set_source_files_properties(${RESOURCES} PROPERTIES
|
set_source_files_properties(${RESOURCES} PROPERTIES
|
||||||
MACOSX_PACKAGE_LOCATION Resources)
|
MACOSX_PACKAGE_LOCATION Resources)
|
||||||
else()
|
elseif(USE_X11)
|
||||||
if(NOT ANDROID)
|
|
||||||
set(SRCS ${SRCS} Src/X11Utils.cpp)
|
set(SRCS ${SRCS} Src/X11Utils.cpp)
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
|
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
|
||||||
|
@ -17,14 +17,18 @@
|
|||||||
#ifndef _GLINTERFACE_H_
|
#ifndef _GLINTERFACE_H_
|
||||||
#define _GLINTERFACE_H_
|
#define _GLINTERFACE_H_
|
||||||
|
|
||||||
|
#if USE_EGL
|
||||||
|
#include "GLInterface/Platform.h"
|
||||||
|
#else
|
||||||
|
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <GLInterface/InterfaceBase.h>
|
#include "GLInterface/EGL.h"
|
||||||
#elif defined(USE_EGL) && USE_EGL
|
#elif defined(USE_EGL) && USE_EGL
|
||||||
#include "GLInterface/EGL_X11.h"
|
#include "GLInterface/EGL.h"
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include "GLInterface/AGL.h"
|
#include "GLInterface/AGL.h"
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
@ -36,19 +40,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef ANDROID
|
#if defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
|
||||||
#elif defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
|
|
||||||
int screen;
|
int screen;
|
||||||
Display *dpy;
|
|
||||||
Display *evdpy;
|
|
||||||
Window win;
|
|
||||||
Window parent;
|
|
||||||
EGLSurface egl_surf;
|
EGLSurface egl_surf;
|
||||||
EGLContext egl_ctx;
|
EGLContext egl_ctx;
|
||||||
EGLDisplay egl_dpy;
|
EGLDisplay egl_dpy;
|
||||||
XVisualInfo *vi;
|
|
||||||
XSetWindowAttributes attr;
|
|
||||||
std::thread xEventThread;
|
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
@ -74,3 +70,4 @@ extern cInterfaceBase *GLInterface;
|
|||||||
extern GLWindow GLWin;
|
extern GLWindow GLWin;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -19,59 +19,30 @@
|
|||||||
#include "RenderBase.h"
|
#include "RenderBase.h"
|
||||||
|
|
||||||
#include "../GLInterface.h"
|
#include "../GLInterface.h"
|
||||||
#include "EGL_X11.h"
|
#include "EGL.h"
|
||||||
|
|
||||||
// Show the current FPS
|
// Show the current FPS
|
||||||
void cInterfaceEGL::UpdateFPSDisplay(const char *text)
|
void cInterfaceEGL::UpdateFPSDisplay(const char *text)
|
||||||
{
|
{
|
||||||
XStoreName(GLWin.dpy, GLWin.win, text);
|
Platform.UpdateFPSDisplay(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cInterfaceEGL::SwapInterval(int Interval)
|
|
||||||
{
|
|
||||||
eglSwapInterval(GLWin.egl_dpy, Interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cInterfaceEGL::Swap()
|
void cInterfaceEGL::Swap()
|
||||||
{
|
{
|
||||||
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
||||||
}
|
}
|
||||||
|
void cInterfaceEGL::SwapInterval(int Interval)
|
||||||
|
{
|
||||||
|
eglSwapInterval(GLWin.egl_dpy, Interval);
|
||||||
|
}
|
||||||
|
|
||||||
// Create rendering window.
|
// Create rendering window.
|
||||||
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
|
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
|
||||||
bool cInterfaceEGL::Create(void *&window_handle)
|
bool cInterfaceEGL::Create(void *&window_handle)
|
||||||
{
|
{
|
||||||
int _tx, _ty, _twidth, _theight;
|
const char *s;
|
||||||
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);
|
|
||||||
|
|
||||||
// Control window size and picture scaling
|
|
||||||
s_backbuffer_width = _twidth;
|
|
||||||
s_backbuffer_height = _theight;
|
|
||||||
|
|
||||||
EGLint egl_major, egl_minor;
|
EGLint egl_major, egl_minor;
|
||||||
|
EGLConfig config;
|
||||||
GLWin.dpy = XOpenDisplay(NULL);
|
EGLint num_configs;
|
||||||
|
|
||||||
if (!GLWin.dpy) {
|
|
||||||
ERROR_LOG(VIDEO, "Error: couldn't open display\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLWin.egl_dpy = eglGetDisplay(GLWin.dpy);
|
|
||||||
if (!GLWin.egl_dpy) {
|
|
||||||
ERROR_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
|
|
||||||
ERROR_LOG(VIDEO, "Error: eglInitialize() failed\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VERSION));
|
|
||||||
INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VENDOR));
|
|
||||||
INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS));
|
|
||||||
INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS));
|
|
||||||
|
|
||||||
// attributes for a visual in RGBA format with at least
|
// attributes for a visual in RGBA format with at least
|
||||||
// 8 bits per color and a 24 bit depth buffer
|
// 8 bits per color and a 24 bit depth buffer
|
||||||
@ -94,69 +65,78 @@ bool cInterfaceEGL::Create(void *&window_handle)
|
|||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
GLWin.evdpy = XOpenDisplay(NULL);
|
if(!Platform.SelectDisplay())
|
||||||
GLWin.parent = (Window)window_handle;
|
return false;
|
||||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
|
||||||
if (GLWin.parent == 0)
|
|
||||||
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
|
|
||||||
|
|
||||||
XVisualInfo visTemplate;
|
GLWin.egl_dpy = Platform.EGLGetDisplay();
|
||||||
int num_visuals;
|
|
||||||
EGLConfig config;
|
|
||||||
EGLint num_configs;
|
|
||||||
EGLint vid;
|
|
||||||
|
|
||||||
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
|
if (!GLWin.egl_dpy) {
|
||||||
ERROR_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
printf("Error: eglGetDisplay() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
GLWin.platform = Platform.platform;
|
||||||
ERROR_LOG(VIDEO, "Error: eglGetConfigAttrib() failed\n");
|
|
||||||
|
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
|
||||||
|
printf("Error: eglInitialize() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The X window visual must match the EGL config */
|
|
||||||
visTemplate.visualid = vid;
|
|
||||||
GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
|
|
||||||
if (!GLWin.vi) {
|
|
||||||
ERROR_LOG(VIDEO, "Error: couldn't get X visual\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLWin.x = _tx;
|
|
||||||
GLWin.y = _ty;
|
|
||||||
GLWin.width = _twidth;
|
|
||||||
GLWin.height = _theight;
|
|
||||||
|
|
||||||
XWindow.CreateXWindow();
|
|
||||||
#ifdef USE_GLES
|
#ifdef USE_GLES
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
#else
|
#else
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
#endif
|
#endif
|
||||||
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
|
||||||
if (!GLWin.egl_ctx) {
|
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||||
ERROR_LOG(VIDEO, "Error: eglCreateContext failed\n");
|
printf("Error: couldn't get an EGL visual config\n");
|
||||||
return false;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, (NativeWindowType)GLWin.win, NULL);
|
if (!Platform.Init(config))
|
||||||
if (!GLWin.egl_surf) {
|
|
||||||
ERROR_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
|
||||||
|
printf("EGL_VERSION = %s\n", s);
|
||||||
|
|
||||||
|
s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
|
||||||
|
printf("EGL_VENDOR = %s\n", s);
|
||||||
|
|
||||||
|
s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
|
||||||
|
printf("EGL_EXTENSIONS = %s\n", s);
|
||||||
|
|
||||||
|
s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
|
||||||
|
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||||
|
|
||||||
|
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
||||||
|
if (!GLWin.egl_ctx) {
|
||||||
|
printf("Error: eglCreateContext failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLWin.native_window = Platform.CreateWindow();
|
||||||
|
|
||||||
|
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config,
|
||||||
|
GLWin.native_window, NULL);
|
||||||
|
if (!GLWin.egl_surf) {
|
||||||
|
printf("Error: eglCreateWindowSurface failed\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) {
|
if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) {
|
||||||
ERROR_LOG(VIDEO, "Error: eglMakeCurrent() failed\n");
|
|
||||||
|
printf("Error: eglMakeCurrent() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(VIDEO, "GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||||
INFO_LOG(VIDEO, "GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||||
INFO_LOG(VIDEO, "GL_VERSION: %s\n", glGetString(GL_VERSION));
|
printf("GL_VERSION: %s\n", glGetString(GL_VERSION));
|
||||||
INFO_LOG(VIDEO, "GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
||||||
window_handle = (void *)GLWin.win;
|
|
||||||
|
Platform.ToggleFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
||||||
|
|
||||||
|
window_handle = (void *)GLWin.native_window;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +147,7 @@ bool cInterfaceEGL::MakeCurrent()
|
|||||||
// Close backend
|
// Close backend
|
||||||
void cInterfaceEGL::Shutdown()
|
void cInterfaceEGL::Shutdown()
|
||||||
{
|
{
|
||||||
XWindow.DestroyXWindow();
|
Platform.DestroyWindow();
|
||||||
if (GLWin.egl_ctx && !eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx))
|
if (GLWin.egl_ctx && !eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx))
|
||||||
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
||||||
if (GLWin.egl_ctx)
|
if (GLWin.egl_ctx)
|
||||||
@ -178,4 +158,3 @@ void cInterfaceEGL::Shutdown()
|
|||||||
GLWin.egl_ctx = NULL;
|
GLWin.egl_ctx = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,24 +17,23 @@
|
|||||||
#ifndef _INTERFACEEGL_H_
|
#ifndef _INTERFACEEGL_H_
|
||||||
#define _INTERFACEEGL_H_
|
#define _INTERFACEEGL_H_
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#if USE_GLES
|
||||||
#ifdef USE_GLES
|
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#else
|
#else
|
||||||
#include <GL/glxew.h>
|
#include <GL/glxew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "X11_Util.h"
|
|
||||||
#include "InterfaceBase.h"
|
#include "InterfaceBase.h"
|
||||||
|
|
||||||
|
class cPlatform;
|
||||||
|
|
||||||
class cInterfaceEGL : public cInterfaceBase
|
class cInterfaceEGL : public cInterfaceBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
cX11Window XWindow;
|
cPlatform Platform;
|
||||||
public:
|
public:
|
||||||
friend class cX11Window;
|
friend class cPlatform;
|
||||||
void SwapInterval(int Interval);
|
void SwapInterval(int Interval);
|
||||||
void Swap();
|
void Swap();
|
||||||
void UpdateFPSDisplay(const char *Text);
|
void UpdateFPSDisplay(const char *Text);
|
@ -39,6 +39,7 @@
|
|||||||
#include <android/native_window_jni.h>
|
#include <android/native_window_jni.h>
|
||||||
JNIEnv *g_env = NULL;
|
JNIEnv *g_env = NULL;
|
||||||
ANativeWindow* surf;
|
ANativeWindow* surf;
|
||||||
|
int g_width, g_height;
|
||||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__))
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__))
|
||||||
|
|
||||||
bool rendererHasFocus = true;
|
bool rendererHasFocus = true;
|
||||||
@ -83,8 +84,8 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
|
|||||||
{
|
{
|
||||||
x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;
|
x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;
|
||||||
y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos;
|
y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos;
|
||||||
width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth;
|
width = g_width;
|
||||||
height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight;
|
height = g_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host_RequestRenderWindowSize(int width, int height) {}
|
void Host_RequestRenderWindowSize(int width, int height) {}
|
||||||
@ -122,18 +123,12 @@ void Host_SysMessage(const char *fmt, ...)
|
|||||||
|
|
||||||
void Host_SetWiiMoteConnectionState(int _State) {}
|
void Host_SetWiiMoteConnectionState(int _State) {}
|
||||||
|
|
||||||
extern void DrawReal();
|
|
||||||
extern void PrepareShit();
|
|
||||||
extern void DrawButton(int tex, int ID);
|
extern void DrawButton(int tex, int ID);
|
||||||
extern void SetButtonCoords(float *Coords);
|
extern void SetButtonCoords(float *Coords);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PrepareME(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
PrepareShit();
|
|
||||||
}
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords)
|
||||||
{
|
{
|
||||||
jfloat* flt1 = env->GetFloatArrayElements(Coords, 0);
|
jfloat* flt1 = env->GetFloatArrayElements(Coords, 0);
|
||||||
@ -148,33 +143,30 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawButton(
|
|||||||
DrawButton((int)GLTex, (int)ID);
|
DrawButton((int)GLTex, (int)ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_UnPauseEmulation(JNIEnv *env, jobject obj)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
PowerPC::Start();
|
PowerPC::Start();
|
||||||
}
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PauseEmulation(JNIEnv *env, jobject obj)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_PauseEmulation(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
PowerPC::Pause();
|
PowerPC::Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_StopEmulation(JNIEnv *env, jobject obj)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEmulation(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
PowerPC::Stop();
|
PowerPC::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawME(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
DrawReal();
|
|
||||||
}
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key)
|
||||||
{
|
{
|
||||||
WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value);
|
WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value);
|
||||||
KeyStates[(int)Key] = (int)Value == 0 ? true : false;
|
KeyStates[(int)Key] = (int)Value == 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
|
||||||
{
|
{
|
||||||
surf = ANativeWindow_fromSurface(env, _surf);
|
surf = ANativeWindow_fromSurface(env, _surf);
|
||||||
|
g_width = (int)_width;
|
||||||
|
g_height = (int)_height;
|
||||||
g_env = env;
|
g_env = env;
|
||||||
|
|
||||||
LogManager::Init();
|
LogManager::Init();
|
||||||
|
@ -51,9 +51,7 @@ void VideoBackend::UpdateFPSDisplay(const char *text)
|
|||||||
}
|
}
|
||||||
void InitInterface()
|
void InitInterface()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID
|
#if defined(USE_EGL) && USE_EGL
|
||||||
GLInterface = new cInterfaceBase;
|
|
||||||
#elif defined(USE_EGL) && USE_EGL
|
|
||||||
GLInterface = new cInterfaceEGL;
|
GLInterface = new cInterfaceEGL;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
GLInterface = new cInterfaceAGL;
|
GLInterface = new cInterfaceAGL;
|
||||||
|
@ -77,10 +77,13 @@ void CreateShaders()
|
|||||||
uni_tex = glGetUniformLocation(program, "Texture");
|
uni_tex = glGetUniformLocation(program, "Texture");
|
||||||
attr_pos = glGetAttribLocation(program, "pos");
|
attr_pos = glGetAttribLocation(program, "pos");
|
||||||
attr_tex = glGetAttribLocation(program, "TexCoordIn");
|
attr_tex = glGetAttribLocation(program, "TexCoordIn");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#include <EGL/egl.h>
|
|
||||||
void PrepareShit()
|
void SWRenderer::Prepare()
|
||||||
{
|
{
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
|
||||||
glGenTextures(1, &s_RenderTarget);
|
glGenTextures(1, &s_RenderTarget);
|
||||||
|
|
||||||
@ -94,9 +97,6 @@ void PrepareShit()
|
|||||||
#endif
|
#endif
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
void SWRenderer::Prepare()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
|
void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
|
||||||
{
|
{
|
||||||
@ -135,17 +135,14 @@ void SWRenderer::DrawDebugText()
|
|||||||
p+=sprintf(p,"Rasterized Pix: %i\n",swstats.thisFrame.rasterizedPixels);
|
p+=sprintf(p,"Rasterized Pix: %i\n",swstats.thisFrame.rasterizedPixels);
|
||||||
p+=sprintf(p,"TEV Pix In: %i\n",swstats.thisFrame.tevPixelsIn);
|
p+=sprintf(p,"TEV Pix In: %i\n",swstats.thisFrame.tevPixelsIn);
|
||||||
p+=sprintf(p,"TEV Pix Out: %i\n",swstats.thisFrame.tevPixelsOut);
|
p+=sprintf(p,"TEV Pix Out: %i\n",swstats.thisFrame.tevPixelsOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render a shadow, and then the text.
|
// Render a shadow, and then the text.
|
||||||
SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
|
SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
|
||||||
SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
|
SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
|
||||||
}
|
}
|
||||||
u8 image[1024*1024*4];
|
#ifdef ANDROID
|
||||||
float ButtonCoords[8 * 2];
|
float ButtonCoords[8 * 2];
|
||||||
int gW, gH;
|
|
||||||
bool once = false;
|
|
||||||
std::recursive_mutex section;
|
|
||||||
void SetButtonCoords(float *Coords)
|
void SetButtonCoords(float *Coords)
|
||||||
{
|
{
|
||||||
memcpy(ButtonCoords, Coords, sizeof(float) * 8 * 2);
|
memcpy(ButtonCoords, Coords, sizeof(float) * 8 * 2);
|
||||||
@ -184,22 +181,20 @@ void DrawButton(int tex, int ID)
|
|||||||
glDisableVertexAttribArray(attr_tex);
|
glDisableVertexAttribArray(attr_tex);
|
||||||
|
|
||||||
glBindTexture(TEX2D, 0);
|
glBindTexture(TEX2D, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
void DrawReal()
|
#endif
|
||||||
|
void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
||||||
{
|
{
|
||||||
section.lock();
|
GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();
|
||||||
if (!once)
|
GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
|
||||||
{
|
|
||||||
section.unlock();
|
// Update GLViewPort
|
||||||
return;
|
glViewport(0, 0, glWidth, glHeight);
|
||||||
}
|
glScissor(0, 0, glWidth, glHeight);
|
||||||
int width = gW;
|
|
||||||
int height = gH;
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, s_RenderTarget);
|
glBindTexture(GL_TEXTURE_2D, s_RenderTarget);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
@ -228,19 +223,20 @@ void DrawReal()
|
|||||||
glDisableVertexAttribArray(attr_tex);
|
glDisableVertexAttribArray(attr_tex);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
section.unlock();
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
|
||||||
{
|
|
||||||
section.lock();
|
|
||||||
memcpy(image, texture, width * height * 4);
|
|
||||||
gW = width;
|
|
||||||
gH = height;
|
|
||||||
once = true;
|
|
||||||
section.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SWRenderer::SwapBuffer()
|
void SWRenderer::SwapBuffer()
|
||||||
{
|
{
|
||||||
|
DrawDebugText();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
GLInterface->Swap();
|
||||||
|
|
||||||
|
swstats.ResetFrame();
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user