mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-13 01:20:34 +02:00
New function GL2D::checkErrors() - prints GL errors codes,
bugs fixes in GL2D::makeShaderProgram and CButtion class
This commit is contained in:
@ -19,15 +19,11 @@ CImage::~CImage()
|
||||
void CImage::loadToVideoRAM()
|
||||
{
|
||||
if (texHandle > 0) return;
|
||||
|
||||
glGenTextures(1, &texHandle);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE, texHandle);
|
||||
GL2D::checkErrors("CImage::loadToVideoRAM");
|
||||
|
||||
GLenum err = glGetError();
|
||||
if (err != GL_NO_ERROR)
|
||||
{
|
||||
tlog1 << "Gfx Error: glBindTexture faild in loadToVideoRAM\n";
|
||||
tlog1 << "GL error code = " << err << std::endl;
|
||||
}
|
||||
textureTransfer();
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ void CButton::clickLeft(tribool down, bool previousState)
|
||||
|
||||
if (down)
|
||||
{
|
||||
state == PRESSED;
|
||||
state = PRESSED;
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
|
||||
if (text) text->moveTo(Point(pos.x+pos.w/2+1, pos.y+pos.h/2+1));
|
||||
|
@ -68,6 +68,17 @@ static GLuint paletteBitmapProgram = 0;
|
||||
static GLint coord_uniform = -1;
|
||||
|
||||
|
||||
// Check for errors
|
||||
void checkErrors(const std::string & place)
|
||||
{
|
||||
GLenum err;
|
||||
while ((err = glGetError()) != GL_NO_ERROR)
|
||||
{
|
||||
tlog1 << "GL Error in " << place << "; code = " << err << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print out the information log for a shader object
|
||||
void printInfoLog(PFNGLGETPROGRAMINFOLOGPROC logFunc, GLuint object, GLint status)
|
||||
{
|
||||
@ -103,13 +114,15 @@ GLuint makeShaderProgram(const char * frg_src)
|
||||
// Link the shaders into a complete GLSL program.
|
||||
glLinkProgram(program_object);
|
||||
|
||||
glGetProgramiv(shader_object, GL_LINK_STATUS, &ret);
|
||||
ret = GL_FALSE;
|
||||
glGetProgramiv(program_object, GL_LINK_STATUS, &ret);
|
||||
printInfoLog(glGetProgramInfoLog, program_object, ret);
|
||||
|
||||
if (ret == GL_TRUE) return program_object;
|
||||
}
|
||||
|
||||
glDeleteShader(shader_object);
|
||||
checkErrors("makeShaderProgram");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -160,6 +173,8 @@ void initVideo(ui32 w, ui32 h, bool fullscreen)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
checkErrors("initVideo - early");
|
||||
|
||||
paletteBitmapProgram = makeShaderProgram(frag_palette_bitmap);
|
||||
if (paletteBitmapProgram == 0)
|
||||
{
|
||||
@ -174,6 +189,8 @@ void initVideo(ui32 w, ui32 h, bool fullscreen)
|
||||
glUniform1i(bitmap_uniform, 0);
|
||||
glUniform1i(palette_uniform, 1);
|
||||
|
||||
checkErrors("initVideo - late");
|
||||
|
||||
// unhook OpenGL context from display context/window
|
||||
#ifdef _WIN32
|
||||
if (!wglMakeCurrent(NULL, NULL))
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace GL2D
|
||||
{
|
||||
void checkErrors(const std::string & place);
|
||||
|
||||
void initVideo(ui32 w, ui32 h, bool fullscreen);
|
||||
void attachToCurrentThread();
|
||||
bool setScreenRes(ui32 w, ui32 h, bool fullscreen);
|
||||
|
@ -167,6 +167,7 @@
|
||||
<ClCompile Include="BattleHex.cpp" />
|
||||
<ClCompile Include="BattleState.cpp" />
|
||||
<ClCompile Include="CArtHandler.cpp" />
|
||||
<ClCompile Include="CBonusTypeHandler.cpp" />
|
||||
<ClCompile Include="CBuildingHandler.cpp" />
|
||||
<ClCompile Include="CConfigHandler.cpp" />
|
||||
<ClCompile Include="CConsoleHandler.cpp" />
|
||||
|
Reference in New Issue
Block a user