• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

138 Neutral

About Marusu

  • Rank
  1. ppfd->iPixelType must be PFD_TYPE_RGBA in release mode, but not in debug, which is so messed up I can't even begin to describe how furious I was finding this out after long hours of trial and errors...
  2. I still can't seem to find any way to make working release version. Could someone please try this code on visual studio and tell me if release version works for them without any errors? [CODE] #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new DEBUG_NEW #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <WindowsX.h> #define GLEW_STATIC #include <glew.h> #pragma comment(lib, "glew32s.lib") #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") #include <string> #include <vector> #include <set> #include <hash_map> #include <sstream> #include <stdio.h> #include <fstream> #include <iostream> HWND hWnd; HDC hDC; HGLRC hRC; #define LOGI(...) { char buff[10240]; sprintf_s(buff, __VA_ARGS__); OutputDebugStringA("INFO: "); OutputDebugStringA(buff); OutputDebugStringA("\n"); } #define LOGW(...) { char buff[10240]; sprintf_s(buff, __VA_ARGS__); OutputDebugStringA("WARNING: "); OutputDebugStringA(buff); OutputDebugStringA("\n"); } #define LOGE(...) { char buff[10240]; sprintf_s(buff, __VA_ARGS__); MessageBoxA(0, buff, "Error", MB_ICONERROR); \ OutputDebugStringA("ERROR: "); OutputDebugStringA(buff); OutputDebugStringA("\n"); } // Set up pixel format for graphics initialization void SetupPixelFormat() { PIXELFORMATDESCRIPTOR pfd, *ppfd; int pixelformat; ppfd = &pfd; ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); ppfd->nVersion = 1; ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; ppfd->dwLayerMask = PFD_MAIN_PLANE; ppfd->iPixelType = PFD_TYPE_COLORINDEX; ppfd->cColorBits = 16; ppfd->cDepthBits = 24; ppfd->cAccumBits = 0; ppfd->cStencilBits = 0; pixelformat = ChoosePixelFormat(hDC, ppfd); SetPixelFormat(hDC, pixelformat, ppfd); } // Initialize OpenGL graphics bool InitGraphics() { hDC = GetDC(hWnd); SetupPixelFormat(); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); GLenum err = glewInit(); if (err != GLEW_OK) { LOGE("GLEW not initialized."); return false; } if (!GLEW_VERSION_2_1) { LOGE("GLEW doesn't support OpenGL 2.1"); return false; } return true; } // Resize graphics to fit window void ResizeGraphics() { // Get new window size RECT rect; GetClientRect(hWnd, &rect); int width = rect.right; int height = rect.bottom; } // Draw frame void DrawGraphics() { // Show the new scene SwapBuffers(hDC); } // Handle window events and messages LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_MOUSEMOVE: break; case WM_SIZE: ResizeGraphics(); break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; // Default event handler default: return DefWindowProc (hWnd, uMsg, wParam, lParam); break; } return 1; } int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #ifdef _DEBUG _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG ); #endif const LPCWSTR appname = TEXT("Ghost engine"); WNDCLASS wndclass; MSG msg; // Define the window class wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)MainWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, appname); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wndclass.lpszMenuName = appname; wndclass.lpszClassName = appname; //wndclass.hIcon = static_cast<HICON>(LoadImage(hInstance, MAKEINTRESOURCE(IDI_ERROR), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE)); // Register the window class if (!RegisterClass(&wndclass)) { LOGE("Failed to register window struct."); return FALSE; } // Create the window hWnd = CreateWindow( appname, appname, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if (!hWnd) { LOGE("Failed to initialize window."); return false; } // Initialize OpenGL if (!InitGraphics()) { LOGI("Deleting engine."); wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); } // Display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Event loop while (true) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) { if (!GetMessage(&msg, NULL, 0, 0)) break; TranslateMessage(&msg); DispatchMessage(&msg); } DrawGraphics(); } LOGI("Deleting engine."); wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); return 1; } [/CODE]
  3. They were indeed in .h file, but the file had include guards and even trying this didn't changed anything, but your post gave me an idea, on what is wrong, so I went into linker->additional dependencies and what I found was glew32.lib which was causing the error, after removing it I can compile again in debug and release. But unfortunately the problem still persist, in release mode I get the same error with GLEW_STATIC defined. Does the following warning might have anything to do with this? [indent=1]LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library D:\Dropbox\Workspace\Visual Studio\GhostEngine\LINK GhostEngine[/indent] EDIT: just tried to create new project on different machine and older visual studio 2010 compiler. Same thing happens there. EDIT2: even tried moving released mode binary to yet another different PC, and even there the problem persists. Probably has nothing to do with PC's graphic cards drivers.
  4. Thanks for reply. So I tried a few options. 1.) I replaced my include code to this one (instead of "GL/glew.h" I use<GL/glew.h>, this markup script has some issues.): [source lang="cpp"]#define GLEW_STATIC #include "GL/glew.h" #pragma comment(lib, "glew32s.lib")[/source] This is what error I get now: [indent=1]Error 3 error LNK1169: one or more multiply defined symbols found D:\Dropbox\Workspace\Visual Studio\GhostEngine\Release\GhostEngine.exe 1 1 GhostEngine Error 2 error LNK2005: _glewInit@0 already defined in glew32.lib(glew32.dll) D:\Dropbox\Workspace\Visual Studio\GhostEngine\glew32s.lib(glew.obj) GhostEngine Warning 1 warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library D:\Dropbox\Workspace\Visual Studio\GhostEngine\LINK GhostEngine[/indent] 2) I downloaded latest glew binaries and changed my glew32.dll found in system and system32 folders with new one. Unfortunately it didn't helped. 3) I tried including source files into my project, but it also spilled loads of error messages about missing functions or something. I have latest nvidia drivers for 670GTX. Can this be the cause? I also don't include following lines [indent=1]#pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib")[/indent] because they don't seem to do anything.
  5. Hi, I have this strange problem, which I've ignored for quite some time... I develop in debug mode, which works fine. But whenever I switch to release mode the following part of my code [source lang="cpp"] GLenum err = glewInit(); if (err != GLEW_OK) LOGI("GLEW not initialized."); if (!GLEW_VERSION_2_1) LOGI("GLEW doesn't support OpenGL 2.1");[/source] produces this message: INFO: GLEW doesn't support OpenGL 2.1 I have this line in my header (glew.h is between <>): [source lang="cpp"]#include glew.h #pragma comment(lib, "glew32.lib")[/source] I include these directories: [indent=1]C:\api\FMOD Programmers API Windows\api\inc;[/indent] [indent=1]C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\inc;[/indent] [indent=1]C:\Binaries\DevIL-SDK-x86-1.7.8\include\IL;[/indent] [indent=1]C:\api\Glew\include\GL;[/indent] [indent=1]C:\api\DevIL\include\IL;$(IncludePath)[/indent] and these libraries: [indent=1]C:\api\Glew\lib;[/indent] [indent=1]C:\api\DevIL\lib;[/indent] [indent=1]C:\api\FMOD Programmers API Windows\api\lib;[/indent] [indent=1]C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\lib;[/indent] [indent=1]C:\Binaries\DevIL-SDK-x86-1.7.8\lib;$(LibraryPath)[/indent] I've had copied debug include and library entries to release mode, so they should be the same. Any ideas, why in release mode glew doesn't add support for OpenGL2.1? Thanks, Martin.
  6. Hello, now I use eclipse (with sequoyah) to write application with ndk for android. I'm experiencing a strange problem where I can't succesfully include any classes into current cpp file which is invoked by android system. My cpp fle looks like this: [CODE] #include "Core/Ghost.h" #include "Multiplatform/PlatformAndroid.h" #ifdef ANDROID int g_nWidth, g_nHeight; Ghost* ghost_; Platform* platform_; extern "C" { void Java_com_ghost_Renderer_init(JNIEnv* env) { ghost_ = new Ghost(); } void Java_com_ghost_Renderer_resize(JNIEnv* env, void* reserved, int w, int h) { ghost_->resize(w, h); } void Java_com_ghost_Renderer_render(JNIEnv* env, void* reserved) { ghost_->computeFrame(); } }; #endif [/CODE] Whenever I try to use variable "ghost_" I get "Undefined reference to Ghost::..." Any Ideas what might be causing this? [EDIT] Apparently it has something to do with mk file, because after adding Ghost.cpp to it, the error went from Ghost to Renderer object which is used in Ghost.cpp. Unfortunately even adding all files to mk file didn't solve the problem. [EDIT2] It was a syntax error on Renderer object. Now it works. But still, does that mean, that whenewer I add new files to project, I will also have to add them to mk file? Thank you, Martin
  7. Hi, karwosts, unfortunately it doesn't work that way, camera just starts rotating around one point.
  8. Hi, I have been thinking for a few days on how to properly create camera matrix so I could specify it just as any other model in scene and the view would still be from camera object. I use these methods to get camera matrix: [code] public static float[] getViewMatrix(float[] position, float[] rotation) { float[] matTrans = Matrix3D.copy(position); float[] matRot = Matrix3D.copy(rotation); // Transpose rotation matrix. float tmp; tmp = matRot[0 * 4 + 1]; matRot[0 * 4 + 1] = matRot[1 * 4 + 0]; matRot[1 * 4 + 0] = tmp; tmp = matRot[0 * 4 + 2]; matRot[0 * 4 + 2] = matRot[2 * 4 + 0]; matRot[2 * 4 + 0] = tmp; tmp = matRot[1 * 4 + 2]; matRot[1 * 4 + 2] = matRot[2 * 4 + 1]; matRot[2 * 4 + 1] = tmp; // Invert translation. matTrans[3 * 4 + 0] *= -1.0f; matTrans[3 * 4 + 1] *= -1.0f; matTrans[3 * 4 + 2] *= -1.0f; return Matrix3D.multiply(matRot, matTrans); }[/code] [code] public static final float[] multiply(float[] b, float[] a) { // Return identity if matrices aren't 4x4. if (a.length != b.length && a.length != 16) return identity(); // Initialize empty matrix. float[] result = new float[16]; // Multiply. int k = 15; for (int i = 3; i >= 0; i--) { for (int j = 3; j >= 0; j--) { result[k] += a[i * 4] * b[j]; result[k] += a[i * 4 + 1] * b[4 + j]; result[k] += a[i * 4 + 2] * b[8 + j]; result[k] += a[i * 4 + 3] * b[12 + j]; k--; } } return result; }[/code] position and rotation float arrays are matrices. The problem is, that viewing arround doesn't quite work on some directions unless I comment these lines: [code] tmp = matRot[0 * 4 + 1]; matRot[0 * 4 + 1] = matRot[1 * 4 + 0]; matRot[1 * 4 + 0] = tmp; tmp = matRot[0 * 4 + 2]; matRot[0 * 4 + 2] = matRot[2 * 4 + 0]; matRot[2 * 4 + 0] = tmp; tmp = matRot[1 * 4 + 2]; matRot[1 * 4 + 2] = matRot[2 * 4 + 1]; matRot[2 * 4 + 1] = tmp;[/code] Any ideas what I'm doing wrong? This is on android. Multiply method is tested and is working. Thank you, Martin. EDIT: if I understand correctly, I need to inverse my camera position and rotation matrix to be able to get view from where camera is positioned with original matrix. Is there something wrong with my inverse matrix implementation?
  9. Hi, I am developing on android and I have encountered one problem. In opengl documentation it says, that matrices are in column-major order and translation matrix looks like this: 1 0 0 x 0 1 0 y 0 0 1 z 0 0 0 1 But in my program I use method like this: [source] public static final float[] translation(float x, float y, float z) { // 4x4 translation matrix. return new float[] { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, x, y, z, 1.0f, }; }[/source] And it works until I try to change x, y, z position to last column. Does this have to do with the fact that I use 1D array and not 2D? Does each row in this array represents a column when passed to opengl methods? Thank you, Martin
  10. Thank you both, Relfos explanation and V-man link were very useful, I finnaly managed to properly load a cube with texture, just like 3ds max does. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] One notice though, I had to multiply each v coordinate by -1.0f and set texture wrap to repeat to properly map texture, otherwise it would map everything upside down. Is there an explanation to this?
  11. Hi, I made a simple textured box in blender and exported to .obj file. Content looks like this: [CODE] # Blender v2.61 (sub 0) OBJ File: 'skybox.blend' # www.blender.org mtllib skybox.mtl v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 vt 0.744716 0.379594 vt 0.503906 0.379595 vt 0.503906 0.138785 vt 0.744716 0.138784 vt 0.744717 0.620404 vt 0.744717 0.861216 vt 0.503906 0.861216 vt 0.503906 0.620405 vt 0.263096 0.620405 vt 0.263096 0.379595 vt 0.022287 0.620405 vt 0.022287 0.379595 vt 0.985527 0.379594 vt 0.985527 0.620404 usemtl skybox_mat_skybox.png s off f 1/1 2/2 3/3 f 1/1 3/3 4/4 f 5/5 8/6 7/7 f 5/5 7/7 6/8 f 1/1 5/5 6/8 f 1/1 6/8 2/2 f 2/2 6/8 7/9 f 2/2 7/9 3/10 f 3/10 7/9 8/11 f 3/10 8/11 4/12 f 5/5 1/1 4/13 f 5/5 4/13 8/14 [/CODE] The problem is, that I have no idea how to correctly map textures. As for now I only use vt for textures (ignore f). I thought that opengl es requires vt to be exact same amount as v. But there we have more texture coordinates than vertices. Can someone tell me or give me some urls on how to make sense of numbers after the slash signs in faces? Not what they mean, but how to use them. Thank you, Martin
  12. Thanks, after all I decided to stick with using more synchronized methods, because it appears to work faster than using single thread. This is a simple program, so it shouldn't a problem to make sure everything works fine. All your replies were really helpful, and I did learned something. Thanks again, Martin
  13. ApochPiQ , your answer was very helpful, because now I believe I understand what should be done, but there still are a few questions I want to ask: [list][*]What if, the updater thread works faster than renderer, and renderer doesn't catch up? Do I need to implement routines to evade this?[*]What if GC is something that I want to evade at all costs (developing for mobile) and I can't have a new object every update method?[*]The way I have built my scene graph is that each node has one Logic object (has update()) and Entity object (has render() and all attributes). Logic Object has a pointer to Entity so it could change it's attributes. So no matter what I do, I still have to synchronize Entity in update method, when I change attributes and in renderer when I call render() method. So if I understand correctly, this is another [i]shared state concurrency[/i]. You said that it is very wrong and I like doing everything the right way, so what could I possibly do about this?[/list]Antheus, yes, I see this now, but I would really like to know how a real scene graph should look.
  14. Thanks for reply, I'm very sorry, but I am not experienced enough java user (also it is my first scene graph) and it seems I have a hard time understanding the concept of using "shared data structure mutations". Also I only used buffer to store vertices and indices, so it confuses me, because I don't know what exactly to put inside these buffers as they are only of primitive types. Maybe to understand better I will ask a question: What is wrong with following approach? - Pass to each update method a container like this: [code]class Container { public int size; public Entity[] entityArray; public Container(int maxEntities) { entityArray = new Entity[maxEntities]; size = 0; } }[/code] - Each master update call set container size to 0. - In each node update method add that node Entity object (Entity is like mesh wrapper and has its own translate, rotation and other data, which I change in update method). - Addition would look like this: [code]public void update(int timeDelta, Container cont) { //... cont.entityArray[cont.size++] = m_Entity; //... }[/code] - In master update call I would have something lke this: [code]public void UpdatersUpdateMethod() { //... synchronized(container) { m_RootNode.update(timeDelta, container); } //... }[/code] - Then in master render method I would have something like this: [code]public void RenderersRenderMethod() { //... Container c = m_HandleToUpdater.getContainer(); synchronized(c) { for (int i = 0; i < c.size; i++) { c.entityArray[i].render(openGL); } } //... }[/code] EDIT: After writing I can see that this wouldn't solve the synchronization problem as both threads would still be waiting for lock release on Container. But I could just implement clone() method and clone this container to new one in render method and only then would I call each Entity render method. Like this: [code]public void RenderersRenderMethod() { //... Container c = m_HandleToUpdater.getContainer(); synchronized(c) { localContainer = c.clone(); } for (int i = 0; i < localContainer.size; i++) { localContainer.entityArray[i].render(openGL); } //... }[/code]
  15. Thanks for reply, would it be okay to have an array of Entity objects the size of current max entities on scene? Or I should use list or something else? I would also like to hear what are the other approaches. Thanks, Martin