parent
f1628b98de
commit
f8751bd1fb
68
melonDS.cbp
68
melonDS.cbp
|
@ -19,22 +19,6 @@
|
|||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add library="SDL2" />
|
||||
<Add library="shell32" />
|
||||
<Add library="comctl32" />
|
||||
<Add library="comdlg32" />
|
||||
<Add library="advapi32" />
|
||||
<Add library="wsock32" />
|
||||
<Add library="oleacc" />
|
||||
<Add library="ole32" />
|
||||
<Add library="usp10" />
|
||||
<Add library="gdi32" />
|
||||
<Add library="d2d1" />
|
||||
<Add library="dwrite" />
|
||||
<Add library="uxtheme" />
|
||||
<Add library="iphlpapi" />
|
||||
<Add library="user32" />
|
||||
<Add library="ws2_32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Windows">
|
||||
|
@ -51,22 +35,6 @@
|
|||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add library="SDL2" />
|
||||
<Add library="shell32" />
|
||||
<Add library="comctl32" />
|
||||
<Add library="comdlg32" />
|
||||
<Add library="advapi32" />
|
||||
<Add library="wsock32" />
|
||||
<Add library="oleacc" />
|
||||
<Add library="ole32" />
|
||||
<Add library="usp10" />
|
||||
<Add library="gdi32" />
|
||||
<Add library="d2d1" />
|
||||
<Add library="dwrite" />
|
||||
<Add library="uxtheme" />
|
||||
<Add library="iphlpapi" />
|
||||
<Add library="user32" />
|
||||
<Add library="ws2_32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="DebugFast Windows">
|
||||
|
@ -82,22 +50,6 @@
|
|||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add library="SDL2" />
|
||||
<Add library="shell32" />
|
||||
<Add library="comctl32" />
|
||||
<Add library="comdlg32" />
|
||||
<Add library="advapi32" />
|
||||
<Add library="wsock32" />
|
||||
<Add library="oleacc" />
|
||||
<Add library="ole32" />
|
||||
<Add library="usp10" />
|
||||
<Add library="gdi32" />
|
||||
<Add library="d2d1" />
|
||||
<Add library="dwrite" />
|
||||
<Add library="uxtheme" />
|
||||
<Add library="iphlpapi" />
|
||||
<Add library="user32" />
|
||||
<Add library="ws2_32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
|
@ -107,6 +59,25 @@
|
|||
<Add option="-pipe" />
|
||||
<Add directory="src" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="SDL2" />
|
||||
<Add library="shell32" />
|
||||
<Add library="comctl32" />
|
||||
<Add library="comdlg32" />
|
||||
<Add library="advapi32" />
|
||||
<Add library="wsock32" />
|
||||
<Add library="oleacc" />
|
||||
<Add library="ole32" />
|
||||
<Add library="usp10" />
|
||||
<Add library="gdi32" />
|
||||
<Add library="d2d1" />
|
||||
<Add library="dwrite" />
|
||||
<Add library="uxtheme" />
|
||||
<Add library="iphlpapi" />
|
||||
<Add library="user32" />
|
||||
<Add library="ws2_32" />
|
||||
<Add library="opengl32" />
|
||||
</Linker>
|
||||
<Unit filename="melon.rc">
|
||||
<Option compilerVar="WINDRES" />
|
||||
</Unit>
|
||||
|
@ -135,6 +106,7 @@
|
|||
<Unit filename="src/GPU2D.h" />
|
||||
<Unit filename="src/GPU3D.cpp" />
|
||||
<Unit filename="src/GPU3D.h" />
|
||||
<Unit filename="src/GPU3D_OpenGL43.cpp" />
|
||||
<Unit filename="src/GPU3D_Soft.cpp" />
|
||||
<Unit filename="src/NDS.cpp" />
|
||||
<Unit filename="src/NDS.h" />
|
||||
|
|
|
@ -275,14 +275,16 @@ bool Init()
|
|||
|
||||
CmdStallQueue = new FIFO<CmdFIFOEntry>(64);
|
||||
|
||||
if (!SoftRenderer::Init()) return false;
|
||||
//if (!SoftRenderer::Init()) return false;
|
||||
if (!GLRenderer43::Init()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
SoftRenderer::DeInit();
|
||||
//SoftRenderer::DeInit();
|
||||
GLRenderer43::DeInit();
|
||||
|
||||
delete CmdFIFO;
|
||||
delete CmdPIPE;
|
||||
|
@ -382,7 +384,8 @@ void Reset()
|
|||
FlushAttributes = 0;
|
||||
|
||||
ResetRenderingState();
|
||||
SoftRenderer::Reset();
|
||||
//SoftRenderer::Reset();
|
||||
GLRenderer43::Reset();
|
||||
}
|
||||
|
||||
void DoSavestate(Savestate* file)
|
||||
|
@ -2331,7 +2334,7 @@ void CheckFIFODMA()
|
|||
|
||||
void VCount144()
|
||||
{
|
||||
SoftRenderer::VCount144();
|
||||
//SoftRenderer::VCount144();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2413,17 +2416,20 @@ void VBlank()
|
|||
|
||||
void VCount215()
|
||||
{
|
||||
SoftRenderer::RenderFrame();
|
||||
//SoftRenderer::RenderFrame();
|
||||
GLRenderer43::RenderFrame();
|
||||
}
|
||||
|
||||
void RequestLine(int line)
|
||||
{
|
||||
return SoftRenderer::RequestLine(line);
|
||||
//return SoftRenderer::RequestLine(line);
|
||||
return GLRenderer43::RequestLine(line);
|
||||
}
|
||||
|
||||
u32* GetLine(int line)
|
||||
{
|
||||
return SoftRenderer::GetLine(line);
|
||||
//return SoftRenderer::GetLine(line);
|
||||
return GLRenderer43::GetLine(line);
|
||||
}
|
||||
|
||||
|
||||
|
|
14
src/GPU3D.h
14
src/GPU3D.h
|
@ -132,6 +132,20 @@ u32* GetLine(int line);
|
|||
|
||||
}
|
||||
|
||||
namespace GLRenderer43
|
||||
{
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
void Reset();
|
||||
|
||||
void VCount144();
|
||||
void RenderFrame();
|
||||
void RequestLine(int line);
|
||||
u32* GetLine(int line);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Copyright 2016-2019 Arisotura
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS 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.
|
||||
|
||||
melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "NDS.h"
|
||||
#include "GPU.h"
|
||||
#include "Platform.h"
|
||||
|
||||
namespace GPU3D
|
||||
{
|
||||
namespace GLRenderer43
|
||||
{
|
||||
|
||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||
|
||||
|
||||
GLuint FramebufferID;
|
||||
u8 Framebuffer[256*192*4];
|
||||
u8 CurLine[256*4];
|
||||
|
||||
|
||||
bool InitGLExtensions()
|
||||
{
|
||||
#define LOADPROC(type, name) \
|
||||
name = (PFN##type##PROC)Platform::GL_GetProcAddress(#name); \
|
||||
if (!name) return false;
|
||||
|
||||
LOADPROC(GLGENFRAMEBUFFERS, glGenFramebuffers);
|
||||
LOADPROC(GLBINDFRAMEBUFFER, glBindFramebuffer);
|
||||
LOADPROC(GLFRAMEBUFFERTEXTURE, glFramebufferTexture);
|
||||
|
||||
#undef LOADPROC
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if (!InitGLExtensions()) return false;
|
||||
|
||||
u8* test_tex = new u8[256*192*4];
|
||||
u8* ptr = test_tex;
|
||||
for (int y = 0; y < 192; y++)
|
||||
{
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
if ((x & 0x10) ^ (y & 0x10))
|
||||
{
|
||||
*ptr++ = 0x00;
|
||||
*ptr++ = 0x00;
|
||||
*ptr++ = 0x3F;
|
||||
*ptr++ = 0x1F;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = 0;
|
||||
*ptr++ = y>>2;
|
||||
*ptr++ = 0x3F;
|
||||
*ptr++ = 0x1F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glGenFramebuffers(1, &FramebufferID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID);
|
||||
|
||||
GLuint frametex;
|
||||
glGenTextures(1, &frametex);
|
||||
glBindTexture(GL_TEXTURE_2D, frametex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 192, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_tex);
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, frametex, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
void VCount144()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderFrame()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void RequestLine(int line)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
u32* GetLine(int line)
|
||||
{
|
||||
if (line == 0)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadPixels(0, 0, 256, 192, GL_RGBA, GL_UNSIGNED_BYTE, Framebuffer);
|
||||
}
|
||||
|
||||
return (u32*)&Framebuffer[256*4 * line];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -129,9 +129,9 @@ void DeInit()
|
|||
|
||||
void Reset()
|
||||
{
|
||||
memset(ColorBuffer, 0, 256*192 * 4);
|
||||
memset(DepthBuffer, 0, 256*192 * 4);
|
||||
memset(AttrBuffer, 0, 256*192 * 4);
|
||||
memset(ColorBuffer, 0, BufferSize * 2 * 4);
|
||||
memset(DepthBuffer, 0, BufferSize * 2 * 4);
|
||||
memset(AttrBuffer, 0, BufferSize * 2 * 4);
|
||||
|
||||
PrevIsShadowMask = false;
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ void Semaphore_Reset(void* sema);
|
|||
void Semaphore_Wait(void* sema);
|
||||
void Semaphore_Post(void* sema);
|
||||
|
||||
void* GL_GetProcAddress(const char* proc);
|
||||
|
||||
// local multiplayer comm interface
|
||||
// packet type: DS-style TX header (12 bytes) + original 802.11 frame
|
||||
bool MP_Init();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "PlatformConfig.h"
|
||||
#include "LAN_Socket.h"
|
||||
#include "LAN_PCap.h"
|
||||
#include "libui/ui.h"
|
||||
#include <string>
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
@ -302,6 +303,12 @@ void Semaphore_Post(void* sema)
|
|||
}
|
||||
|
||||
|
||||
void* GL_GetProcAddress(const char* proc)
|
||||
{
|
||||
return uiGLGetProcAddress(proc);
|
||||
}
|
||||
|
||||
|
||||
bool MP_Init()
|
||||
{
|
||||
int opt_true = 1;
|
||||
|
|
|
@ -604,7 +604,7 @@ _UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayou
|
|||
|
||||
typedef struct uiGLContext uiGLContext;
|
||||
|
||||
_UI_EXTERN uiGLContext *uiGLNewContext(uiControl* c);
|
||||
_UI_EXTERN uiGLContext *uiGLNewContext(uiControl* c, int vermajor, int verminor);
|
||||
_UI_EXTERN void uiGLFreeContext(uiGLContext* ctx);
|
||||
_UI_EXTERN void uiGLMakeContextCurrent(uiGLContext* ctx);
|
||||
_UI_EXTERN void *uiGLGetProcAddress(const char* proc);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// 31 march 2019
|
||||
#include "uipriv_windows.hpp"
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/wglext.h>
|
||||
|
||||
struct uiGLContext
|
||||
{
|
||||
uiControl* c;
|
||||
|
@ -11,9 +14,10 @@ struct uiGLContext
|
|||
};
|
||||
|
||||
|
||||
uiGLContext* uiGLNewContext(uiControl* c)
|
||||
uiGLContext* uiGLNewContext(uiControl* c, int vermajor, int verminor)
|
||||
{
|
||||
uiGLContext* ctx;
|
||||
BOOL res;
|
||||
|
||||
ctx = uiNew(uiGLContext);
|
||||
|
||||
|
@ -25,7 +29,10 @@ uiGLContext* uiGLNewContext(uiControl* c)
|
|||
else
|
||||
{
|
||||
// windowless context
|
||||
ctx->hwnd = GetDesktopWindow();
|
||||
//ctx->hwnd = GetDesktopWindow();
|
||||
// nope.
|
||||
uiFree(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
@ -41,15 +48,71 @@ uiGLContext* uiGLNewContext(uiControl* c)
|
|||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
ctx->dc = GetDC(ctx->hwnd);
|
||||
if (!ctx->dc)
|
||||
{
|
||||
uiFree(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int pixelformat = ChoosePixelFormat(ctx->dc, &pfd);
|
||||
SetPixelFormat(ctx->dc, pixelformat, &pfd);
|
||||
res = SetPixelFormat(ctx->dc, pixelformat, &pfd);
|
||||
if (!res)
|
||||
{
|
||||
ReleaseDC(ctx->hwnd, ctx->dc);
|
||||
uiFree(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->rc = wglCreateContext(ctx->dc);
|
||||
if (!ctx->rc)
|
||||
{
|
||||
ReleaseDC(ctx->hwnd, ctx->dc);
|
||||
uiFree(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wglMakeCurrent(ctx->dc, ctx->rc);
|
||||
|
||||
if (vermajor >= 3)
|
||||
{
|
||||
HGLRC (*wglCreateContextAttribsARB)(HDC,HGLRC,const int*);
|
||||
HGLRC rc_better = NULL;
|
||||
|
||||
wglCreateContextAttribsARB = (HGLRC(*)(HDC,HGLRC,const int*))wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
if (wglCreateContextAttribsARB)
|
||||
{
|
||||
int attribs[15];
|
||||
int i = 0;
|
||||
|
||||
attribs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
|
||||
attribs[i++] = vermajor;
|
||||
attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
||||
attribs[i++] = verminor;
|
||||
|
||||
attribs[i] = 0;
|
||||
rc_better = wglCreateContextAttribsARB(ctx->dc, NULL, attribs);
|
||||
}
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(ctx->rc);
|
||||
|
||||
if (!rc_better)
|
||||
{
|
||||
ReleaseDC(ctx->hwnd, ctx->dc);
|
||||
uiFree(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->rc = rc_better;
|
||||
wglMakeCurrent(ctx->dc, ctx->rc);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void uiGLFreeContext(uiGLContext* ctx)
|
||||
{
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(ctx->rc);
|
||||
ReleaseDC(ctx->hwnd, ctx->dc);
|
||||
uiFree(ctx);
|
||||
|
|
|
@ -392,6 +392,14 @@ void FeedMicInput()
|
|||
|
||||
int EmuThreadFunc(void* burp)
|
||||
{
|
||||
// TODO: fail gracefully, support older OpenGL, etc
|
||||
uiGLContext* glctx = uiGLNewContext(uiControl(MainDrawArea), 4, 3); // haw haw haw
|
||||
uiGLMakeContextCurrent(glctx);
|
||||
|
||||
void* testor = uiGLGetProcAddress("glUseProgram");
|
||||
void* testor2 = uiGLGetProcAddress("glBindFramebuffer");
|
||||
printf("OPENGL: %p %p\n", testor, testor2);
|
||||
|
||||
NDS::Init();
|
||||
|
||||
MainScreenPos[0] = 0;
|
||||
|
@ -616,6 +624,8 @@ int EmuThreadFunc(void* burp)
|
|||
NDS::DeInit();
|
||||
Platform::LAN_DeInit();
|
||||
|
||||
uiGLFreeContext(glctx);
|
||||
|
||||
return 44203;
|
||||
}
|
||||
|
||||
|
@ -1652,6 +1662,7 @@ void ApplyNewSettings(int type)
|
|||
|
||||
if (type == 0) // general emu settings
|
||||
{
|
||||
// TODO!! REMOVE ME
|
||||
GPU3D::SoftRenderer::SetupRenderThread();
|
||||
}
|
||||
else if (type == 1) // wifi settings
|
||||
|
|
Loading…
Reference in New Issue