Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 991021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:02:23+00:00 2026-05-16T06:02:23+00:00

I was wondering if there was any tutorial that introduces 3D Graphics theory while

  • 0

I was wondering if there was any tutorial that introduces 3D Graphics theory while showing relevant code, without using OpenGL or DirectX or something. I’m very comfortable with engineering math (I’m an A/V DSP student, so I work with a lot of math all the time).

Most of the tutorials I see either show me the same old matrix translation/rotation examples, along with a discussion on projections and show me using similar triangles how projections work or assume you know everything about 3D or just use a bunch of OpenGL primitives. I’ve ordered a book (Interactive Computer Graphics: A Top-Down Approach) on the topic but I’d like to get started right now.

I’d really like something that just worked with an SDL surface or a Java Graphics2D object and just used matrix math to render everything. I was hoping to be able to do some simple stuff, like rendering some simple shapes before the book arrived. Ideally something that introduced topics and gave coded examples on how they worked.

EDIT: All the answers were great, but I just loved the code. Exactly what I was looking for, even if it was in Pascal 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:02:24+00:00Added an answer on May 16, 2026 at 6:02 am

    Buried out some old pascal source 😀 About 14 years ago, I used it for displaying very simple 3d objects. xrot, yrot, zrot are to rotate points ([x,y,z] multiplied by rotation matrix). And I used a very simple 3d-to-2d-transformation, based on vanishing-point projection with the vanishing-point at the middle of the screen. As an example, there is a vertex array defined. You also have to add a trigons array.

    const depth = 1500;
          deg = pi / 180;
    
          { some vertices for a dice :) }
          vertices:array[0..23] of real= (50, 50, 50,       { 0}
                                     -50, 50, 50,       { 1}
                                      50,-50, 50,       { 2}
                                     -50,-50, 50,       { 3}
                                      50, 50,-50,       { 4}
                                     -50, 50,-50,       { 5}
                                      50,-50,-50,       { 6}
                                     -50,-50,-50,       { 7}
                                      );
    
    { transform 3d coordinates to pixel coordinates }
    procedure 3d_to_2d(x, y, z : real; var px, py : longint);
     var k:real;
    begin
     k:=((depth shr 1)+z)/depth;
     px:=(getmaxx shr 1)+trunc(x*k);      { getmaxx is the width of the screen }
     py:=(getmaxy shr 1)+trunc(y*k);      { getmaxy is the height of the screen }
    end;
    
    { rotate around the x axis by rx degrees }
    procedure xrot(var x,y,z:real;rx:integer);
     var x1,y1,z1:real;
    begin
     y1:=(y * cos(rx * deg))+(z* (sin(rx * deg)));
     z1:=(-y* sin(rx * deg))+(z* (cos(rx * deg)));
     y:=y1; z:=z1;
    end;
    
    { rotate around the y axis by ry degrees }
    procedure yrot(var x,y,z:real;ry:integer);
     var x1,y1,z1:real;
    begin
     x1:=(x * cos(ry * deg))+(z*(sin(ry * deg)));
     z1:=(-x * sin(ry * deg))+(z*(cos(ry * deg)));
     x:=x1; z:=z1;
    end;
    
    { rotate around the z axis by rz degrees }
    procedure zrot(var x,y,z:real; rz:integer);
     var x1,y1,z1:real;
    begin
     x1:=(x* cos(rz * deg))+(y*(sin(rz * deg)));
     y1:=(-x* sin(rz * deg))+(y*(cos(rz * deg)));
     x:=x1; y:=y1;
    end;
    

    For filled trigons, I used a friend’s function, which draws the shape using horizontal lines (Hline(x,y,width, color)):

        TYPE pt=RECORD x,y:LongInt;END;  
    
    PROCEDURE Tri(P:ARRAY OF pt;co:BYTE);
    VAR q,w:INTEGER;
        S:pt;
        f12,f13,f23:LongInt;
        s1,s2:LongInt;
    
    
    BEGIN
    
      IF p[0].y>p[2].y THEN BEGIN s:=p[0];p[0]:=p[2];p[2]:=s;END; { sort the points }
      IF p[0].y>p[1].y THEN BEGIN s:=p[0];p[0]:=p[1];p[1]:=s;END;
      IF p[1].y>p[2].y THEN BEGIN s:=p[1];p[1]:=p[2];p[2]:=s;END;
    
      q:=(p[0].y-p[1].y); { y distance between point 0 and 1 }
      IF q<>0 THEN f12:=LongInt((p[0].x-p[1].x) shl 6) DIV q ELSE f12:=0;
    
      q:=(p[0].y-p[2].y);
      IF q<>0 THEN f13:=LongInt((p[0].x-p[2].x) shl 6) DIV q ELSE f13:=0;
    
      q:=(p[1].y-p[2].y);
      IF q<>0 THEN f23:=LongInt((p[1].x-p[2].x) shl 6) DIV q ELSE f23:=0;
    
      s1:=p[0].x shl 6;s2:=s1;
      FOR q:=p[0].y TO p[1].y DO
      BEGIN
        Hline(s1 shr 6,s2 shr 6,q,co);
        s1:=s1+f12;
        s2:=s2+f13;
      END;
      s1:=p[2].x shl 6;s2:=s1;
      FOR q:=p[2].y DOWNTO p[1].y DO
      BEGIN
        Hline(s1 shr 6,s2 shr 6,q,co);
        s1:=s1-f23;
        s2:=s2-f13;
      END;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering if there are any well-known algorithms that I should be aware
Wondering if there is any Text to Speech software available as a plug in
Wondering if there's any not-too-hard way to edit non-form text in html 4. I
Just wondering if there is any way (in C) to get the contents of
I was wondering if there are any alternatives to Microsoft's SQL Server Management Studio?
i'm wondering if there is any nice and neat tool to replace the GNU
I was wondering if there is any way to escape a CDATA end token
I'm wondering if there are any architectural frameworks out there to create desktop or
I'm wondering if there are any simple ways to get a list of all
I am wondering if there is any way to list all the calls to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.