I am having an issue where my menu an menu items for a panel are being cropped, so the stuff doesn't go below the top of the panel. Everything works fine, you just can't see the stuff below that point. When I check where that panel is with this code
if (Position.X <= 400)
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(700, 200), Item1, Item2, Item3, Item4);
else
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(100, 200), Item1, Item2, Item3, Item4);
the first 4 crop off the entire menu, then the next 8 crop off all but one section, and so on. When I don't check it (I just use line 2), then the first 8 cut off everything, the next 8 cut off all but one section, and so on. (Side note: each section is 100 pixels high.)
Here is the code used to initialize each panel, and the menu and menu items:
for (int i = 0; i <= 7; i++)
{
for (int q = 0; q <= 7; q++)
{
Panel Panel = new Panel();
Panel.Initialize(TestTextureStill, TestTextureHover, TestTextureActive, new Vector2 (q * 100 + 50, i * 100 + 50), MenuTexture, menuItem1, menuItem2, menuItem3, menuItem4);
Panels[i, q] = Panel;
}
}
Panel menu
if (Position.X <= 400)
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(700, 200), Item1, Item2, Item3, Item4);
else
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(100, 200), Item1, Item2, Item3, Item4);
Here is the drawing code:
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
for (int i = 0; i <= 7; i++)
{
for (int q = 0; q <= 7; q++)
Panels[i, q].Draw(spriteBatch);
}
spriteBatch.End();
base.Draw(gameTime);
Inside Panel.Draw()
if (selected)
panelMenu.Draw(spriteBatch);
spriteBatch.Draw(PanelTextureCurrent, Position, null, Color.White, 0f, new Vector2(Width / 2, Height / 2), 1f, SpriteEffects.None, 0f);
Inside PanelMenu.Draw()
spriteBatch.Draw(PanelMenuTexture, Position, null, Color.White, 0f, new Vector2(Width / 2, Height / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item1.CurrentTexture, new Vector2(Position.X, 50), null, Color.White, 0f, new Vector2(WidthMI1 / 2, HeightMI1 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item2.CurrentTexture, new Vector2(Position.X, 150), null, Color.White, 0f, new Vector2(WidthMI2 / 2, HeightMI2 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item3.CurrentTexture, new Vector2(Position.X, 250), null, Color.White, 0f, new Vector2(WidthMI3 / 2, HeightMI3 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item4.CurrentTexture, new Vector2(Position.X, 350), null, Color.White, 0f, new Vector2(WidthMI4 / 2, HeightMI4 / 2), 1f, SpriteEffects.None, 0f);
If you need ANYTHING else, please let me know!
Move the drawing of the menu&items to after all the panels have been drawn. This is because the panels overlapped the menu, causing it to vanish.
Related
problem
When Canvas's width and height were scaled by window.devicePixelRatio, .ie 2x, gl.readPixels can not correctly pick Pixels, probably the left half and bottom half side of canvas always pick background clearColor. And how to fix it please?
code
//...
twgl.resizeCanvasToDisplaySize(gl.canvas, window.devicePixelRatio) // <<!important
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); // default 400x400, and 800x800 while devicePixelRatio == 2
//...
function pickColor(ev) {
drawScene(gl);
const x = ev.clientX;
const y = ev.clientY;
const rect = ev.target.getBoundingClientRect();
const pixels = new Uint8Array(4);
const x_in_canvas = x - rect.left;
const y_in_canvas = rect.bottom - y;
gl.readPixels(x - rect.left, rect.bottom - y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
console.log(pixels);
}
gl.canvas.onmousedown = pickColor;
I would like to flip character when it walks left\right, I created a character from different body parts so flipping each of them caused this:
the reason of course was because it flipped the body parts in their own position, but not all the player together.
after that I had an idea and it was to draw the player to render target and flip the rendertarget when drawing, it worked (kind of), but when I walked when flipped it walked backwards and it also flipped the player position on the screen. here is the code:
if(mLeavusSprite.isflipped==0)
spriteBatch.Draw(character, rec,rec, Color.White,0,Vector2.Zero,SpriteEffects.None,0);
else
spriteBatch.Draw(character, rec, rec, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0);
character=render target that the player was drawn to.
is there anything I can do? flipping manually going to be a serious pain, I will need to move manually over 10 animations with 4+ frames each twice!
edit:
here is the code for drawing:
if (Frame == 0)
{
HeadPosition.X = Position.X;
HeadPosition.Y = Position.Y;
BodyPosition.X = HeadPosition.X + 8;
BodyPosition.Y = HeadPosition.Y + 32;
TopHandPosition.X = HeadPosition.X + 2;
TopHandPosition.Y = HeadPosition.Y + 36;
BackHandPosition.X = HeadPosition.X + 20;
BackHandPosition.Y = HeadPosition.Y + 36;
HeadSource = new Rectangle(0, 0, this.Head.Width, this.Head.Height);
BodySource = new Rectangle(0, 0, 24, 54);
TopHandSource = new Rectangle(0, 0, 10, 27);
BackHandSource = new Rectangle(0, 0, 15, 27);
theSpriteBatch.Draw(BackHand, BackHandPosition, BackHandSource,
Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Body, BodyPosition, BodySource,
Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Head, HeadPosition, HeadSource,
Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(TopHand, TopHandPosition, TopHandSource,
Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
}
Edit 2:
if (Frame == 0)
{
HeadPosition.X = Position.X;
HeadPosition.Y = Position.Y;
BodyPosition.X = HeadPosition.X + 8 ;
BodyPosition.Y = HeadPosition.Y + 32;
TopHandPosition.X = HeadPosition.X + 2 ;
TopHandPosition.Y = HeadPosition.Y + 36;
BackHandPosition.X = HeadPosition.X + 20 ;
BackHandPosition.Y = HeadPosition.Y + 36;
HeadSource = new Rectangle(0, 0, this.Head.Width, this.Head.Height);
BodySource = new Rectangle(0, 0, 24, 54);
TopHandSource = new Rectangle(0, 0, 10, 27);
BackHandSource = new Rectangle(0, 0, 15, 27);
int bigx=0;
int smallx=0;
float[] numbers = new[] { HeadPosition.X, BodyPosition.X , TopHandPosition.X, BackHandPosition.X};
float min = numbers.Min();
numbers = new[] { HeadPosition.X+HeadSource.Width, BodyPosition.X + BodySource.Width, TopHandPosition.X + TopHandSource.Width, BackHandPosition.X + BackHandSource.Width };
float max = numbers.Max();
float center = (max - min) / 2;
if (flip==1)
{
HeadPosition.X = Position.X;
BodyPosition.X = HeadPosition.X +center+ 8*flipOffset;
TopHandPosition.X = HeadPosition.X +center+ 2*flipOffset;
BackHandPosition.X = HeadPosition.X +center+ 20*flipOffset;
}
Debug.WriteLine("fff: " + center);
theSpriteBatch.Draw(BackHand, BackHandPosition, BackHandSource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Body, BodyPosition, BodySource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Head, HeadPosition, HeadSource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(TopHand, TopHandPosition, TopHandSource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
}
hmm.. that is a tricky one.
There's probably a few different ways to do this and I think drawing they player to a render target is a reasonable approach if you can get it to work.
However, if you want a quick and dirty approach you might be able to simply flip the offsets of each part like this:
var flipOffset = FlipIs == SpriteEffects.FlipHorizontally ? -1 : 1;
if (Frame == 0)
{
HeadPosition.X = Position.X;
HeadPosition.Y = Position.Y;
BodyPosition.X = HeadPosition.X + 8 * flipOffset;
BodyPosition.Y = HeadPosition.Y + 32 * flipOffset;
TopHandPosition.X = HeadPosition.X + 2 * flipOffset;
TopHandPosition.Y = HeadPosition.Y + 36 * flipOffset;
BackHandPosition.X = HeadPosition.X + 20 * flipOffset;
BackHandPosition.Y = HeadPosition.Y + 36 * flipOffset;
HeadSource = new Rectangle(0, 0, this.Head.Width, this.Head.Height);
BodySource = new Rectangle(0, 0, 24, 54);
TopHandSource = new Rectangle(0, 0, 10, 27);
BackHandSource = new Rectangle(0, 0, 15, 27);
theSpriteBatch.Draw(BackHand, BackHandPosition, BackHandSource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Body, BodyPosition, BodySource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(Head, HeadPosition, HeadSource, Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
theSpriteBatch.Draw(TopHand, TopHandPosition, TopHandSource,Color.White, 0.0f, Vector2.Zero, Scale, FlipIs, 0);
}
This is assuming that Position is right in the center of the sprite, if not you might need to do some tweaking.
Look, I'll be honest with you. There are better ways to approach this problem, but they'd require a significant redesign of the code and it's difficult to explain in one answer.
The first thing I would do to refactor the design is create a class to represent a single Sprite part to hold the common data points (offset, source rectangle, texture, color, etc) and setup data in one place. The animation code needs to be decoupled from the drawing code, etc.
I am developing a side scroller game using monogame 3.0 (XNA-C#). I am using a TriangleStrip to draw the ground and a spritebatch to draw a fence. I want the fence to be on top of the ground but it seems to be using a different axis (negative instead of positive). In order to align things up I need to flip the fence and use a negative x and y. Both the sprite and the primitive are using the same view matrix and project.
Why is the spritebatch need a negative axis while the primitive is using a positive one when they are using the same matrixes?
protected override void Initialize()
{
viewMatrix = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, new Vector3(0,1, 0));
projectionMatrix = Matrix.CreateOrthographicOffCenter(0,GraphicsDevice.Viewport.Width,
0, GraphicsDevice.Viewport.Height, 0f, 200f) *Matrix.CreateScale(new Vector3(.5f, .5f, 1f));
GraphicsDevice.RasterizerState.CullMode = CullMode.None;
_groundBasicEffect = new BasicEffect(GraphicsDevice);
_groundBasicEffect.View = viewMatrix;
_groundBasicEffect.Projection = projectionMatrix;
_groundBasicEffect.VertexColorEnabled = true;
_groundBasicEffect.World = world;
_fenceBasicEffect = new BasicEffect(GraphicsDevice);
_fenceBasicEffect.View = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, new Vector3(0,1, 0));
_fenceBasicEffect.Projection = projectionMatrix;
_fenceBasicEffect.TextureEnabled = true;
_fenceBasicEffect.World = world;
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
fenceTexture = this.Content.Load<Texture2D>(#"Fence1");
vertexData = new VertexPositionColor[8];
vertexData[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
vertexData[1] = new VertexPositionColor(new Vector3(0, 400, 0), Color.Black);
vertexData[2] = new VertexPositionColor(new Vector3(200, 0, 0), Color.Black);
vertexData[3] = new VertexPositionColor(new Vector3(200, 400, 0), Color.Black);
vertexData[4] = new VertexPositionColor(new Vector3(300, 0, 0), Color.Black);
vertexData[5] = new VertexPositionColor(new Vector3(300, 430, 0), Color.Black);
vertexData[6] = new VertexPositionColor(new Vector3(1200, 0, 0), Color.Black);
vertexData[7] = new VertexPositionColor(new Vector3(1200, 430, 0), Color.Black);
vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), vertexData.Length, BufferUsage.None);
vertexBuffer.SetData(vertexData);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
GraphicsDevice.SetVertexBuffer(vertexBuffer);
_groundBasicEffect.CurrentTechnique.Passes[0].Apply();
GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertexData, 0, vertexData.Length -2);
_spriteBatch.Begin(0, null, null, null, null, _fenceBasicEffect);
_spriteBatch.Draw(fenceTexture, Vector2.Zero, new Rectangle(0, 0, 1130, 221), Color.White, 0, new Vector2(0, 200), 1, SpriteEffects.None, 0);
_spriteBatch.End();
base.Draw(gameTime);
}
How it looks...
How I expect it to look...
In order to get this look I need to change the Draw of the fence to this...
_spriteBatch.Draw(fenceTexture, Vector2.Zero, new Rectangle(0, 0, 1130, 221), Color.White, 0, new Vector2(0, -400), 1, SpriteEffects.FlipVertically, 0);
I want to add a bar at the bottom of the screen which has images and a string ,i wanted to have the spacing equally like
img1 string img2|img3 ,this is how the bottom bar should look like,below code is not wroking properly i am gettign the alignment and the last iamge is getting disappeared.
HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(
FIELD_BOTTOM) {
public void paint(Graphics graphics) {
graphics.setBackgroundColor(0x316AC5);
graphics.clear();
super.paint(graphics);
}
};
Bitmap fadeBitmap = Bitmap
.getBitmapResource("GE_TimeZone_Fade_blue.PNG");
Bitmap clockBitmap = Bitmap.getBitmapResource("GE_Cal_icon_blue.PNG");
Bitmap tzBitmap = Bitmap
.getBitmapResource("GE_TimeZone_Button_blue.PNG");
final ImageButtonField unfocus = new ImageButtonField("",
Field.FOCUSABLE | FIELD_LEFT, "GE_TimeZone_Fade_blue.PNG",
"GE_TimeZone_Fade_blue.PNG", 0xFFFFFF);
LabelField test = new LabelField("hello");
final ImageButtonField bitmapField = new ImageButtonField("",
Field.FOCUSABLE | FIELD_HCENTER, "GE_Cal_icon_blue.PNG",
"GE_Cal_icon_onSelect.PNG", 0xFFFFFF);
final ImageButtonField bitmapField1 = new ImageButtonField("",
Field.FOCUSABLE | FIELD_RIGHT, "GE_TimeZone_Button_blue.PNG",
"GE_TimeZone_Btn_OnSelect.PNG", 0xFFFFFF);
int margin = ((Display.getWidth() - (fadeBitmap.getWidth()
+ clockBitmap.getWidth() + tzBitmap.getWidth() + test
.getWidth())) / 4);
unfocus.setMargin(0, margin, 0, 0);
test.setMargin(0, margin, 0, 0);
bitmapField.setMargin(0, margin, 0, 0);
bitmapField1.setMargin(0, margin, 0, 0);
horizontalFieldManager.add(unfocus);
horizontalFieldManager.add(test);
horizontalFieldManager.add(bitmapField);
horizontalFieldManager.add(bitmapField1);
this.setStatus(horizontalFieldManager);
There is a problem on the code you are using. Check following line.
int margin = ((Display.getWidth() - (fadeBitmap.getWidth()
+ clockBitmap.getWidth() + tzBitmap.getWidth() + test
.getWidth())) / 4);
The getWidth() and getHeight() of any Field will return valid values if the layout method of it's parent manager gets called.
So, adjusting the margin using getWidth(), getHeight() is not safe.
But it is possible to control the alignment and position of the Fields via extending HorizontalFieldManager. Check the following codes and output to get an idea about how it can be done.
Output
Using the StatusFieldManager:
StatusFieldManager statusFieldManager = new StatusFieldManager();
statusFieldManager.setBackground(BackgroundFactory.createSolidBackground(0x316AC5));
final Bitmap bmTest = Bitmap.getBitmapResource("bitmap.png");
BitmapField bmOne = new BitmapField(bmTest, Field.FOCUSABLE | FIELD_LEFT);
BitmapField bmTwo = new BitmapField(bmTest, Field.FOCUSABLE | FIELD_LEFT);
BitmapField bmThree = new BitmapField(bmTest, Field.FOCUSABLE | FIELD_LEFT);
LabelField lblTest = new LabelField("Test");
statusFieldManager.add(bmOne);
statusFieldManager.add(lblTest);
statusFieldManager.add(bmTwo);
statusFieldManager.add(bmThree);
setStatus(statusFieldManager);
Implementation of StatusFieldManager
class StatusFieldManager extends HorizontalFieldManager {
protected void sublayout(int width, int height) {
int numField = getFieldCount();
Field f;
int nHeight = 0, maxFieldWidth = width / 4;
if (numField == 4) {
f = getField(0);
layoutChild(f, maxFieldWidth, height);
nHeight = Math.max(nHeight, f.getHeight());
f = getField(1);
layoutChild(f, maxFieldWidth, height);
nHeight = Math.max(nHeight, f.getHeight());
f = getField(2);
layoutChild(f, maxFieldWidth, height);
nHeight = Math.max(nHeight, f.getHeight());
f = getField(3);
layoutChild(f, maxFieldWidth, height);
nHeight = Math.max(nHeight, f.getHeight());
// set position of the child fields
int x = 0, y = 0;
int requiredFieldWidth = 0;
for (int i=0;i<numField;i++) {
requiredFieldWidth += getField(i).getWidth();
}
int spaceBetweenFields = (width - requiredFieldWidth) / (numField - 1);
for (int i=0;i<numField;i++) {
setPositionChild(getField(i), x, (nHeight - getField(i).getHeight()) / 2);
x += getField(i).getWidth() + spaceBetweenFields;
}
setExtent(width, nHeight);
} else {
setExtent(0, 0);
}
}
}
try this -
unfocus.setMargin(0, margin, 0, 0);
test.setMargin(0, 10, 0, 0);
bitmapField.setMargin(0, 10, 0, 0);
bitmapField1.setMargin(0, 10, 0, 0);
In my project, I draw a house, which consists of wall, floor, mirror, a switch to turn on or turn off the fire system. Everything is going on well by here.
At last, I want to draw a person's reflection on the mirror, but after I add the drawReflection function, things go wrong, scene became a mess. Why? I write the function according to the book.
void House::draw(float timeDelta)
{
_device->SetFVF(d3d::Vertex::FVF);
_device->SetStreamSource(0, _vb, 0, sizeof(d3d::Vertex));
// draw wall
_device->SetMaterial(&d3d::WHITE_MTRL);
_device->SetTexture(0, _wall);
_device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 10);
// draw floor
_device->SetMaterial(&d3d::WHITE_MTRL);
_device->SetTexture(0, _floor);
_device->DrawPrimitive(D3DPT_TRIANGLELIST, 30, 2);
// draw mirror
_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
_device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
_device->SetMaterial(&d3d::WHITE_MTRL);
_device->SetTexture(0, _mirror);
_device->DrawPrimitive(D3DPT_TRIANGLELIST, 36, 2);
_device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
// draw switch button
D3DXMATRIX T, Ry, P;
D3DXMatrixTranslation(&T, -4.95f, 2.0f, 3.0f);
D3DXMatrixRotationY(&Ry, D3DX_PI * 1.5f);
P = Ry * T;
_device->SetTransform(D3DTS_WORLD, &P);
_device->SetMaterial(&d3d::BLUE_MTRL);
_device->SetTexture(0, NULL);
_switch->DrawSubset(0);
// draw fire system
D3DXMATRIX I;
D3DXMatrixIdentity(&I);
_device->SetTransform(D3DTS_WORLD, &I);
if(_fSwitchOn)
{
if(_fs->isDead())
_fs->reset();
_fs->update(timeDelta);
_fs->render();
}
// draw reflection of person
//drawReflection();
}
But after I add drawReflection() function to it, it became a mess. Why?
drawReflection() function is below:
void House::drawReflection()
{
// enable stencil
_device->SetRenderState(D3DRS_STENCILENABLE, true);
_device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
_device->SetRenderState(D3DRS_STENCILREF, 0x1);
_device->SetRenderState(D3DRS_STENCILMASK, 0xffffffff);
_device->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff);
_device->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
_device->SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
_device->SetRenderState(D3DRS_STENCILPASS,
D3DSTENCILOP_REPLACE);
// stop write to target buffer and depth buffer
_device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
_device->SetRenderState(D3DRS_ZWRITEENABLE, false);
// draw the mirror to stencil buffer
_device->SetFVF(d3d::Vertex::FVF);
_device->SetStreamSource(0, _vb, 0, sizeof(d3d::Vertex));
_device->SetMaterial(&d3d::WHITE_MTRL);
_device->SetTexture(0, _mirror);
D3DXMATRIX I;
D3DXMatrixIdentity(&I);
_device->SetTransform(D3DTS_WORLD, &I);
_device->DrawPrimitive(D3DPT_TRIANGLELIST, 36, 2);
_device->SetRenderState(D3DRS_ZWRITEENABLE, true);
// transform the mesh
_device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL);
_device->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
D3DXMATRIX Reflect, S, T, P;
D3DXPLANE plane(0.0f, 0.0f, 1.0f, -5.0f);
D3DXMatrixReflect(&Reflect, &plane);
// D3DXMatrixScaling(&S, 0.2f, 0.2f, 0.2f);
D3DXVECTOR3 pos;
_person->getPosition(&pos);
D3DXMatrixTranslation(&T, pos.x, pos.y, pos.z);
P = T * Reflect;
_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
_device->SetTransform(D3DTS_WORLD, &P);
_person->draw();
_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
_device->SetRenderState(D3DRS_STENCILENABLE, false);
_device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
}