DOS graphics with dev-cpp??

This is a discussion on DOS graphics with dev-cpp?? within the Game Programming forums, part of the General Programming Boards category; Hi, I think I am the newest newbee on the block here, and want to do simple 2d modeling. You ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    1

    DOS graphics with dev-cpp??

    Hi,

    I think I am the newest newbee on the block here, and want to do simple 2d modeling. You know, produce rotating orbs, triangles, that stuff.

    But... I don't know anything. I know Visual Basic language, and I know a bit C++. I want to continue in the C++ for the modeling. I have downloaded Dev-C++ (bloodshed) and thought I could do some modeling in that.

    But silly girl that I am, I don't even know where to start!!
    What I really need, is a tutorial that says to me:
    1. open dev-cpp
    2. make a new project
    3. take this kind of project (window app, console app, etc)
    4. type this code in, and explains all about what the code does

    Just to give me some examples, to start of with. I don't have to be programming beautiful stuff within one week, but i don't even know which programs to use, which links to make. Heard someone talking about BGI, don't have a clue what they are talking about.

    So... I'm a real newbe, they don't get newer. And i'm very in need of a tutorial or extended advice..

    Anyone can help me?

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    hey there..
    i dont know much bout dev c++ as i have not worked with it....but if u are tryin to work with dos graphics.....then i think that u need to know c++ kinda throughly well....in c++,u ll have to initialize the graphics section by using the initgraph() function...the parameters that it takes can be found in the help section....u will have to specify the location of the egavga.bgi file as the last parameter i think...the file is required for the initialization of graphics....
    neways...hope u find solace in coding.....lol.......

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Well I'm not sure about your IDE of choice as I do not use it. If you want to use DOS then the compiler must support interrupts and DOS programs. MSVC does not, but I'm not sure about Dev-C.

    As far as rotating and scaling these will do the trick. I will write them in Visual Basic code.

    Code:
    type point3D
      x as single
      y as single
      z as single
    end type
     
    type ipoint2D
      x as integer
      y as integer
    end type
     
     
    type vertex3D
      model as point3D
      world as point3D
      view as point3D
      scrn as point2D
      tex as point2D
    end type
     
    type object3D
      verts() as vertex3D
      numverts as long
      
      vertindices() as integer
      numindices as integer
       
      position as point3D
      mrotation as point3D
      wrotation as point3D
     
    end type
     
    '0-based arrays
    option base 0
     
     
    sub SetRotationZ(angle as single,matrix[4][4] as single)
      'angle is specified in radians
      'radians = (degrees*PI/180)
     
      'Setup Z rotation matrix
      matrix[0][0]=cos(angle)
      matrix[0][1]=-sin(angle)
      matrix[1][0]=sin(angle) 
      matrix[1][1]=cos(angle)
     
      matrix[0][2]=0:matrix[0][3]=0
      matrix[1][2]=0:matrix[2][3]=0
      matrix[2][0]=0:matrix[2][1]=0:matrix[2][2]=1:matrix[2][3]=0
      matrix[3][0]=0:matrix[3][1]=0:matrix[3][2]=0:matrix[3][3]=1
     
    end sub
     
     
    sub MatrixMultiply(m1[4][4] as single,m2[4][4] as single,result[4][4] as single)
     
      for i=0 to 3 step 1
    	for j=0 to3 step 1
    	  result[i][j]=0
    		for k=0 to 3 step 1
    		  result[i][j]=m3[i][j]+(m1[i][k]*m2[k][j])
    		next
    	next
      next
     
    end sub
     
     
    sub ModelToWorld(verts() as vertex3D,numverts as long,matrix[4][4] as single)
     
      dim i as long
      for i=0 to numverts
    	mx=verts(i).model.x
    	my=verts(i).model.y
    	mz=verts(i).model.z
     
    	wx=mx*matrix[0][0]+my*matrix[1][0]+mz*matrix[2][0]+matrix[3][0]
    	wy=mx*matrix[0][1]+my*matrix[1][1]+mz*matrix[2][1]+matrix[3][1]
    	wz=mx*matrix[0][2]+my*matrix[1][2]+mz*matrix[2][2]+matrix[3][2]
     
    	'Discard w for now
    	verts(i).world.x=wx
    	verts(i).world.y=wy
    	verts(i).world.z=wz
      next
     
    end sub
     
     
    sub WorldToView(verts() as vertex3D,numverts as long,matrix[4][4] as single)
     
      dim i as long
      for i=0 to numverts
    	wx=verts(i).world.x
    	wy=verts(i).world.y
    	wz=verts(i).world.z
     
    	vx=wx*matrix[0][0]+wy*matrix[1][0]+wz*matrix[2][0]+matrix[3][0]
    	vy=wx*matrix[0][1]+wy*matrix[1][1]+wz*matrix[2][1]+matrix[3][1]
    	vz=wx*matrix[0][2]+wy*matrix[1][2]+wz*matrix[2][2]+matrix[3][2]
     
    	'Discard w for now
    	verts(i).view.x=wx
    	verts(i).view.y=wy
    	verts(i).view.z=wz
      next
    end sub
     
     
    sub SetTranslation(dx as single,dy as single,dz as single,matrix[4][4] as single)
     
      matrix[3][0]=dx
      matrix[3][1]=dy
      matrix[3][2]=dz
      matrix[3][3]=1
     
      matrix[0][0]=1:matrix[0][1]=0:matrix[0][2]=0:matrix[0][3]=0
      matrix[1][0]=0:matrix[1][1]=1:matrix[1][2]=0:matrix[1][3]=0
      matrix[2][0]=0:matrix[2][1]=0:matrix[2][2]=1:matrix[1][3]=0
     
    end sub
     
     
    sub SetScaling(sx as single,sy as single,sz as single,matrix[4][4] as single)
     
      matrix[0][0]=sx
      matrix[1][1]=sy
      matrix[2][2]=sz
      matrix[3][3]=1
     
      matrix[0][1]=0:matrix[0][2]=0:matrix[0][3]=0
      matrix[1][0]=0:matrix[1][2]=0:matrix[1][3]=0
      matrix[2][0]=0:matrix[2][1]=0:matrix[2][3]=0
      matrix[3][0]=0:matrix[3][1]=0:matrix[3][2]=0
     
    end sub
     
     
    sub MatrixIdentity(matrix[4][4] as single)
     
       matrix[0][0]=1:matrix[1][0]=0:matrix[2][0]=0:matrix[3][0]=0
       matrix[0][1]=0:matrix[1][1]=1:matrix[2][1]=0:matrix[3][1]=0
       matrix[0][2]=0:matrix[1][2]=0:matrix[2][2]=1:matrix[3][2]=0
       matrix[0][3]=0:matrix[1][3]=0:matrix[2][3]=0:matrix[3][3]=1
     
    end sub
     
    sub Project(verts() as vertex3D,numverts as long,disttoplane as single,cx as integer,cy as integer)
     
      for i=0 to numverts
    	 vx=verts(i).view.x
    	 vy=verts(i).view.y
    	 vz=verts(i).view.z
     
    	 sx=(vx*disttoplane)/vz+cx
    	 sy=(vy*disttoplane)/vz+cy
     
    	 verts(i).screen.x=sx
    	 verts(i).screen.y=sy
      next
     
    end sub
    To use this as a 2D system set all you z vertex components to 1.

    Here is one way to use this:

    1. Create an object of type object3D
    2. Create your vertexes for your object or load them from disk
    3. Create your indices for this object or load from disk
    4. Create a master transformation matrix
    5. Call translation function to set position in world space
    6. Call scaling function to set scale factors in world space
    7. Call rotation function to rotate object in model space
    8. Do rotation*scaling*translation and store in matrix
    9. Pass model's vertexes and the matrix from step 8 to ModelToWorld
    10. Call rotation function to rotate object in world space (like earth orbiting sun)
    11. Set master matrix to identity
    12. Translate, rotate, scale object in view space by calling correct function
    13. Do rotation*scaling*translation and store in matrix
    14. Pass model's vertexes and the matrix from step 13 to WorldToView
    15. Compute projection plane
    16. Do clipping on model vertexes
    17. Call Project with model's vertexes, distance to plane of projection, center of screen on x and y
    18. Draw clipped object in screen space using scrn coordinates from step 17
    19. Draw lines from verts(indices) to verts(indices+1).


    Note that this pseudo graphics pipeline leaves out z buffering, texturing, lighting, rasterization, clipping, etc., etc. It is extremely primitive. But you can use it for 2D as long as your screen coords are guaranteed to be within the screen extents.

    That's a lot of information and should keep you busy for some time.

    Incidentally we cannot explain every graphic concept in one post. You can clearly see why. I would recommend buying some books on the topic from www.amazon.com

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Quote Originally Posted by Liedje
    Hi,

    I think I am the newest newbee on the block here, and want to do simple 2d modeling. You know, produce rotating orbs, triangles, that stuff.

    But... I don't know anything. I know Visual Basic language, and I know a bit C++. I want to continue in the C++ for the modeling. I have downloaded Dev-C++ (bloodshed) and thought I could do some modeling in that.

    But silly girl that I am, I don't even know where to start!!
    What I really need, is a tutorial that says to me:
    1. open dev-cpp
    2. make a new project
    3. take this kind of project (window app, console app, etc)
    4. type this code in, and explains all about what the code does
    I hate to state the obvious, but have tried this:

    Start dev-c++
    Click on the "Help" menu item
    Click on "Help on Dev-C++"
    Click some more to see topics like
    "Getting Started"
    "Basic Steps" ==>Creating a Project
    Adding/Removing Files
    Compiling and Running

    "An Introduction to C programming"

    etc.

    Then, click on the File Menu item

    Click "Open Project or File"
    Navigate to Dev-Cpp\Examples.

    Try the different directories from here:
    "Hello" looks like a good place to start.
    "Jackpot"

    "Simpwin" A simple windows application


    etc.


    Regards,

    Dave

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    It might be best to learn C++ just a little bit more before tryng to produce graphics.
    When you comfortable look into Allegro and SDL

    DOS isnt really used anymore particularly for games and graphical applications. That's why I posted the above links. There is adequate support for both libraries.
    Last edited by sand_man; 11-22-2004 at 01:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DOS graphics help!!
    By kiss_psycho in forum C Programming
    Replies: 2
    Last Post: 02-21-2003, 01:28 PM
  2. Graphics for DOS under Dev-C++
    By bubux in forum C Programming
    Replies: 16
    Last Post: 07-08-2002, 01:24 PM
  3. Dos graphics header
    By Vicious in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-14-2002, 12:24 PM
  4. Extremely Simple Graphics In Dos
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-07-2002, 06:25 PM
  5. VC++ graphics in dos.
    By StormySpike in forum C++ Programming
    Replies: 5
    Last Post: 09-28-2001, 10:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21