colors = surface->format->BytesPerPixel;
if (colors == 4) { // alpha
if (surface->format->Rmask == 0x000000ff)
texture_format = GL_RGBA;
else
texture_format = GL_BGRA;
} else { // no alpha
if (surface->format->Rmask == 0x000000ff)
format = GL_RGB;
else
format = GL_BGR;
}
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, colors, surface->w, surface->h, 0,
texture_format, GL_UNSIGNED_BYTE, surface->pixels);
我正在尝试将在 Stack Overflow 上找到的代码转换为 Vala。但是,我遇到了 glGenTextures 的问题。
第一部分很简单:
int texture_format;
uchar colors = screen.format.BytesPerPixel;
if (colors == 4) {
if (screen.format.Rmask == 0x000000ff) {
texture_format = GL_RGBA;
} else {
texture_format = GL_BGRA;
}
} else {
if (screen.format.Rmask == 0x000000ff) {
texture_format = GL_RGB;
} else {
texture_format = GL_BGR;
}
}
不过,这部分我不知道如何转换: glGenTextures(1, &texture);
我试过了:
GL.GLuint[] texture = {};
glGenTextures (1, texture);
我有:
.vala:46.27-46.33: error: Argument 2: Cannot pass value to reference or output parameter
我也试过:
GL.GLuint[] texture = {};
glGenTextures (1, out texture);
我有:
ERROR:valaccodearraymodule.c:1183:vala_ccode_array_module_real_get_array_length_cvalue: assertion failed: (_tmp48_)
我试过了:
glGenTextures (1, &texture);
我有:
.vala:46.27-46.34: error: Argument 2: Cannot pass value to reference or output parameter
我尝试了各种其他类似的东西,有什么想法吗?