0

我开始学习 SDL,并且正在关注互联网上的一些教程。我写了一个简单的代码,在屏幕上显示窗口 2 秒:

#include <SDL2/SDL.h>
#include <stdio.h>

#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

int main(void)
{
    SDL_Window* window = NULL;
    SDL_Surface* screenSurface = NULL;

    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
    }
    else
    {
        window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( window == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
        }
        else
        {
            screenSurface = SDL_GetWindowSurface( window );
            SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
            SDL_UpdateWindowSurface( window );
            SDL_Delay( 2000 );
        }
    }

    SDL_DestroyWindow( window );
    SDL_Quit();

    return 0;
}

当我运行它时,它运行良好。但是,如果我使用 运行它Valgrind,则会显示许多无效读取和其他错误。要查看错误,请参见此处

所有这些似乎都与它有关fglrx_dri.so

长话短说:我最近买了一台装有 Ubuntu 14.04 和 AMD 显卡的戴尔笔记本电脑。我无法安装它。我尝试了很多方法来安装它,但都失败了。所以当我在终端lspci | grep VGA显示时输入:

00:02.0 VGA compatible controller: Intel Corporation Broadwell-U Integrated Graphics (rev 09)

所以我正在使用我的集成显卡。(不是我的 AMD 显卡)

当我在终端上输入时fglrxinfo

display: :0  screen: 0
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: AMD Radeon R7 M260
OpenGL version string: 4.4.13374 Compatibility Profile Context 15.20.1013

根据第 3 节的内容,我的 AMD 显卡已安装并可以正常工作。(但事实并非如此)。

所以,回到我的 SDL 问题,当我运行我的第一个 SDL 程序时,libGL error: dlopen /usr/lib/fglrx/dri/i965_dri.so failed (/usr/lib/fglrx/dri/i965_dri.so: cannot open shared object file: No such file or directory)显示了一个错误。我打开了这个问题,但我无法解决。所以我将文件复制i965_dri.so到目录/usr/lib/fglrx/dri/。这使得这个错误消失了。

那么,有人知道为什么会发生这种情况吗?我真的很想让我的图形视频卡工作。但是经过多次尝试,我忘记了我的图形视频卡,只想让我的 SDL 代码正常工作,没有错误或内存泄漏。

谢谢 !

4

0 回答 0