• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Jeff D

Windows programming

6 posts in this topic

Ok I buy this bbok called "OpenGL Game Programming", never programmed in windows maybe jumped the gun a little but I dont think thats why this is happening. They show you how to make a Hello World program in windows. I did it and it worked. Next they show a little more advanced version of Hello World in windows, but this one gives me a strange error here is the code:
  
#define WIN32_MEAN_AND_LEAN

#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT paintStruct;
	HDC hDC;
	char string[] = "Hello, World!";
	switch(message)
	{
	case WM_CREATE:
		 return 0;
		 break;

	case WM_CLOSE:
		 PostQuitMessage(0);
		 return 0;
		 break;

	case WM_PAINT:
		 hDC = BeginPaint(hwnd, &paintStruct);
		 SetTextColor(hDC, COLORREF(0x00FF0000));
		 TextOut(hDC, 150, 150, string, sizof(string)-1);
		 EndPaint(hwnd, &paintStruct);
		 return 0;
		 break;

	default:
		 break;
	}
	return (DefWindowProc(hwnd, message, wParam, lParam));
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX windowClass;
	HWND hwnd;
	MSG msg;
	bool done;
	windowClass.cbSize = sizeof(WNDCLASSEX);
	windowClass.style = CS_HREDRAW | CS_VREDRAW;
	windowClass.lpfnWndProc = WndProc;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	windowClass.lpszMenuName = NULL;
	windowClass.lpszClassName = "MyClass";
	windowClass.hIconSM = LoadIcon(NULL, IDI_WINLOGO);

	if (!RegisterClassEx(&windowClass))
			return 0;

	hwnd = CreateWindowEx(Null,
						  "MyClass",
						  "A real Windows Application!",
						  WS_OVERLAPPEDWINDOW |
						  WS_VISIBLE |
						  WS_SYSMENU,
						  100, 100,
						  400, 400,
						  NULL,
						  NULL,
						  hInstance,
						  NULL);

	if (!hwnd)
		return 0;

	done = false;

	while (!done)
	{
		PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE);

		if (msg.message == WM_QUIT)
		{
			done = true;
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;
}
  
Now when I compile I get this error: --------------------Configuration: firsttry - Win32 Debug-------------------- Compiling... firsttry1.cpp c:\dev-c++\examples\firsttry\firsttry1.cpp(92) : fatal error C1010: unexpected end of file while looking for precompiled header directive Error executing cl.exe. firsttry.exe - 1 error(s), 0 warning(s) Now when I go to help to look up the error it tells me this: Fatal Error C1010 unexpected end of file while looking for precompiled header directive A precompiled header was specified, but it did not contain a precompiled header directive. This error can be caused by specifying an incorrect file as a header file, or by specifying an include file with the /Yu (Use Precompiled Header) command line option that is not listed in the source file as an include file. Since reading this I think its because I am running Dev-c++ Windows.h but really not sure thats why I writing to you . BTW I am usuing VC++. Thx, Jeff Desrosiers
0

Share this post


Link to post
Share on other sites
Can''t say that I have an answer to your question... I am new to Microsoft programming and Visual C++ as well

Anyway, I was wondering if YOU might be able to help ME -- I have the same book as you I believe (by Kevin Hawkins and Dave Astle -- bigwigs of GameDev.net) and I am having problems with the first windows programs as well (they don''t make it very clear what to do if you have never compiled windows code from scratch! I have only used the app wizards in VC++)

Anyway, I appear to be having linker problems or something. The CPP file COMPILES okay, but...

I get a message about "unresolved external symbol _main"

I assume this has to do with my use of
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

Is there another standard windows library that I need to link? The books make no mention of this (I have two Visual C++ books and two game programming books and they all conveniently IGNORE library linking!!) I have no idea why it won''t recognize the call to WinMain or what is going on... (I had similar unresolved symbol problems with the OpenGL function calls, until I linked two OpenGL libraries for my project. But I have NO IDEA what lib to link for this _main problem)


If you can help me, that would be great, and maybe would let me get to the next step where you are and see if I get the same troubles...
0

Share this post


Link to post
Share on other sites
Jeff D, try disabling precompiled headers.
You can find this option in Project->Settings, then click the C++ tab and choose "precompiled headers" from the drop down list box. There you can deactivate them by choosing the top most option ("do not use precompiled header"... or sth. like this).
The program compiles fine on my machine when I create a win32 app.

(BTW you have three typos in your code but the compiler should tell you (sizof~sizeof, hIconSM~hIconSm, Null~NULL))

baumep
0

Share this post


Link to post
Share on other sites
You should ALWAYS disable pre-compiled headers. Those things cause more problems than all the virii listed on www.mcafee.com . Microsoft should perminently remove those things from visual studio, I can''t think of a single case where having them turned on actualy did anyone any good.
0

Share this post


Link to post
Share on other sites
Jeff D: You probably created a "Simple Win32 Application" project, which automatically has pre-compiled headers enabled. What you need to do is to #include "stdafx.h" in every source-file you have (or just turn off pre-compiled headers as baumep suggested).

When pre-compiled headers are enabled the compiler will pre-compile everything that is included in stdafx.cpp (through stdafx.h). Then when another source-file includes the stdafx.h file the compiler has already compiled all the stuff in it (and its #included headers), so compilation of everything except the stdafx.cpp file should be sped up.

I never use PCH myself, though, so I cant say whether it works well or not. For the small projects you will be creating as you learn to program, the compilation times (probably) won''t be very long anyway, so you might want to follow baumep''s and AP''s advice, just to be sure.
0

Share this post


Link to post
Share on other sites
Blueboycurtis...

Are you trying to make a console program instead? Console apps use Main instead of WinMain, and that *may* be the source of your problem.
0

Share this post


Link to post
Share on other sites