Page 1 of 2

Framework Mk III (Sound Effects)

Posted: April 25th, 2012, 11:17 am
by chili
For the details of this release, check the blog kiddies.

NOTE: Do NOT use this version of the framework for the tutorials until lesson 16. Use the version that is meant for download at lesson 1.

Re: Framework Mk III (Sound Effects)

Posted: April 25th, 2012, 9:17 pm
by KPence
You're amazing, thank you

Re: Framework Mk III (Sound Effects)

Posted: April 26th, 2012, 3:33 am
by chili
No problem bro, I live to give. 8-)

Re: Framework Mk III (Sound Effects)

Posted: April 29th, 2012, 5:01 pm
by nG Inverse
Nice, I'll get experimenting with it soon.

By the way, you're missing the colon in the URL after "http" with the link from the blog.

Re: Framework Mk III (Sound Effects)

Posted: April 29th, 2012, 5:17 pm
by chili
Thanks for the heads up bro.

Re: Framework Mk III (Sound Effects)

Posted: June 10th, 2012, 5:08 pm
by Itsme
May I tell you this is not a really user friendly code. You can optimize it by ordering the classes differently. For example you don't need WinMain. This makes it possible that the user starts in the main class with an almost empty file. This will make it more user friendly and less messy. You may use it if you want to.
See:

main.cpp

Code: Select all

#include "Window.h"

int main(){
	Window a_window(400,400,"aye captain");
	
	while (a_window.isOpen()){
// you can do here the same stuff as in  Game::ComposeFrame() with a few small changes.

}
}
Window.h

Code: Select all

#ifndef WINDOW_H
#define WiNDOW_H
#include <Windows.h>
#include <string>
class Window{


private:
	const char* WINDOWTITLE;
	void CreateWWindow();
	void RegisterWClass();
	int width, height;
public:
	Window(unsigned int widht, unsigned int height, std::string);

	bool isOpen();
};

#endif
windows.cpp

Code: Select all

#include "Window.h"

HINSTANCE Ghinst;	// Global hinstance
HWND fWindow;	// Global handle
MSG msg;		// Global Message
int Wcount =0;	// prevents crash when creating more than one window
bool quit;		// fixes quit glich
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParan);	//calling result call back


/// registering WindowClass
void Window::RegisterWClass(){
	WNDCLASS wc;		
	wc.cbClsExtra	= 0;
	wc.cbWndExtra	= 0;
	wc.hbrBackground	= (HBRUSH) LTGRAY_BRUSH;
	wc.hCursor		= LoadCursor(Ghinst,IDC_ARROW);
	wc.hIcon		= LoadIcon(Ghinst,IDI_APPLICATION);
	wc.hInstance	= Ghinst;
	wc.lpfnWndProc	= WndProc;
	wc.lpszClassName	= "THIS";
	wc.lpszMenuName	= NULL;
	wc.style		= CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW;

	if(!RegisterClassA(&wc))throw "Could not register class!";
}
/// creating Window
void Window::CreateWWindow(){
	fWindow = CreateWindow("THIS", WINDOWTITLE,		// class name | Title
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,			//style
		0,0,								//position
		width, height						//size
		,NULL, NULL,						// parent  | Menu
		Ghinst, NULL);						// HINSTANCE | lparam
	if (fWindow == NULL)throw "Could not create Window.";
}

/// constructor defines window width, window height, window title
Window::Window(unsigned int width, unsigned int height, std::string title){
	quit = false;
	if (Wcount == 0)	RegisterWClass();	// register class if first window
	// init
	WINDOWTITLE		= title.c_str();
	this->width		= width;
	this->height	= height;
	//creatingwindow
	CreateWWindow();
	Wcount++;
}

//handles messages and checks if window is open
bool Window::isOpen(){
	if (PeekMessage(&msg, NULL,0,0,PM_REMOVE)){
	if(msg.message == WM_QUIT) return false;
	TranslateMessage(&msg);
	DispatchMessage(&msg);
	}
	return !quit;
}

//LRESULT CALLBACK WndProc
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){switch (msg){
case WM_DESTROY: quit = true; break;


}return (DefWindowProc(hwnd,msg,wParam,lParam));}

Re: Framework Mk III (Sound Effects)

Posted: June 11th, 2012, 3:40 am
by chili
I don't worry about creating a wrapper for the Win32 stuff because it's mostly boilerplate and it's insignificant compared to rest of the code in any decent-sized project.

If I were to pretty it up, I would take an approach similar to what is done here:

http://rastertek.com/dx11tut02.html

Re: Framework Mk III (Sound Effects)

Posted: June 11th, 2012, 5:06 am
by magusofmirrors
I finished that tutorial recently! It's funny seeing how I typed down all the example source instead of copy-pasting. I believe that was the old-fashioned way of learning things, right? (And before then was experimentation and development?)

Re: Framework Mk III (Sound Effects)

Posted: July 28th, 2012, 11:42 pm
by cameron
I put the program on my desktop and put my game into it i get 0 errors and pops this up.
Assertion failed!

Program: C:\Users\cameron\ShipGame2.exe
File: c:\users\cameron\desktop\shipgame2\D3DGraphics.cpp
Line: 73


Expression: x < 800

blah blah blah



Note this only pops up in debug configuration.

Re: Framework Mk III (Sound Effects)

Posted: July 29th, 2012, 7:13 am
by viruskiller
from what i saw in the framework so far i think most of the assertion errors are when your game code try'ts to access pixels off the screen.
so make sure u're not trying to draw anything outside the screen.
or if u'r drawing objects then make sure they all exist at the draw time,an empty object will have giberish in it's x,y coordinates and will tell the gfx.putpixel to draw somewhere like x -843424,y32342
and that will trigger the assertion check.
an assertion is a condition check that will trigger an error if the condition is not met,in your case x value of the pixel u drawing is no longer on the screen:)