mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
#52 fixes macOS OpenGL core profile
This commit is contained in:
parent
7229a2a34e
commit
05d665dea9
@ -1,7 +1,7 @@
|
|||||||
#ifndef OPENGLSHADER_H
|
#ifndef OPENGLSHADER_H
|
||||||
#define OPENGLSHADER_H
|
#define OPENGLSHADER_H
|
||||||
|
|
||||||
// old
|
// OpenGL 2.0
|
||||||
|
|
||||||
const char PASSTHROUGH_VERT_SHADER_110[] =
|
const char PASSTHROUGH_VERT_SHADER_110[] =
|
||||||
"#version 110\n"
|
"#version 110\n"
|
||||||
@ -37,7 +37,7 @@ const char PASSTHROUGH_FRAG_SHADER_110[] =
|
|||||||
" gl_FragColor = texel; \n"
|
" gl_FragColor = texel; \n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// new
|
// OpenGL 3.0
|
||||||
|
|
||||||
const char PASSTHROUGH_VERT_SHADER[] =
|
const char PASSTHROUGH_VERT_SHADER[] =
|
||||||
"#version 130\n"
|
"#version 130\n"
|
||||||
@ -82,4 +82,49 @@ const char PASSTHROUGH_FRAG_SHADER[] =
|
|||||||
" FragColor = texel;\n"
|
" FragColor = texel;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
// OpenGL 3.2 (Core Profile)
|
||||||
|
|
||||||
|
const char PASSTHROUGH_VERT_SHADER_CORE[] =
|
||||||
|
"#version 150\n"
|
||||||
|
"in vec4 VertexCoord;\n"
|
||||||
|
"in vec4 COLOR;\n"
|
||||||
|
"in vec4 TexCoord;\n"
|
||||||
|
"out vec4 COL0;\n"
|
||||||
|
"out vec4 TEX0;\n"
|
||||||
|
"uniform mat4 MVPMatrix;\n"
|
||||||
|
"\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = MVPMatrix * VertexCoord;\n"
|
||||||
|
" COL0 = COLOR;\n"
|
||||||
|
" TEX0.xy = TexCoord.xy;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
const char PALETTE_FRAG_SHADER_CORE[] =
|
||||||
|
"#version 150\n"
|
||||||
|
"out vec4 FragColor;\n"
|
||||||
|
"uniform sampler2D SurfaceTex;\n"
|
||||||
|
"uniform sampler2D PaletteTex;\n"
|
||||||
|
"in vec4 TEX0;\n"
|
||||||
|
"\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 pIndex = texture(SurfaceTex, TEX0.xy);\n"
|
||||||
|
" FragColor = texture(PaletteTex, vec2(pIndex.r * (255.0/256.0) + (0.5/256.0), 0));\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
const char PASSTHROUGH_FRAG_SHADER_CORE[] =
|
||||||
|
"#version 150\n"
|
||||||
|
"out vec4 FragColor;\n"
|
||||||
|
"uniform sampler2D SurfaceTex;\n"
|
||||||
|
"in vec4 TEX0;\n"
|
||||||
|
"\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 texel = texture(SurfaceTex, TEX0.xy);\n"
|
||||||
|
" FragColor = texel;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "opengl_utils.h"
|
#include "opengl_utils.h"
|
||||||
|
#include "dd.h"
|
||||||
|
|
||||||
PFNWGLCREATECONTEXTPROC xwglCreateContext;
|
PFNWGLCREATECONTEXTPROC xwglCreateContext;
|
||||||
PFNWGLDELETECONTEXTPROC xwglDeleteContext;
|
PFNWGLDELETECONTEXTPROC xwglDeleteContext;
|
||||||
@ -209,7 +210,7 @@ void oglu_init()
|
|||||||
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
|
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
|
||||||
glGetUniformLocation;
|
glGetUniformLocation;
|
||||||
|
|
||||||
if (g_oglu_got_version3 && glversion && glversion[0] == '2') // macOS
|
if (g_ddraw->wine && glversion && glversion[0] == '2') // macOS
|
||||||
{
|
{
|
||||||
g_oglu_got_version3 = FALSE;
|
g_oglu_got_version3 = FALSE;
|
||||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
|
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
|
||||||
|
@ -79,8 +79,8 @@ static HGLRC ogl_create_core_context(HDC hdc)
|
|||||||
|
|
||||||
if (made_current)
|
if (made_current)
|
||||||
{
|
{
|
||||||
g_oglu_got_version3 = TRUE;
|
|
||||||
xwglDeleteContext(g_ogl.context);
|
xwglDeleteContext(g_ogl.context);
|
||||||
|
oglu_init();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
else if (context)
|
else if (context)
|
||||||
@ -169,10 +169,20 @@ static void ogl_build_programs()
|
|||||||
if (g_ddraw->bpp == 8)
|
if (g_ddraw->bpp == 8)
|
||||||
{
|
{
|
||||||
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PALETTE_FRAG_SHADER);
|
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PALETTE_FRAG_SHADER);
|
||||||
|
|
||||||
|
if (!g_ogl.main_program)
|
||||||
|
{
|
||||||
|
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER_CORE, PALETTE_FRAG_SHADER_CORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (g_ddraw->bpp == 16)
|
else if (g_ddraw->bpp == 16)
|
||||||
{
|
{
|
||||||
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PASSTHROUGH_FRAG_SHADER);
|
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER, PASSTHROUGH_FRAG_SHADER);
|
||||||
|
|
||||||
|
if (!g_ogl.main_program)
|
||||||
|
{
|
||||||
|
g_ogl.main_program = oglu_build_program(PASSTHROUGH_VERT_SHADER_CORE, PASSTHROUGH_FRAG_SHADER_CORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ogl.main_program)
|
if (g_ogl.main_program)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user