Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 06 Oct 2006
Offline Last Active Oct 25 2016 02:53 PM

#5306111 Depth buffer not working

Posted by on 16 August 2016 - 02:27 AM

Just worked out what was going on.

I had another call to OMSetRenderTargets() in my render target manager, but the last parameter was set to zero, causing the depth buffer to no longer be associated with the target.

#5302894 D3D11_Create_Device_Debug Question

Posted by on 28 July 2016 - 04:27 AM

Found it just then. Hiding away in a tab.

So, in the end nothing needed to be touched in the control panel.

Thanks for your help guys.

(Posted the solution so I don't come back asking the same thing in two years time :))

#5301876 Matrix Calculation Efficiency

Posted by on 21 July 2016 - 11:08 PM

It's my premature optimisation that is allowing me to be able to render so much in the first place.


I was just wondering what the normal practice was.

#5300358 Getting address of an item in a std::vector

Posted by on 12 July 2016 - 05:18 AM

Hehe! Probably.

But that's why I am here, trying to learn :)

Well, the conundrum I have is that I have an vector of class instances. But inside the class I am trying to allocate a char array with 'new' and having a data 'blob' inside the class instance.

All is working ok (with the allocation done in the OP) and the data 'blob' that gets allocated is fine.

But if I then add another instance to the vector the 'blob' gets a heap corruption. I am guessing it is because of the internal shuffle that goes on in the vector and the data 'blob' pointer is pointing to the wrong place.

The data blob is a particularly important aspect for me and I need a way to be able to iterate through all of the instances and process this data, without having to manually know about each class instance.

Any advice on how I should approach this would be great :)

#5300310 Getting address of an item in a std::vector

Posted by on 12 July 2016 - 12:31 AM

Thanks man!


I understand this is a hazardous thing to do if elements are deleted, sorted, etc. So, I'll use with caution :)

#5294130 Win32 Problem with wm_command message

Posted by on 30 May 2016 - 05:01 AM

Seems I needed to DestroyWindow(hWnd) instead of PostQuitMessage(0) at that call.


All working ok now.

#5281754 Recompile VS.net C++ generated ASM file?

Posted by on 17 March 2016 - 04:03 PM

So I have now managed to successfully created an exe file reconstructed by the ASM file alone cool.png
For anyone who might be interested, this is what I had to do in the end.
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23026.0 

	TITLE	PathToProject
	include listing.inc ; Located in "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
	.model	flat

INCLUDELIB OLDNAMES ; Located in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib

; These were listed in the VS linker project properties 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\kernel32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\user32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\gdi32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\winspool.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\comdlg32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\advapi32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\shell32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\ole32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\oleaut32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\uuid.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\odbc32.lib" 
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86\odbccp32.lib"

; **** These are required but are not listed in the project properties - Why is this? How does VS know to include them? ****
INCLUDELIB "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib"
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\libucrt.lib"
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\ucrt.lib"

PUBLIC	??_C@_05DIAHPDGL@PAUSE?$AA@			; `string'
EXTRN	__imp__system:PROC
;EXTRN	@__security_check_cookie@4:PROC
??_C@_05DIAHPDGL@PAUSE?$AA@ DB 'PAUSE', 00H		; `string'
PUBLIC	_main
; Function compile flags: /Ogtp
;	COMDAT _main
_main	PROC						; COMDAT
; File c:\users\user\documents\visual studio 2015\projects\playing_with_optimisation\playing_with_optimisation\main.cpp
; Line 5
	call	DWORD PTR __imp__system
	add	esp, 4
; Line 6
	xor	eax, eax
; Line 7
	ret	0
_main	ENDP
I built and linked it like this (probably not optimal, but it works with the example)

Ml.exe /c /coff source.asm
Link.exe /SUBSYSTEM:CONSOLE source.obj

I'm still not sure how VS.net 2015 knows how to reference these libraries as I can't see any trace of these in the VS linker pages.

INCLUDELIB "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib"
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\libucrt.lib"
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\ucrt.lib"
Apart from that, the mystery is solved as to how to reconstruct from an ASM file.

I'm interested to see how ASM handles a basic 'class'. That will probably be my next experiment.

#5281738 Recompile VS.net C++ generated ASM file?

Posted by on 17 March 2016 - 02:44 PM

Hmmm, seems like a dead end. Doesn't seem there is a 'libc' as such in VS.net. Maybe it hides under an alternate name.

Depending on your version of Visual Studio, you may have to use ucrtbase.lib and libvcruntime.lib instead of libc(mt):

Thanks dude, this got me on the right track.

I am using the Windows SDK v10 so I had to include the following

INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\libucrt.lib"
INCLUDELIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86\ucrt.lib"
Seems that the 'Universal CRT' is new way that Microsoft is doing things. With the earlier SDK's you'd probably need to link ucrtbase.lib and libvcruntime.lib as mentioned above.

#5281618 Recompile VS.net C++ generated ASM file?

Posted by on 17 March 2016 - 03:21 AM

So try linking libc as well you mean?

So far I have only tried linking what was in the linker properties box in VS.net. So, it seems that VS must do more behind the scenes that it lets on.

#5279750 Class 'Virtual' question

Posted by on 05 March 2016 - 05:16 PM

Breaks LSP. Don't do it.

Liskov says don't do something in 1994. Breaks creativity.

#5279598 Class 'Virtual' question

Posted by on 04 March 2016 - 10:02 PM

Yep, that would be the plan. I wouldn't use class A in this case, it would always be a derivation. So, I'd only ever use class B, C, D, etc. :)

#5279594 Class 'Virtual' question

Posted by on 04 March 2016 - 08:43 PM

Thanks guys for information.


I have up-voted all answers and understand the pro's and (mainly) con's of doing such a thing now.


Thanks again :)

#5279437 Class 'Virtual' question

Posted by on 04 March 2016 - 03:34 AM

Hi guys,

With classes and how you can override 'virtual' members with your own implementation, is it possible to also override (or add additional) public & private variables to the new class instance also?

For example class instance A might just used the default public variables and class instance B might have additional variables X,Y, & Z.

Then you could query the value of X by doing Something = B.X

Is this sort of thing possible?

Thanks in advance.

#5273819 Problems reading back values from a file

Posted by on 02 February 2016 - 03:12 AM

		fs.open(filename, std::fstream::in, std::fstream::binary);
I'm not sure what function you are calling there since I could not find any documentation of a three argument open member function, but you want
fs.open(filename, std::fstream::in | std::fstream::binary);
Note the operator | instead of the ','. Also, while this does not matter, I would usually prefer to call the flags std::ios::in and std::ios::binary since they belong to streams in general and not just file streams.

Genius, changing the comma to a pipe fixed it instantly.

It is odd because I copy and pasted the code from the project that I made that does the encoding in the first place.

I was obviously lucky that the writing component worked in the first place - hehe.

Thanks again guys! Saved my day :)

#5273445 Structuring a Simple 2D Engine

Posted by on 31 January 2016 - 04:32 AM

Game engines are hard to design, at some point the generic engine code stops, and the game specific code starts. The problem is, where is that point.
I am reading from your post there are no obvious open areas in your engine any more. That means to me, you're finished making your engine!
Now, it is probably useful for learning purposes, to evaluate your engine. In other words, how good does it do its job?
(I do hope you have a list of requirements what your engine is supposed to handle).
Thus, testing time has arrived. Package the engine, give it a fancy name and version number (fooengine, 0.1 alpha, build 21583).
Then make a new directory, unpack the engine, and now make a game, like pong, tetris, pacman, space invaders, whatever you want. (Smaller is better, it's the first test, don't try anything big until you're confident small things "are trivial".)
Here you're supposed to write only game-specific code. Assuming you will finish at some point, leave it for a week, and then look again at the code you actually wrote, and the changes you made in the engine code (which you are not supposed to change?!). Could you re-use parts for another game? Did the engine code cause restrictions where you had to work around, or even hack the engine code to make it work?
At this point, you can decide to fix or expand the engine, making a new version, and a new test cycle begins.
If things look good, it's probably useful to do at least 2 or 3 games, to verify your findings.
And here you see the disadvantage of focusing at an engine. The games are not the goal any more, the engine is the goal. The games you make become sort of by-products of testing the engine. With each test cycle of the engine you have to write a lot of games, or update already written games.
If this is what you want to do, it's fine, just be aware of it.

For myself, being someone working on an engine myself, this is arguably the best post I have ever read!