Results 1 to 10 of 179

Thread: nxPascal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    There's propably bug in your code. I get black screen and green rectangle with this code, using TButton and TTimer (enabled and 17 interval):
    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if not nx.Initialized then
        nx.CreateGlWindow(self);
    end;
    
    procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    begin
      nx.KillGLWindow;
    end;
    
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      if not nx.AllOK then exit;
      nx.Clear(true, true);
      nx.Enable2D(0, 0, nx.Width, nx.Height);
      nx.SetColor(0, 1, 0);
      nx.RectT(10, 10, 110, 110);
      nx.Disable2D;
      nx.Flip;
    end;
    It just took over 1 second to initialize on button click.

    Oh, if i recall the picking demo also uses onPaint event after onCreate? You need to do those in the click event too, and not when app initially does Paint first time.
    Last edited by User137; 29-01-2013 at 02:18 PM.

  2. #2
    Quote Originally Posted by User137 View Post
    Oh, if i recall the picking demo also uses onPaint event after onCreate? You need to do those in the click event too, and not when app initially does Paint first time.
    I dont use any TTimers, i use your picking demo as "core". TTimers are ugly.
    The most they can push out is 16ms, if even that. Your nxPascal uses better method: "game loop".
    I used also TTimer until i found nxPascal and now im happy user of game loop.

    I will try that onpaint thingy.

  3. #3
    OK, it works if i make it with OnPaint code. This looks fine to you? Add / remove anything?

    If i use this, do i still have to use the code in OnPaint or i can remove it from there now?
    Currently i commented this out in OnPaint. Seems to work fine.

    Code:
    procedure TfrmMain.InitEngine(Ctrl: TWinControl);
    begin
      if not nx.CreateGlWindow(ctrl) then
      begin
        ShowMessage('Failed to initialize OpenGL!'); Exit;
      end;
    
      // Create game
      if (game=nil) and nx.AllOK then begin
        game:=TGraphicalGame.Create;
        if not game.Initialized then begin
          FreeAndNil(game);
          showmessage('Game failed to initialize!');
          exit;
        end;
      end;
        
      pnlRenderResize(Self);
    end;
    I will use this now.

  4. #4
    1) Why do you need to reinitialize rendering context other way than usual, application start? Notice that you will lose all loaded textures when doing so. If TGraphicalGame was freed properly, it will recreate them in constructor as should. For something like using multiple "rendering windows", this sort of behavior is not needed at least. OpenGL can quickly switch between rendering contexts. That's again going to territory i haven't tested, and implementation differs on Delphi and Lazarus.

    2) You will be ok without the onPaint. In the constructor of TGraphicalGame, it might be calling CenterMouse() if you want to make for example FPS game, or space simulator like that picking demo. onFormCreate does not know much about window size and position yet, so it would give mouse a random "warp" effect at start... That's why TGraphicalGame should only be created once the window exists and is visible.
    For example, if form1.Position is poScreenCenter, it is only made effective at onPaint the earliest. onFormCreate and even onShow still don't know the real values.

  5. #5
    I don't care about reloading textures, i work with tiles of 64x64 and i have my own cache system that loads and deletes textures from memory, if they are needed, they are always automatically loaded. User wouldn't even notice that textures were removed or reloaded.

    I don't need to init OpenGL immediately in FormCreate if user opens the map, then i will init the opengl. Otherwise there is no point. For games this of course is fine, but im working on a map editor and not a game. I need to have control over things. The code in previous post works fine so i will use it.

    Of course for any game i will make i will leave things as you did in your examples. At least the initializing.
    But yes, for map editor i must do things differently.

  6. #6
    I don't know any map editor (or any other software) in existence which would discard rendering context Not even Starcraft 2 map editor when there is only trigger/script editor window open. Exception is fullscreen resolution change.

    At the meantime with nxPascal, work on Edit3D has continued. Solved the polygon picking and other matrix math for all cursor controls. Camera, objects and selected vertices can be moved and rotated. Selection with rectangle region, using gluProject(). Periodic fighting with small bugs etc... in editor code that is. It is very very rare occasion that i find bugs in nxPascal core. There are still 0 known ones.

  7. #7
    Is it possible to load "tex" textures from memory? (Pointer).
    Atm i see only "LoadFromFile" or "FileName" everywhere.
    If there isn't, you should add this possibility to load texture data from pointer.
    User will supply W, H and maybe transparency (on, off) and bits.

    I tried right now to mess with these NPOT textures to see how your engine handles that and im unable to load texture from pointer.
    I will temporarly try to load it from BMP and see how it works. If it will work..
    I tried to render something NPOT and i see only black box or even nothing. Dunno, maybe my code is faulty.
    But tile loading which are 64x64 is ok. I modified it for NPOT sprites.
    Last edited by hwnd; 20-02-2013 at 01:13 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •