Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Erik Rufelt

Member Since 17 Apr 2002
Offline Last Active Today, 03:43 PM

Topics I've Started

CotBot City for Kids, on AppStore and Play

27 August 2014 - 04:14 AM

Hey everyone. Today is the release of a children's game I've been working on for about a year, together with my collaborators!

I've done all the coding, whereas others are in charge of the graphics (though a few of the simpler models are by me too, so I got to practice my Blender skills a bit =).

 

It's a driving game with mini-games depending on the vehicle you drive, mainly aimed at 3-6 year olds.

 

Check out CotBot City on AppStore or Google Play!

 

Attached File  splash_1280x720.jpg   114.1KB   1 downloads

Attached File  firetruck_1280x720.jpg   91.26KB   1 downloads

Attached File  driving_garbage_1280x720.jpg   108.07KB   1 downloads


Before I learned the ++ ..

22 October 2013 - 09:29 PM

Last modified January 2001, good old days.. ^^

// Global
struct Global
{
	// Windows stuff
	HINSTANCE					hInstance;
	HWND						hWnd;
	HDC							hDC;
	HGLRC						hRC;
	bool						active_app;
	bool						pressed_keys[256];
	bool						old_keys[256];
	
	// Direct Input
	//LPDIRECTINPUT7				di;
	//LPDIRECTINPUTDEVICE7		di_keyboard;
	//BYTE						di_buffer[256];
	
	// Screen info
	GLushort					screen_width;
	GLushort					screen_height;
	GLushort					bit_depth;
	
	// Loop done
	GLboolean					done;
	
	// Controls
	GLboolean					forward_pressed;
	GLboolean					backward_pressed;
	GLboolean					left_pressed;
	GLboolean					right_pressed;
	
	GLfloat						turn_angle;
	GLfloat						look_angle;
	
	GLboolean					new_left_button;
	GLboolean					new_right_button;
	
	GLboolean					left_button_pressed;
	GLboolean					left_button_was_pressed;
	GLboolean					right_button_pressed;
	GLboolean					right_button_was_pressed;
	
	GLboolean					shift_pressed;
	
	GLshort						mouse_x;
	GLshort						mouse_y;
	GLshort						mouse_x_start;
	GLshort						mouse_y_start;
	GLfloat						mouse_x_fraction;
	GLfloat						mouse_y_fraction;
	GLfloat						mouse_x_start_fraction;
	GLfloat						mouse_y_start_fraction;
	
	// FPS
	GLfloat						fps;
	
	// Global time (in milliseconds)
	unsigned long				time;
	
	// Trig tables
	GLfloat						cosTable[36000];
	GLfloat						sinTable[36000];
	
	// Main menu
	GLshort						main_menu_selection;
	GLshort						main_menu_which_menu;
	GLshort						main_menu_selection_red_change;
	GLshort						main_menu_selection_green_change;
	GLfloat						main_menu_selection_red;
	GLfloat						main_menu_selection_green;
	GLfloat						main_menu_x_move;
	GLfloat						main_menu_y_move;
	GLfloat						main_menu_points_x[11][11];
	GLfloat						main_menu_points_y[11][11];
	
	GLboolean					main_menu_up_pressed;
	GLboolean					main_menu_down_pressed;
	GLboolean					main_menu_confirm_pressed;
	
	GLfloat						angle;
	
	// Game state
	GLshort						game_state;
	GLboolean					end_game;
	
	// Camera
	GLfloat						camera_offset_x;
	GLfloat						camera_offset_y;
	GLfloat						camera_offset_z;
	GLfloat						camera_rot_x;
	GLfloat						camera_rot_y;
	GLfloat						camera_rot_z;
	
	// Textures
	GLuint						*textures;
	GLushort					texture_count;
	GLshort						at_texture;
	TextureFilePtr				texture_files;
	GLshort						current_texture;
	GLshort						added_textures;
	GLshort						num_global_textures;
	
	// Global textures
	GLshort						font_texture;
	GLshort						button_mark_texture;
	GLshort						selection_texture;
	GLshort						statusbar_texture;
	GLshort						buildbar_texture;
	GLshort						minimap_texture;
	
	GLshort						blood_texture;
	
	GLshort						gys_barracks_selection_texture;
	GLshort						gys_bc_selection_texture;
	GLshort						gys_utsatt_selection_texture;
	
	GLshort						cancel_button_texture;
	
	GLshort						grass_texture;
	GLshort						main_menu_texture;
	
	GLshort						single_texture;
	GLshort						host_texture;
	GLshort						join_texture;
	GLshort						options_texture;
	GLshort						quit_texture;
	
	// Sky dome
	GLshort						skydome_texture;
	GLshort						cloud_texture;
	GLshort						sky_box_start_texture;
	
	// Floor/wall textures
	GLshort						floor_texture;
	GLshort						wall_texture;
	
	// Players
	PlayerPtr					players;
	PlayerPtr					camera_player;
	
	// Structures/units
	UnitPtr						units;
	StructurePtr				structures;
	SelectionPtr				selection;
	char						*mouse_target;
	char						*highlighted_target;
	
	unsigned int				next_unit_id;
	unsigned int				next_structure_id;
	
	BloodSourcePtr				blood_sources;
	BloodPtr					blood;
	ProjectilePtr				projectiles;
	TerrainEffectPtr			terrain_effects;
	
	// Models
	SMPtr						model_gys_utsatt;
	SMPtr						model_gys_bc;
	SMPtr						model_gys_barracks;
	SMPtr						model_gys_arm;
	SMPtr						model_gys_leg;
	SMPtr						model_gys_torso;
	SMPtr						model_gys_head;
	
	// Resources
	GLshort						minerals;
	GLshort						gas;
	
	// Chat
	ChatMPtr					chat_messages;
	GLboolean					chatting;
	GLshort						chat_message_length;
	GLubyte						chat_message[256];
	
	// Button marks
	ButtonMarkPtr				button_marks;
	
	// Network
	Server						server;
	Client						client;
	GLshort						net_type;
	MessagePtr					messages;
	
	GLshort						ip_string_length;
	GLubyte						ip_string[256];
	
	// World
	GLfloat						world_y[101][101];
	GLfloat						world_shade[101][101];
	GLfloat						bottom_y;
	GLfloat						world_y_change[101][101];
	WorldTriangle				world_triangles[100][100][2];
	
	char						text[256];
	char						text2[256];
	GLboolean					do_it;
	
	FILE						*log_file;
	
	GLboolean					compressed;
};
typedef struct Global Global;

At least functions had representative names..

void Draw3DModelFast(SMPtr model, float offset_x, float offset_y, float offset_z,
					float rotation_x, float rotation_y, float rotation_z)
{
	BonePtr					bone = 0;
	int						i;
	int						j;
	float					x;
	float					y;
	float					z;
	float					shade;
	
	//glEnable(GL_DEPTH_TEST);
	//glCullFace(GL_BACK);
	//glEnable(GL_CULL_FACE);
	//glEnable(GL_TEXTURE_2D);
	
	for(i=0;i<model->triCount;i++)
	{
		if(g.current_texture != (model->triList[i].texture+model->firstTexture))
		{
			glBindTexture(GL_TEXTURE_2D, g.textures[model->triList[i].texture+model->firstTexture]);
			g.current_texture = model->triList[i].texture + model->firstTexture;
		}
		
		glBegin(GL_TRIANGLES);
		for(j=0;j<3;j++)
		{
			x = model->vertexList[model->triList[i].vertex[j]].point.x;
			y = model->vertexList[model->triList[i].vertex[j]].point.y;
			z = model->vertexList[model->triList[i].vertex[j]].point.z;
			
			shade = model->vertexList[model->triList[i].vertex[j]].shade;
			glColor4f(shade, shade, shade, 1.0f);
			
			glTexCoord2f(model->vertexList[model->triList[i].vertex[j]].u,
							model->vertexList[model->triList[i].vertex[j]].v);
			
			RotatePt(&x, &y, &z, rotation_x, rotation_y, rotation_z);
			
			x += offset_x;
			y += offset_y;
			z += offset_z;
			
			glVertex3f(x, y, z);
		}
		
		glEnd();
	}
}// Draw3DModelFast

D3D11 Drawing Text

17 March 2011 - 07:46 PM

I've written a wrapper for drawing text in D3D11, using DirectWrite to draw the glyphs and format the text. DirectWrite text-layouts have a Draw method that enable callbacks for every part of the formatted text, which I use to get the text formatting and glyphs. Then every glyph is replaced with a quad that is drawn with D3D11, and every unique glyph is cached in a texture atlas. This works rather nicely, as DirectWrite is in charge of all formatting, text direction, unicode, glyph combining, word wrapping etc.

The question of fonts and D3D11 comes up rather often, so I hope it can benefit someone else too, and also I'd be happy if anyone has any suggestions for improvements, feature or code wise, or other comments. :) I wrote it using interfaces similar to D3D and DWrite to make it fit in nicely.

I uploaded it at CodePlex: http://fw1.codeplex.com/

Documentation for all the interfaces is available here: http://www.rufelt.com/fw1fontwrapper/

Simple one-file samples for using the library is also available at those locations.

Simple text drawing works like this:
#include "FW1FontWrapper.h"

void drawText(ID3D11DeviceContext *pContext) {
	IFW1Factory *pFW1Factory;
	HRESULT hResult = FW1CreateFactory(FW1_VERSION, &pFW1Factory);
	
	IFW1FontWrapper *pFontWrapper;
	hResult = pFW1Factory->CreateFontWrapper(pDevice, L"Arial", &pFontWrapper);
	
	pFontWrapper->DrawString(
		pContext,
		L"Text",// String
		128.0f,// Font size
		100.0f,// X position
		50.0f,// Y position
		0xff0099ff,// Text color, 0xAaBbGgRr
		0// Flags
	);
}

New screenshot:
Posted Image

Happy New Year!

31 December 2010 - 11:39 AM

Though depending on where you live it might be a few hours too early or too late. =)

Here was supposed to be a javascript fireworks but it seems it's not allowed :( A Google image will have to do. :)


[Edited by - Erik Rufelt on December 31, 2010 5:57:39 PM]

Crash with level 9 D3D11 + D3D10.1 devices

08 November 2010 - 07:53 AM

I'm experiencing a very strange crash. If I create a level 9.1 or 9.3 D3D11 device, and then a level 9.1 or 9.3 D3D10.1 device, then I get a crash while Presenting from the D3D11 swap-chain, usually with one frame delay. If either of the devices uses level 10.0 then there is no crash.
I'm running 64-bit Windows Vista, and the crash only happens when compiling for 32-bit, while it all works fine when compiling for 64-bit. There is also no crash if using two level 9 D3D11 devices or two level 9 D3D10.1 devices.
Is there something I need to think about when creating multiple level 9 devices, or is this a bug?
I have a GeForce 8800 GT with the latest WHQL drivers, and the latest Windows updates. It doesn't crash on another system I tried it on with integrated graphics. Unfortunately I haven't been able to test it on another NVidia system.

This is a minimal example that crashes for me on pDevice11->Release().

#include <windows.h>
#include <D3D11.h>
#include <D3D10_1.h>

#pragma comment (lib, "D3D11.lib")
#pragma comment (lib, "D3D10_1.lib")

// Main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
// Create D3D11 device
ID3D11Device *pDevice11;

D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_9_1;

HRESULT hResult = D3D11CreateDevice(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
0,
&featureLevel,
1,
D3D11_SDK_VERSION,
&pDevice11,
NULL,
NULL
);
if(FAILED(hResult)) {
MessageBox(NULL, TEXT("D3D11CreateDevice"), TEXT("Error"), MB_OK);
}
else {
// D3D10.1 device
ID3D10Device1 *pDevice10;

hResult = D3D10CreateDevice1(
NULL,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
0,
D3D10_FEATURE_LEVEL_9_1,
D3D10_1_SDK_VERSION,
&pDevice10
);
if(FAILED(hResult)) {
MessageBox(NULL, TEXT("D3D10CreateDevice1"), TEXT("Error"), MB_OK);
}
else {
pDevice10->Release();
}

pDevice11->Release();
}

MessageBox(NULL, TEXT("Complete!"), TEXT("Message"), MB_OK);

return 0;
}



EDIT: And here's the call stack:

PARTNERS