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

Wrapping A Render Call?

Started by dave Mar 12, 2005 at 2:57 PM 4 replies 1k views
Original Post
dave
dave
Im doing some experimentation with wrapping render calls. What i mean by this is say for example you want to do a simple DIP call where u just rendering the whole lot. The code for this is often monotonous to write albeit there isn't very much to write. But neverless i figure it may be useful to wrap. So im coming up with a prototype class definition of how this class may look. The template T is for the vertex struct. def

#ifndef STANDARD_DIP_RENDER
#define STANDARD_DIP_RENDER

#include <d3dx9.h>

template<class T>
class StandardDIPRender
{
public:
	StandardDIPRender(	LPDIRECT3DDEVICE9			device, 
						LPDIRECT3DINDEXBUFFER9		indexBuffer,
						LPDIRECT3DVERTEXBUFFER9		vertexBuffer,
						DWORD						fvf,
						D3DPRIMITIVETYPE			primitiveType
						unsigned int				primitiveCount);

	~StandardDIPRender();

	void Call();			// will contain the implementation of the render

private:
	LPDIRECT3DDEVICE9			device;
	LPDIRECT3DINDEXBUFFER9		ib;
	LPDIRECT3DVERTEXBUFFER9		vb;
	DWORD						fvf;
	D3DPRIMITIVETYPE			primitive_type;
};

#endif


Now im wondering if this is overkill. For a simple i-wanna-write-a-quick-app-to-test-something scenario this would be useful rite? ace
Raloth
Raloth
The question you have to ask yourself is this: what do I get out of it?

I don't see how using this is any less work than simply calling DrawIndexedPrimitives. If it is for a test app like you suggest you probably won't be worrying about code structure in the first place. If it's something more complex a wrapper like this is hard to make practical.

What I did is make a Batch structure that holds all the parameters to pass to DrawIndexedPrimitive. I find that to be a little more useful, since I can just calll DIP with each of the parameters from the batch. DIP never has to actually care what it is rendering.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
dave
dave
Yeah, see i was wondering whether this would be overkill.

Any other opinions?

ace
Galapaegos
Galapaegos
ace,

Sounds like you're writing a scene-graph renderer. Another option to the template of the vertex type, think about this: you have a class with a structure to all the points, all the colors, all the normals, all the tu's, all the lights, and anything else you want to render at one time. Then you simply define all these in the class and pass these to your api to render (ie make a 'render (scene)' call).

Now to answer your question: would something like this (either your method or the one I proposed) save you anything? The one I proposed definitely will, and you're will to (if done properly). If you wanted to go dx all the way, here's what you might consider: apply a scene-graph type structure to what you already have. How would this work? I don't think you would need the template, but you would need some method for passing the rendering information (the polys, colors, etc) which is where the scene-graph would come into play. You don't need the fvf, this can be calculated when you render your scene (ie i've got polys, add that section, then or this with colors if they exist, etc). Also, the primitivecount and primitivetype can both be within the scene. All you would need to do is implement your render function, and determine how you feel like passing the scene around (ie part of the class, or just pass the scene-graph as a parameter).

-brad
-brad
dave
dave
Ok, thats interesting.

See when i view a scenegraph i seeeit differently to the way you do (and probably most others). The way i see it is u register batches to the SG and it sorts out things for efficiency etc. Also register textures to it then u can request what is to be drawn.

So i figured the code i supplied above might replcae those 4 lines. I suppose there is no particular need for a class with my method. Could just be a function call.

ace
JohnBolton
JohnBolton
It definitely is not overkill -- in fact, it doesn't do enough. To be useful, the class should have all the information needed to render the VB, so that all the appropriate setup is done inside.

However, what you have created is just a simplified version of D3DXMesh. Perhaps you might use D3DXMesh, instead of writing your own.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

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

Sign in to reply to this topic.