diff --git a/common/lc_context.cpp b/common/lc_context.cpp index e0e6b1e6..6e1562e0 100644 --- a/common/lc_context.cpp +++ b/common/lc_context.cpp @@ -146,10 +146,11 @@ void lcContext::CreateShaderPrograms() // LC_PROGRAM_TEXTURE "#version 110\n" "varying vec2 PixelTexCoord;\n" + "uniform vec4 Color;\n" "uniform sampler2D Texture;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(Texture, PixelTexCoord);\n" + " gl_FragColor = texture2D(Texture, PixelTexCoord) * Color;\n" "}\n", // LC_PROGRAM_VERTEX_COLOR "#version 110\n" diff --git a/common/lc_glextensions.h b/common/lc_glextensions.h index eca6ee2d..29cf0ee4 100644 --- a/common/lc_glextensions.h +++ b/common/lc_glextensions.h @@ -61,58 +61,58 @@ extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC lcFramebufferRenderbufferEXT; extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC lcGetFramebufferAttachmentParameterivEXT; extern PFNGLGENERATEMIPMAPEXTPROC lcGenerateMipmapEXT; -extern PFNGLATTACHSHADERPROC lcAttachShader; -extern PFNGLBINDATTRIBLOCATIONPROC lcBindAttribLocation; -extern PFNGLCOMPILESHADERPROC lcCompileShader; -extern PFNGLCREATEPROGRAMPROC lcCreateProgram; -extern PFNGLCREATESHADERPROC lcCreateShader; -extern PFNGLDELETEPROGRAMPROC lcDeleteProgram; -extern PFNGLDELETESHADERPROC lcDeleteShader; -extern PFNGLDETACHSHADERPROC lcDetachShader; -extern PFNGLDISABLEVERTEXATTRIBARRAYPROC lcDisableVertexAttribArray; -extern PFNGLENABLEVERTEXATTRIBARRAYPROC lcEnableVertexAttribArray; -extern PFNGLGETACTIVEATTRIBPROC lcGetActiveAttrib; -extern PFNGLGETACTIVEUNIFORMPROC lcGetActiveUniform; -extern PFNGLGETATTACHEDSHADERSPROC lcGetAttachedShaders; -extern PFNGLGETATTRIBLOCATIONPROC lcGetAttribLocation; -extern PFNGLGETPROGRAMIVPROC lcGetProgramiv; -extern PFNGLGETPROGRAMINFOLOGPROC lcGetProgramInfoLog; -extern PFNGLGETSHADERIVPROC lcGetShaderiv; -extern PFNGLGETSHADERINFOLOGPROC lcGetShaderInfoLog; -extern PFNGLGETSHADERSOURCEPROC lcGetShaderSource; -extern PFNGLGETUNIFORMLOCATIONPROC lcGetUniformLocation; -extern PFNGLGETUNIFORMFVPROC lcGetUniformfv; -extern PFNGLGETUNIFORMIVPROC lcGetUniformiv; -extern PFNGLGETVERTEXATTRIBDVPROC lcGetVertexAttribdv; -extern PFNGLGETVERTEXATTRIBFVPROC lcGetVertexAttribfv; -extern PFNGLGETVERTEXATTRIBIVPROC lcGetVertexAttribiv; -extern PFNGLGETVERTEXATTRIBPOINTERVPROC lcGetVertexAttribPointerv; -extern PFNGLISPROGRAMPROC lcIsProgram; -extern PFNGLISSHADERPROC lcIsShader; -extern PFNGLLINKPROGRAMPROC lcLinkProgram; -extern PFNGLSHADERSOURCEPROC lcShaderSource; -extern PFNGLUSEPROGRAMPROC lcUseProgram; -extern PFNGLUNIFORM1FPROC lcUniform1f; -extern PFNGLUNIFORM2FPROC lcUniform2f; -extern PFNGLUNIFORM3FPROC lcUniform3f; -extern PFNGLUNIFORM4FPROC lcUniform4f; -extern PFNGLUNIFORM1IPROC lcUniform1i; -extern PFNGLUNIFORM2IPROC lcUniform2i; -extern PFNGLUNIFORM3IPROC lcUniform3i; -extern PFNGLUNIFORM4IPROC lcUniform4i; -extern PFNGLUNIFORM1FVPROC lcUniform1fv; -extern PFNGLUNIFORM2FVPROC lcUniform2fv; -extern PFNGLUNIFORM3FVPROC lcUniform3fv; -extern PFNGLUNIFORM4FVPROC lcUniform4fv; -extern PFNGLUNIFORM1IVPROC lcUniform1iv; -extern PFNGLUNIFORM2IVPROC lcUniform2iv; -extern PFNGLUNIFORM3IVPROC lcUniform3iv; -extern PFNGLUNIFORM4IVPROC lcUniform4iv; -extern PFNGLUNIFORMMATRIX2FVPROC lcUniformMatrix2fv; -extern PFNGLUNIFORMMATRIX3FVPROC lcUniformMatrix3fv; -extern PFNGLUNIFORMMATRIX4FVPROC lcUniformMatrix4fv; -extern PFNGLVALIDATEPROGRAMPROC lcValidateProgram; -extern PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer; +extern PFNGLATTACHSHADERPROC lcAttachShader; +extern PFNGLBINDATTRIBLOCATIONPROC lcBindAttribLocation; +extern PFNGLCOMPILESHADERPROC lcCompileShader; +extern PFNGLCREATEPROGRAMPROC lcCreateProgram; +extern PFNGLCREATESHADERPROC lcCreateShader; +extern PFNGLDELETEPROGRAMPROC lcDeleteProgram; +extern PFNGLDELETESHADERPROC lcDeleteShader; +extern PFNGLDETACHSHADERPROC lcDetachShader; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC lcDisableVertexAttribArray; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC lcEnableVertexAttribArray; +extern PFNGLGETACTIVEATTRIBPROC lcGetActiveAttrib; +extern PFNGLGETACTIVEUNIFORMPROC lcGetActiveUniform; +extern PFNGLGETATTACHEDSHADERSPROC lcGetAttachedShaders; +extern PFNGLGETATTRIBLOCATIONPROC lcGetAttribLocation; +extern PFNGLGETPROGRAMIVPROC lcGetProgramiv; +extern PFNGLGETPROGRAMINFOLOGPROC lcGetProgramInfoLog; +extern PFNGLGETSHADERIVPROC lcGetShaderiv; +extern PFNGLGETSHADERINFOLOGPROC lcGetShaderInfoLog; +extern PFNGLGETSHADERSOURCEPROC lcGetShaderSource; +extern PFNGLGETUNIFORMLOCATIONPROC lcGetUniformLocation; +extern PFNGLGETUNIFORMFVPROC lcGetUniformfv; +extern PFNGLGETUNIFORMIVPROC lcGetUniformiv; +extern PFNGLGETVERTEXATTRIBDVPROC lcGetVertexAttribdv; +extern PFNGLGETVERTEXATTRIBFVPROC lcGetVertexAttribfv; +extern PFNGLGETVERTEXATTRIBIVPROC lcGetVertexAttribiv; +extern PFNGLGETVERTEXATTRIBPOINTERVPROC lcGetVertexAttribPointerv; +extern PFNGLISPROGRAMPROC lcIsProgram; +extern PFNGLISSHADERPROC lcIsShader; +extern PFNGLLINKPROGRAMPROC lcLinkProgram; +extern PFNGLSHADERSOURCEPROC lcShaderSource; +extern PFNGLUSEPROGRAMPROC lcUseProgram; +extern PFNGLUNIFORM1FPROC lcUniform1f; +extern PFNGLUNIFORM2FPROC lcUniform2f; +extern PFNGLUNIFORM3FPROC lcUniform3f; +extern PFNGLUNIFORM4FPROC lcUniform4f; +extern PFNGLUNIFORM1IPROC lcUniform1i; +extern PFNGLUNIFORM2IPROC lcUniform2i; +extern PFNGLUNIFORM3IPROC lcUniform3i; +extern PFNGLUNIFORM4IPROC lcUniform4i; +extern PFNGLUNIFORM1FVPROC lcUniform1fv; +extern PFNGLUNIFORM2FVPROC lcUniform2fv; +extern PFNGLUNIFORM3FVPROC lcUniform3fv; +extern PFNGLUNIFORM4FVPROC lcUniform4fv; +extern PFNGLUNIFORM1IVPROC lcUniform1iv; +extern PFNGLUNIFORM2IVPROC lcUniform2iv; +extern PFNGLUNIFORM3IVPROC lcUniform3iv; +extern PFNGLUNIFORM4IVPROC lcUniform4iv; +extern PFNGLUNIFORMMATRIX2FVPROC lcUniformMatrix2fv; +extern PFNGLUNIFORMMATRIX3FVPROC lcUniformMatrix3fv; +extern PFNGLUNIFORMMATRIX4FVPROC lcUniformMatrix4fv; +extern PFNGLVALIDATEPROGRAMPROC lcValidateProgram; +extern PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer; #define glBindBuffer lcBindBufferARB #define glDeleteBuffers lcDeleteBuffersARB @@ -165,57 +165,57 @@ extern PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer; #define glGetFramebufferAttachmentParameterivEXT lcGetFramebufferAttachmentParameterivEXT #define glGenerateMipmapEXT lcGenerateMipmapEXT -#define glAttachShader lcAttachShader -#define glBindAttribLocation lcBindAttribLocation -#define glCompileShader lcCompileShader -#define glCreateProgram lcCreateProgram -#define glCreateShader lcCreateShader -#define glDeleteProgram lcDeleteProgram -#define glDeleteShader lcDeleteShader -#define glDetachShader lcDetachShader -#define glDisableVertexAttribArray lcDisableVertexAttribArray -#define glEnableVertexAttribArray lcEnableVertexAttribArray -#define glGetActiveAttrib lcGetActiveAttrib -#define glGetActiveUniform lcGetActiveUniform -#define glGetAttachedShaders lcGetAttachedShaders -#define glGetAttribLocation lcGetAttribLocation -#define glGetProgramiv lcGetProgramiv -#define glGetProgramInfoLog lcGetProgramInfoLog -#define glGetShaderiv lcGetShaderiv -#define glGetShaderInfoLog lcGetShaderInfoLog -#define glGetShaderSource lcGetShaderSource -#define glGetUniformLocation lcGetUniformLocation -#define glGetUniformfv lcGetUniformfv -#define glGetUniformiv lcGetUniformiv -#define glGetVertexAttribdv lcGetVertexAttribdv -#define glGetVertexAttribfv lcGetVertexAttribfv -#define glGetVertexAttribiv lcGetVertexAttribiv -#define glGetVertexAttribPointerv lcGetVertexAttribPointerv -#define glIsProgram lcIsProgram -#define glIsShader lcIsShader -#define glLinkProgram lcLinkProgram -#define glShaderSource lcShaderSource -#define glUseProgram lcUseProgram -#define glUniform1f lcUniform1f -#define glUniform2f lcUniform2f -#define glUniform3f lcUniform3f -#define glUniform4f lcUniform4f -#define glUniform1i lcUniform1i -#define glUniform2i lcUniform2i -#define glUniform3i lcUniform3i -#define glUniform4i lcUniform4i -#define glUniform1fv lcUniform1fv -#define glUniform2fv lcUniform2fv -#define glUniform3fv lcUniform3fv -#define glUniform4fv lcUniform4fv -#define glUniform1iv lcUniform1iv -#define glUniform2iv lcUniform2iv -#define glUniform3iv lcUniform3iv -#define glUniform4iv lcUniform4iv -#define glUniformMatrix2fv lcUniformMatrix2fv -#define glUniformMatrix3fv lcUniformMatrix3fv -#define glUniformMatrix4fv lcUniformMatrix4fv -#define glValidateProgram lcValidateProgram -#define glVertexAttribPointer lcVertexAttribPointer +#define glAttachShader lcAttachShader +#define glBindAttribLocation lcBindAttribLocation +#define glCompileShader lcCompileShader +#define glCreateProgram lcCreateProgram +#define glCreateShader lcCreateShader +#define glDeleteProgram lcDeleteProgram +#define glDeleteShader lcDeleteShader +#define glDetachShader lcDetachShader +#define glDisableVertexAttribArray lcDisableVertexAttribArray +#define glEnableVertexAttribArray lcEnableVertexAttribArray +#define glGetActiveAttrib lcGetActiveAttrib +#define glGetActiveUniform lcGetActiveUniform +#define glGetAttachedShaders lcGetAttachedShaders +#define glGetAttribLocation lcGetAttribLocation +#define glGetProgramiv lcGetProgramiv +#define glGetProgramInfoLog lcGetProgramInfoLog +#define glGetShaderiv lcGetShaderiv +#define glGetShaderInfoLog lcGetShaderInfoLog +#define glGetShaderSource lcGetShaderSource +#define glGetUniformLocation lcGetUniformLocation +#define glGetUniformfv lcGetUniformfv +#define glGetUniformiv lcGetUniformiv +#define glGetVertexAttribdv lcGetVertexAttribdv +#define glGetVertexAttribfv lcGetVertexAttribfv +#define glGetVertexAttribiv lcGetVertexAttribiv +#define glGetVertexAttribPointerv lcGetVertexAttribPointerv +#define glIsProgram lcIsProgram +#define glIsShader lcIsShader +#define glLinkProgram lcLinkProgram +#define glShaderSource lcShaderSource +#define glUseProgram lcUseProgram +#define glUniform1f lcUniform1f +#define glUniform2f lcUniform2f +#define glUniform3f lcUniform3f +#define glUniform4f lcUniform4f +#define glUniform1i lcUniform1i +#define glUniform2i lcUniform2i +#define glUniform3i lcUniform3i +#define glUniform4i lcUniform4i +#define glUniform1fv lcUniform1fv +#define glUniform2fv lcUniform2fv +#define glUniform3fv lcUniform3fv +#define glUniform4fv lcUniform4fv +#define glUniform1iv lcUniform1iv +#define glUniform2iv lcUniform2iv +#define glUniform3iv lcUniform3iv +#define glUniform4iv lcUniform4iv +#define glUniformMatrix2fv lcUniformMatrix2fv +#define glUniformMatrix3fv lcUniformMatrix3fv +#define glUniformMatrix4fv lcUniformMatrix4fv +#define glValidateProgram lcValidateProgram +#define glVertexAttribPointer lcVertexAttribPointer #endif diff --git a/common/texfont.cpp b/common/texfont.cpp index 2a076edf..cb937217 100644 --- a/common/texfont.cpp +++ b/common/texfont.cpp @@ -121,14 +121,17 @@ bool TexFont::Load() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - unsigned char ExpandedData[sizeof(TextureData) * 8]; + unsigned char ExpandedData[sizeof(TextureData) * 8 * 2]; for (unsigned int TexelIdx = 0; TexelIdx < sizeof(TextureData) * 8; TexelIdx++) - ExpandedData[TexelIdx] = TextureData[TexelIdx / 8] & (1 << (TexelIdx % 8)) ? 255 : 0; + { + unsigned char Texel = TextureData[TexelIdx / 8] & (1 << (TexelIdx % 8)) ? 255 : 0; + ExpandedData[TexelIdx * 2] = ExpandedData[TexelIdx * 2 + 1] = Texel; + } mTextureWidth = 128; mTextureHeight = 128; - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mTextureWidth, mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, ExpandedData); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, mTextureWidth, mTextureHeight, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, ExpandedData); const unsigned char* Ptr = GlyphData; diff --git a/common/view.cpp b/common/view.cpp index 64999405..28739071 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -821,7 +821,8 @@ void View::DrawRotateOverlay() Verts[0] = lcVector3(0.0f, 0.0f, 0.0f); int NumVerts = 1; - glVertexPointer(3, GL_FLOAT, 0, Verts); + mContext->SetVertexBufferPointer(Verts); + mContext->SetVertexFormat(0, 3, 0, 0); float StartAngle; int i = 0; @@ -840,7 +841,7 @@ void View::DrawRotateOverlay() if (NumVerts == 33) { - glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts); + mContext->DrawPrimitives(GL_TRIANGLE_FAN, 0, NumVerts); Verts[1] = Verts[32]; NumVerts = 2; } @@ -854,7 +855,7 @@ void View::DrawRotateOverlay() } while (Angle >= 0.0f); if (NumVerts > 2) - glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts); + mContext->DrawPrimitives(GL_TRIANGLE_FAN, 0, NumVerts); glDisable(GL_BLEND); } @@ -882,8 +883,10 @@ void View::DrawRotateOverlay() mContext->SetColor(0.1f, 0.1f, 0.1f, 1.0f); mContext->SetWorldMatrix(lcMatrix44Identity()); - glVertexPointer(3, GL_FLOAT, 0, Verts); - glDrawArrays(GL_LINE_LOOP, 0, 32); + mContext->SetVertexBufferPointer(Verts); + mContext->SetVertexFormat(0, 3, 0, 0); + + mContext->DrawPrimitives(GL_LINE_LOOP, 0, 32); } lcVector3 ViewDir = mCamera->mTargetPosition - mCamera->mPosition; @@ -953,8 +956,10 @@ void View::DrawRotateOverlay() } } - glVertexPointer(3, GL_FLOAT, 0, Verts); - glDrawArrays(GL_LINES, 0, NumVerts); + mContext->SetVertexBufferPointer(Verts); + mContext->SetVertexFormat(0, 3, 0, 0); + + mContext->DrawPrimitives(GL_LINES, 0, NumVerts); } // Draw tangent vector. @@ -1009,13 +1014,16 @@ void View::DrawRotateOverlay() Verts[4] = lcVector3(0.0f, StartY, EndZ); Verts[5] = lcVector3(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ); - glVertexPointer(3, GL_FLOAT, 0, Verts); - glDrawArrays(GL_LINES, 0, 6); + mContext->SetVertexBufferPointer(Verts); + mContext->SetVertexFormat(0, 3, 0, 0); + + mContext->DrawPrimitives(GL_LINES, 0, 6); } // Draw text. lcVector3 ScreenPos = ProjectPoint(OverlayCenter); + mContext->SetProgram(LC_PROGRAM_TEXTURE); mContext->SetWorldMatrix(lcMatrix44Identity()); mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0))); mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f));