DirectDraw in Windows mobile6 smartphone

Source: Internet
Author: User

I am also new to mobile development. I used to do Java, and later I started Symbian for a few months. Now I have switched to mobile for development, I want to write out some small achievements on mobile and share them with you. I hope that later users can release the signatures and avoid detours. Haha. If there is something wrong, please point it out. Thank you very much.

First of all, our development environment is the development environment of wm6 smartphone. we need to decode the image and display it on the main interface plane. At the early stage of development, none of our companies had access to mobile, therefore, the solution to this problem is far from a good technical solution. After several days of research, we decided to use the DirectDraw technology, at the early stage of development, we found a lot of DirectDraw materials based on PPC, and there were almost no use cases in our environment. We used the materials with PPC, in our environment, we have basically understood the entire DirectDraw process, and we can still see it in our environment, later, some technical empirical conclusions were obtained through continuous learning and research. The attributes that can be implemented in PPC are not supported in this environment, as shown in figure

1: The standard mode is not supported when you set the level of collaboration. Only full screen mode is supported.

2: double buffering is not supported.

3: The off-screen page is not supported.

4: page turning is not supported.

Next I will introduce and explain the entire process of DirectDraw in wm6 smartphone. I hope to help the developers who will use this environment. If there is no correction from the expected experts, thank you for your support.

1: first define several global variables

PRIVATE:
Lpdirectdraw m_pdd;
Lpdirectdrawsurface m_pddprimarybuffer;
Lpdirectdrawsurface m_pddbackbuffer;
Lpdirectdrawclipper m_pddclipper;
Ddcaps m_ddcaps;

Bool m_bpageflipping;

2: Create a DirectDraw object

// Perform DirectDraw initialization:
If (failed (directdrawcreate (0, & m_pdd, 0 )))
{Shutdown (); return ;}

3: set the level of collaboration

// Set co-operative level
If (failed (m_pdd-> setcooperativelevel (m_hwnd, ddscl_fullscreen )))
{Shutdown (); return ;}

Note that the second parameter must be in full screen mode under smartphone.

4:

// Cache ddraw device capabilities
M_pdd-> getcaps (& m_ddcaps, 0 );

5:

// True if backbuffers and flipping are supported by hardware
M_bpageflipping = checksurfacecaps (ddscaps_backbuffer | ddscaps_flip );

6:

// Create clipper
If (failed (m_pdd-> createid per (0, & m_pddclipper, null )))
{Shutdown (); return ;}

7:

// Setting it to our hwnd gives the Clipper the coordinates from our window
If (failed (m_pddclipper-> sethwnd (0, m_hwnd )))
{Shutdown (); return ;}

8:

// Set up our surface
Ddsurfacedesc ddsdprim;

Zeromemory (& ddsdprim, sizeof (ddsdprim ));

9: m_bpageflipping. If it is true, page turning is supported. Otherwise, response operations are not supported.

Ture:

Ddsdprim. dwsize = sizeof (ddsdprim );
Ddsdprim. dwflags = ddsd_caps | ddsd_backbuffercount;
Ddsdprim. ddscaps. dwcaps = ddscaps_primarysurface | ddscaps_flip;
Ddsdprim. dwbackbuffercount = 1;

// Create primary surface
If (failed (m_pdd-> createsurface (& ddsdprim, & m_pddprimarybuffer, 0 )))
{Shutdown (); return ;}

// Attach flipping surface.
If (failed (m_pddprimarybuffer-> enumattachedsurfaces (& m_pddbackbuffer, enumcallback )))
{Shutdown (); return ;}

False:

Ddsdprim. dwsize = sizeof (ddsdprim );
Ddsdprim. dwflags = ddsd_caps;
Ddsdprim. ddscaps. dwcaps = ddscaps_primarysurface;
Ddsdprim. dwbackbuffercount = 1;
// Create primary surface
If (failed (m_pdd-> createsurface (& ddsdprim, & m_pddprimarybuffer, 0 )))
{Shutdown (); return ;}

// M_pddprimarybuffer-> getddinterface (& m_pdd );//----------------
// Query full surface description
If (failed (m_pddprimarybuffer-> getsurfacedesc (& ddsdprim )))
{Shutdown (); return ;}
// Using caps, width and height, in system memory...
Ddsdprim. dwsize = sizeof (ddsdprim );
Ddsdprim. dwflags = ddsd_caps | ddsd_width | ddsd_height;
Ddsdprim. ddscaps. dwcaps = ddscaps_systemmemory;
Ddsdprim. dwwidth = 240;
Ddsdprim. dwheight = 300;
// Create back-buffer Surface
If (failed (m_pdd-> createsurface (& ddsdprim, & m_pddbackbuffer, 0 )))
{Shutdown (); return ;}

10: clipboard to main surface

// Attach the Clipper to the primary surface
If (failed (m_pddbackbuffer-> setclipper (m_pddclipper )))
{Shutdown (); return ;}

11: loop display

While (1)
{
HDC; //, hdc1;
Ddbltfx;
Memset (& ddbltfx, 0, sizeof (ddbltfx ));
Ddbltfx. dwsize = sizeof (ddbltfx );
Ddbltfx. dwfillcolor = RGB (0, 0, 31 );
// M_pddprimarybuffer-> BLT (null, ddblt_colorfill | ddblt_waitnotbusy, & ddbltfx );
If (m_pddprimarybuffer-> getdc (& HDC) = dd_ OK)
{

// The code to be displayed on the home page

M_pddprimarybuffer-> releasedc (HDC );

}

If (m_pddbackbuffer-> getdc (& HDC) = dd_ OK)
{

// Code displayed on the back page
M_pddbackbuffer-> releasedc (HDC); // release the DC from the screen. Be sure to release it.

// This is a repeating display on the home page.
M_pddprimarybuffer-> BLT (null, m_pddbackbuffer, null, ddblt_waitnotbusy, & ddbltfx );

}

Sleep (1000 );

This is a general process. You need to study other details on your own.

As for the key part of the stream reading into the playback file in the swf format, we are still studying. If someone who has done this and has good implementation insights can provide a good idea, I would like to thank you very much, I also hope that my summary will help you.

 

If you need technical exchange, contact me QQ: 67530591

At the same time, I hope more colleagues can find the problems they want to solve in my space, and also hope that people passing by will leave the technical problems they encountered during development, who can help and solve the problem, haha

 

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.