mirror of
https://github.com/Relintai/sfw.git
synced 2024-11-08 07:52:09 +01:00
More work on Texture.
This commit is contained in:
parent
f101e99d17
commit
feec0785bc
@ -3,6 +3,18 @@
|
||||
#include "memory.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
void Texture::set_as_render_target() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
|
||||
glViewport(0, 0, _fbo_width, _fbo_height);
|
||||
}
|
||||
|
||||
void Texture::unset_render_target() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, AppWindow::get_singleton()->get_width(), AppWindow::get_singleton()->get_height());
|
||||
}
|
||||
|
||||
void Texture::create_from_image(const Ref<Image> &img) {
|
||||
if (_image == img) {
|
||||
return;
|
||||
@ -28,7 +40,6 @@ void Texture::create_from_image(const Ref<Image> &img) {
|
||||
Ref<Image> Texture::get_data() {
|
||||
ERR_FAIL_COND_V(!_texture, Ref<Image>());
|
||||
ERR_FAIL_COND_V(_data_size == 0, Ref<Image>());
|
||||
//TODO Error if not render target
|
||||
|
||||
//GLES
|
||||
|
||||
@ -256,8 +267,12 @@ Texture::Texture() {
|
||||
_data_size = 0;
|
||||
_texture_index = 0;
|
||||
_flags = 0;
|
||||
_render_target = false;
|
||||
|
||||
_texture_format = Image::FORMAT_RGBA8;
|
||||
|
||||
_fbo_width = 0;
|
||||
_fbo_height = 0;
|
||||
_fbo = 0;
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
|
@ -17,9 +17,8 @@ public:
|
||||
return _texture;
|
||||
}
|
||||
|
||||
//TODO
|
||||
//set_as_render_target()
|
||||
//unset_render_target()
|
||||
void set_as_render_target();
|
||||
void unset_render_target();
|
||||
|
||||
void create_from_image(const Ref<Image> &img);
|
||||
|
||||
@ -43,8 +42,12 @@ protected:
|
||||
int _texture_index;
|
||||
int _data_size;
|
||||
int _mipmaps;
|
||||
bool _render_target;
|
||||
|
||||
GLuint _texture;
|
||||
|
||||
int _fbo_width;
|
||||
int _fbo_height;
|
||||
GLuint _fbo;
|
||||
};
|
||||
|
||||
#endif // TEXTURE_H
|
||||
|
Loading…
Reference in New Issue
Block a user