glGenTextures(1, (GLuint*)&texture_id);
glBindTexture(GL_TEXTURE_2D, (GLuint)texture_id);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, (GLuint*)&texture_id);
glBindTexture(GL_TEXTURE_2D, (GLuint)texture_id);
glEnable(GL_TEXTURE_2D);
- if(texture_components == 4)
- glTexImage2D(GL_TEXTURE_2D, 0, 4, texture_w, texture_h,
+ int internal_format = texture_components == 4 ? GL_RGBA8 : GL_RGB8 ;
+ glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture_w, texture_h,
0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- else
- glTexImage2D(GL_TEXTURE_2D, 0, 3, texture_w, texture_h,
- 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
-
window_id = BC_WindowBase::get_synchronous()->current_window->get_id();
BC_WindowBase::get_synchronous()->put_texture(texture_id,
texture_w, texture_h, texture_components);
window_id = BC_WindowBase::get_synchronous()->current_window->get_id();
BC_WindowBase::get_synchronous()->put_texture(texture_id,
texture_w, texture_h, texture_components);
if(texture_unit >= 0) glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(GL_TEXTURE_2D, texture_id);
glEnable(GL_TEXTURE_2D);
if(texture_unit >= 0) glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(GL_TEXTURE_2D, texture_id);
glEnable(GL_TEXTURE_2D);
- if(texture_unit >= 0)
- {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ if(texture_unit >= 0) {
+ int filter = nearest ? GL_NEAREST : GL_LINEAR;
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glBindTexture(GL_TEXTURE_2D, texture_id);
glEnable(GL_TEXTURE_2D);
int w = get_texture_w(), h = get_texture_h();
uint8_t *img = new uint8_t[w*h*3];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, img);
write_ppm(img, w, h, "%s", fn);
glBindTexture(GL_TEXTURE_2D, texture_id);
glEnable(GL_TEXTURE_2D);
int w = get_texture_w(), h = get_texture_h();
uint8_t *img = new uint8_t[w*h*3];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, img);
write_ppm(img, w, h, "%s", fn);