Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 06 Feb 2011
Offline Last Active Mar 14 2015 06:15 PM

#5212504 what would make vc text unreadable.?

Posted by SyncViews on 23 February 2015 - 01:17 PM

Yes, MS seems to have made a mistake, you can get the update from the MS site, I guess windows update should have it as well, but seems odd it would come up now unless you manually played with them.





Fix for text quality degradation after security update 3013455 (MS15-010) is installed

After you install security update 3013455 (described in MSRC bulletin MS15-010), you may notice some text quality degradation in certain scenarios. This problem occurs on computers that are running the following operating systems:
Windows Server 2008 Service Pack 2 (SP2)
Windows Server 2003 SP2
Windows Vista SP2
Release Date: February 18, 2013
EDIT: Actually seems MS made a second mistake and put the wrong year on that lol, 

#5208110 When to use pointers or objects in 'Composition'?

Posted by SyncViews on 01 February 2015 - 06:09 PM

In all my stuff, my main Win32 window class and my main graphics object are actually completely unrelated. I just give the graphics constructor the HWND it needs.

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    Window window(...);
    Graphics graphics(window.getHandle(), ...);
    while (window.processMessages())

I then have higher level logic that contains both these components to deal with both together (e.g. the game loop, managing window/fullscreen/borderless transitions, resizing, etc.).

#5187377 Converting project code from VS13 to Code::Blocks, massive amount of errors

Posted by SyncViews on 16 October 2014 - 06:39 AM

Thats not really a "genuine bug". If you turn off the MSVC extensions switch you get the correct error for the reference thing, or you can enable the relevant warning, or you can make that warning an error. There just accommodating old code by default there, because it is already hard enough to get enterprises to upgrade (and even on Linux, I had to write code for GCC 4.1 not long ago, making changes that effect old programs or code just really does not go down well).



The warning, off by default (I suppose you could argue that maybe, but some enterprises like there "treat warnings as errors" then complain about every little thing when an update breaks the build...):

warning C4239: nonstandard extension used : 'argument' : conversion from 'Vector2f' to 'Vector2f &'

If you turn extensions off entirely

error C2664: 'void func(Vector2f &)' : cannot convert argument 1 from 'Vector2f' to 'Vector2f &'


GCC has some non-standard features as well. e.g. for c++ see https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/C_002b_002b-Extensions.html. And I recall GCC has some compliance issues as well, like two-phase-lookup not being completely perfect? Likewise Linux/GCC programmers seem to be forever depending on things from POSIX that are not actually C/C++ so porting them off of GCC/Linux is far harder than it should be, even when not dealing with GUI's, etc, so just because its a GCC compatible lib that process some data (no network,gui,drivers,etc.), in my experience can still mean that "porting is incredibly difficult"....

#5185991 using xml for crafting recipes

Posted by SyncViews on 09 October 2014 - 08:15 AM

I use a datafile to define my recipes, its a fairly simple thing to have as long item types can be reference by some kind of id.


For example for me the "Item" class only defines the item type (e.g. I only have 1 Item instance for my iron bar item, and every iron bar in the world references that single instance). There are other, possibly cleaner ways, the main point in this situation is it gave me an easy "const Item *getItemByName(const std::string &name)" for console commands and data file loading.

class ItemStack
    const Item *item;
    unsigned quantity;
    /**Exact meaning, default value, etc. is defined by virtual methods on Item.
     * e.g. for a tool this might be durability (and I also prevent non-new tools
     * from being stacked).
    unsigned metadata;
class Recipe
    std::vector<ItemStack> inputs;
    ItemStack output;
List<Recipe> recipes;

        <input item="log" quantity="1" />
        <output item="plank" quantity="1" />
        <input item="iron" quantity="1" />
        <input item="plank" quantity="1" />
        <output item="pickaxe-iron" quantity="1" />
        <input item="lead" quantity="1" />
        <input item="gunpowder" quantity="1" />
        <output item="bullet" quantity="100" />

#5182076 Direct3D don't draw my vertices

Posted by SyncViews on 22 September 2014 - 06:37 AM

Use the debugger to check the contents of the array your passing to D3D (e.g. put a breakpoint just after you assign stuff so you can look at the contents). I don't know what IDE your using, but you should be able to find an introductory tutorial for it.


Also that "SimpleVertex(XMFLOAT3)" as shown is wrong, your not actually assigning the value.

#5181965 simple crafting system

Posted by SyncViews on 21 September 2014 - 04:42 PM

"class RecipeItem"

My main thought on this is there is nothing here specific to a recipe. Why not just have it as a generic Item & Amount class?


"public bool CanCraft;"

What is this?


"public bool CheckForItemsNeeded(Player player)"

Appears to be wrong. Should it not return true if the player has all the items, and false otherwise?

Currently it returns false always, and sets CanCraft to true if the player has any required item (rather than all), and regardless of quantity.


"slot.item == item.Item"

Not sure what language you are using, but since your using types/objects, it is likely that == here is not going to do what you want, since I suspect it is comparing specific instances of an item, not the type of item. e.g. in Java you should use "item.Item.equals(slot.item)"  (and override Item.equals appropriately), or if you only care about the types (not the data in the instances), use "item.Item.getClass() == slot.item.getClass()".


"public class HammerRecipe : ItemRecipe"

Personally id prefer to avoid the subclass...



Makes even less sense. You start off well by iterating over the crafting list, by why iterate the inventory? CheckForItemsNeeded should already be taking care of that, your just calling it multiple times for no reason.


"if (recipe.CanCraft == true)"

Like I said, why does CanCraft exist? Use the return value of CheckForItemsNeeded.

#5181766 simple crafting system

Posted by SyncViews on 20 September 2014 - 02:18 PM

Personally Ive always created a recipe object that at its core has the inputs and outputs. I can then just have a list of recipes (initially at least). This basically goes through every recipe and the players entire inventory for each, so don't plan to use it every frame or such (i.e. I don't have this bool thing of yours, since there is generally no need).

class ItemStack
    Item item;//reference to an item type, e.g. sand, glass, etc.
    int quantity;//the number of units in this stack

class Recipe
    List<ItemStack> inputs;//This can assume that each ItemStack has a unique item
    ItemStack output;//could be extended to List<ItemStack> outputs, but makes things a bit more complex and is a rarer feature/requriement

    //Goes through inputs and sees if inventory contains everything
    //you may also want to check there is space for the output
    //this is used to show in the UI what items the player is currently able to craft
    bool canCraft(Inventory inventory);

    //Craft the item, checks canCraft again to sure, removes all the inputs from inventory, and puts the output in the inventory
    void craft(Inventory inventory);
List<Recipe> recipes;//all the recipes...

The other nice thing about this is that it becomes really easy to add and modify recipes (no new code), and its even easy to load them from a file

#5180995 Simple 2D lighting effects

Posted by SyncViews on 17 September 2014 - 07:22 AM

Glass_Knife: thank you for the link, I will check it out. The lights will not necessarily stay in the same spot (the player might be able to place torches on the ground, or start a fire, I am not entirely sure but I dont want to limit myself). I also am looking to do much simpler lighting, mostly just rendering certain pixels with less color if it is supposed to be darker. 


SyncViews: Awesome, this is something I can look into, thanks. From my original research, I remember reading that there is no multiplication blend (step 7), so this sounds like something I'll use the shader for. However, this is basically back to my original problem of not knowing what I need to search. I tried searching for passing textures/buffers to pixel shaders but I am getting a variety of responses, none of which have proven helpful to me. Is there a particular term that this process is called that I can look into?

What do you mean by passing textures/buffers to the pixel shader? I'm sure your already doing that with your normal rendering, and if I recall correctly even pretty old hardware can support somthing like 8 input textures. For D3D9 I believe you can just declare 2 (or more) samplers in your HLSL pixels hader file, and all the relevant functions take the sampler index like IDirect3DDevice9::SetTexture(DWORD sampler, IDirect3DBaseTexture9*).


Then working on my previous suggestion, I think you can do it pretty much like a simple non-cached lightmap:

  1. Set an RGB texture the same size as your screen as the render target
  2. Clear the texture/render target to 0/black
  3. Set the blending mode to additive (dest = dest + source, rather than say your "dest = dest * (1-alpha) + source* alpha" for alpha blending)
  4. Render your light gradients (they can be coloured, because "a + b == b + a" order does not matter, overlapping areas just get brighter till you saturate the channel at full brightness)
  5. Put your backbuffer back as the render target
  6. Set that RGB lighting texture as the second texture
  7. Render your scene as without lighting, but in the pixel shader, sample that second texture using the screen space coordinate, then multiply it by your unlit colour to get the lit colour
    //HLSL pixel shader like pseudo code as not on development system
    sampler texture;//The texture for the sprite your rendering
    sampler lighting;//The lighting texture from 2-4
    struct Input
        float2 texcoord : TEXCOORD;
        //anything else you have
        float2 screenPos : VPOS;//provided by D3D9, is the location on the screen/render target. I am assuming its in 0-1 space, correctly orientated etc. You will need to check this.
    float4 main(Input input) : COLOR
        //do what you normally would
        float4 col = texture.sample(input.texcoord);
        float4 light = texture.sample(screenPos);
        return col * light;

#5180723 Simple 2D lighting effects

Posted by SyncViews on 16 September 2014 - 09:35 AM

Thank you for the reply, I wasnt clear, but I also meant that these light sources would be in the environment - think a light post or something.  I was thinking about doing it the way you described, and determine where in the screen each light is, render the mask as you described, then figure out which areas are not touched by the light, and render a simple mask over it. I suppose that idea doesnt actually sound so bad.


edit: Ah, I know why it would be tough - when multiple lights are on the screen at once, if they overlap, it will be rendered weirdly.

I have never done lighting based on sprites, but I suspect the correct approach is

  1. Render your scene/screen as if you are not doing lighting
  2. Set an RGB texture the same size as your screen as the render target
  3. Clear the texture/render target to 0/black
  4. Set the blending mode to additive (dest = dest + source, rather than say your "dest = dest * (1-alpha) + source* alpha" for alpha blending)
  5. Render your light gradients (they can be coloured, because "a + b == b + a" order does not matter, overlapping areas just get brighter till you saturate the channel at full brightness)
  6. Put your backbuffer back as the render target
  7. Multiply your backbuffer/scene with the lighting texture (dest = dest * source) which makes unlit areas black (dest = dest * 0) and leaves fully lit areas alone (dest = dest * 1) and everything inbetween, for red, green and blue independently.

#5177524 Compiling and using shaders

Posted by SyncViews on 01 September 2014 - 04:30 PM

I am not sure what you mean? If just talking about the compiling and loading of a shader.


Pre-compiled shaders:

  1. Creating shaders in VS2013 by adding a new item, Visual C++ -> HLSL then picking the type of shader I want.
  2. These will compile to .cso files
  3. Loading the .cso file into memory
  4. Using ID3D11Device::CreateVertexShader etc. to turn that loaded cso file into one of the shader objects such as ID3D11VertexShader.

Runtime-compiled shaders:

  1. Get/load your shader code
  2. Use D3DCompile or D3DCompile2 to compile the shader to byte code (the same as the .cso file)
  3. Use ID3D11Device::CreateVertexShader etc. to create your shader object.


By global variables I guess you means constants (ID3D11Context::VSSetConstantBuffers etc.)?  In which case the constants for each type of shader exist separately from whatever the current shader is. If you change shaders and have different constants, you need to set them again.


If you are using the effects system, use D3DX11CreateEffectFromMemory instead of the CreateVertexShader etc. I understand that ID3D11XEffectPass will call all the individual ID3D11Context:: set methods automatically, including putting the effects variables back as the GPU's active constants/variables/globals.

#5177296 Anyone Actually Releasing Games Using Assets From Marketplace Models?

Posted by SyncViews on 31 August 2014 - 05:10 PM

Lots of games now have character editors that do a pretty good job (The Sims, Saints Row The Third, Eve Online, Dragon Age, to name a few Ive very recently used), so I guess there's at least the information needed to implement, if not tools & libraries to do it. Then all you need from any kind of asset store is a good selection of content to choose from in the way of hair models, cloths and accessories. I wouldn't take any character models entirely, and certainly never for any character that isn't just there in the background to populate an area.


As far as generic content goes. a lot of basic textures and props, vehicles, and possibly buildings (although Id make my own key buildings & vehicles given the textures&props) I think is fine if they fit your art style.

#5177104 unity monthly subscription question?

Posted by SyncViews on 30 August 2014 - 01:43 PM

I have really not looked at Unity much, but the questions that come to my mind are:


  1. Can the free version be used for commercial purposes?
  2. If not 1., can existing unreleased closed source code be legally transferred to the commercial pro-version later?
  3. Is there a free version for Android and iOS?
  4. How much effort is needed to port between platforms? I know the "native" platform languages and API's are different, but I understand Unity abstracts all of that nearly entirely.
  5. Assuming 4. is somewhat less than "you really need to be working on all platforms from the very begining", why can you not just develop on Windows on the Free or Pro version until pretty late in development (you have a mobile like OS in Windows 8 if you need that), then get the extra mobile licenses later?
  6. can you not pick either iOS or Android, and only if you have a successful project consider porting to the other?
  7. If either 1. or 2., is there actually any feature in the Pro version you really need thats worth that investment?
  8. If 7. and 3., why would you ever need to get the pro version?


It certainly seems to me like you should be able to proceed by paying nothing now, later maybe getting just the core pro version, sometime later getting one mobile addon, and only getting the second mobile addon after you start having some income.

#5177101 3D Coordinate Systems confusion

Posted by SyncViews on 30 August 2014 - 01:31 PM

I have already read those articles, they don't cover my issue in any way that I see....


  • Yes D3D11 as I am using it is left-handed with row-major matrices. D3D supports right-handed as well, but some parts of DirectX math I used don't, and now a fair amount of other code is based around left-handed as well, and I also understand generally the GPU itself for D3D11 uses column-major, but it seems again DirectX Math does not, requiring that XMMatrixTranspose in my code.
  • The main difference I am aware of from those articles is that the z axis is reversed. I also know that OpenGL is column major.
  • As far as Bullet goes, I understand internally it should not matter. As long as all object positions, meshes, velocities, etc. are consistant. It even has options for putting say gravity on the Z axis if the XY plane is horizontal.
  • I think the fact the OpenGL matrix it creates is right handed AND column-major has something to do with why I could use it "directly" like I showed.
  • The only semi-relevant thing I saw to rotation was "To rotate a figure counterclockwise around the origin by some angle 50d91f80cbb8feda1d10e167107ad1ff.png..." which suggests that (regardless of left or right hand?) yaw should go counterclockwise. But simply doing that does not solve all my issues, it gets rid of the -yaw being passed to Bullet sure, but then the getForwardVec maths has -yaw instead, so at least part of my maths there must be wrong still? And is thinking that it should be counterclockwise right anyway? I cant find a solid answer, at least not in a context I am positive relates to use with D3D's left-handed row-major matrices.

#5113018 Graphical user interfaces in a multithreaded environment

Posted by SyncViews on 29 November 2013 - 11:50 AM

So I have two main threads in my game. One managing the window and rendering, and another thread doing all the logic.
The logic thread is then filling out state buffers with relevant bits of the world data that the render thread can then render (interpolating between the two most recent buffers). The window thread forwards the keyboard and mouse input events to the logic thread to keep player movement and such simple.
My current idea is to follow the same system as the main game world, and keep all interactions on the logic thread, while telling the render thread what it needs to render. However a solution that lets all the ingame UI stuff not care about threads so much would be nice.

I am also thinking about breaking some of the logic stuff out more (e.g. clickedOnSlot and the functions it works with) to help with working on multiplayer, but that still seems to leave me with this problem where that stuff is on a different thread to the actual rendering, even if I moved the UI's user input events back to the render thread...

    /**@brief Abstract class for interacting with and rendering an inventory.*/
    class BaseInventoryUi
        /**Will be constructed on the logic thread when the player does
         * something that needs a UI.
            grf::HudRenderer &renderer,
            Inventory &inventory);
        virtual ~BaseInventoryUi(){}

        /**Must be called on the render thread!*/
        void init();

        void render(int stateIndex);
        /**Must be called by the logic thread since it access the inventory
         * reference.
        void logicUpdate(int stateIndex);

        /**Must be called on the logic thread!*/
        void onMouseDown(const MouseEvent &evt);
        /**Called by render thread to handle tool tips*/
        ItemStack getRenderStackAt(int x, int y, int stateIndex)const;
        Inventory &inventory;
        const unsigned size;

        virtual Vector2I getSlotPos(unsigned slot)const=0;
        virtual int getSlotAt(int x, int y)const=0;
        virtual ItemStack getHeldStack()const=0;
        virtual void setHeldStack(ItemStack itemStack)=0;
        /**In UI's screens with 2 inventories, move this stack to the other
         * inventory.
         * @return The number of units that could not be moved.
        virtual uint16_t moveToOtherInventory(unsigned from, ItemStack itemStack)=0;
        ItemSlotsRenderer itemSlotsRenderer;

        //A better way?
        struct State
            Inventory inventory;
        State states[3];

        /**Must be called on the logic thread!
         * - Shift click to move stack to other inventory
         * - Left click to place held stack, and pick up existing stack if different
         * - Right click when holding nothing to pick up half the stack
         * - Right click when holding something to place 1
         * Calls:
         * - Any methods using the this->inventory reference
         * - getHeldStack
         * - setHeldStack
         * - moveToOtherInventory
        void clickedOnSlot(
            unsigned slot,
            bool left,
            bool shift);
#include "Precompiled.hpp"
#include "BaseInventoryUi.hpp"
#include "../ItemStack.hpp"
#include "../Items.hpp"
namespace game
        grf::HudRenderer &renderer,
        Inventory &inventory)
    : inventory(inventory)
    , size((unsigned)inventory.getSize())
    , itemSlotsRenderer(renderer)


void BaseInventoryUi::init()
    std::vector<Vector2I> slots;
    for (unsigned i = 0; i < size; ++i)

void BaseInventoryUi::render(int stateIndex)
    const auto& state = states[stateIndex];
void BaseInventoryUi::logicUpdate(int stateIndex)
    states[stateIndex].inventory = inventory;

void BaseInventoryUi::onMouseDown(const MouseEvent &evt)
    int slot = getSlotAt(evt.pos.x, evt.pos.y);
    if (slot < 0) return;
    //TODO: Multiplayer?
    clickedOnSlot((unsigned)slot, evt.button == VK_LBUTTON, evt.shiftDown);

void BaseInventoryUi::clickedOnSlot(
    unsigned slot,
    bool left,
    bool shift)

#5084809 Quadratic Formula -1#ind?

Posted by SyncViews on 10 August 2013 - 05:49 PM

The more usual way would be to just take the contents of sqrt, calculate it and check it for negative.

assert(a != 0);//if may be true, do something about it
double d = b * b - 4 * a * c;
if (d < 0)
    return; //no root

double dSqrt = std::sqrt(d);

double x1 = (-b + dSqrt) / (2 * a);
double x2 = (-b - dSqrt) / (2 * a);