我試圖改變* SDL_opengl *中的累積緩衝區顏色組件的大小,但SetAttribute
命令似乎沒有做任何事情。這是我正在使用的代碼。
(爲了減少代碼量,我只處理紅色成分在這裏,但在實際的代碼中,我通過所有4種成分的顏色都和積累緩衝器和效果是一樣的)SDL_GL_SetAttribute不設置顏色大小
#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
int main(int argc, char *argv[])
{
//Initialize all SDL subsystems
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)std::cout << "SDL ERROR!";
// Try to Set the BitSize, while checking for errors
int BitSize = 1; //This number never makes a difference!!
int ErrorCode = 0;
ErrorCode += SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) // This one WORKS
+ SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, BitSize) // These ones DON'T
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, BitSize)
;
if(ErrorCode < 0)std::cout << "SDL ERROR!";
// Create the Window
int w = 1000, h = 700;
int bpp = 32;
SDL_Surface* Screen = SDL_SetVideoMode(w, h, bpp, SDL_OPENGL |
SDL_NOFRAME |
SDL_DOUBLEBUF);
if(!Screen)std::cout << "SDL ERROR!";
// Check if BitSize's are correct (they are not)
// I'm using glGetInteger, but SDL_GL_GetAttribute yields the same output.
glGetIntegerv(GL_ACCUM_RED_BITS, &BitSize);
std::cout << "AccumBuffer color component size in bits is " << BitSize << "\n";
glGetIntegerv(GL_RED_BITS, &BitSize);
std::cout << "ColorBuffer color component size in bits is " << BitSize << "\n";
ErrorCode = SDL_GL_GetAttribute(SDL_GL_BUFFER_SIZE, &BitSize);
std::cout << "FrameBuffer BitSize is " << BitSize << "\n";
if(ErrorCode < 0)std::cout << "SDL ERROR!";
if(glGetError() != GL_NO_ERROR)std::cout << "GL ERROR";
return 0;
}
編譯沒有問題,始終輸出以下:
AccumBuffer color component size in bits is 16
ColorBuffer color component size in bits is 8
FrameBuffer Bit Size is 32
不管我了BitSize
變量設置爲。這就像SDL_GL_SetAttribute(SDL_GL_*_SIZE, int)
沒有任何效果。我可以理解,顏色緩衝區組件可能被限制爲8位,因爲我用32 bpp初始化窗口。但是,我不應該能夠編輯累積緩衝區的顏色分辨率嗎?