Jump to content

  • Log In with Google      Sign In   
  • Create Account

Hodgman

Member Since 14 Feb 2007
Online Last Active Today, 09:23 PM
*****

#4815585 What's the point of having a single render device?

Posted by Hodgman on 25 May 2011 - 07:15 AM

To support multiple platforms, but still allow high-level rendering code to be ignorant of the actual platform, I always wrap the low-level device (e.g. D3D) in some kind of low-level rendering layer. My current low-level layer provides these classes:

StateGroups => set of RenderStates.
States => sub-classed into RenderStates (blend mode, shader constants, shader programs, stream sources, etc) and DrawCalls.
CommandList => sequence of States.
RenderInstance => a DrawCall paired with a stack of StateGroups, and a sort-key.
RenderGroup => a set of RenderInstances.

High-level rendering modules are then built on top of these classes (e.g. GuiRenderer, LevelRenderer, etc).
High-level 'Drawables' can exist in many different formats, as long as they can be converted into a RenderInstance (i.e. are composed of DrawCalls and StateGroups).
These high-level modules then collect a list of 'Drawables' (each of which has a DrawCall and stack of StateGroups), and gives them to a function along with a default/global StateGroup (the default/global group is for states like the viewport/render-target that apply to every drawable in the list), which produces a RenderGroup. This RenderGroup can then be handed to the low-level renderer.

The low-level module can sort the submitted RenderGroups and then convert them into CommandLists, which are then executed by the device.

N.B. there's no global states in this design. One thing can't "set a ortho matrix" by itself -- that "set" command has to be part of a state-group, which is attached to a 'Drawable' somehow.


#4815491 [C++, DX11] Creating Index Buffer problem

Posted by Hodgman on 25 May 2011 - 02:29 AM

I didn't actually spot that bug from your code straight up -- the other details that you posted helped. When I saw this, I knew that something was suss with the index data and looked closely at that logic:
...pIndexData == 0x02f4f884 .. supposed to be a ~190KB allocation starting at this address
reading location 0x02f56000 .. but not allowed to access a value that's 25KB into the allocation??

So those hexidecimal numbers can be useful when sometimes ;)


#4815484 [C++, DX11] Creating Index Buffer problem

Posted by Hodgman on 25 May 2011 - 02:04 AM

See the problem:
uint16 *pIndexData = new uint16[...];

        pIndexData++;

        pIndexData++;

        pIndexData++;

        pIndexData++;

        pIndexData++;

        InitData.pSysMem = pIndexData;
You're passing a pointer to the end of your data block instead of the beginning.


#4815466 proof of evolution?

Posted by Hodgman on 25 May 2011 - 12:32 AM

There certainly are people who would deny that evolution exists (http://www.disinfo.c...n-doesnt-exist/).

That guy is confused between abiogenesis and evolution -- a common mistake made by people who think that they don't believe in evolution, when really they don't believe in non-theological creation of life, which is something completely different!

But evolution is still not a 100% accepted fact, and realistically speaking, it probably never will be.

It's accepted as fact by people who rely on it for new research, which is really all that matters.
If 50% of Joe Rapture Public chooses to ignore science, that's not my problem (until there's a mass riot stemming from brawndo related incidents).


#4815442 What is Expected from a Portfolio

Posted by Hodgman on 24 May 2011 - 10:38 PM

If you want to be a physics programmer, your portfolio should show some cool physics. Like your own rigid body system dealing with hundreds of stacked boxes, or a car with pacejka friction, etc..
It doesn't matter how it looks as long as you can easily explain the cool physics that's going on.

If you want to be an AI programmer, your portfolio should show some cool AI. Like two teams of cooperating agents using a pathfinder and a planner to work against each other towards some goal.
It doesn't matter how it looks as long as you can easily explain the cool AI that's going on.

If you want to get in to a AAA company like EA, then your portfolio better show something that's as advanced as current tech is. Don't just show a 'stacked boxes' demo built on top of PhysX, or some agents navigating via your own A* implementation -- find something that makes you seem passionate about becoming an expert in your field.


#4815438 Anyone know of any Keylogger for mac thats free?

Posted by Hodgman on 24 May 2011 - 10:18 PM

I don't think a keylogger is what you're looking for -- all it does is log key-strokes.

You're probably looking for something like this: http://www.orbicule.com/undercover/

And yes, this type of monitoring software is common and legitimate, so don't down-rate the guy just because he used the K word.


#4815427 proof of evolution?

Posted by Hodgman on 24 May 2011 - 09:45 PM

Evolution's been proved, you don't need to prove it.

Note that proving a theory doesn't mean it's actually what happened though. It just means that this explanation for what happened perfectly fits all observations without contradicting itself, which we can then use to assume that this explanation is fact.


#4815382 Post Processing Coordinate System

Posted by Hodgman on 24 May 2011 - 06:55 PM

The above sprite methods are over-kill for a simple full-screen quad, and also aren't taking the half-pixel offset into account (meaning you end up with slightly blurred results).

I'm using D3D9. I wrote a quick shader that does no transform in the vertex shader, so I set my quad to (-1,1) coordinates. I read that I should nudge the quad by (-0.5) but it doesn't make sense with the coordinate system I'm using, so should I be using screen coordinates instead, or maybe some other way ?

You need to nudge by half a pixel, so you need to find out how big a pixel is in your coordinate system.
If the screen ranges from -1 to 1 horizontally, then it's 2 units wide. If your post-processing texture is 1280 pixels wide, then 1 pixel == 0.0015625 units (2/1280).

So instead of drawing from -1 to 1, you want to draw from -1.00078125 to + 0.99921875 (i.e. -1-(2/1280)*0.5 to 1-(2/1280)*0.5).
Then do the same calculations vertically.

Obviously change these depending on the resolution of the textures that you're blitting.


#4814570 Hints for my new engine (v3)

Posted by Hodgman on 23 May 2011 - 07:12 AM

The one thing that you don't mention is how content is created, and how this content is delivered to the engine's runtime. There's no planned workflow or asset pipeline. These parts of the engine are just as important as the runtime itself.

Do you have an existing tool-chain that you'll be reusing?


#4814445 memory leak?

Posted by Hodgman on 22 May 2011 - 10:12 PM

hmmmm. unfortunately, a virtual function is likely not the problem, and having a virtual destructor in the base class doesn't imply anything about freeing any memory. Typically, a base class should free up any memory that it allocated.

With his code, if stage does not have a virtual destructor, then Intro's destructor will never be run at all
Stage* stage = new Intro(/*parameters*/);
delete stage;
When this code runs, new will allocate sizeof(Intro) bytes and then call Stage::Stage() and Intro::Intro(), but then when delete is called it will only call Stage::~Stage() but NOT Intro::~Intro(). Furthermore, it will pass an invalid size (i.e. sizeof(stage) instead of sizeof(Intro)) to the deallocation function.


#4814230 Bugs you expected to throw a compiler error ...

Posted by Hodgman on 22 May 2011 - 08:21 AM

There is nothing wrong in that code.

The author knows it's valid. It's not wrong, except for the part where it didn't do what the author intended, meaning it caused a bug (and in a memory allocator a bug is quite a wrong thing).

So, this thread is for any other things in C, C++ or any other languages that you think other people would find strange, amusing or unbelievable.

Did you all miss this part? ^^^
Too busy bikeshedding in Parkinson's committee? I heard you like bike sheds (any colour will do)...


#4814202 Calculating x,y,z of each frame in an MD2

Posted by Hodgman on 22 May 2011 - 05:29 AM

After loading the file, you can make an array of bounding-box structures of size num_frames. For each frame, get the vertex positions. For each position, find the min+max of the x/y/z components. Use these min/max values to make an AABB and put it in the array.

Then later when you want to get an AABB for the model, you just have to use the frame-number as an index into this array.

Ideally your build-tools / exporters would do this and save the array into the file-format so you don't have to calculate it on load, but if you're using an existing format like MD2 (which is very outdated BTW) I guess you don't have that option.


#4814180 Bugs you expected to throw a compiler error ...

Posted by Hodgman on 22 May 2011 - 04:16 AM

I think you two missed the point of the thread...


#4814179 Relations of classes in C++

Posted by Hodgman on 22 May 2011 - 04:15 AM

Put #include "a.h" and #include "b.h" into the CPP file.


#4814142 So much for the end of days...

Posted by Hodgman on 22 May 2011 - 12:28 AM

Harold camping seems to have got it wrong.... again....

Does anyone care about the stupidity of one famously stupid man? Why is his prediction even news?

Those mayans though...

You mean the ones that have to go out and buy a new calendar next year, like we do every year? ;)

How can such a developed nation have these backward people?

Every nation has backwards people...

Why is the rest of the world obsessed with labeling things American. America is one of the most diverse nations and still people label us in a negative light. It must because most of whats on tv is American but I dont know how many times ive seen the phrase "stupid American"

Are you saying that America is culturally diverse as someone who's only lived in America, or as someone who has lived in many different countries?

Someone from outside won't see all the sub-cultural differences that a local sees, but at the same time, a local won't see any cultural aspects that permeate throughout all sub-cultures, while an outsider will. This cultural aggregation of America (the values that are common to the majority) is IME very different from that of European or Asian nations, so it's just as valid to label those differences as "American" as it is to label dancing around a midsummer phallus while eating preserved herring as "Swedish".

America exports a ton of culture to other countries, yes, so most people are familiar with this exported view of American values (conversely, most Americans do not watch a lot of foreign TV/films). When you come from a non-American culture, a lot of these values do seem very shocking, and for want of a better word, stupid.

Also speaking of the phrase "the rest of the world", the stereotypical American is very fond of that dichotomy -- the view that there's the USA, and then there's the rest of the world. This view is so strong sometimes that it's got it's own respected academic name.
When you combine America's stereotypically bad education system and high levels of crime/poverty with the exported view of a culture that places high value on personal greed, along with this stereotypical ignorance towards all things foreign, you end up with a stereotype of extreme stupidity, ignorance and narcissism.
Plus everyone seems to have an anecdote about fat, rude and loud American tourists, which just reinforces the stereotype in their minds.
This doesn't mean the stereotype is true, but there's a damn lot that's gone into creating and perpetuating it. The "stupid American" stereotype is not without cause or reason.




PARTNERS