Subversion Repositories Kolibri OS

Rev

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