그래픽 : AMD 라데온 HD 7900 시리즈의 OpenGL : 아무것도 그려
실행 : 윈도우 7 (64 비트)
프로그램 : CodeBlocks (32 비트)
의 OpenGL 라이브러리 : GLee
창문. OpenGL 렌더링을 사용하는 SDL 창.
void Init(int w, int h, bool fullScr)
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
}
winW = w*scale;
winH = h*scale;
original_winW = w;
origianl_winH = h;
putenv("SDL_VIDEO_WINDOW_POS");
putenv("SDL_VIDEO_CENTERED=1");
getenv("SDL_VIDEO_WINDOW_POS");
getenv("SDL_VIDEO_CENTERED");
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // *new*
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); // *new*
//Sets up the screen and displays the window
screen = SDL_SetVideoMode(winW, winH, 32, SDL_OPENGL | (fullScr*SDL_FULLSCREEN) ); // *changed*
screenRect.x = 0;
screenRect.y = 0;
screenRect.w = winW;
screenRect.h = winH;
SDL_ShowCursor(false);
SetGLState();
}
이은 (는) 전술 한 SetGLState이다. 이미지가이 창에는 아무것도 그리지 않고 화면
void DrawImage(GLSurface image, float x, float y)
{
// Bind the texture to which subsequent calls refer to
if(boundTexture != image.Surface){glBindTexture(GL_TEXTURE_2D, image.Surface); boundTexture = image.Surface; }
glReadPixels(x,y,image.w*2,image.h*2,GL_UNSIGNED_BYTE,NULL,NULL);
glLoadIdentity();
glScalef(scale,scale,1);
glRotatef(image.rotation[0], 1.0f, 0.0f, 0.0f);
glRotatef(image.rotation[1], 0.0f, 1.0f, 0.0f);
glRotatef(image.rotation[2], 0.0f, 0.0f, 1.0f);
if(scale == 7.5)x += 48;
glBegin(GL_QUADS);
//Bottom-left vertex (corner)
glColor3b(127,127,127);
glTexCoord2i(0, 0); //Position on texture to begin interpolation
glVertex3f(x, y, 0.f); //Vertex Coords
//Bottom-right vertex (corner)
glTexCoord2i(1, 0);
glVertex3f(x+image.w, y, 0.f);
//Top-right vertex (corner)
glTexCoord2i(1, 1);
glVertex3f(x+image.w, y+image.h, 0.f);
//Top-left vertex (corner)
glTexCoord2i(0, 1);
glVertex3f(x, y+image.h, 0.f);
glEnd();
}
에 그려진 곳
void SetGLState(){
glEnable(GL_TEXTURE_2D); //Enable 2d texturing
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Set clear color (rgba)
glViewport(0, 0, winW, winH); //Set the viewport
glClear(GL_COLOR_BUFFER_BIT); //Clear back buffer?
glMatrixMode(GL_PROJECTION); //Set to projection
glLoadIdentity();
glOrtho(0.0f, winW, winH, 0.0f, -1.0f, 1.0f); //Create orthogonal projection matrix
glMatrixMode(GL_MODELVIEW); //Set back to model view
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
이이며, 그 이유를 알아낼 수 없습니다. 나는 잠시 후에이 코드를 보지 못했지만, 이전에 설치 한 Windows에서 작동했음을 알고 있습니다. 다른 모든 프로젝트가 실행되지만이 프로젝트는 실행되지 않습니다. 그냥 빈 화면을 렌더링합니다. 이상한 것은 -이 창에 대한 크기 조정 기능이 있습니다. 해당 함수가 호출되면 화면에 검은 색이 아닌 흰색 화면이 표시됩니다.
편집 ** 이 코드는 모든 것이 화면에 그려지면 끝나면 호출됩니다. 그것은 이미 내 코드에 포함되어있었습니다. SetGLState 설정
void Flip(){
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT);
}
방금 내 게시물을 편집했습니다. 네가하는 말은 모두 이미 다 끝났어. 그냥 별도의 기능으로. 나는 그것을 포함하는 것을 잊었다. 지금 내 게시물에서 누락 된 다른 코드가 없어야합니다. 미안합니다. 문제는 여전히 남아 있습니다. – bennybroseph
@ user1959403 : 버퍼 스왑 호출 후에 glClear를 넣지 않아야합니다. 이상하게 보이고 혼란 스러울 수 있습니다. 일반적으로 프레임 그리기 시작시 항상 지 웁니다. – datenwolf
나는 당신의 제안을 모두 고친 후에도 여전히이 문제를 파악하지 못했습니다. 문제가 될 수있는 코드와 관련이없는 것이 있습니까? – bennybroseph