win32-improve opengl initialization some more, add gma965 hack
This commit is contained in:
parent
006d39c3a3
commit
a08b1a3d0a
|
@ -37,6 +37,7 @@ typedef struct
|
||||||
|
|
||||||
static OGLVersion _OGLDriverVersion = {0, 0, 0};
|
static OGLVersion _OGLDriverVersion = {0, 0, 0};
|
||||||
static OpenGLRenderer *_OGLRenderer = NULL;
|
static OpenGLRenderer *_OGLRenderer = NULL;
|
||||||
|
static bool isIntel965 = false;
|
||||||
|
|
||||||
// Lookup Tables
|
// Lookup Tables
|
||||||
CACHE_ALIGN GLfloat material_8bit_to_float[256] = {0};
|
CACHE_ALIGN GLfloat material_8bit_to_float[256] = {0};
|
||||||
|
@ -272,7 +273,7 @@ static const char *fragmentShader_100 = {"\
|
||||||
void main() \n\
|
void main() \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
vec4 texColor = vec4(1.0, 1.0, 1.0, 1.0); \n\
|
vec4 texColor = vec4(1.0, 1.0, 1.0, 1.0); \n\
|
||||||
vec4 flagColor; \n\
|
vec4 fragColor; \n\
|
||||||
float flagDepth; \n\
|
float flagDepth; \n\
|
||||||
\n\
|
\n\
|
||||||
if(hasTexture) \n\
|
if(hasTexture) \n\
|
||||||
|
@ -280,69 +281,70 @@ static const char *fragmentShader_100 = {"\
|
||||||
texColor = texture2D(texMainRender, vtxTexCoord); \n\
|
texColor = texture2D(texMainRender, vtxTexCoord); \n\
|
||||||
} \n\
|
} \n\
|
||||||
\n\
|
\n\
|
||||||
flagColor = texColor; \n\
|
fragColor = texColor; \n\
|
||||||
\n\
|
\n\
|
||||||
if(polygonMode == 0) \n\
|
if(polygonMode == 0) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagColor = vtxColor * texColor; \n\
|
fragColor = vtxColor * texColor; \n\
|
||||||
} \n\
|
} \n\
|
||||||
else if(polygonMode == 1) \n\
|
else if(polygonMode == 1) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
if (texColor.a == 0.0 || !hasTexture) \n\
|
if (texColor.a == 0.0 || !hasTexture) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagColor.rgb = vtxColor.rgb; \n\
|
fragColor.rgb = vtxColor.rgb; \n\
|
||||||
} \n\
|
} \n\
|
||||||
else if (texColor.a == 1.0) \n\
|
else if (texColor.a == 1.0) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagColor.rgb = texColor.rgb; \n\
|
fragColor.rgb = texColor.rgb; \n\
|
||||||
} \n\
|
} \n\
|
||||||
else \n\
|
else \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagColor.rgb = texColor.rgb * (1.0-texColor.a) + vtxColor.rgb * texColor.a;\n\
|
fragColor.rgb = texColor.rgb * (1.0-texColor.a) + vtxColor.rgb * texColor.a;\n\
|
||||||
} \n\
|
} \n\
|
||||||
\n\
|
\n\
|
||||||
flagColor.a = vtxColor.a; \n\
|
fragColor.a = vtxColor.a; \n\
|
||||||
} \n\
|
} \n\
|
||||||
else if(polygonMode == 2) \n\
|
else if(polygonMode == 2) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
if (toonShadingMode == 0) \n\
|
if (toonShadingMode == 0) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
vec3 toonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb); \n\
|
vec3 toonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb); \n\
|
||||||
flagColor.rgb = texColor.rgb * toonColor.rgb;\n\
|
fragColor.rgb = texColor.rgb * toonColor.rgb;\n\
|
||||||
flagColor.a = texColor.a * vtxColor.a;\n\
|
fragColor.a = texColor.a * vtxColor.a;\n\
|
||||||
} \n\
|
} \n\
|
||||||
else \n\
|
else \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
vec3 toonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb); \n\
|
vec3 toonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb); \n\
|
||||||
flagColor.rgb = texColor.rgb * vtxColor.rgb + toonColor.rgb; \n\
|
fragColor.rgb = texColor.rgb * vtxColor.rgb + toonColor.rgb; \n\
|
||||||
flagColor.a = texColor.a * vtxColor.a; \n\
|
fragColor.a = texColor.a * vtxColor.a; \n\
|
||||||
} \n\
|
} \n\
|
||||||
} \n\
|
} \n\
|
||||||
else if(polygonMode == 3) \n\
|
else if(polygonMode == 3) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
if (polyID != 0) \n\
|
if (polyID != 0) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagColor = vtxColor; \n\
|
fragColor = vtxColor; \n\
|
||||||
} \n\
|
} \n\
|
||||||
} \n\
|
} \n\
|
||||||
\n\
|
\n\
|
||||||
if (flagColor.a == 0.0 || (enableAlphaTest && flagColor.a < alphaTestRef)) \n\
|
if (fragColor.a == 0.0 || (enableAlphaTest && fragColor.a < alphaTestRef)) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
discard; \n\
|
discard; \n\
|
||||||
} \n\
|
} \n\
|
||||||
\n\
|
\n\
|
||||||
|
#ifdef WANT_DEPTHLOGIC \n\
|
||||||
if (oglWBuffer == 1) \n\
|
if (oglWBuffer == 1) \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
// TODO \n\
|
// TODO \n\
|
||||||
flagDepth = (vtxPosition.z / vtxPosition.w) * 0.5 + 0.5; \n\
|
gl_FragDepth = (vtxPosition.z / vtxPosition.w) * 0.5 + 0.5; \n\
|
||||||
} \n\
|
} \n\
|
||||||
else \n\
|
else \n\
|
||||||
{ \n\
|
{ \n\
|
||||||
flagDepth = (vtxPosition.z / vtxPosition.w) * 0.5 + 0.5; \n\
|
gl_FragDepth = (vtxPosition.z / vtxPosition.w) * 0.5 + 0.5; \n\
|
||||||
} \n\
|
} \n\
|
||||||
|
#endif //WANT_DEPTHLOGIC \n\
|
||||||
\n\
|
\n\
|
||||||
gl_FragColor = flagColor; \n\
|
gl_FragColor = fragColor; \n\
|
||||||
gl_FragDepth = flagDepth; \n\
|
|
||||||
} \n\
|
} \n\
|
||||||
"};
|
"};
|
||||||
|
|
||||||
|
@ -515,6 +517,9 @@ static char OGLInit(void)
|
||||||
const char *oglVendorString = (const char *)glGetString(GL_VENDOR);
|
const char *oglVendorString = (const char *)glGetString(GL_VENDOR);
|
||||||
const char *oglRendererString = (const char *)glGetString(GL_RENDERER);
|
const char *oglRendererString = (const char *)glGetString(GL_RENDERER);
|
||||||
|
|
||||||
|
if(!strcmp(oglVendorString,"Intel") && strstr(oglRendererString,"965"))
|
||||||
|
isIntel965 = true;
|
||||||
|
|
||||||
// Check the driver's OpenGL version
|
// Check the driver's OpenGL version
|
||||||
OGLGetDriverVersion(oglVersionString, &_OGLDriverVersion.major, &_OGLDriverVersion.minor, &_OGLDriverVersion.revision);
|
OGLGetDriverVersion(oglVersionString, &_OGLDriverVersion.major, &_OGLDriverVersion.minor, &_OGLDriverVersion.revision);
|
||||||
|
|
||||||
|
@ -1093,7 +1098,15 @@ Render3DError OpenGLRenderer_1_2::CreateShaders(const std::string *vertexShaderP
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *vertexShaderProgramChar = vertexShaderProgram->c_str();
|
const char *vertexShaderProgramChar = vertexShaderProgram->c_str();
|
||||||
glShaderSource(OGLRef.vertexShaderID, 1, (const GLchar **)&vertexShaderProgramChar, NULL);
|
const char* sources[] = { "#define WANT_DEPTHLOGIC\n", vertexShaderProgramChar };
|
||||||
|
|
||||||
|
//not only does this hardware not work, it flat-out freezes the system.
|
||||||
|
//the problem is due to writing gl_FragDepth (it seems theres no way to successfully use it)
|
||||||
|
//so, we disable that feature. it still works pretty well.
|
||||||
|
if(isIntel965)
|
||||||
|
sources[0] = "";
|
||||||
|
|
||||||
|
glShaderSource(OGLRef.vertexShaderID, 2, (const GLchar **)sources, NULL);
|
||||||
glCompileShader(OGLRef.vertexShaderID);
|
glCompileShader(OGLRef.vertexShaderID);
|
||||||
if (!this->ValidateShaderCompile(OGLRef.vertexShaderID))
|
if (!this->ValidateShaderCompile(OGLRef.vertexShaderID))
|
||||||
{
|
{
|
||||||
|
|
|
@ -172,6 +172,7 @@ bool windows_opengl_init()
|
||||||
PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
|
PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
|
||||||
PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB");
|
PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB");
|
||||||
PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
|
PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
|
||||||
|
PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
||||||
|
|
||||||
if(!wglCreatePbufferARB)
|
if(!wglCreatePbufferARB)
|
||||||
{
|
{
|
||||||
|
@ -180,10 +181,13 @@ bool windows_opengl_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
int intAttrs[32] ={
|
int intAttrs[32] ={
|
||||||
|
WGL_COLOR_BITS_ARB,24,
|
||||||
WGL_RED_BITS_ARB,8,
|
WGL_RED_BITS_ARB,8,
|
||||||
WGL_GREEN_BITS_ARB,8,
|
WGL_GREEN_BITS_ARB,8,
|
||||||
WGL_BLUE_BITS_ARB,8,
|
WGL_BLUE_BITS_ARB,8,
|
||||||
WGL_ALPHA_BITS_ARB,8,
|
WGL_ALPHA_BITS_ARB,8,
|
||||||
|
WGL_DEPTH_BITS_ARB,24,
|
||||||
|
WGL_STENCIL_BITS_ARB,8,
|
||||||
WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,
|
WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,
|
||||||
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
|
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
|
||||||
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
|
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
|
||||||
|
@ -202,10 +206,7 @@ bool windows_opengl_init()
|
||||||
//pbuf attributes
|
//pbuf attributes
|
||||||
int pbuf_width = 256; //try 192 later, but i think it has to be square
|
int pbuf_width = 256; //try 192 later, but i think it has to be square
|
||||||
int pbuf_height = 256;
|
int pbuf_height = 256;
|
||||||
static const int pbuf_attributes[]= {
|
static const int pbuf_attributes[]= {0};
|
||||||
WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
|
|
||||||
WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
|
|
||||||
0};
|
|
||||||
|
|
||||||
HPBUFFERARB pbuffer = wglCreatePbufferARB(main_hDC, pixelFormat, pbuf_width, pbuf_height, pbuf_attributes);
|
HPBUFFERARB pbuffer = wglCreatePbufferARB(main_hDC, pixelFormat, pbuf_width, pbuf_height, pbuf_attributes);
|
||||||
HDC hdc = wglGetPbufferDCARB(pbuffer);
|
HDC hdc = wglGetPbufferDCARB(pbuffer);
|
||||||
|
|
Loading…
Reference in New Issue