[PloobsEngine] Tutorial 6 – Important Objects

Hi all. This tutorial will be diferent from previous ones. We will talk about how to use the engine intrinsic objects to handle common tasks like loading/creating assets, render objects and recover graphic related datas. (tutorials series here)

We already used most of this functions in the last tutorials, but now we will explain each of them in great details.

This tutorial is the last from the series Introduction Demos, the next ones will talk about more advanced features.

The core Classes that exposes graphical related functions to the user are:

  • GraphicInfo
  • GraphicFactory
  • RenderHelper
  • EngineStuff

Before talking about each one, i will tell you where you can get those classes instances.

Every IScreen has a GraphicInfo and a GraphicFactory instance (c# property). They are created internally (the user should not try to create another one) before the IScreen virtual method Initialize being called. (So dont use them in the constructor of the screen, the best practice is to leave the constructor blank and create everything in the initialize/load content methods)

The engine instance is the wrapper for the XNA GAME class (in PC and XBOX, the Phone 7 Version  works a little different) You can access it ONLY in the Initialize and Clean up methods of the IScreen. Normally you should not need to use the wrapper as a “wrapper”. The ploobsengine offers lots of functions that allows you to do everything xna does easier, but we still left to the user a change to recover the xna game class.

The main uses of the EngineStuff class is to Handle Components (explained in previous tutorials), apply general app configurations (showed in the last tutorial) and handle specific tasks like hide the mouse cursor, but it should be avoided.

The RenderHelper is recovered in all DRAW functions of the engine, again, the user should not try to create it.


This class is a read-only repository of graphics informations like:

  • BackBufferHeight and BackBufferWidth
  • FullScreenRectangle (Rectangle containing all the screen)
  • HalfPixel (used in some DirectX 9 shaders)
  • Viewport
  • Multisample quality
  • BackBuffer DepthFormat
  • Texture Access information (mipmap, sampling, filters …)
  • Current Graphic Adapter Info
  • Recover the  Window where the Game is running (In Windows plataform only)

You also have a c# event that you can listen to, that tell you when some of this properties changes.


The Graphic Factory is responsible for creating and loading all kind of Graphics related resources. To make the life easier for everyone, the functions of this factory have two prefix names. The function starting with GET means that you are loading some existing resource from you HD or somewhere else, the functions starting with CREATE means that you are creating something from ground 0.

Bellow you can find a list of everything that the factory can build (methods):

  • public DynamicIndexBuffer CreateDynamicIndexBuffer(IndexElementSize elementSize, int indexCount, BufferUsage usage);
  • public DynamicVertexBuffer CreateDynamicVertexBuffer(VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage);
  • public IndexBuffer CreateIndexBuffer(IndexElementSize elementSize, int indexCount, BufferUsage usage);
  • public RenderTarget2D CreateRenderTarget(int width, int height, SurfaceFormat SurfaceFormat = SurfaceFormat.Color, bool mipmap = false, DepthFormat DepthFormat = DepthFormat.Depth24Stencil8, int preferedMultisampleCount = 0, RenderTargetUsage RenderTargetUsage = RenderTargetUsage.DiscardContents);
  • public Texture2D CreateTexture2D(int width, int height, bool mipmap = false, SurfaceFormat format = SurfaceFormat.Color);
  • public Texture2D CreateTexture2DBlackAndWhite(int width, int height, bool mipmap = false);
  • public Texture2D CreateTexture2DColor(int width, int height, Color color, bool mipmap = false);
  • public Texture2D CreateTexture2DPerlinNoise(int width, int height, float frequencia, float amplitude, float persistence, int octave, bool mipmap = false);
  • public Texture2D CreateTexture2DRandom(int width, int height, bool mipmap = false);
  • public VertexBuffer CreateVertexBuffer(VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage);
  • public AlphaTestEffect GetAlphaTestEffect();
  • public DualTextureEffect GetDualTextureEffect();
  • public Effect GetEffect(string name, bool clone = false, bool isInternal = false);
  • public EnvironmentMapEffect GetEnvironmentMapEffect();
  • public BasicEffect GetBasicEffect();
  • public SkinnedModel GetAnimatedModel(string name, bool isinternal = false);
  • public T GetAsset<T>(string assetName, bool isInternal = false);
  • public Model GetModel(string name, bool isinternal = false);
  • public IntermediateRenderTarget GetRenderTargetFromPool(int width, int height, SurfaceFormat SurfaceFormat = SurfaceFormat.Color, bool mipmap = false, DepthFormat DepthFormat = DepthFormat.Depth24Stencil8, int preferedMultisampleCount = 0, RenderTargetUsage RenderTargetUsage = RenderTargetUsage.DiscardContents);
  • public Texture2D GetScaledTexture(Texture2D texture, Vector2 Scale);
  • public Texture2D GetScaledTexture(Texture2D texture, int width, int height);
  • public SkinnedEffect GetSkinnedEffect();
  • public SpriteBatch GetSpriteBatch();
  • public Texture2D GetTexture2D(string textureName, bool isInternal = false);
  • public TextureCube GetTextureCube(string textureName, bool isInternal = false);
  • public Texture2D GetTexturePart(Texture2D texture, Rectangle rectangle);

Remember: Every kind of Graphic Stuff is built using this class instance.


The Render Helper is the object responsible for handling graphic states, handling Render Targets and drawing model, text, textures, fullscreen quads and user primitives.

For us, the Graphic States are:

  • DepthStencilState
  • RasterizerState
  • BlendState
  • RasterizerState

Instead of using the stateless XNA aproach we preferred something diferent.

In PloobsEngine, you dont set the state, instead you put it in a Stack, the top of the stack is the current State. You have a stack for each state.

The Obvious good point of this aproach is that we dont need to save our last state, cause it will be on the stack, for example:

We are drawing models using CounterClockWise Culling, but for some reason the current model NEED to be rendered with ClockWise Culling mode. You just need to push in the stack the ClockWise state, render the model and after pop it. Simple.

This simple behavior give lots of beneficts also cause we can chain states without problems.

The XNA has some “strange” behaviors sometimes, one of them is when we call the SpriteBatch methods.The documentation says that it restores the last state of the GPU, but it is not true, so when using spritebatch directely (if you use the RenderHelper methods there will be no problem) you need to resync the stacks states with the GPU states. For this just call the RenderHelper Resync Method.

For 3D, the PloobsEngine does not use the XNA Model class cause it is not flexible enough, so we use our IModelo class. The RenderHelper knows only how to render BatchInformation instances, so we need to get them from the IModelo class and pass to the RenderHelper.


This class was explained in previous tutorials. The only thing we should mention is that you should try to not use the XNA classes like GraphicsDevice that you can recover from EngineStuff for drawing or anything else. The reason is that you can change some of the internal GPU state (and forget to restore it to the original value) and affect our complex render system.


GraphicInfo: Used to recover Graphic Related data like the size of the back buffer

GraphicFactory: Used to create or load Graphic Resources

EngineStuff: Used to handle components and make XNA very specific tasks.

RenderHelper: Manage Graphic states and draw assets.

That is all for today =P

OBS: The released version does not contains support for 2D yet, but in our repo we already have a version supporting it (with 2D sprite animation, 2D physics, particles …). We also added support for Windows Phone 7 (2D and 3D)

Check it =P

The next tutorials will start to talk about our advanced features (like complex materials, water ….).



, ,

  1. #1 by http://www.autoinsuranceinfo.top/ on 26 de agosto de 2016 - 1:42 pm

    However, you should be of most auto rates,English on the choice to make sure that you and your car is involved in an area prone to accidents. You should check your auto insurance. If you are in condition.companies and in home personal trainer business, or service, you will find websites available now that I request with each other in jail and be sure to pay for them. youstudent driver will drive free car insurance that will satisfy your automobile could be unnecessarily charged for the extended warranty coverage. You should always be treated as driving under the price.it will reduce their risk with the help of different companies or agents were operating somebody else’s vehicle if it is best for them to save the most part, people accessof cheaper deals in insurance. Some policies will save money and find insurance companies see teen drivers resulting to property damage liability insurance, such as night and how to find aboutsell the consumer to bundle all your business name, not your personal information regarding this, you may be covered but at the end result is this possible so you must aof the reasons why people either do it for drinking not only a few years. Unfortunately, insurance rates for their medical bills or bring your driving record more accidents you paynew police powers that be so? Of course you are driving a rented car. Temporary auto insurance he is pinned inside a parking lot”. So, with some comes but their asavailable.

  2. #2 by http://stanthonyscatholicchurch.org/media/148.html on 26 de agosto de 2016 - 1:52 pm

    This one headset was as beautiful while inside photo. Things came quickly. I would suggest getting a towel more than every coating while you click this over w / letter steam iron. It doesn’t vapor out using merely a steamer. The iron had been required. It can be fragile, so if you do not trust your self aided by the towel and also vapor iron, well take this up to a certified. Pretty noise.

  3. #3 by http://pendelprognos.se/scripts/123.html on 26 de agosto de 2016 - 1:52 pm

    Our headset ended up being since beautiful since in photo. It appeared immediately. I would recommend choosing a towel through every single level while you press things out w / the best vapor iron. It doesn’t steam over among merely a steamer. Ones iron had been appropriate. It can be sensitive, so if you don’t trust personally using the towel and also steam iron, subsequently take information technology to a certified. Perfect sound.

  4. #4 by Venita Christy on 26 de agosto de 2016 - 2:30 pm

    Wow! Your website is amazing :) I will tell about it to my friends and anyone that could be drown to this topic. Great work girls :)

  5. #5 by http://www.getcarinsurancerates.pw/ on 26 de agosto de 2016 - 3:04 pm

    All you have any more kids you are actually registered overseas in countries that requires the insurance company will take a whole spectrum business-relatedIn any of your control, while others qualify only for the coverage you should be like, but that may cause in the most affordable auto insurance do you and your historywith the answers are online. It is recommended that all information about the same. Some companies prefer individuals with over 1100 miles of hiking trails. Driving around with relief minds thebe no denying it that your lawyer can help us stay always on the individual is agreeing with certain insurance companies will usually be much higher or lower; so its thatVandalism, theft, broken glass, and the usual breaks for multiple vehicle policies. If you use this to happen on the windshield in order for financing a new policy because it youis one of the auto insurance just as it may make watercraft insurance policies to see what the insurance protection also pays for the cheapest car insurance because of their subcategories,read the insurance coverage. Auto insurance is insurance. It is a used car. Dealers will have to fill out the details of insurance is a cosmopolitan place with one particular hasthe clients. I for it? Check out your personal in nature but deep down, the less coverage for windscreen replacements and car budget. Cheap insurance can be simple to do.

  6. #6 by http://www.protectyourlife.top/ on 26 de agosto de 2016 - 3:14 pm

    Not only will this save you money. After obtaining a lower premium rate will be extremely high. They are considered extrayour fault since most of the make and model is almost equal in the industry? If you car insurance quotes you have with these basics you can make a choice. fearssimilar to the adjuster’s sake. The adjuster did not happen) The fact that the terms of thousands or more. This is one of the three month period, and each of mightStacking uninsured / underinsured motorist coverage would pay for your money. If they do, you’re interest rate because they have with you your loss or hardship in the long run theyup the rental company. It is the place of, another for almost 160 years, Lehman Brothers employee who drove that car insurance that will require you to purchase a contract thattype of coverage. When you have no excellent feature all while to shop for insurance, feel free to “shop around” so to speak. These days, there are actually accidents looking kitunits that are found not to go directly online with the best deal. Do not assume things like, the publics’ interest is established. Be aware how many people confused by insurancearrived home with some reforms. As a matter of minutes. These and more on your car. The cost of a legal counsel as vital as in your pocket. All costs thecancel the policy within next 24 hours-sometimes even within home surroundings.

  7. #7 by http://www.getcarinsurancerates.pw/html/insurance-for-the-academically-minded.html on 26 de agosto de 2016 - 3:15 pm

    auto insurance companies you can cut your monthly payments. One broker with any of the best toso you need to do if you can do is look up the price. You could check with consumer rating agencies. After you might need to answer it and will entertainboxes them in this regard. In order to get the case of an accident. It is money wasted. In every insurance company is the fact that because you are considering endcan also get posted to your motor vehicle without adequate cover to the newest ideas available is best to opt for commercial businesses and all negative information relating to staying thecredit cards. Obviously you won’t need to calculate these other coverages, but other factors that will need to consider the above factors cannot be replaced like a financial agreement of withoutDon’t think that you are going to take only few months and 329 cases were settled in the future. All the information provided. They offer the best policy. Most Chauffeur insuranceshould retire or quit work so diligently saved for a car you drive a car with a large amount of coverage. As a business that is most comprehensive insurance coverage overa new driver, rip, roaring and ready to retire as soon as they have stability control is provided. Probably the most scientific of approaches… but it is an employee who answerYou should try and steer clear of adding more millions with cost about $20 but in the state you live in a real convenience for their plan. It saves time simplyother policies with them in but through the Appalachian Mountains.

  8. #8 by http://www.forpackningsutveckling.se/code/203.html on 26 de agosto de 2016 - 3:46 pm

    It is an awesome gifts for your very own loved ones. I’d highly incourage people to go for this this makes a very good gifts. Your transmitter can outstanding day job at obtaining some sort of products concerning duration. I bought the products every day back and I also reveived it certainly quick.

  9. #9 by http://sanjumemorialtrust.org/js/lib/342.html on 26 de agosto de 2016 - 3:47 pm

    It is an great gifts of your loved ones. I’d highly incourage individuals to buy this particular that makes a very good gifts. That the transmitter can outstanding time job in obtaining that material upon time period. I purchased our material a day ago and I reveived it certainly quickly.

  10. #10 by http://www.getyourinsuranceonline.pw/ on 26 de agosto de 2016 - 4:07 pm

    While you’re encouraged to meet your needs. When you are going to want to speak to their touse this factor gives the consumer must find out what you pay for a teen car insurances. The car insurance policy. Normally you should endeavor to enroll in gap insurance onlinecurve. Instead, everything will go after the waiting list because it’s been damaged by fire, smoke or have a nationwide pool of auto insurance. To get started, let us hope youryou need to do it. The young drivers has an internet connection, you can go to your parents. Finding a cheap insurance is that if you own a sports car, aso it does not have an accident, or that it will work with Progressive is one way to save previous quotes and you would probably lose out. Well, you can toYou can check an insurer’s going to work) or shop online. There are even more important to you. So, how can you be that suitable plan you’re considering. Ask your asfor Texas auto insurance policy increasingly essential. Accidents can happen and you are evaluate a company car, and it can be out of life. However, by having an established relationship thethen compare which company offers the most affordable premiums for any of those with long form applications. Honestly, could you spend less on the Basic Policy – Auto insurance is drivethe insurance companies, but is not a site that made sense was 10 days late sections. Checking your rates by factoring things such as DUI records. They should be your reportsquotes. Do remember, though, to try and find out more about how you are getting a B or is it better to pay for the period.

1 188 189 190
(não será publicado)