Legacy GM Drawing Primitives, Transparency issue.

Brenden

Member
So I am just normally drawing a textured primitive yet for some reason when two or more primitives overlap they become slightly transparent. I have not used any blending or alphas within any of the code.
I am taking a view and pasting it to a surface and then make that surface into a texture to be place onto the primitive.
Code Example:
Code:
if !surface_exists(surface5){
    surface5 = surface_create(400, 400);
    surface_set_target(surface5);
        draw_clear(c_black);
    surface_reset_target();
    view_surface_id[5] = surface5;
}
var tex=0;
draw_set_colour(c_white);
tex = surface_get_texture(surface1);

draw_primitive_begin_texture(pr_trianglestrip, tex);
    draw_vertex_texture(face1[| 2], face1[| 6], 0, 1);//bottom left
    draw_vertex_texture(face1[| 0], face1[| 4], 0, 0);//top left
    draw_vertex_texture(face1[| 3], face1[| 7], 1, 1);//bottom right
    draw_vertex_texture(face1[| 1], face1[| 5], 1, 0);//top right
draw_primitive_end();
Here is what happens when two collide
upload_2018-3-18_0-14-14.png
If you could help me understand what I may be doing wrong, that would be great.

EDIT:
I was messing around an it seems that sense I have a black square over each face in the room and those squares each an opacity setting to them witch some how cause the whole texture/surface to be that opacity?
 
Last edited:

Brenden

Member
How are you setting the opacity of the black squares?
The black squares have a creation code with a variable for what face it relates to.
Then references from the instance drawing the primitives every step to check an alpha variable.
EX:
Creation code
Code:
face=1;
Step event
Code:
switch (face){
    case 1: alp=oCubeFX.face1[| 8]; break;
    case 2: alp=oCubeFX.face2[| 8]; break;
    case 3: alp=oCubeFX.face3[| 8]; break;
    case 4: alp=oCubeFX.face4[| 8]; break;
    case 5: alp=oCubeFX.face5[| 8]; break;
    case 6: alp=oCubeFX.face6[| 8]; break;
}
image_alpha=alp
 

Brenden

Member
The issue seems to be with those squares, yet I am not sure why that is an issue. If there is an alpha setting on one of the squares the primitive or texture (which is just a view) also has the same transparency as the square.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You could do
Code:
draw_set_color_write_enable(0, 0, 0, 1)
draw_rectangle(0, 0, 400, 400, false);
draw_set_color_write_enable(1, 1, 1, 1)
prior to starting to draw the surface to make sure that it's alpha is 1.
 

Brenden

Member
Code:
draw_set_color_write_enable(0, 0, 0, 1);
if !surface_exists(surface1){
    surface1 = surface_create(400, 400);
    surface_set_target(surface1);
        draw_clear(c_black);
    surface_reset_target();
    view_surface_id[1] = surface1;
}
draw_set_color_write_enable(1, 1, 1, 1);
//draw primitives here
Thats what I did. Its still dose not seem to work though.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Code:
draw_set_color_write_enable(0, 0, 0, 1);
if !surface_exists(surface1){
    surface1 = surface_create(400, 400);
    surface_set_target(surface1);
        draw_clear(c_black);
    surface_reset_target();
    view_surface_id[1] = surface1;
}
draw_set_color_write_enable(1, 1, 1, 1);
//draw primitives here
Thats what I did. Its still dose not seem to work though.
that's resetting alpha once upon creation, not prior to drawing. You would surface_set_target to the to-be-drawn surface before resetting alpha on it.
 

Brenden

Member
that's resetting alpha once upon creation, not prior to drawing. You would surface_set_target to the to-be-drawn surface before resetting alpha on it.
I'm not sure what you mean. If you could change my script (the first ones at the top) to the way you think it should be that would be helpful.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Should I keep bumping or post a new thread? This is rhetorical.
is the implication that a week wasn't sufficient to figure out to move 3 lines of code to stand before the first draw_primitive_ call

you did manage to write rest of the code correctly after all
 
Top