OpenCores
URL https://opencores.org/ocsvn/wf3d/wf3d/trunk

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [demo_app/] [main_space_ship.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 specular
//=======================================================================
2
// Project Monophony
3
//   Wire-Frame 3D Graphics Accelerator IP Core
4
//
5
// File:
6
//   main_space_ship.c
7
//
8
// Abstract:
9
//   3D model(space ship and landscape) rendering sample program.
10
//
11
// Author:
12 9 specular
//   Kenji Ishimaru (info.info.wf3d@gmail.com)
13 4 specular
//
14
//======================================================================
15
//
16
// Copyright (c) 2016, Kenji Ishimaru
17
// All rights reserved.
18
//
19
// Redistribution and use in source and binary forms, with or without
20
// modification, are permitted provided that the following conditions are met:
21
//
22
//  -Redistributions of source code must retain the above copyright notice,
23
//   this list of conditions and the following disclaimer.
24
//  -Redistributions in binary form must reproduce the above copyright notice,
25
//   this list of conditions and the following disclaimer in the documentation
26
//   and/or other materials provided with the distribution.
27
//
28
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
//
40
// Revision History
41
 
42
#include "mp_hwdep.h"
43
#include "mp_lib.h"
44
#include <stdio.h>
45
 
46
 
47
#include "ship.h"
48
#include "landscape.h"
49
 
50
void mp_loop() {
51
  static float transY = 0.0f;
52
  static int cframe = 1;
53
  static float cScale = 4.0;
54
  float pos_z_l,pos_z_r;
55
  int pos_z_l_inc,pos_z_r_inc;
56
  unsigned char col;
57
  int i;
58
  int frame  = 0;
59
  int mat_index;
60
  mpClearColor(0.0, 0.0, 0.0);
61
  mpViewport(640, 480);
62
  mpMatrixMode(MP_PROJECTION);
63
  mpPerspective(30.0, 4.0 / 3.0, 1, 100);
64
 
65
  pos_z_l = 0.0;
66
  pos_z_r = 0.0;
67
  pos_z_l_inc = 0;
68
  pos_z_r_inc = 0;
69
  col = 0xff;
70
  int j;
71
  while(1){
72
        for (i=0;i<360;i++) {
73
      printf("frame %d\n",frame++);
74
      mpClear();
75
      mpMatrixMode(MP_MODELVIEW);
76
      mpLoadIdentity();
77
      mpLookAt(0, 0.5, 3.0, 0, 0, -50, 0, 1.0, 0);
78
      // ship
79
      mpPushMatrix();
80
      mpTranslate(0.0, 0.0, -8);
81
      mpTranslate(-1.3, 1.0, 0.0);
82
      mpRotate(i, 0, 1, 0);
83
      mpScale(0.2,0.2,0.2);
84
      mpVertexPointer(vtx_ship_array);
85
      mpRenderColor(1.0,0.5,1.0);
86
      mpDrawArrays(num_vtx_ship*3);
87
      mpPopMatrix();
88
      // landscape
89
      mpPushMatrix();
90
      mpTranslate(0.0, 0.0, -8/*+pos_z_l*/);
91
      mpTranslate(0.0, -1.0, 0.0);
92
      mpScale(3.0,3.0,3.0);
93
      mpVertexPointer(vtx_array);
94
      mpRenderColor(1.0,0.3,0.0);
95
      mpDrawArrays(num_vtx*3);
96
      mpPopMatrix();
97
 
98
      cframe++;
99
      mpSwapBuffers();
100
    }
101
  }
102
}
103
 
104
int main()
105
{
106
 
107
  printf("Space Ship Demo\n");
108
  mpInit();
109
  buffer_clear(0x00000000,0);
110
  buffer_clear(0x00000000,1);
111
  mp_loop();
112
  return 0;
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.