C++ sdl osx eclipse c++;显示错误

C++ sdl osx eclipse c++;显示错误,c++,eclipse,macos,opengl,sdl,C++,Eclipse,Macos,Opengl,Sdl,我在osx下的eclipse中运行SDL应用程序时遇到问题 #include <SDL/SDL_opengl.h> #include <SDL/SDL.h> #include <SDL_ttf/SDL_ttf.h> #include <SDL_image/SDL_image.h> #include <iostream.h> int main(int argc, char* argv[]){ int error; err

我在osx下的eclipse中运行SDL应用程序时遇到问题

#include <SDL/SDL_opengl.h>
#include <SDL/SDL.h>
#include <SDL_ttf/SDL_ttf.h>
#include <SDL_image/SDL_image.h>
#include <iostream.h>

int main(int argc, char* argv[]){
    int error;
    error = SDL_Init(SDL_INIT_EVERYTHING);
    std::cout << "error " << error << std::endl;
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);

    Uint32 flags;

    flags = SDL_OPENGL | SDL_HWSURFACE | SDL_HWPALETTE| SDL_DOUBLEBUF ;
    drawContext = SDL_SetVideoMode(1024, 768, 16, flags);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0f, 1024, 768, 0.0f, 0.0f, 1000.0f);

    glMatrixMode(GL_MODELVIEW);

    while(true){
        glFinish();
        SDL_GL_SwapBuffers();
    }
}
#包括
#包括
#包括
#包括
#包括
int main(int argc,char*argv[]){
整数误差;
error=SDL_Init(SDL_Init_一切);

std::cout您永远不会费心将默认帧缓冲区清除为已知值,GL实现也不需要为您提供已清除的缓冲区

,第254页,第1段(重点):

默认帧缓冲区最初用作绘制和读取帧缓冲区, 和提供的所有位平面的初始状态未定义。可以按照第9.2.3节的说明查询绘制和读取帧缓冲区中缓冲区的格式和编码

在交换前的某个时间清除帧缓冲区:

while(true)
{
    glClear( GL_COLOR_BUFFER_BIT );

    // draw stuff

    SDL_GL_SwapBuffers();
}

在eclipse中查看代码的不是实际的“破碎”屏幕,而是您的应用程序吗?该应用程序随机显示部分屏幕分幅。在某些情况下,我会看到几分钟前运行的一些屏幕保护程序。此窗口就是应用程序窗口。