forked from blender/blender
Move to use the GPU API instead OpenGL #23
@ -194,20 +194,20 @@ void GLTexture::draw(GPUShader *shader, float x, float y)
|
||||
GPUVertFormat format = {0};
|
||||
GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
GPU_vertformat_attr_add(&format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
GPUVertBuf *vertex_buffer = GPU_vertbuf_create_with_format(&format);
|
||||
GPU_vertbuf_data_alloc(vertex_buffer, 4);
|
||||
GPU_vertbuf_attr_fill(vertex_buffer, 0, position);
|
||||
GPU_vertbuf_attr_fill(vertex_buffer, 1, texcoord);
|
||||
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
|
||||
GPU_vertbuf_data_alloc(vbo, 4);
|
||||
GPU_vertbuf_attr_fill(vbo, 0, position);
|
||||
GPU_vertbuf_attr_fill(vbo, 1, texcoord);
|
||||
|
||||
int slot = GPU_shader_get_sampler_binding(shader, "image");
|
||||
GPU_texture_bind(texture, slot);
|
||||
GPU_shader_uniform_1i(shader, "image", slot);
|
||||
|
||||
GPUBatch *gpu_batch = GPU_batch_create(GPU_PRIM_TRI_FAN, vertex_buffer, nullptr);
|
||||
GPUBatch *gpu_batch = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, nullptr, GPU_BATCH_OWNS_VBO);
|
||||
GPU_batch_set_shader(gpu_batch, shader);
|
||||
GPU_batch_draw(gpu_batch);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(gpu_batch);
|
||||
GPU_batch_discard(gpu_batch);
|
||||
}
|
||||
|
||||
void ViewportEngine::sync(Depsgraph *depsgraph,
|
||||
|
Loading…
Reference in New Issue
Block a user