java - lwjgl attach or union shapes to make transparancy look correct -
i've been trying figure out while now. there way have multiple shapes have rendered become 1 single object? manipulate object in way want? if try use glcolor method doesn't change because have multiple colors changing objects already. maybe i'm not realizing obvious, or it's can't find in tutorial. put i'm looking way change alpha value of multiple shapes draw make more complex shape, keeping colors have been predefined.
if want multiple shapes become 1 single object calculate or write correct x, y, z numbers each vertex, fit together.
for instance can make 2 triangles become square, this.
to same in code this.
glbegin(gl_triangles); glvertex3f(0f, 0f, 0f); glvertex3f(0f, 100f, 0f); glvertex3f(100f, 0f, 0f); glvertex3f(100f, 100f, 0f); glvertex3f(100f, 0f, 0f); glvertex3f(0f, 100f, 0f); glend();
you can of course use gl_quads
, though triangles better in lot of ways. if want color shape 1 color, need , can write 1 color before.
so instance work , gives whole red square/quad.
glcolor3f(1f, 0f, 0f); glbegin(gl_triangles); glvertex3f(0f, 0f, 0f); glvertex3f(0f, 100f, 0f); glvertex3f(100f, 0f, 0f); glvertex3f(100f, 100f, 0f); glvertex3f(100f, 0f, 0f); glvertex3f(0f, 100f, 0f); glend();
though if add more glcolor
in between end giving result.
if want use transparency/opacity/alpha need use glcolor4f
last number amount of transparency. before able use transparency need enable blending mode within opengl. calling.
glenable(gl_blend); glblendfunc(gl_src_alpha, gl_one_minus_src_alpha);
i wasn't 100% sure questions if i've forgotten answer something, write comment , tell me.
info
if don't statically import classes remember glenable(gl_blend);
gl11.glenable(gl11.gl_blend);
, same goes rest of code.
also take in mind glvertex
, glnormal
, glcolor
, etc. deprecated methods , should not used reason, extremely slow when rendering huge amount of vertices, though purpose of learning opengl, , should used learning. new , better alternative use vbos , shaders.
Comments
Post a Comment