Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 旧版OpenGL和Emscripten出错,WebGL警告:vertexAttrib[1234]u?[fi]{v}:`index`必须是<;最大顶点属性_C++_Opengl_Webgl_Webassembly_Emscripten - Fatal编程技术网

C++ 旧版OpenGL和Emscripten出错,WebGL警告:vertexAttrib[1234]u?[fi]{v}:`index`必须是<;最大顶点属性

C++ 旧版OpenGL和Emscripten出错,WebGL警告:vertexAttrib[1234]u?[fi]{v}:`index`必须是<;最大顶点属性,c++,opengl,webgl,webassembly,emscripten,C++,Opengl,Webgl,Webassembly,Emscripten,我不知道这意味着什么。一切正常(程序启动,预期行为),但屏幕完全为黑色,不会呈现任何内容: //Prepare SDL_GL_MakeCurrent(win, gContext); DestR = { sp_offset_x, sp_offset_y, int(int_res_x * scale), int(int_res_y * scale) }; glViewport(DestR.x, DestR.y, DestR.w, DestR.h); glClearColor(0.f, 0.f, 0

我不知道这意味着什么。一切正常(程序启动,预期行为),但屏幕完全为黑色,不会呈现任何内容:

//Prepare
SDL_GL_MakeCurrent(win, gContext);

DestR = { sp_offset_x, sp_offset_y, int(int_res_x * scale), int(int_res_y * scale) };
glViewport(DestR.x, DestR.y, DestR.w, DestR.h);
glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Draw texture
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Tex);
glColor4ub(rc, gc, bc, 255);

glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2i(XS, YS);
glTexCoord2f(0, 1); glVertex2i(XS, YE);
glTexCoord2f(1, 1); glVertex2i(XE, YE);
glTexCoord2f(1, 0); glVertex2i(XE, YS);
glEnd();

glDisable(GL_TEXTURE_2D);

//redraw, probably not important
SDL_GL_SwapWindow(win);
如果需要,我用来生成纹理的代码是

GL_Texture ConvertSDLSurfaceToOpenGL(SDL_Surface* surface) {
GLenum texture_format;
GLint  nOfColors;
// get the number of channels in the SDL surface
nOfColors = surface->format->BytesPerPixel;
if (nOfColors == 4) {
    texture_format = GL_RGBA;
}
else if (nOfColors == 3) {
    texture_format = GL_RGB;
}
else {
    cout << red << "[OpenGL] Critical: Texture format is broken. nOfColors: " << nOfColors << endl;
    return 0;
}

GL_Texture textureid;
// create one texture name
glGenTextures(1, &textureid);
glBindTexture(GL_TEXTURE_2D, textureid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// this reads from the sdl surface and puts it into an opengl texture
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, surface->w, surface->h, 0, texture_format, GL_UNSIGNED_BYTE, surface->pixels);


return textureid;
}
GL_纹理转换器SDL曲面OOPENGL(SDL_曲面*曲面){
骨盂纹理图;
闪烁的彩色;
//获取SDL曲面中的通道数
nOfColors=表面->格式->字节/像素;
if(nOfColors==4){
纹理_格式=GL_RGBA;
}
else if(nOfColors==3){
纹理_格式=GL_RGB;
}
否则{
cout-Emscripten的。您可能会遇到各种各样的问题和死机。如果您专门为Emscripten编写应用程序,请使用适当的方法。