Я пишу свой собственный графический API на вершине OpenGL, но пока я реализовал текстуры, возникла ошибка. Прямоугольная форма с текстурой была отображена совершенно нормальной. Но режим каркаса показывает только второй треугольник. < /P>
каркасной каркас (да, это текстура) < /p>
каркас на < /p>
Я обнаружил, что если я установил текстуру координат на 0,0f на второй точ курс)). Но я не могу найти решение. Я проверял изучение OpenGL несколько раз и не мог выяснить, что такое нарушитель нарушителя.#include "EasyGL.h"
#include "Mesh.h"
#include
#include
const char* vertexShaderSource = R"glsl(#version 330 core
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aColor;
layout(location = 2) in vec2 aTexCoord;
out vec3 ourColor;
out vec2 TexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = aTexCoord;
} )glsl";
const char* fragmentShaderSource = R"glsl(#version 330 core
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform sampler2D ourTexture;
void main()
{
FragColor = texture(ourTexture, TexCoord);
})glsl";
int main()
{
ez::Init();
ez::Window window(1920, 1080, "Hello Window");
ez::InitGlad();
//window.SetFullscreen(true);
//window.UpdateViewport();
std::vector vertices =
{
// positions // colors // texture coords
0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top right
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom right This causes the bug
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom left
-0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left And also this
};
std::vector indices =
{
0, 1, 3,
1, 2, 3
};
//Mesh
ez::Mesh2D mesh(&vertices, &indices);
mesh.UseEBO(true);
mesh.SetVertexShaderSource(vertexShaderSource);
mesh.SetFragmentShaderSource(fragmentShaderSource);
mesh.SetAttribPointer(0, 3, 8, 0);
mesh.SetAttribPointer(1, 3, 8, 3);
mesh.SetAttribPointer(2, 2, 8, 6);
mesh.UseTexture(true);
mesh.InitTexture(0, "C:/Dev/Zap/Rec/Textures/texture.png", 0, ez::TextureFilters::NEAREST, ez::MipmapSettings::NEAREST_MIPMAP_NEAREST, ez::TextureWrapping::CLAMP_TO_BORDER);
mesh.UsePNG(0);
mesh.Finish();
//
//window.Maximize();
//window.SetFPSLimit(60);
while (window.Open())
{
window.StartTime();
window.ClearBackground(ez::BackgroundColors::BLACK);
if (window.GetInput(ez::Key::ESC, ez::State::EZ_PRESSED))
{
window.Close();
}
if (window.GetInput(ez::Key::F10, ez::State::EZ_PRESSED))
{
window.ShowWireFrame(true);
}
if (window.GetInput(ez::Key::F10, ez::State::EZ_RELEASED))
{
window.ShowWireFrame(false);
}
mesh.SetTexture(0);
mesh.Write(6);
window.SetTitle(std::to_string(window.GetDelta()));
window.UpdateViewport();
window.Update();
window.Draw();
//std::cout
#include "Mesh.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
namespace ez
{
AttributeConfig::AttributeConfig(int shader_location, int value_ct, unsigned int data_stride, unsigned int start_pos)
{
i_shader_location = shader_location;
i_value_ct = value_ct;
i_data_stride = data_stride;
i_start_pos = start_pos;
}
AttributeConfig::~AttributeConfig()
{
}
Texture::Texture(unsigned int id, const std::string path, unsigned int texture_index, TextureFilters filter, MipmapSettings settings, TextureWrapping wrapping)
{
i_id = id;
i_path = path;
stbi_set_flip_vertically_on_load(true);
i_texturedata = stbi_load(i_path.c_str(), &i_width, &i_height, &i_nrChannels, 0); // Bessere Lösung nutze Filepath wie im Tutorial !
i_filter = filter;
i_settings = settings;
i_wrapping = wrapping;
i_texture_index = texture_index;
if (i_texturedata)
{
i_textureloaded = true;
}
else
{
messages::PrintMessage("Failed to load Texture at path: " + i_path, "Mesh.cpp/ez::Texture::Texture(...)", MessageTypes::error);
}
}
Texture::~Texture()
{
stbi_image_free(i_texturedata);
}
Mesh2D::Mesh2D(std::vector* extern_vertices, std::vector* extern_indices)
{
vertices = *extern_vertices;
indices = *extern_indices;
VBO_ACCESS_MODE = BufferAccessModes::HIGH_ACESS_DYNAMIC;
EBO_ACCESS_MODE = BufferAccessModes::HIGH_ACESS_DYNAMIC;
}
Mesh2D::~Mesh2D()
{
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
glDeleteBuffers(1, &EBO);
glDeleteProgram(shaderProgram);
}
void Mesh2D::SetVertexShaderSource(const char* source)
{
if (!vSourceset)
{
vertexShaderSource = source;
vSourceset = true;
}
}
void Mesh2D::SetVertexShaderSource(const std::string* source)
{
if (!vSourceset)
{
vertexShaderSource = source->c_str();
vSourceset = true;
}
}
void Mesh2D::SetFragmentShaderSource(const char* source)
{
if (!fSourceset)
{
fragmentShaderSource = source;
fSourceset = true;
}
}
void Mesh2D::SetFragmentShaderSource(const std::string* source)
{
if (!fSourceset)
{
fragmentShaderSource = source->c_str();
fSourceset = true;
}
}
void Mesh2D::SetVBOAccessMode(BufferAccessModes mode)
{
VBO_ACCESS_MODE = mode;
}
void Mesh2D::SetEBOAccessMode(BufferAccessModes mode)
{
EBO_ACCESS_MODE = mode;
}
void Mesh2D::UseEBO(bool state)
{
useEBO = state;
}
void Mesh2D::UsePNG(unsigned int id)
{
for (int i = 0; i < texturecfg.size(); i++)
{
if (texturecfg->i_id == id)
{
texturecfg->i_usePNG = true;
}
}
}
void Mesh2D::SetAttribPointer(int shader_location, int value_ct, unsigned int data_stride, unsigned int start_pos)
{
attribcfg.push_back(std::make_unique(shader_location, value_ct, data_stride, start_pos));
}
void Mesh2D::UseTexture(bool state)
{
use_texture = state;
}
void Mesh2D::InitTexture(unsigned int id, const std::string path, unsigned int texture_index, TextureFilters filter, MipmapSettings settings, TextureWrapping wrapping)
{
texturecfg.push_back(std::make_unique(id, path, texture_index, filter, settings, wrapping));
}
void Mesh2D::Finish()
{
/******************************************************************************************/
// Shader
//Source
if (!vSourceset)
{
vertexShaderSource = R"glsl(
#version 330 core
layout (location = 0) in vec3 aPos;
void main()
{
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}
)glsl";
}
if (!fSourceset)
{
fragmentShaderSource = R"glsl(
#version 330 core
out vec4 FragColor;
void main()
{
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
}
)glsl";
}
//
// Vertex Shader
vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
glCompileShader(vertexShader);
int ok;
char info[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &ok);
if (!ok)
{
glGetShaderInfoLog(vertexShader, 512, NULL, info);
messages::PrintMessage("Failed to compile Vertex Shader:", "Mesh.cpp/void ez::Mesh2D::Finish()", MessageTypes::error);
std::cerr i_texture);
glBindTexture(GL_TEXTURE_2D, texturecfg[t]->i_texture);
if (texturecfg[t]->i_wrapping == TextureWrapping::REPEAT)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::MIRRORED_REPEAT)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::CLAMP_TO_EDGE)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::CLAMP_TO_BORDER)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
}
if (texturecfg[t]->i_settings == MipmapSettings::NEAREST_MIPMAP_NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
else if (texturecfg[t]->i_settings == MipmapSettings::LINEAR_MIPMAP_LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
else if (texturecfg[t]->i_settings == MipmapSettings::NEAREST_MIPMAP_LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
}
else if (texturecfg[t]->i_settings == MipmapSettings::LINEAR_MIPMAP_NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
}
if (texturecfg[t]->i_filter == TextureFilters::NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else if (texturecfg[t]->i_filter == TextureFilters::LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (texturecfg[t]->i_textureloaded)
{
if (texturecfg[t]->i_usePNG)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturecfg[t]->i_width, texturecfg[t]->i_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturecfg[t]->i_texturedata);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texturecfg[t]->i_width, texturecfg[t]->i_height, 0, GL_RGB, GL_UNSIGNED_BYTE, texturecfg[t]->i_texturedata);
glGenerateMipmap(GL_TEXTURE_2D);
}
}
}
}
/*****************************************************************************************/
}
void Mesh2D::SetTexture(unsigned int id)
{
if (use_texture)
{
for (int e = 0; e < texturecfg.size(); e++)
{
if (texturecfg[e]->i_id == id)
{
glActiveTexture(0x84BF + texturecfg[e]->i_texture_index);
glBindTexture(GL_TEXTURE_2D, texturecfg[e]->i_texture);
}
}
}
}
void Mesh2D::Write(int vertices_count)
{
if (useEBO)
{
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, vertices_count, GL_UNSIGNED_INT, 0);
}
else
{
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, vertices_count);
}
}
}
< /code>
Редактировать: я переименован Easygl. Теперь это называется Zap.
Подробнее здесь: https://stackoverflow.com/questions/797 ... y-triangle
OpenGL не показывает каждый треугольник [закрыто] ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1754916058
Anonymous
Я пишу свой собственный графический API на вершине OpenGL, но пока я реализовал текстуры, возникла ошибка. Прямоугольная форма с текстурой была отображена совершенно нормальной. Но режим каркаса показывает только второй треугольник. < /P>
каркасной каркас (да, это текстура) < /p>
каркас на < /p>
Я обнаружил, что если я установил текстуру координат на 0,0f на второй точ курс)). Но я не могу найти решение. Я проверял изучение OpenGL несколько раз и не мог выяснить, что такое нарушитель нарушителя.#include "EasyGL.h"
#include "Mesh.h"
#include
#include
const char* vertexShaderSource = R"glsl(#version 330 core
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aColor;
layout(location = 2) in vec2 aTexCoord;
out vec3 ourColor;
out vec2 TexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = aTexCoord;
} )glsl";
const char* fragmentShaderSource = R"glsl(#version 330 core
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform sampler2D ourTexture;
void main()
{
FragColor = texture(ourTexture, TexCoord);
})glsl";
int main()
{
ez::Init();
ez::Window window(1920, 1080, "Hello Window");
ez::InitGlad();
//window.SetFullscreen(true);
//window.UpdateViewport();
std::vector vertices =
{
// positions // colors // texture coords
0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top right
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom right This causes the bug
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom left
-0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left And also this
};
std::vector indices =
{
0, 1, 3,
1, 2, 3
};
//Mesh
ez::Mesh2D mesh(&vertices, &indices);
mesh.UseEBO(true);
mesh.SetVertexShaderSource(vertexShaderSource);
mesh.SetFragmentShaderSource(fragmentShaderSource);
mesh.SetAttribPointer(0, 3, 8, 0);
mesh.SetAttribPointer(1, 3, 8, 3);
mesh.SetAttribPointer(2, 2, 8, 6);
mesh.UseTexture(true);
mesh.InitTexture(0, "C:/Dev/Zap/Rec/Textures/texture.png", 0, ez::TextureFilters::NEAREST, ez::MipmapSettings::NEAREST_MIPMAP_NEAREST, ez::TextureWrapping::CLAMP_TO_BORDER);
mesh.UsePNG(0);
mesh.Finish();
//
//window.Maximize();
//window.SetFPSLimit(60);
while (window.Open())
{
window.StartTime();
window.ClearBackground(ez::BackgroundColors::BLACK);
if (window.GetInput(ez::Key::ESC, ez::State::EZ_PRESSED))
{
window.Close();
}
if (window.GetInput(ez::Key::F10, ez::State::EZ_PRESSED))
{
window.ShowWireFrame(true);
}
if (window.GetInput(ez::Key::F10, ez::State::EZ_RELEASED))
{
window.ShowWireFrame(false);
}
mesh.SetTexture(0);
mesh.Write(6);
window.SetTitle(std::to_string(window.GetDelta()));
window.UpdateViewport();
window.Update();
window.Draw();
//std::cout
#include "Mesh.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
namespace ez
{
AttributeConfig::AttributeConfig(int shader_location, int value_ct, unsigned int data_stride, unsigned int start_pos)
{
i_shader_location = shader_location;
i_value_ct = value_ct;
i_data_stride = data_stride;
i_start_pos = start_pos;
}
AttributeConfig::~AttributeConfig()
{
}
Texture::Texture(unsigned int id, const std::string path, unsigned int texture_index, TextureFilters filter, MipmapSettings settings, TextureWrapping wrapping)
{
i_id = id;
i_path = path;
stbi_set_flip_vertically_on_load(true);
i_texturedata = stbi_load(i_path.c_str(), &i_width, &i_height, &i_nrChannels, 0); // Bessere Lösung nutze Filepath wie im Tutorial !
i_filter = filter;
i_settings = settings;
i_wrapping = wrapping;
i_texture_index = texture_index;
if (i_texturedata)
{
i_textureloaded = true;
}
else
{
messages::PrintMessage("Failed to load Texture at path: " + i_path, "Mesh.cpp/ez::Texture::Texture(...)", MessageTypes::error);
}
}
Texture::~Texture()
{
stbi_image_free(i_texturedata);
}
Mesh2D::Mesh2D(std::vector* extern_vertices, std::vector* extern_indices)
{
vertices = *extern_vertices;
indices = *extern_indices;
VBO_ACCESS_MODE = BufferAccessModes::HIGH_ACESS_DYNAMIC;
EBO_ACCESS_MODE = BufferAccessModes::HIGH_ACESS_DYNAMIC;
}
Mesh2D::~Mesh2D()
{
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
glDeleteBuffers(1, &EBO);
glDeleteProgram(shaderProgram);
}
void Mesh2D::SetVertexShaderSource(const char* source)
{
if (!vSourceset)
{
vertexShaderSource = source;
vSourceset = true;
}
}
void Mesh2D::SetVertexShaderSource(const std::string* source)
{
if (!vSourceset)
{
vertexShaderSource = source->c_str();
vSourceset = true;
}
}
void Mesh2D::SetFragmentShaderSource(const char* source)
{
if (!fSourceset)
{
fragmentShaderSource = source;
fSourceset = true;
}
}
void Mesh2D::SetFragmentShaderSource(const std::string* source)
{
if (!fSourceset)
{
fragmentShaderSource = source->c_str();
fSourceset = true;
}
}
void Mesh2D::SetVBOAccessMode(BufferAccessModes mode)
{
VBO_ACCESS_MODE = mode;
}
void Mesh2D::SetEBOAccessMode(BufferAccessModes mode)
{
EBO_ACCESS_MODE = mode;
}
void Mesh2D::UseEBO(bool state)
{
useEBO = state;
}
void Mesh2D::UsePNG(unsigned int id)
{
for (int i = 0; i < texturecfg.size(); i++)
{
if (texturecfg[i]->i_id == id)
{
texturecfg[i]->i_usePNG = true;
}
}
}
void Mesh2D::SetAttribPointer(int shader_location, int value_ct, unsigned int data_stride, unsigned int start_pos)
{
attribcfg.push_back(std::make_unique(shader_location, value_ct, data_stride, start_pos));
}
void Mesh2D::UseTexture(bool state)
{
use_texture = state;
}
void Mesh2D::InitTexture(unsigned int id, const std::string path, unsigned int texture_index, TextureFilters filter, MipmapSettings settings, TextureWrapping wrapping)
{
texturecfg.push_back(std::make_unique(id, path, texture_index, filter, settings, wrapping));
}
void Mesh2D::Finish()
{
/******************************************************************************************/
// Shader
//Source
if (!vSourceset)
{
vertexShaderSource = R"glsl(
#version 330 core
layout (location = 0) in vec3 aPos;
void main()
{
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}
)glsl";
}
if (!fSourceset)
{
fragmentShaderSource = R"glsl(
#version 330 core
out vec4 FragColor;
void main()
{
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
}
)glsl";
}
//
// Vertex Shader
vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
glCompileShader(vertexShader);
int ok;
char info[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &ok);
if (!ok)
{
glGetShaderInfoLog(vertexShader, 512, NULL, info);
messages::PrintMessage("Failed to compile Vertex Shader:", "Mesh.cpp/void ez::Mesh2D::Finish()", MessageTypes::error);
std::cerr i_texture);
glBindTexture(GL_TEXTURE_2D, texturecfg[t]->i_texture);
if (texturecfg[t]->i_wrapping == TextureWrapping::REPEAT)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::MIRRORED_REPEAT)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::CLAMP_TO_EDGE)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
else if (texturecfg[t]->i_wrapping == TextureWrapping::CLAMP_TO_BORDER)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
}
if (texturecfg[t]->i_settings == MipmapSettings::NEAREST_MIPMAP_NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
else if (texturecfg[t]->i_settings == MipmapSettings::LINEAR_MIPMAP_LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
else if (texturecfg[t]->i_settings == MipmapSettings::NEAREST_MIPMAP_LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
}
else if (texturecfg[t]->i_settings == MipmapSettings::LINEAR_MIPMAP_NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
}
if (texturecfg[t]->i_filter == TextureFilters::NEAREST)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else if (texturecfg[t]->i_filter == TextureFilters::LINEAR)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (texturecfg[t]->i_textureloaded)
{
if (texturecfg[t]->i_usePNG)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturecfg[t]->i_width, texturecfg[t]->i_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturecfg[t]->i_texturedata);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texturecfg[t]->i_width, texturecfg[t]->i_height, 0, GL_RGB, GL_UNSIGNED_BYTE, texturecfg[t]->i_texturedata);
glGenerateMipmap(GL_TEXTURE_2D);
}
}
}
}
/*****************************************************************************************/
}
void Mesh2D::SetTexture(unsigned int id)
{
if (use_texture)
{
for (int e = 0; e < texturecfg.size(); e++)
{
if (texturecfg[e]->i_id == id)
{
glActiveTexture(0x84BF + texturecfg[e]->i_texture_index);
glBindTexture(GL_TEXTURE_2D, texturecfg[e]->i_texture);
}
}
}
}
void Mesh2D::Write(int vertices_count)
{
if (useEBO)
{
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, vertices_count, GL_UNSIGNED_INT, 0);
}
else
{
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, vertices_count);
}
}
}
< /code>
Редактировать: я переименован Easygl. Теперь это называется Zap.
Подробнее здесь: [url]https://stackoverflow.com/questions/79731240/opengl-is-not-showing-every-triangle[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия