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 05 Jul 2013
Offline Last Active Apr 23 2015 08:59 AM

Topics I've Started

How to pass DeviceContext to other classes?

07 April 2015 - 09:58 AM

Hi there,


I've been following this tutorial on how to render a texture with DirectX tool Kit. It's all clear.

In the example everything is created and executed inside the Game.cpp. I am still new to C++ so I was wondering, how would I transfer all the logic for rendering a sprite to a separate class. So I came Up with this:

#pragma once

#include "SpriteBatch.h"

class MyTexture

	void Create();
	void OnDeviceLost();
	void Render();
	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_texture;
	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_texture;
	std::unique_ptr<DirectX::SpriteBatch> m_spriteBatch;
	DirectX::SimpleMath::Vector2 m_screenPos;
	DirectX::SimpleMath::Vector2 m_origin;
	UINT backBufferWidth;
	UINT backBufferHeight;
#include "pch.h"
#include "Grid.h"
#include "SpriteBatch.h"

using namespace DirectX;

using Microsoft::WRL::ComPtr;
using namespace DirectX::SimpleMath;

	m_screenPos.x = backBufferWidth / 2.f;
	m_screenPos.y = backBufferHeight / 2.f;


void MyTexture::Create()
	m_spriteBatch.reset(new SpriteBatch(m_d3dContext.Get()));

	ComPtr<ID3D11Resource> resource;
		CreateWICTextureFromFile(m_d3dDevice.Get(), L"cat.png", resource.GetAddressOf(),

	ComPtr<ID3D11Texture2D> cat;


	m_origin.x = float(catDesc.Width / 2);
	m_origin.y = float(catDesc.Height / 2);

void MyTexture::OnDeviceLost()

void MyTexture::Render()

	m_spriteBatch->Draw(m_texture.Get(), m_screenPos, nullptr, Colors::White, 0.f, m_origin);


But in this class I still need a reference to the m_d3dDevice and m_d3dContext. As i said I am pretty new to C++. So what would be the best way to do this? Something like passing a pointer or something? Maybe somebody can show me some example code.


Btw in Game.h the variables are declared like this:

    Microsoft::WRL::ComPtr<ID3D11Device>            m_d3dDevice;
    Microsoft::WRL::ComPtr<ID3D11DeviceContext>     m_d3dContext;

Pros and Cons Unity for Android

27 February 2015 - 12:45 AM



I would like to start Android game developement. Apparently there are several ways to do this. The Android Studio seems to run with Eclipse and seems to be pure Java. And there is also Unity, which also enables one to develop Android games. Now I am a little confused. Does Android Studio have any advantages over Unity?


Here I read the following:



Unity3D uses very unique approach for doing things, most of knowledge acquired while using it, would completely non transferable to other engines. Advanced Unity3D programming is really dealing with Unity3D bugs, and finding loopholes around engine issues, nothing to do with graphics, etc - skills which would be valuable with other engines.


This seems to be a great disadvantage to me, or is it?


Is Android Studio maybe more system affiliated with Android devices or does it have richer libraries?


If it is not, Why would anybody pick Android Studio over Unity in case of game developement? Originally I am a C# .NET developer but I am also very comfortable with Java. So what should I consider when making this decision?

How to pass content through the project's structure efficiently?

29 January 2015 - 01:39 AM

Hi there,


so following situation. I have a project which is structured something like this.


Game1 -> GameManager -> Module1-X (so multiple instances)


During runtime units are being spawned in each instance of the Module class. Those Units require spritesheets for animation. Let us say each unit has a "Move", "Attack" and "Die" state, each using a individual spritesheet. This makes three Texutre2D instances per unit and with 5 different units this adds up to 15 different Texture files. Those are being passed to the unit's constructor on creation.


As I am loading those textures in Game1's LoadContent method I have to pass them the entire way to the Module class which then uses those textures to instaciate units.


Game1.LoadContent(15x textures) -> GameManager(15x textures) -> Module(15x textures) -> Unit(3x textures)


Imo this has several disadvantages:

  1. As far as I can judge all those 15 textures are being held in memory of the Module classes the entire time. I would like to avoid that.
  2. Also passing 15 textures through the project's entire structure makes the classes unreadable and ugly.
  3. I've got the overall feeling that this is not the way things should be done here.

In order to avoid problem #2 I created a class, its only purpose is to hold all textures that are needed in Module.cs. I called the class AnimationCollection. It holds Texture2D variables and the according getters and setters. So now my Project looks like this.


Game1.LoadContent(new AnimationCollection(15x textures)) -> GameManager(AnimationCollection) -> Module(AnimationCollection) -> Unit(AnimationCollection)


While this does seem to solve problem #2 the other problems remain.


Are there other options on how to handle this problem? I could think of something like loading all content in the Module Class itself, but I never saw this before. I always load my stuff in Game1.LoadContent().


Any ideas, suggestions or expert knowledge is highly appreciated.


Thanks in advance!

What is the ideal solution for a repository in my case?

07 January 2015 - 12:54 AM

I am trying to implement something similar to Scrabble or Letter Quest. I am still using XNA with C#. The game I write has to be able to check if the user input is a valid word in the dictionary. So I wonder what would be the most efficient way to implement a repository for the dictionary. I can think of two things:


  1. I could save all the valid words in XML files
  2. I could make the user install and use a Service-based database (SQL)

I think XML files have the disadvantage of having a poor lookup performance compared to SQL, note this is just an assumption of my own I do not know this for sure. On the other hand SQL might produce a little overhead during installation of the game if the user has no SQL Server Express installed, he will be forced to download it. Well actually the download will start automatically, still it requires a internet connection.

So what would be a good solution for this? Is there maybe another way I have not thought of? I am open to any suggestion. Also if you think that I got something wrong in my thoughts above, please let me know.


Btw I also was wondering how people fill dictionaries like the one in Letter Quest. I mean, are they sitting there for months inserting every single word they know into a repository?


Thanks in advance!

Please give me some advice for future plans.

08 September 2014 - 06:27 AM

When I had my first encounter (8 years old) with a PC I was pretty damn sure that I have to study this stuff and make it my profession. Many years later I finished studying computer science. You can't even imagine how big my disappointment was when I started looking for jobs.


In germany there is almost nothing to find and if you do find something it is mainly about developing browser games. My main topics in university were .NET with C# and I had plenty of time to learn XNA. But now I had to realize that nobody is looking for C# or XNA developers in the (german) gaming industry especially not for junior applicants. So I had no choice but to apply for a boring Sharepoint job (and I got it).


Still I did not want to accept this, so this is my plan for the future. I will go on with my current job for several years. Mainly because I think that getting a job with several years of experience is always easier. Meanwhile I started learning OpenGL.


Still there are some issues I am wondering about.


  1. It seems that nowadays nobody really needs that many game programmers (developers). I mean there is Unity, CryEngine, Unreal Engine...Does that mean that the game programmer is dying out and only the very best will find jobs in Engine developement?
  2. What are the best things I can do in order to meet the requirements for a game developer job, let's say in 2 years? By game developer job I mean everything but those freemium titles that pop everywhere! I mean want to do some real graphics/game logic programming. I hope you get the idea, it still do not have to be AAA titles but titles one can put his entire love for the medium in.

I really look forward for advice especially from people who are already in the industry.


Btw: The fact that I worked with C# for the most part, does not mean that I am not capable of anything else. Java, C/C++ are also languages I am pretty comfortable with. I also have experience with tools like 3Ds Max, Maya, Blender, Photoshop....