Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


SM ForeveR

Member Since 04 Sep 2009
Offline Last Active Oct 29 2012 12:35 PM

Posts I've Made

In Topic: Windows OpenGL project doesn't compile under release mode

29 October 2012 - 04:56 AM

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

In Topic: Windows OpenGL project doesn't compile under release mode

27 October 2012 - 09:16 AM

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?
#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;
}

In Topic: Windows OpenGL project doesn't compile under release mode

12 October 2012 - 11:17 PM

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?

LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library D:\Dropbox\Workspace\Visual Studio\GhostEngine\LINK GhostEngine


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.

In Topic: Windows OpenGL project doesn't compile under release mode

12 October 2012 - 05:51 AM

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:

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


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

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

because they don't seem to do anything.

In Topic: Camera positioning

08 February 2012 - 10:36 PM

Hi, karwosts, unfortunately it doesn't work that way, camera just starts rotating around one point.

PARTNERS