Windows Phone 7 Development log (first try, study at Will)

Source: Internet
Author: User
Tags dotnet

Played with xna4 development.

First, install the two laptops. It is very troublesome to download a complete package. I have installed it six times ......

The desktop computer in the home cannot be installed, and window7 can be reinstalled. It may be related to the installation of vs2010.

I tested the development of the windows and Windows phone7 simulators and made a simple graphical operation. Basically, it was still the interfaces of DX, which seemed familiar and did not encounter any difficulties. That is, the C # syntax is entangled for a long time. Speaking of C ++ and C #, # Is to overlap the two +, but it is still a lot worse. Although the system has learned a little about DOTNET, it has been a long time, but it still took a lot of effort.

1. References.

1. The windows and Windows Phone 7 platforms are similar to the referenced libraries at first glance. It's not a little bit worse to start looking at the reference libraries. If you want to do it in the future, you should always pay attention to the compatibility with Windows Phone 7.Code.

2. Projects, content projects, and resource pipelines are not convenient. They may be abused. Instead, they have to be bound to the whole automation. I 've been desperately trying to load resources from the outside. This is a bit of a result. Let's wait. The libraries that can be referenced in the project and those that can be referenced in the content are completely unavailable. It seems that DOTNET is still a great spirit. How can this restriction be produced? I have not understood yet. Therefore, in xna4, runtime processing resources is almost impossible.

Ii. About Resources

I have read the document to introduce the architecture of the resource pipeline, which allows us to follow this path and add our own resource format to run it again. I am very disgusted with this.

PC production-> content project compilation-> runtime call. The restrictions produced by this fixed mode imprison my creativity.

Textures, models, shader, and other custom formats. I want to bypass Microsoft's design.

The model is a pile of vertex data. As long as the texture can lock the surface to write data, there should be no problem.

So I followed shader and vomited blood to the ground. All the modules found in xna4 related to Shader compilation can only be referenced in the content project.

The runtime compilation effect path is completely blocked ......

So I opened the xNb file generated by FX in binary format and did some analysis and testing. At least I can now directly load the effect file compiled by fxc.

We can also see that there is a shadercompiler module in xna3.1 that can be used at runtime. I have time to test it again.

3. pleasant places

Quick porting: almost the same code can be used on PC and Windows phone7. The DOTNET framework is not built across platforms.

The support for multi-point touch is perfect. It works well with tx2z on Windows 7, and the multi-point touch interface is very useful. In addition, tx2z also shows completely consistent behavior in the Windows phone7 simulator. On the issue of multi-touch debugging, as long as there is a screen that supports multi-touch, we can forget that this is a problem.

Recently, HP has launched another TM2, which supports multi-point touch and starts to work slowly.

Accelerator support is also available, but it is not used at all on the PC, and I have always felt that it is amazing to use accelerators in the subway to play games, but it is also an exciting feature.

Automatically flip the screen. I have not tested whether there is any direct interface in xNa. Even if it is not, it can be determined by the accelerator. This is also a function that is not easy to debug-P.

Comparison of the new dx, from the study of effect found that the shader compiler uses d3dcompiler_41 d3dx9_41, And the dxsdk in November is _ 42.

My research record on the effect file.

I. fx_2_0 generated by fxc

The binary comparison shows that the xNb clear Code directly inserts the fx_2_0 file compiled by fxc.

2. Unique File Header

 
Public effect (graphicsdeviceGraphicsdevice, Byte []Effectcode)
 
Effectcode, which does not have any description. It looks like code. Put a string in it. An exception gives the answer and the code that needs to be compiled.
 
Find the header of the compiled fx_2_0 file in xNb and put it in. The exception too occurs.
 
This is hard for us, hey. I expected you could add something useless before and try it one by one.

For (int A = 0; A <100; A ++)
{
System. Io. Stream S = system. Io. file. Open ("content \ glow. xNb", system. Io. filemode. Open );
Int n = (INT) S. length;
Byte [] B = new byte [N];
S. Seek (A * 4, system. Io. seekorigin. Begin );
S. Read (B, 0, N );
// Byte [] fg = B + 12;
S. Close ();
Try
{
E = new effect (graphicsdevice, B );
NPOs =;
}
Catch (exception)
{
}
}

When NPOs = 42, it passed. I found some more tests and the conclusion was stable.

The first 168 is the xNb file header, as long as it is opened from 168, It is the effectcode format used in xna4.

Now we start to build some DX effect files to compile with fxc, load the test, and fail. In

Create a default effect file in xNa content, compile it with fxc, and add the file header consistent with that in xNb

Cf0bf0bc 0c000000 00000000 load test, passed.

It seems that there are still many names in these 12 bytes.

After more tests, more information is obtained. Although fx_2_0 is used, some FX cannot be compiled in xNa content.

Colodrop [0] = selectarg2;

The prompt is as follows:

Error 1 errors compiling E: userslightsdocumentsvisual studio 2010projectsxnashaderxnashaderxnashadercontentglow. FX:
Error: The effect State 'drop' is obsolete and can no longer be used. E: userslightsdocumentsvisual studio 2010projectsxnashaderxnashaderxnashadercontentglow. FX xnashader

I don't know how to set fxc to get the same compiling environment as xNa content.

In short, the effect file of a single pass of technique can be loaded after being compiled by fxc.

But when there are multiple passes, different file headers ......

Cf0bf0bc is the same. 0c000000: one pass 10000000: Two Pass 14000000: three pass

In four increments, the subsequent 00000000 random write data test is irrelevant, one pass 4 bytes, two pass 8 bytes, three pass 12 bytes

Increase too by four.

Write a paragraphProgramAs follows:

Int passsize = 2; // number of passes
{
System. Io. Stream S = system. Io. file. Open ("content \ glow. fxo", system. Io. filemode. Open );
Int n = (INT) S. length;
Int headlen = 8 + passsize * 4;
Byte [] B = new byte [n + headlen];
B [0] = 0xcf;
B [1] = 0x0b;
B [2] = 0xf0;
B [3] = 0xbc;
Int tag = 0x0c + (passsize-1) * 4;
B [4] = (byte) Tag;
S. Read (B, headlen, N );
S. Close ();
E2 = new effect (graphicsdevice, B );
}

After testing several cases, they are all OK and basically master the xna4 effect runtime loading problem.

Iii. Why?

The conclusion is very simple. It is not a pleasure to use a hexadecimal editor to analyze the results.

I want to easily load the shader at runtime, and further develop the shadertree to generate the shader at runtime.

Now we have basically solved the load problem, and the rest is the compilation problem.

Currently, the most difficult way is to save the dynamically generated tcode to a file, call fxc for compilation, and load it again. It is feasible, not elegant, and relies on the Windows platform.

Solution 2: Write a database and use xna3.1 to compile effect to return code. I haven't tested it yet. Windows platforms should be feasible. I wonder if xNa on Windows phone7 will retain 3.1

Solution 3: the official version of xna4 will allow runtime compier effect. In fact, if Microsoft does not solve this problem, our shadertree will become a technical feature.

Solution 4: solution 2 has not been tested. The shadercompier of xna3.1 does not include FX..., so after the official release of xNa, you can use C ++ to call DX for direct compilation. However, it is estimated that the C ++ native code can only be used on Windows platforms to call dx.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.