Use DSA for textures
This commit is contained in:
parent
6d687e63d8
commit
b31d9129e2
@ -85,9 +85,8 @@ int init() {
|
||||
|
||||
std::cout << "Initialized GLFW" << std::endl;
|
||||
|
||||
// Create a rendering window with OpenGL 3.3 context
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
@ -124,6 +123,8 @@ int init() {
|
||||
|
||||
std::cout << "Initialized GLEW" << std::endl;
|
||||
|
||||
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
|
||||
|
||||
int flags;
|
||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) {
|
||||
|
@ -32,7 +32,6 @@ static GLuint compileShader(GLenum type, std::string path) {
|
||||
}
|
||||
|
||||
std::string code = stream.str();
|
||||
std::cout << code << std::endl;
|
||||
delete buf;
|
||||
|
||||
const char *src = code.c_str();
|
||||
|
@ -10,16 +10,16 @@ namespace kek {
|
||||
|
||||
static GLuint allocTexture(unsigned char *data, int width, int height, float borderColor[4]) {
|
||||
GLuint id;
|
||||
glGenTextures(1, &id);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &id);
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTextureParameterfv(id, GL_TEXTURE_BORDER_COLOR, borderColor);
|
||||
glTextureParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTextureParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTextureStorage2D(id, 1, GL_RGB8, width, height);
|
||||
glTextureSubImage2D(id, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
//glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glGenerateTextureMipmap(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user