Jump to content

Vida Marcell

Members
  • Posts

    320
  • Joined

  • Last visited

Posts posted by Vida Marcell

  1. I'm trying to rotate an object in its local space in OpenGL
     

    glm::mat4 model = glm::mat4(1.0f);
    model = glm::rotate(model, glm::radians(75.0f), glm::vec3(1.0f, 0.0f, 0.0f));
    model = glm::rotate(model, glm::radians(75.0f), glm::vec3(0.0f, 1.0f, 0.0f));
    model = glm::rotate(model, glm::radians(75.0f), glm::vec3(0.0f, 0.0f, 1.0f));

    The proglem is when i rotate the object around its X axis, the rotations after that will rotate it on global coordinates...

  2. For example, if someone makes a 3d modeling software, how is he going to separate the front-end code form back-end code. I always coded UAK apps in one file, and now its getting complex, i want to have a 3d viewer in one of the panels, and i already got the ui, but i dont want to write everything in one cpp file.

  3. I'm currently working with dlls in c++, and the first thing i noticed is this function __declspec(dllexport/import). There isn't too much explanations for it, but i think, the export if for making a function usable by other software that can acess the dll file, and the import is for the software to call a function from the dll? Am i correct?

  4. I want to be short, so i have a project manager, it can create and open projects. When creating it creates an xml file with properties like name, date, ect..

    But i have problems with opening, whenever i launch it, i want it to read all the projects from a txt file where in every line a path leads to their xml file, and i load it into a listbox.

    How do i detect that there are already text in a line? And if i want to delete a project from the manager (so also from the listbox) how do i know wich line should i delete?

  5. If i want to create 2 windows in 2 separate cpp files i get an error message saying "symbols already existing", when i rename every component (for example window->nwindow, ui->nui, displays->ndisplays) i only get 1 window opened, and its the original window, so not the one i modifyed.

  6. I'm trying to make a Directx 9 context in UAK based on this tutorial: http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-1

    And so far so good, but then this happens: (this is the only syntax problem)

    image.png.3a519370515cc386e3db72f8b3d39fd8.png

    here is my code:

    #include "UltraEngine.h"
    #include <d3d9.h>
    
    using namespace UltraEngine;
    
    // include the Direct3D Library file
    #pragma comment (lib, "d3d9.lib")
    
    // global declarations
    LPDIRECT3D9 d3d;    
    LPDIRECT3DDEVICE9 d3ddev;
    
    // function prototypes
    void initD3D(HWND hWnd);
    void render_frame(void);
    void cleanD3D(void);
    
    // Callback function for resizing the viewport
    bool ResizeViewport(const Event& ev, shared_ptr<Object> extra)
    {
        // If the window resize event is captured
        auto window = ev.source->As<Window>();
    
        // Get the new size of the applications window
        iVec2 sz = window->ClientSize();
    
        return true;
    }
    
    int main(int argc, const char* argv[])
    {
    
        HWND hWnd;
    
        // Get the available displays
        auto displays = GetDisplays();
    
        // Create a window
        auto window = CreateWindow("OpenGL Example", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CENTER);
    
        // Create user interface
        auto ui = CreateInterface(window);
    
        // Get the size of the user-interface
        iVec2 sz = ui->root->ClientSize();
    
        // Initialize an OpenGL context (get a hdc)
        HWND hwnd = (HWND)(window->GetHandle());
        HDC hdc = GetDC(hwnd);
    
        // set up and initialize Direct3D
        initD3D(hWnd);
    
        // Render loop (applications run loop)
        while (true)
        {
            // Check for events
            const Event ev = WaitEvent();
    
            switch (ev.id)
            {
            case EVENT_WINDOWPAINT:
                if (ev.source == window)
                {
                    // Get and set the current size of the viewport
                    iVec2 sz = window->ClientSize();
                    if (sz.x < 1 or sz.y < 1) break;
    
                    HWND hwnd = window->GetHandle();
                    auto hdc = GetDC(hwnd);
                    SwapBuffers(hdc);
                    ReleaseDC(hwnd, hdc);
                }
                break;
    
            case EVENT_WINDOWCLOSE:
                if (ev.source == window)
                {
                    return 0;
                }
                break;
            }
    
            render_frame();
    
        }
    
        // clean up DirectX and COM
        cleanD3D();
    
    
        // this function initializes and prepares Direct3D for use
        void initD3D(HWND hWnd)
        {
            d3d = Direct3DCreate9(D3D_SDK_VERSION);    // create the Direct3D interface
    
            D3DPRESENT_PARAMETERS d3dpp;    // create a struct to hold various device information
    
            ZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use
            d3dpp.Windowed = TRUE;    // program windowed, not fullscreen
            d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
            d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D
    
    
            // create a device class using this information and the info from the d3dpp stuct
            d3d->CreateDevice(D3DADAPTER_DEFAULT,
                D3DDEVTYPE_HAL,
                hWnd,
                D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                &d3dpp,
                &d3ddev);
        }
    
    
        // this is the function used to render a single frame
        void render_frame(void)
        {
            // clear the window to a deep blue
            d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
    
            d3ddev->BeginScene();    // begins the 3D scene
    
            // do 3D rendering on the back buffer here
    
            d3ddev->EndScene();    // ends the 3D scene
    
            d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
        }
    
    
        // this is the function that cleans up Direct3D and COM
        void cleanD3D(void)
        {
            d3ddev->Release();    // close and release the 3D device
            d3d->Release();    // close and release Direct3D
        }
    
        return 0;
    }

     

×
×
  • Create New...