Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Cannot load texture

Started by Alex060381 Apr 5, 2011 at 6:33 PM 0 replies 650+ views
Original Post
Alex060381
Alex060381
Please help. I can not load the texture with mipmap = 1, instead of the texture displayed a white square.

Here is a sample application:




using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Microsoft.WindowsMobile.DirectX;
using Microsoft.WindowsMobile.DirectX.Direct3D;
using System.Text;
using System.Windows.Forms;

namespace SmartDeviceProject1
{
public partial class Form1 : Form
{
Device device = null;
Texture FTexture = null;
Sprite DXSprite;
public Form1()
{

string FCurrentDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

InitializeComponent();

PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Default, this, CreateFlags.None, presentParams);

DXSprite = new Sprite(device);

FTexture = TextureLoader.FromFile(device,FCurrentDirectory + "\\1.png",0,0,1,Usage.Texture,
Format.A8R8G8B8, Pool.Managed, Filter.None, Filter.None, 0x00);



}

private void Form1_Paint(object sender, PaintEventArgs e)
{
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
device.BeginScene();
DXSprite.Begin(SpriteFlags.None);

DXSprite.Draw(FTexture,Rectangle.Empty,new Vector3(0,0,0),new Vector3(0,0,0),-1);


DXSprite.End();
device.EndScene();
device.Present();

}
}
}





If the string new textureloader.fromfile as a parameter to specify the mipLevels = 0, then the texture is displayed normally. But at the same loaded 7 mip levels and get more memory overruns.

What could be wrong in my program??

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.