Page 9 of 18 FirstFirst ... 7891011 ... LastLast
Results 81 to 90 of 179

Thread: nxPascal

  1. #81
    New SVN version of nxPascal was just uploaded. Among many additions, i did the font saving and loading to file. 1024x1024 texture size courier font loaded up in 30ms... Yeah, that's 3 times faster than it generates a 256x256 font, and 1024 is so big font you rarely need it. The compression stream made font file size to 30kb. To make new font, do:
    Code:
    var f: TGLFont;
    ...
      f:=TGLFont.CreateBMPAndSave('Courier', 50, 1024, 'courierBig.nxf');
      // File extension doesn't matter. Use .nxf for clarity i guess.
      f.Free;
    Loading goes simply:
    Code:
    nx.LoadFont('courierBig.nxf');
    Last edited by User137; 20-11-2012 at 09:49 PM.

  2. #82
    @User137 perfect, thanks

    @Full screen discussion, ok ok, maybe I'm thinking too anachronistic

  3. #83
    Hey, i tried to do the windowed fullscreen mode and it worked. Just need to do things in this order:
    Code:
      BorderStyle:=bsNone;
      WindowState:=wsMaximized;
      nx.CreateGlWindow(self);
    If you do nx.CreateGlWindow() before those 2 lines, you need to KillGLWindow and CreateGlWindow again or you get white textures. And i'm not entirely sure if already loaded textures will remain loaded, or if you have to load them again. Who knows that might depend on graphics card. You are basically resetting rendering context so...

    Above code will simply make game window fill the entire screen (not even taskbar shows, until alt+tab). It can't alter the resolution. For that you can use scaling of the graphics. In the end what matters is how many things you draw. You can make a 320x200 picture fill the entire 1680x1050 screen, and disable linear filtering to get that retro-look, if needed. Not sure if i explained that in wiki, but it's done with:
    Code:
    uses ... , dglOpenGL;
    ...
      tex.TextureQuality:=GL_NEAREST; // Blocky textures
      tex.TextureQuality:=GL_LINEAR; // Smooth textures
    It is a mode that must be set before loading 1 or more textures, and can be changed per each one.
    Last edited by User137; 23-11-2012 at 11:06 AM.

  4. #84
    Not too many news on nxPascal this time, very busy with school things, at least in theory.

    3D-Editor is progressing bit by bit. There is already 1 old version i made with Delphi, but i want to redo it with Lazarus along with many new features. Just vague list of things in progress and to come:
    - Saving and loading all nxPascal supported model formats - done.
    - Loading many models at the time, and creating multiple instances of them in the scene - done, just for viewing.
    - Interface design is big ongoing work, deciding on how to access each feature easiest way. That's maybe the hardest part.

    I had 1 setback that loading the demo ship model took about 20 seconds when debugging, but 1 second when run on .exe, but that's fixed now.
    Note to self: Do NOT! Ever! ..check "Generate code for valgrind (-gv)" in project options.

    Always looking for more developers to assist with coding too.

  5. #85
    Hey.

    Atm in your picking demo the engine is initialized in FormCreate event.
    But i want to init it by button click. But for some reason it doesn't work. If i move
    Code:
    if not nx.CreateGlWindow(self) then begin
        showmessage('Failed to initialize OpenGL!'); exit;
      end;
    to Button1Click event and click the button, nothing happens, it does something but the black screen doesn't appear (i.e OpenGL doesn't initialize) but if i move this to FormCreate, i run the app and get that black screen without problems (OpenGL initialized fine).

    If i shut down the engine in my buttonclick with
    Code:
      if game<>nil then FreeAndNil(game);
      nx.KillGLWindow;
    and then call
    Code:
    if not nx.CreateGlWindow(self) then begin
        showmessage('Failed to initialize OpenGL!'); exit;
      end;
    Then it initializes also with ButtonClick.
    Why is that?
    What's so special about FormCreate?

    Initializing the engine in formcreate and then shutting down again to init it again when user opens a map is not way to go for me.

    Is this a bug?

  6. #86
    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.

  7. #87
    Quote Originally Posted by hwnd View Post
    Hey.

    Atm in your picking demo the engine is initialized in FormCreate event.
    But i want to init it by button click. But for some reason it doesn't work. If i move
    Code:
    if not nx.CreateGlWindow(self) then begin
        showmessage('Failed to initialize OpenGL!'); exit;
      end;
    to Button1Click event and click the button, nothing happens, it does something but the black screen doesn't appear (i.e OpenGL doesn't initialize) but if i move this to FormCreate, i run the app and get that black screen without problems (OpenGL initialized fine).
    Wait doesn't "self" in Button-s OnClick event points to the buton which fired that OnClick event? From what I see you are trying to force nxPascal to use TButtom as rendering targe which probably won't work.
    Try replacing "self" with the name of your Form. For instance:
    Code:
    if not nx.CreateGlWindow(MainForm) then begin
        showmessage('Failed to initialize OpenGL!'); exit;
      end;
    NOTE: This is just my speculation (haven't got any real expirience with nxPascal) so it might not work.

  8. #88
    Quote Originally Posted by SilverWarior View Post
    Wait doesn't "self" in Button-s OnClick event points to the buton which fired that OnClick event? From what I see you are trying to force nxPascal to use TButtom as rendering targe which probably won't work.
    Try replacing "self" with the name of your Form.
    Nope, it is TForm1.Button1Click(Sender: TObject); so self refers to main form variable (Sender refers to Button1). But good point. nxPascal uses form information to use it as parent to TLazOpenGLContext, and copy onMouseMove events and so on from TForm to the context. (Delphi implementation differs internally, cause it doesn't have the context component at all.)
    Last edited by User137; 29-01-2013 at 03:06 PM.

  9. #89
    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.

  10. #90
    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.

Page 9 of 18 FirstFirst ... 7891011 ... LastLast

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
  •