Jump to content

  • Log In with Google      Sign In   
  • Create Account

precious roy

Member Since 30 Oct 2007
Offline Last Active Yesterday, 02:12 PM

Topics I've Started

Visual studio 2013 HLSL compiler Question

15 December 2014 - 10:34 AM



I am struggling to set the shader version, i have a pixel shader and a vertex shader in the properties of that file i tell it to use 5_0, but when i compile and run the program the visual studio graphics analyzer tells me i am using 4_0_level_9_1. this is a problem because i want to access my position data in my pixel shader but it tells me i can when i am using 4_0_level_9_1.

i get the error: error X4502: Shader model ps_4_0_level_9_1 doesn't allow reading from position semantics.



i think i am missing a setting but i have no idea what it is.

(Fixed)(Beginner) How to use D3DXCreateTextureFromFile to load a texture

08 February 2013 - 07:53 AM



i  have been looking for an answer to this question for the past 2 days and have only been able to find one that sometimes works. i will start by showing my code. the code in this case loads a model and continues to load the materials and textures.


void LoadModel(LPWSTR FileName, LPWSTR FileLocation)
    LPD3DXBUFFER bufShipMaterial;

    D3DXLoadMeshFromX((std::wstring(FileLocation) + FileName).c_str(),    // load this file
                      D3DXMESH_SYSTEMMEM,    // load the mesh into system memory
                      d3ddev,    // the Direct3D Device
                      NULL,    // we aren't using adjacency
                      &bufShipMaterial,    // put the materials here
                      NULL,    // we aren't using effect instances
                      &numMaterials,    // the number of materials in this model
                      &ModelMesh);    // put the mesh here

    // retrieve the pointer to the buffer containing the material information
    D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufShipMaterial->GetBufferPointer();

    // create a new material buffer for each material in the mesh
    material = new D3DMATERIAL9[numMaterials];
	texture = new LPDIRECT3DTEXTURE9[numMaterials];

    for(DWORD i = 0; i < numMaterials; i++)    // for each material...
        material[i] = tempMaterials[i].MatD3D;    // get the material info
        material[i].Ambient = material[i].Diffuse;    // make ambient the same as diffuse

	//if there is a texture to load, load it
		texture[i] = NULL;    // if there is no texture, set the texture to NULL

The code above works fine to a point. when the texture is not in the same folder as the executable it will not lode it. you can see that when i load the texture i add the FileLocation to the Filename and this works like a charm. but now i want to do the same when loading my textures and this is where the problem start. i wiped up this, it probably well i know its not the best way of doing this because this gives me an error 2 out of the 3 times running the program


		if(tempMaterials[i].pTextureFilename != NULL)
			//converting the lpstw from pTextureFilename to lpwstr
			char* convertMe = new char[sizeof(tempMaterials[i].pTextureFilename)];
			int buffSize = (int)strlen(convertMe) + 1;
			LPWSTR TestureName = new wchar_t[buffSize];
			MultiByteToWideChar(CP_ACP, 0, convertMe, buffSize, TestureName, buffSize);
			std::wstring test = (std::wstring(FileLocation) + TestureName);

			//if there is a texture to load, load it
			if(FAILED(D3DXCreateTextureFromFile(d3ddev, test.c_str(), &texture[i])))
				texture[i] = NULL;    // if there is no texture, set the texture to NULL
			texture[i] = NULL;



the error that it gives is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.". anyways what i'm doing here is converting a LPSTR string to LPWSTR and then combine them, just like i did withe the model file.


now i know that the problem is somewhere in the converting of the string, i guess my question is how am i supposed to do this ?

Basic networking question.

05 May 2010 - 08:57 AM

hey every one. I am very new to networking in games.. and I need a couple of pointers. i'm working on a simple rpg style Network game(mmo) just for fun and to learn how things work. I want the server to be able to presses up to 900 clients with ease. but I don't really know the right way to handle client. what would be better. control a character and send cords to server or send possible next position to server and see if you can move or not ?

C++ text to int question

20 May 2009 - 07:37 AM

Hi every one, I’ve just started programming in c++ and was wondering how would you convert a in to string an back ? I’m programming without the standard libraries. any ideas. Roy

Ultimate Game Programming with DirectX

09 March 2009 - 03:57 AM

Hi This is probably the wrong section but I didn’t know where to put it... so does any one have this book (Ultimate Game Programming with DirectX ). And is it a good book??? p-roy