Results 1 to 10 of 14

Thread: getting my stuff together

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    cool, that helped, for some reason i get an error with SDL from the compiler complaining about needing a unit and interface before "program" stuff and i dont even know what that is, guess its some of them fancy stuff from object oriented programming but OOP is out of my reach at least for this year

    so im actually downloading allegro.pas as i write to give it a try. sounds like one hell of a library and one hell of a project; id love to know what you mean by "there is pixel handling issues in windows", is it like it has problems working with single pixels or is it something with raster based stuff in general? id love to use allegro with my ubuntu installation but the free pascal compiler distributed in the software center is completely broken and i couldnt find a way to install it from rpm packages (yhea, im a n00b in linux too) so windows it is

  2. #2
    Quote Originally Posted by sacros View Post
    cool, that helped, for some reason i get an error with SDL from the compiler complaining about needing a unit and interface before "program" stuff and i dont even know what that is, guess its some of them fancy stuff from object oriented programming but OOP is out of my reach at least for this year
    Nope. It sounds like a basic level programming error, similar to this code would tell something crazy
    Code:
    then a=b if
    You'll always get help if you ask though, but then you need to refer the full error and part of the source code.

  3. #3
    thanks for the offer user137, i appreciate your help, i just wish you werent such an asshole with your " a=b " shit

    the problem is the compìler ask for "interface" or "unit" or "implementation" sections before the first line (?). note that i mimicked the code on the SDL tutorial on http://www.freepascal-meets-sdl.net/ (chapter 3) where it is assumed i dont need what im being asked plus it is supposed to work with the command line compiler IDE (which im using)

    since i only learned procedural pascal i dont know what an "interface" or "unit" or "implementation" is and as far as i know, the first line has always been "program program_name;"

    Code:
    program HelloSDL;    // the program intends to show a simple image on the screen
    USES SDL, CRT;     // as said, the problem is the compiler asks for an "interface" and "unit" section before this line
    
    VAR
    screen,picture:pSDL_SURFACE;
    source_rect,destination_rect:pSDL_RECT;
    
    BEGIN
    SDL_INIT(SDL_INIT_VIDEO);
    screen:=SDL_SETVIDEOMODE(423,400,32,SDL_SWSURFACE);
    IF screen=NIL THEN HALT;writeln('problem with the screen');
    
    picture:=SDL_LOADBMP('C:\Documents and Settings\briss\Escritorio\hello_image.bmp');
    IF picture=NIL THEN HALT;writeln('problem with the image');
    
    NEW(source_rect);
    source_rect^.x:=0;
    source_rect^.y:=0;
    source_rect^.w:=423;
    source_rect^.h:=400;
    NEW(destination_rect);
    destination_rect^.x:=0;
    destination_rect^.y:=0;
    destination_rect^.w:=423;
    destination_rect^.h:=400;
    
    REPEAT
      SDL_BLITSURFACE(picture,source_rect,screen,destination_rect);
      SDL_FLIP(screen);
    UNTIL keypressed;
    
    SDL_FREESURFACE(picture);
    SDL_FREESURFACE(screen);
    
    DISPOSE(source_rect);
    DISPOSE(destination_rect);
    
    SDL_QUIT;
    END.
    well, it would be great if you help me make it work, i was planning on checking out allegro pascal tonight anyways so no big deal if i dont get any solution

  4. #4
    Hmm, for console application that code looks valid. Normal pascal units have code structured like this:
    Code:
    unit MyUnit;
    interface
    uses ... 
    type
      ...
    implementation
    uses ...
    
    code...
    So for whatever reason, the compiler is treating your program as normal unit. Is it really the only file in the project, or how is it structured? What command did you use to compile it, or are you using Lazarus?

  5. #5
    For me the code compiles perfectly fine. As User137 already asked - are you using command line, or Lazarus? The other thing I'd suggest is taking a look whether the SDL .pas files are not bugged somehow, or if there aren't any additional files named HelloSDL laying around that the compiler might grab.

    And btw, an advice for the SDL code - it can be easier if you use TSDL_Rects, and use the @ operator to create a pointer for the BlitSurface routine.

  6. #6
    Quote Originally Posted by Super Vegeta View Post
    For me the code compiles perfectly fine. As User137 already asked - are you using command line, or Lazarus? The other thing I'd suggest is taking a look whether the SDL .pas files are not bugged somehow, or if there aren't any additional files named HelloSDL laying around that the compiler might grab.

    And btw, an advice for the SDL code - it can be easier if you use TSDL_Rects, and use the @ operator to create a pointer for the BlitSurface routine.
    whoa! you solved my problem, guess what the name of my file was: SDL.pas; I didnt even know stuff worked like that, i installed the library via an installation wizard - so the compiler was assuming i was talking about the library .pas. Ill also look into which kind of sorcery is that @ operator and TSDL_Rects

    now everything has turned color pink! not...new error, the code above now stops in the line:

    Code:
    screen:=SDL_SETVIDEOMODE(423,400,32,SDL_SWSURFACE);
    IF screen=NIL THEN HALT;writeln('problem with the screen');
    i also get the output "problem with the screen" so maybe there is a problem with the SDL_SETVIDEOMODE procedure? why nothing ever works at this rate im nevar gon build stuf

  7. #7
    I asume you skiped first two chapters wich explain what is needed to be done to sucsesfully initialize SDL. SO i recomend to read them one by one, becouse only this way you will manage to get things going.
    Probably the cuse of the problem in your case is that your program can't find path to sdl.dll dynamic library wich is requred for SDL to work at all. So make sure that sdl.dll is either inside your projects directory or somwhere on the system path, "C:\Windows\System32" for instance.

  8. #8
    Quote Originally Posted by sacros View Post
    id love to know what you mean by "there is pixel handling issues in windows", is it like it has problems working with single pixels or is it something with raster based stuff in general?
    The OpenGL raster does work, I mean you can use all "gl..." procedures and it will work, but Allegro.pas 5 "software raster" (i.e. the "al_..." procedures) does fail if you try to draw pixels (al_draw_pixel) or text (al_draw_text, etc.) but it doesn't fail if you draw lines (al_draw_line).

    It isn't a big problem because you can do all graphic drawing using OpenGL but then you can't create textures or modify them on the fly (you can still load them from disk, anyway). On Linux it works without problem.

    Allegro.pas 4 does work both Windows and Linux without problem, but it doesn't allows OpenGL.
    Last edited by Ñuño Martínez; 19-03-2012 at 11:00 PM.
    No signature provided yet.

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
  •