Magn0733's Profile User Rating: -----

Reputation: 2 Apprentice
Active Posts:
48 (0.09 per day)
04-April 13
Profile Views:
Last Active:
User is offline Apr 30 2014 02:48 AM

Previous Fields

Dream Kudos:
Icon   Magn0733 has not set their status

Posts I've Made

  1. In Topic: Setting Up OpenGL

    Posted 3 Apr 2014

    View PostBBeck, on 03 April 2014 - 02:39 PM, said:

    I'm glad it was useful.

    I hope to one day follow you into the world of OpenGl. For now I'm going to stick to DirectX, but I think I want to do OpenGL eventually. I've got a couple of really good DirectX books that I want to get everything I can out of before really starting OpenGL. On the other hand, I've got a bunch of books that are not "OpenGL" books, but when you start reading them you find out they are coded in OpenGL. A couple of books I have on shaders come to mind there. So, it will eventually be good for me to do OpenGL for that if nothing else.

    I'd like to know what you decide about input and sound and so forth, you know - what other libraries are you going to use with it?

    Well as far as I am now i actually use freeGlut for all the input. I don't know if it handles sound too? havnt' really been that far yet, I've only made a square spin on the screen when the space bar is down. So yeah it's still very basics

    And you were right OpenGl comes with your graphics driver so update them :D
    This was the video i used to guide me through it all, and he explains it all very simple and it's super simple to follow so I'd strongly recomend it when you switch to OpenGL.

    Anyways good luck with directX untill then and OpenGl when you get to that part :D
  2. In Topic: Setting Up OpenGL

    Posted 3 Apr 2014

    View PostBBeck, on 03 April 2014 - 11:06 AM, said:

    I had no idea getting OpenGL setup was such an ordeal until you pointed it out.

    I can't stand tutorials that are supposed to be for beginners and don't tell you how to get started. It's like, "Read my mind and add the additional steps that I left out of the instructions. And of course, until you do that everything I'm going to say will be absolutely worthless and pointless to you and basically a total waste of your time."

    If you can't compile, there's no point in going any further.

    So, I looked into it a bit. Of course, I haven't done any OpenGL in forever and it was totally different when I did do it. And I never got deep into it even back then. So, basically, I have no clue.

    But it looks like there are a whole slew of options which just serves to make the whole thing more difficult to understand how you're supposed to do things.

    First of all, it sounds like OpenGL actually ships with your graphics card. So, if your graphics card drivers are loaded, OpenGL is loaded. That's my understanding anyway.

    But if you're writing OpenGL code, it sounds like there's a couple other steps. It looks like there's a bunch of options that generate code to attach OpenGL to Windows. I think a lot of the choices are actually to support cross platform compatibility. It looks like WGL is the option chosen in one of the only books really published on OpenGL. And so that's what I chose to investigate further. Some of the options are maybe outdated and don't support things you may need support for later.

    I think the WGL options is Windows only, if cross platform is a concern for you. For me, I'm thinking "Just let me get it compiled and running, and I'll worry about cross platform later if I even care." The fact of the mater is I only work in Windows anyway, personally. Also, I imagine OpenGL itself and WGL don't support any of the critical game programming stuff like sound and input. Being able to receive input from the user is ... um... kinda important. But you'll have to go elsewhere for that. A temp solution is just to use the Windows WIN32 event loop just like any other program, but that doesn't support game controllers and your program may get latency because the Windows loop has no responsibility to deliver keyboard to you... well ever really but certainly not in a timely manner. It's good enough to get started though.

    It appears that WGL is actually built into Windows itself.

    Anyway, you'll probably want to enlist other libraries for the functionality OpenGL doesn't provide.

    But to get to the point, I did manage to get an OpenGL code example compiled and running. So, maybe this will help you. The code example would not compile as given (who'da guessed). But I found the problem. I added the missing closing bracket and "#pragma comment(lib, "opengl32.lib")" and it fired right up.

    I didn't do anything else special. I didn't download anything, not OpenGL, not anything. I had VS2012 Express edition installed already. I don't think I have anything installed (or configured) that it didn't come with except AssImp.

    You "should" be able to simply create an empty project, add a .cpp file, and paste this code in and it should just work. Give it a try. Maybe it will help get you started anyways. I don't know much about OpenGL but this runs on my sorry excuse for a laptop here without anything other than VS2012 Express. I always like to say that "It's hard to argue with working code."

    #include <windows.h>
    #include <GL/gl.h>
    #pragma comment(lib, "opengl32.lib")
    char *className = "OpenGL";
    char *windowName = "OpenGL Cube";
    int winX = 0, winY = 0;
    int winWidth = 300, winHeight = 300;
    HDC hDC;
    HPALETTE hPalette;
        /* set viewing projection */
        glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
        /* position viewer */
        glTranslatef(0.0F, 0.0F, -2.0F);
        /* position object */
        glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
        glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
        /* clear color and depth buffers */
        /* draw six faces of a cube */
        glNormal3f( 0.0F, 0.0F, 1.0F);
        glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
        glVertex3f(-0.5F,-0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
        glNormal3f( 0.0F, 0.0F,-1.0F);
        glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
        glVertex3f( 0.5F, 0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
        glNormal3f( 0.0F, 1.0F, 0.0F);
        glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
        glVertex3f(-0.5F, 0.5F,-0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
        glNormal3f( 0.0F,-1.0F, 0.0F);
        glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
        glVertex3f( 0.5F,-0.5F, 0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
        glNormal3f( 1.0F, 0.0F, 0.0F);
        glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
        glVertex3f( 0.5F,-0.5F,-0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
        glNormal3f(-1.0F, 0.0F, 0.0F);
        glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
        glVertex3f(-0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
        /* set viewport to cover the window */
        glViewport(0, 0, winWidth, winHeight);
    setupPixelFormat(HDC hDC)
            sizeof(PIXELFORMATDESCRIPTOR),  /* size */
            1,                              /* version */
            PFD_SUPPORT_OPENGL |
            PFD_DRAW_TO_WINDOW |
            PFD_DOUBLEBUFFER,               /* support double-buffering */
            PFD_TYPE_RGBA,                  /* color type */
            16,                             /* prefered color depth */
            0, 0, 0, 0, 0, 0,               /* color bits (ignored) */
            0,                              /* no alpha buffer */
            0,                              /* alpha bits (ignored) */
            0,                              /* no accumulation buffer */
            0, 0, 0, 0,                     /* accum bits (ignored) */
            16,                             /* depth buffer */
            0,                              /* no stencil buffer */
            0,                              /* no auxiliary buffers */
            PFD_MAIN_PLANE,                 /* main layer */
            0,                              /* reserved */
            0, 0, 0,                        /* no layer, visible, damage masks */
        int pixelFormat;
        pixelFormat = ChoosePixelFormat(hDC, &pfd);
        if (pixelFormat == 0) {
            MessageBox(WindowFromDC(hDC), "ChoosePixelFormat failed.", "Error",
                    MB_IConerror | MB_OK);
        if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
            MessageBox(WindowFromDC(hDC), "SetPixelFormat failed.", "Error",
                    MB_IConerror | MB_OK);
    setupPalette(HDC hDC)
        int pixelFormat = GetPixelFormat(hDC);
        LOGPALETTE* pPal;
        int paletteSize;
        DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
        if (pfd.dwFlags & PFD_NEED_PALETTE) {
            paletteSize = 1 << pfd.cColorBits;
        } else {
        pPal = (LOGPALETTE*)
            malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
        pPal->palVersion = 0x300;
        pPal->palNumEntries = paletteSize;
        /* build a simple RGB color palette */
            int redMask = (1 << pfd.cRedBits) - 1;
            int greenMask = (1 << pfd.cGreenBits) - 1;
            int blueMask = (1 << pfd.cBlueBits) - 1;
            int i;
            for (i=0; i<paletteSize; ++i) {
                pPal->palPalEntry[i].peRed =
                        (((i >> pfd.cRedShift) & redMask) * 255) / redMask;
                pPal->palPalEntry[i].peGreen =
                        (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
                pPal->palPalEntry[i].peBlue =
                        (((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
                pPal->palPalEntry[i].peFlags = 0;
        hPalette = CreatePalette(pPal);
        if (hPalette) {
            SelectPalette(hDC, hPalette, FALSE);
        HWND hWnd,
        UINT message,
        WPARAM wParam,
        LPARAM lParam)
        switch (message) {
        case WM_CREATE:
            /* initialize OpenGL rendering */
            hDC = GetDC(hWnd);
            hGLRC = wglCreateContext(hDC);
            wglMakeCurrent(hDC, hGLRC);
            return 0;
        case WM_DESTROY:
            /* finish OpenGL rendering */
            if (hGLRC) {
                wglMakeCurrent(NULL, NULL);
            if (hPalette) {
            ReleaseDC(hWnd, hDC);
            return 0;
        case WM_SIZE:
            /* track window size changes */
            if (hGLRC) {
                winWidth = (int) LOWORD(lParam);
                winHeight = (int) HIWORD(lParam);
                return 0;
            /* realize palette if this is *not* the current window */
            if (hGLRC && hPalette && (HWND) wParam != hWnd) {
                SelectPalette(hDC, hPalette, FALSE);
            /* realize palette if this is the current window */
            if (hGLRC && hPalette) {
                SelectPalette(hDC, hPalette, FALSE);
                return TRUE;
        case WM_PAINT:
                PAINTSTRUCT ps;
                BeginPaint(hWnd, &ps);
                if (hGLRC) {
                EndPaint(hWnd, &ps);
                return 0;
        case WM_CHAR:
            /* handle keyboard input */
            switch ((int)wParam) {
            case VK_ESCAPE:
                return 0;
        return DefWindowProc(hWnd, message, wParam, lParam);
    int APIENTRY
        HINSTANCE hCurrentInst,
        HINSTANCE hPreviousInst,
        LPSTR lpszCmdLine,
        int nCmdShow)
        WNDCLASS wndClass;
        HWND hWnd;
        MSG msg;
        /* register window class */ = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
        wndClass.lpfnWndProc = WndProc;
        wndClass.cbClsExtra = 0;
        wndClass.cbWndExtra = 0;
        wndClass.hInstance = hCurrentInst;
        wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndClass.hbrBackground = NULL;	//GetStockObject(BLACK_BRUSH);
        wndClass.lpszMenuName = NULL;
        wndClass.lpszClassName = className;
        /* create window */
        hWnd = CreateWindow(
            className, windowName,
            winX, winY, winWidth, winHeight,
            NULL, NULL, hCurrentInst, NULL);
        /* display window */
        ShowWindow(hWnd, nCmdShow);
        /* process messages */
        while (GetMessage(&msg, NULL, 0, 0) == TRUE) {
        return msg.wParam;

    Yeah it can be a mess if you are a complete beginner, I guess when you first get used to it, it comes naturally.
    Anyways i actually got a program up and running using freeglut and all i need to do now is get some tutorials i can follow.

    So anyways thanks for your time it DID help still even though i had a solution, so much apprisiated and thumbed up! :D Thanks!
  3. In Topic: Advice on getting onwards?

    Posted 28 Mar 2014

    View Posttarmizi_adam2005, on 28 March 2014 - 12:00 AM, said:


    We all know that practice makes perfect. I would also add that consistency also makes perfect. Especially when programming. You already know the basics much but what is bothering you is the "pause". I have also been trough this kind of "pause" that distracted me (had to focus on my studies).

    If you already mastered the basics, what I would suggest is you now, do some kind of project of your own. Because you said you really liked game programming, then how about making your own game ? Do it consistently every day for say, 1 to 2 hours rather than sitting in front of your computer the whole day on weekends. Doing it consistently, would really help you improve your skills.

    Thank you for our advice. :)

    I guess i just have to get programming again. :)

    There is one thing though i still wonder about?

    i always find som advanced tutorial where people do crazy stuff that i never in my life seen, so how much more than the stuff on the list are there? of course there is a whole lot? but as far as i can tell you are pretty solid with that on the list? right? :D

    Anyways thanks again for the adivce, guess i'll go back to DirectX :D
  4. In Topic: VS-2012 won't compile when i add a .hlsl file?

    Posted 9 Jun 2013

    View Poststayscrisp, on 06 June 2013 - 05:27 AM, said:

    View Poststayscrisp, on 05 June 2013 - 03:32 PM, said:

    You can set the entry point for an HLSL file in its properties

    HLSL Compiler | Entrypoint Name

    Did you try this?

    It's clear that your shader file thinks that your entry point is main when it should be WinMain for a Win32 application.

    Sorry for not replying for some time, my computer died and had to get a replacement computer :(

    Anyways. Yes i did try to do this. Or atleast i tried to search for how to fix it and i found out that i had to set the hlsl files settings :) So i did this and removed the entry point for the hlsl file (thereby making it a compile from file, file ).

    I ran the code and the programm started up as it should :) displaying a blue dirx screne :)
    the only problem was that i think that it didn't compile my shader because it should (insted of just an blue scene) have displayed a lit cube?

    Anyways i guess i'll look more into the problem once i get my main computer repaired.

    So thanks for your help guys! :)
  5. In Topic: VS-2012 won't compile when i add a .hlsl file?

    Posted 5 Jun 2013

    View PostBBeck, on 05 June 2013 - 06:45 AM, said:

    Honestly, I have no idea what you've got going on there. But, I might take a stab at it.

    Did you overwrite your main .cpp file with another file? As you may know, there has to be a "main" function for the program to start. And (although I've never used anything higher than VS2010 and haven't coded in C++ for awhile) there should be a place in the project settings to define which file is the primary file that starts the whole thing off. And the compiler should look for the "main" function in that file to begin compiling and as the starting point for the program.

    If I'm misunderstanding what's going on forgive me. But if that is what's going on I would say don't use High Level Shader Language. High Level Shader Language is an advanced game/graphics topic that shouldn't be approached until you feel pretty confident at the intermediate level of game programming. And probably the intermediate level of 3D game programming as I'm not sure anyone really uses HLSL in 2D much except for advanced special effects... maybe.

    I know a lot of tutorial stuff gets into shading really early. I think that's kind of a mistake unless there is a tremendous amount of hand holding going on with it, since it really is a completely separate subject one must learn on top of game programming and it gets really deep into vector math really quick, which a lot of aspiring game programmers may not be well versed in.

    XNA with C# provides one of the easiest paths into HLSL I think. If you want to see a bare bones HLSL shader file I can produce one of those. Outside of that, you mostly have to know how to call the shader within the program. It's all the stuff you would normally do without the custom shader and then plus the call to the custom shader. If you have the option of built in shaders, use those until you are very familiar with using them before trying to write custom shaders.

    Anyway, maybe that's not what you have going on at all. If not, I apologize for any assumptions.

    You seem to be the closest to what i think is the problem.
    I've had some experiance in hlsl, and WinApp for some time now so things are going just fine.
    I've already made a few programms that ran just fine, displaying triangles and lit cubes etc.
    But the problem started when i switched to VS2012?
    So i guess i'll have to take a look at that file setting somehow :)

    Thanks for the help.

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information

Click here to e-mail me


Magn0733 hasn't added any friends yet.


Magn0733 has no profile comments yet. Why not say hello?