3d - DrawUserPrimitives problems on Monogame -


i'm trying draw simple coloured rectangle on monogame (for windows8) using 3d primitives drawuserprimitives , vertexpositioncolor, thing can see rectangle covers upper half of screen, can see in screenshot below. occurs when drawing triangle, too.

screenshot

here's code:

// camera code camera.position = new vector3(0, 1500, 0); camera.projection = matrix.createperspectivefieldofview(mathhelper.toradians(45), graphicsdevice.viewport.aspectratio, 1, 5000); camera.view = matrix.createlookat(camera.position, vector3.down, vector3.forward);   vertexpositioncolor[] vertexlist = new vertexpositioncolor[4];  basiceffect basiceffect;   vertexbuffer vertexbuffer;  // initializations vertexlist[0] = new vertexpositioncolor(new vector3(-957, 10, -635), color.red);   vertexlist[1] = new vertexpositioncolor(new vector3(957, 10, -635), color.lime);   vertexlist[2] = new vertexpositioncolor(new vector3(-957, 10, 635), color.yellow);   vertexlist[3] = new vertexpositioncolor(new vector3(957, 10, 635), color.blue);  vertexbuffer = new vertexbuffer(graphicsdevice, typeof(vertexpositioncolor), 4, bufferusage.writeonly);   vertexbuffer.setdata<vertexpositioncolor>(vertexlist);  basiceffect = new basiceffect(graphicsdevice);   basiceffect.vertexcolorenabled = true;   basiceffect.lightingenabled = false;   basiceffect.projection = camera.projection;  // draw code graphicsdevice.rasterizerstate = rasterizerstate.cullnone; graphicsdevice.setvertexbuffer(vertexbuffer);  foreach (effectpass p in basiceffect.currenttechnique.passes) {    p.apply();    graphicsdevice.drawuserprimitives<vertexpositioncolor>(primitivetype.trianglestrip, vertexlist, 0, 2); } 

as can see, i've used different colors 4 vertexes, program seems draw 2 of them: vertexlist[0] , vertexlist[1]. suggestion? what's wrong?

i think you're missing

basiceffect.view = camera.view; 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -