Forum > OpenGL

Help (OpenGL-FPC) with the graphic of the view of two polygons in 3D

<< < (2/2)

carlejt:
I have followed the example TEXTURES Tutorial OpenGL but I can not compile it. I have the library glut32.dll.

This is the example TEXTURES del tutorial OpenGL:



--- Code: ---
program textures;

{$mode objfpc}{$H+}

uses
  gl, glu, glut, ImagingOpenGL;

const
  AppWidth = 640;
  AppHeight = 480;
  LIST_OBJECT = 1;
 
var
  Tex1, Tex2: GLuint;
 
procedure InitializeGL;
begin
  glClearColor(0, 0, 0, 0);
  Tex1 := LoadGLTextureFromFile('ashwood.bmp');
  Tex2 := LoadGLTextureFromFile('Flare.bmp');
  glEnable(GL_TEXTURE_2D);
end;

procedure CreateList;
begin
  glNewList(LIST_OBJECT, GL_COMPILE);
    glBegin(GL_QUADS);
      glTexCoord2f(1, 0);
      glVertex3f( 2, 2, 0);
      glTexCoord2f(0, 0);
      glVertex3f(-2, 2, 0);
      glTexCoord2f(0, 1);
      glVertex3f(-2,-2, 0);
      glTexCoord2f(1, 1);
      glVertex3f( 2,-2, 0);
    glEnd;
  glEndList;
end;

procedure DrawGLScene; cdecl;
begin
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);

  glLoadIdentity;
  glTranslatef(-5, 0, -15);
  glBindTexture(GL_TEXTURE_2D, Tex1);
  glCallList(LIST_OBJECT);

  glLoadIdentity;
  glTranslatef(0, 0, -15);
  glBindTexture(GL_TEXTURE_2D, Tex2);
  glCallList(LIST_OBJECT);

  glLoadIdentity;
  glTranslatef(5, 0, -15);
  glBindTexture(GL_TEXTURE_2D, Tex1);
  glCallList(LIST_OBJECT);

  glEnable(GL_BLEND);
  glBlendFunc(GL_ZERO, GL_SRC_COLOR);
  glLoadIdentity;
  glTranslatef(5, 0, -15);
  glBindTexture(GL_TEXTURE_2D, Tex2);
  glCallList(LIST_OBJECT);
  glDisable(GL_BLEND);

  glutSwapBuffers;
end;

procedure ReSizeGLScene(Width, Height: Integer); cdecl;
begin
  if Height = 0 then
    Height := 1;

  glViewport(0, 0, Width, Height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;
  gluPerspective(45, Width / Height, 0.1, 1000);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity;
end;

procedure GLKeyboard(Key: Byte; X, Y: Longint); cdecl;
begin
  if Key = 27 then
  begin
    glDeleteLists(LIST_OBJECT, 1);
    Halt(0);
  end;
end;

procedure glutInitPascal(ParseCmdLine: Boolean);
var
  Cmd: array of PChar;
  CmdCount, I: Integer;
begin
  if ParseCmdLine then
    CmdCount := ParamCount + 1
  else
    CmdCount := 1;
  SetLength(Cmd, CmdCount);
  for I := 0 to CmdCount - 1 do
    Cmd[I] := PChar(ParamStr(I));
  glutInit(@CmdCount, @Cmd);
end;

var
  ScreenWidth, ScreenHeight: Integer;
begin
  glutInitPascal(True);
  glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB or GLUT_DEPTH);
  glutInitWindowSize(AppWidth, AppHeight);
  ScreenWidth := glutGet(GLUT_SCREEN_WIDTH);
  ScreenHeight := glutGet(GLUT_SCREEN_HEIGHT);
  glutInitWindowPosition((ScreenWidth - AppWidth) div 2, (ScreenHeight - AppHeight) div 2);
  glutCreateWindow('OpenGL Tutorial :: Textures');

  InitializeGL;
  CreateList;

  glutDisplayFunc(@DrawGLScene);
  glutReshapeFunc(@ReSizeGLScene);
  glutKeyboardFunc(@GLKeyboard);

  glutMainLoop;
end.

--- End code ---


Anyone know where to find these examples with the Vampyre Imaging Library units for Free Pascal.

On page

http://imaginglib.sourceforge.net/index.php?page=down

Downloaded the Imaging0.26.4. What are the units for free pascal for compile the code TEXTURES?

Not only is the unit ImagingOpenGL.

Carver413:
I'm assuming that this is some sort of school project and that learning modern opengl is not really on the agenda. so here is a site that should help you learn the older more user friendly opengl that most of us grew to love. 
http://www.freepascal-meets-sdl.net/
also you should check out this site as many people there use sdl and opengl
http://www.pascalgamedevelopment.com/

Navigation

[0] Message Index

[*] Previous page

Go to full version