Subversion Repositories Kolibri OS

Rev

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