Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 45 #47

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/Interface/UIInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,35 @@ UIInterface::UIInterface()

void UIInterface::setGLContextAttribute()
{
struct gl_version {
int major;
int minor;
};
struct gl_version approved_versions[] = {
{4, 5 }, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0},
{3, 2}, {3, 1}, /*{3, 0},*/
{2, 1}, {2, 0},
{1, 5}, {1, 4}, {1, 3}, {1, 2}, {1, 1},
{-1, -1}
};
struct gl_version * ver;

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
ver = &approved_versions[0];
while (ver->major != -1 ) {
if ( SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, ver->major) == 0 &&
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, ver->minor) == 0) {
break;
}
}
//printf("Set GL to %d.%d\n", ver->major, ver->minor);
}

bool UIInterface::createWindow(int width, int height)
Expand Down Expand Up @@ -489,7 +508,7 @@ uint8_t *UIInterface::readScreenPixel()
/* Flip Y pixels (row by row) */
for (uint32_t i = 0; i < height; i++) {
memcpy(m_FrameBuffer + i * width * 4,
&ret[(height - i - 1) * width * 4],
&ret[(height - i - 1) * width * 4],
width * 4);
}

Expand Down