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

Reputation: 4 Apprentice
Active Members
Active Posts:
53 (0.09 per day)
04-April 13
Profile Views:
Last Active:
User is offline Sep 28 2014 03:26 PM

Previous Fields

Dream Kudos:
Icon   Magn0733 has not set their status

Posts I've Made

  1. In Topic: Sierpinski's Fractal Triangle.

    Posted 28 Sep 2014

    Problem solved!!! :D

    heres the code for anyone who's having the same problem as me.
    from swampy.TurtleWorld import *
    world = TurtleWorld()
    bob = Turtle()	
    bob.delay = 0.0
    print bob
    def Triangle(turt, len):
    	for i in range(3):
    		fd(turt, len)
    		lt(turt, 120)		
    def SierpinskiTri(turt, len, depth):
    	if depth == 0: #basecase
    		Triangle(turt, len)
    	else:	#logic
    		for i in range(3):
    			#Triangle(turt, len)
    			fd(turt, 2**depth*len)
    			lt(turt, 120)
    			SierpinskiTri(turt, len, depth - 1)
    fd(bob, 500)
    SierpinskiTri(bob, 3, 8)
  2. In Topic: Sierpinski's Fractal Triangle.

    Posted 28 Sep 2014

    I've already done this and i can do it to a depth of 4.

    Heres how in pseudocode:

    def triangle(length):
    for i in range(3)
       if i != 2: 
           forward(length * 2)
    def SierpinskiTriangle(len, depth1, depth2):
       if depth == 0: return
       index = depth2 - depth1
       for i in range(3):
           if index == 0:
              forward(len * 2)
        if index == 1:
           forward( 2 * lenth)
           fd( 2 * length
        SierpinskiTriangle(length, depth1, depth2)

    Now i can do the index steps again and again manually and that way increase the depth.
    But i can not figure out a way to do it so that is is n depth and not a fixed amount that is hardcoded in :S

    Please help. :)
  3. In Topic: Decimal to floating point.

    Posted 25 Sep 2014

    View Postragmar, on 25 September 2014 - 07:45 AM, said:

    0.7 * 2 = 1.4 here you hold on 1 and keep on multiplying the rest decimal
    0.4 * 2 = 0.8 here you hold on 0 and keep on multiplying the rest decimal
    0.8 * 2 = 1.6 here you hold on 1 and keep on multiplying the rest decimal
    0.6 * 2 = 1.2 here you hold on 1 and keep on multiplying the rest decimal
    0.2 * 2 = 0.4 here you hold on 0 and keep on multiplying the rest decimal
    0.4 * 2 = 0.8 here you hold on 0 and keep on multiplying the rest decimal
    0.8 * 2 = 1.6 here you hold on 0 and keep on multiplying the rest decimal

    from this point you can see that it is repeating the pattern and you can stop multiplying
    0.6 * 2 = 1.2 here you hold on 0 and keep on multiplying the rest decimal
    and you start assembling your bits from left to right

    since for 11 is 1011 and for .7 is 1011000
    and your answer will be 1011.1011000

    Thank you for your time. I could see we learned another way of doing this and i have figured it out now (with the helo of some nice class mates).

    Anyways thanks again for taking the time to help me. :)
  4. 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
  5. 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!

My Information

Member Title:
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?