Advanced Lesson 2 .exe error

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
ElectricX
Posts: 3
Joined: July 31st, 2014, 8:55 pm

Advanced Lesson 2 .exe error

Post by ElectricX » July 31st, 2014, 9:19 pm

Hey! I just finished watching the Advanced C++ DirectX Game Porgramming Tutorial - Lesson 2 and I'm getting an error. I'm expecting a facepalm... but these are the 2 problems(ordered worst-best a error can get)

When I run the program via my IDE, random lines show up that don't exist in my file, covering up my actual thing I want to show

I can't run the .exe, wth this error: Debug Assertion Failed!

Program: C:\WINDOWS\SYSTEM32\MSVCP120D.dll
File: d:\microsoft visual studio\vc\include\vector
Line: 159

Expression: vector iterator + offset out of range

Can anyone help? Heres my code:

Game.cpp:

Code: Select all

/****************************************************************************************** 
 *	Chili DirectX Framework Version 14.03.22											  *	
 *	Game.cpp																			  *
 *	Copyright 2014 PlanetChili.net <http://www.planetchili.net>							  *
 *																						  *
 *	This file is part of The Chili DirectX Framework.									  *
 *																						  *
 *	The Chili DirectX Framework is free software: you can redistribute it and/or modify	  *
 *	it under the terms of the GNU General Public License as published by				  *
 *	the Free Software Foundation, either version 3 of the License, or					  *
 *	(at your option) any later version.													  *
 *																						  *
 *	The Chili DirectX Framework is distributed in the hope that it will be useful,		  *
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of						  *
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the						  *
 *	GNU General Public License for more details.										  *
 *																						  *
 *	You should have received a copy of the GNU General Public License					  *
 *	along with The Chili DirectX Framework.  If not, see <http://www.gnu.org/licenses/>.  *
 ******************************************************************************************/
#include "Game.h"

Game::Game( HWND hWnd,KeyboardServer& kServer,const MouseServer& mServer )
:	gfx( hWnd ),
	audio( hWnd ),
	kbd( kServer ),
	mouse( mServer ),
	model( "suprise mothafucka.dxf" )
{
}

Game::~Game()
{
}

void Game::Go()
{
	UpdateModel();
	gfx.BeginFrame();
	ComposeFrame();
	gfx.EndFrame();
}

void Game::UpdateModel( )
{
}

void Game::ComposeFrame()
{
	model.Draw({ 400.0f, 300.0f }, gfx);
}
PolyClosed.h:

Code: Select all

#pragma once

#include "Vec2.h"
#include "Colors.h"
#include "D3DGraphics.h"
#include "dxflib/dl_creationadapter.h"
#include "dxflib/dl_dxf.h"
#include <vector>
#include <memory>

class PolyClosedLoader : public DL_CreationAdapter{
public:
	PolyClosedLoader(std::string filename){
		std::unique_ptr< DL_Dxf > pDxf = std::make_unique<DL_Dxf >();
		pDxf->in(filename, this);
	}
	virtual void addVertex(const DL_VertexData& data) override{
		vertices.push_back({ (float)data.x, -(float)data.y });
	}
	std::vector< const Vec2 >& GetVertices(){
		return vertices;
	}
private:
	std::vector< const Vec2 > vertices;
};

class PolyClosed{
public:
	PolyClosed(std::initializer_list< Vec2 > vList, D3DCOLOR color = WHITE)
		:
		vertices(vList),
		color(color)
	{}
	PolyClosed(std::string filename, D3DCOLOR color = WHITE) :
		vertices(std::move(PolyClosedLoader(filename).GetVertices())), color(color){}
	void Draw(Vec2 pos, D3DGraphics& gfx) const{
		for (auto i = vertices.begin(), end = vertices.end() - 1; i != end; i++){
			gfx.DrawLine(*i + pos, *(i + 1) + pos, color);
		}
		gfx.DrawLine(vertices.back() + pos, vertices.front() + pos, color);
	}
private:
	D3DCOLOR color;
	const std::vector< const Vec2 > vertices;
};

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Advanced Lesson 2 .exe error

Post by chili » August 1st, 2014, 1:14 am

Read the rules. My anaconda don't want none unless you got zips son.
Chili

ElectricX
Posts: 3
Joined: July 31st, 2014, 8:55 pm

Re: Advanced Lesson 2 .exe error

Post by ElectricX » August 1st, 2014, 2:17 am

Shit, thats what I get for fast reading xD Here ya go.
Last edited by LuisR14 on August 1st, 2014, 3:25 pm, edited 1 time in total.
Reason: *Snip*

stagephrite
Posts: 5
Joined: June 20th, 2014, 1:53 pm

Re: Advanced Lesson 2 .exe error

Post by stagephrite » August 1st, 2014, 9:29 am

The debug assertion error is because when you run the program via the IDE it is running in the "chili directx framework 2014......." folder which is where the dxf is so all is good....however when you run the exe directly it is running in the debug folder where there is no dxf file. So copying the dxf to the debug folder will solve that issue. As for the other issue I tried using chili's dxfs and they show up fine so it would really point to the issue being with your dxf.

Finally *insert mention of cleaning solution before uploading to forum here* :-)

Post Reply