Subversion Repositories Kolibri OS

Rev

Rev 5171 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. align 4
  3. proc initSharedState uses eax ebx, context:dword
  4.         mov ebx,[context]
  5.  
  6.         stdcall gl_zalloc, 4*MAX_DISPLAY_LISTS
  7.         mov [ebx+offs_cont_shared_state],eax ;...lists=gl_zalloc(...)
  8.         stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE
  9.         mov [ebx+offs_cont_shared_state+4],eax ;...texture_hash_table=gl_zalloc(...)
  10.  
  11.         stdcall alloc_texture, [context],0
  12.         ret
  13. endp
  14.  
  15. align 4
  16. proc endSharedState uses eax ebx, context:dword
  17.         mov ebx,[context]
  18.         mov ebx,[ebx+offs_cont_shared_state]
  19.  
  20.         ;  int i;
  21. ;  for(i=0;i<MAX_DISPLAY_LISTS;i++) {
  22. ;    /* TODO */
  23. ;  }
  24.         stdcall gl_free, dword[ebx] ;lists
  25.         stdcall gl_free, dword[ebx+4] ;texture_hash_table
  26.         ret
  27. endp
  28.  
  29. align 4
  30. proc glInit uses eax ebx ecx edx, zbuffer1:dword
  31. ;  int i;
  32.  
  33.         stdcall gl_zalloc,sizeof.GLContext
  34.         mov dword[gl_ctx],eax
  35.         mov edx,eax
  36.  
  37.         mov ecx,[zbuffer1]
  38.         mov dword[edx+offs_cont_zb],ecx
  39.  
  40.         ; allocate GLVertex array
  41.         mov dword[edx+offs_cont_vertex_max],POLYGON_MAX_VERTEX
  42.         stdcall gl_malloc, POLYGON_MAX_VERTEX*sizeof.GLVertex
  43.         mov dword[edx+offs_cont_vertex],eax
  44.  
  45.         ; viewport
  46.         mov dword[edx+offs_cont_viewport+offs_vpor_xmin],0
  47.         mov dword[edx+offs_cont_viewport+offs_vpor_ymin],0
  48.         mov eax,[ecx+offs_zbuf_xsize]
  49.         mov dword[edx+offs_cont_viewport+offs_vpor_xsize], eax
  50.         mov eax,[ecx+offs_zbuf_ysize]
  51.         mov dword[edx+offs_cont_viewport+offs_vpor_ysize], eax
  52.         mov dword[edx+offs_cont_viewport+offs_vpor_updated],1
  53.  
  54.         ; shared state
  55.         stdcall initSharedState,edx
  56.  
  57.         ; lists
  58.         mov dword[edx+offs_cont_exec_flag],1
  59.         mov dword[edx+offs_cont_compile_flag],0
  60.         mov dword[edx+offs_cont_print_flag],0
  61.  
  62.         mov dword[edx+offs_cont_in_begin],0
  63.  
  64.         ; lights
  65.         mov ecx,MAX_LIGHTS
  66.         mov eax,edx
  67.         add eax,offs_cont_lights
  68.         .cycle_0:
  69.                 gl_V4_New eax+offs_ligh_ambient, 0.0,0.0,0.0,1.0
  70.                 gl_V4_New eax+offs_ligh_diffuse, 1.0,1.0,1.0,1.0
  71.                 gl_V4_New eax+offs_ligh_specular, 1.0,1.0,1.0,1.0
  72.                 gl_V4_New eax+offs_ligh_position, 0.0,0.0,1.0,0.0
  73.                 gl_V3_New eax+offs_ligh_norm_position, 0.0,0.0,1.0
  74.                 gl_V3_New eax+offs_ligh_spot_direction, 0.0,0.0,-1.0
  75.                 gl_V3_New eax+offs_ligh_norm_spot_direction, 0.0,0.0,-1.0
  76.                 mov dword[eax+offs_ligh_spot_exponent],0.0
  77.                 mov dword[eax+offs_ligh_spot_cutoff],180.0
  78.                 mov dword[eax+offs_ligh_attenuation],1.0
  79.                 mov dword[eax+offs_ligh_attenuation+4],0.0
  80.                 mov dword[eax+offs_ligh_attenuation+8],0.0
  81.                 mov dword[eax+offs_ligh_enabled],0
  82.                 add eax,sizeof.GLLight
  83.                 dec ecx
  84.                 cmp ecx,0
  85.         jg .cycle_0
  86.  
  87.         mov dword[edx+offs_cont_first_light],0 ;NULL
  88.         gl_V4_New edx+offs_cont_ambient_light_model, 0.2,0.2,0.2,1.0
  89.         mov dword[edx+offs_cont_local_light_model],0
  90.         mov dword[edx+offs_cont_lighting_enabled],0
  91.         mov dword[edx+offs_cont_light_model_two_side],0
  92.  
  93.         ; default materials
  94.         mov ecx,2 ;for(i=0;i<2;i++)
  95.         mov eax,edx
  96.         add eax,offs_cont_materials
  97.         @@:
  98.                 gl_V4_New eax+offs_mate_emission, 0.0,0.0,0.0,1.0
  99.                 gl_V4_New eax+offs_mate_ambient, 0.2,0.2,0.2,1.0
  100.                 gl_V4_New eax+offs_mate_diffuse, 0.8,0.8,0.8,1.0
  101.                 gl_V4_New eax+offs_mate_specular, 0.0,0.0,0.0,1.0
  102.                 mov dword[eax+offs_mate_shininess], 0.0
  103.                 add eax,sizeof.GLMaterial
  104.         loop @b
  105.  
  106.         mov dword[edx+offs_cont_current_color_material_mode],GL_FRONT_AND_BACK
  107.         mov dword[edx+offs_cont_current_color_material_type],GL_AMBIENT_AND_DIFFUSE
  108.         mov dword[edx+offs_cont_color_material_enabled],0
  109.  
  110.         ; textures
  111.         stdcall glInitTextures,edx
  112.  
  113.         ; default state
  114.         mov dword[edx+offs_cont_current_color],1.0
  115.         mov dword[edx+offs_cont_current_color+4],1.0
  116.         mov dword[edx+offs_cont_current_color+8],1.0
  117.         mov dword[edx+offs_cont_current_color+12],1.0
  118.         mov dword[edx+offs_cont_longcurrent_color],65535
  119.         mov dword[edx+offs_cont_longcurrent_color+4],65535
  120.         mov dword[edx+offs_cont_longcurrent_color+8],65535
  121.  
  122.         mov dword[edx+offs_cont_current_normal],1.0
  123.         mov dword[edx+offs_cont_current_normal+4],0.0
  124.         mov dword[edx+offs_cont_current_normal+8],0.0
  125.         mov dword[edx+offs_cont_current_normal+12],0.0
  126.  
  127.         mov dword[edx+offs_cont_current_edge_flag],1
  128.  
  129.         mov dword[edx+offs_cont_current_tex_coord],0.0
  130.         mov dword[edx+offs_cont_current_tex_coord+4],0.0
  131.         mov dword[edx+offs_cont_current_tex_coord+8],0.0
  132.         mov dword[edx+offs_cont_current_tex_coord+12],1.0
  133.  
  134.         mov dword[edx+offs_cont_polygon_mode_front],GL_FILL
  135.         mov dword[edx+offs_cont_polygon_mode_back],GL_FILL
  136.  
  137.         mov dword[edx+offs_cont_current_front_face],0 ;0 = GL_CCW  1 = GL_CW
  138.         mov dword[edx+offs_cont_current_cull_face],GL_BACK
  139.         mov dword[edx+offs_cont_current_shade_model],GL_SMOOTH
  140.         mov dword[edx+offs_cont_cull_face_enabled],0
  141.  
  142.         ; clear
  143.         mov dword[edx+offs_cont_clear_color],0.0
  144.         mov dword[edx+offs_cont_clear_color+4],0.0
  145.         mov dword[edx+offs_cont_clear_color+8],0.0
  146.         mov dword[edx+offs_cont_clear_color+12],0.0
  147.         mov dword[edx+offs_cont_clear_depth],0
  148.  
  149.         ; selection
  150.         mov dword[edx+offs_cont_render_mode],GL_RENDER
  151.         mov dword[edx+offs_cont_select_buffer],0 ;NULL
  152.         mov dword[edx+offs_cont_name_stack_size],0
  153.  
  154.         ; matrix
  155.         mov dword[edx+offs_cont_matrix_mode],0
  156.  
  157.         mov dword[edx+offs_cont_matrix_stack_depth_max],MAX_MODELVIEW_STACK_DEPTH
  158.         mov dword[edx+offs_cont_matrix_stack_depth_max+4],MAX_PROJECTION_STACK_DEPTH
  159.         mov dword[edx+offs_cont_matrix_stack_depth_max+8],MAX_TEXTURE_STACK_DEPTH
  160.  
  161.         mov ecx,3 ;for(i=0;i<3;i++)
  162.         mov ebx,edx
  163.         @@:
  164.                 mov edi,[ebx+offs_cont_matrix_stack_depth_max]
  165.                 shl edi,6 ;вместо imul edi,sizeof(M4)
  166.                 stdcall gl_zalloc,edi
  167.                 mov [ebx+offs_cont_matrix_stack],eax
  168.                 mov [ebx+offs_cont_matrix_stack_ptr],eax
  169.                 add ebx,4
  170.         loop @b
  171.  
  172.         stdcall glMatrixMode,GL_PROJECTION
  173.         call glLoadIdentity
  174.         stdcall glMatrixMode,GL_TEXTURE
  175.         call glLoadIdentity
  176.         stdcall glMatrixMode,GL_MODELVIEW
  177.         call glLoadIdentity
  178.  
  179.         mov dword[edx+offs_cont_matrix_model_projection_updated],1
  180.  
  181.         ; opengl 1.1 arrays
  182.         mov dword[edx+offs_cont_client_states],0
  183.  
  184.         ; opengl 1.1 polygon offset
  185.         mov dword[edx+offs_cont_offset_states],0
  186.  
  187.         ; clear the resize callback function pointer
  188.         mov dword[edx+offs_cont_gl_resize_viewport],0 ;NULL
  189.  
  190.         ; specular buffer
  191.         mov dword[edx+offs_cont_specbuf_first],0 ;NULL
  192.         mov dword[edx+offs_cont_specbuf_used_counter],0
  193.         mov dword[edx+offs_cont_specbuf_num_buffers],0
  194.  
  195.         ; depth test
  196.         mov dword[edx+offs_cont_depth_test],0
  197.  
  198.         ret
  199. endp
  200.  
  201. align 4
  202. proc glClose uses eax
  203.         call gl_get_context
  204.         stdcall endSharedState,eax
  205.         stdcall gl_free,eax
  206.         ret
  207. endp
  208.