2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
align 4
|
|
|
|
proc initSharedState uses eax ebx, context:dword
|
|
|
|
mov ebx,[context]
|
|
|
|
|
|
|
|
stdcall gl_zalloc, 4*MAX_DISPLAY_LISTS
|
2016-09-16 10:39:28 +02:00
|
|
|
mov [ebx+GLContext.shared_state],eax ;...lists=gl_zalloc(...)
|
2014-10-31 22:28:24 +01:00
|
|
|
stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE
|
2016-09-16 10:39:28 +02:00
|
|
|
mov [ebx+GLContext.shared_state+4],eax ;...texture_hash_table=gl_zalloc(...)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
stdcall alloc_texture, [context],0
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc endSharedState uses eax ebx, context:dword
|
|
|
|
mov ebx,[context]
|
|
|
|
|
|
|
|
; for(i=0;i<MAX_DISPLAY_LISTS;i++) {
|
|
|
|
; /* TODO */
|
|
|
|
; }
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_free, dword[ebx+GLContext.shared_state] ;lists
|
|
|
|
stdcall gl_free, dword[ebx+GLContext.shared_state+4] ;texture_hash_table
|
2014-10-31 22:28:24 +01:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
2020-05-16 16:36:52 +02:00
|
|
|
proc glInit, zbuffer1:dword
|
|
|
|
pushad
|
2014-10-31 22:28:24 +01:00
|
|
|
stdcall gl_zalloc,sizeof.GLContext
|
|
|
|
mov dword[gl_ctx],eax
|
|
|
|
mov edx,eax
|
|
|
|
|
|
|
|
mov ecx,[zbuffer1]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.zb],ecx
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; allocate GLVertex array
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.vertex_max],POLYGON_MAX_VERTEX
|
2014-10-31 22:28:24 +01:00
|
|
|
stdcall gl_malloc, POLYGON_MAX_VERTEX*sizeof.GLVertex
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.vertex],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; viewport
|
2014-12-26 22:47:10 +01:00
|
|
|
xor eax,eax
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_xmin],eax
|
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_ymin],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
mov eax,[ecx+offs_zbuf_xsize]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_xsize],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
mov eax,[ecx+offs_zbuf_ysize]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_ysize],eax
|
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_updated],1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; shared state
|
|
|
|
stdcall initSharedState,edx
|
|
|
|
|
|
|
|
; lists
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.exec_flag],1
|
|
|
|
mov dword[edx+GLContext.compile_flag],0
|
|
|
|
mov dword[edx+GLContext.print_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.in_begin],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; lights
|
|
|
|
mov ecx,MAX_LIGHTS
|
|
|
|
mov eax,edx
|
2016-09-16 10:39:28 +02:00
|
|
|
add eax,GLContext.lights
|
2014-10-31 22:28:24 +01:00
|
|
|
.cycle_0:
|
2020-09-16 08:59:01 +02:00
|
|
|
gl_V4_New eax+GLLight.ambient, 0.0,0.0,0.0,1.0
|
|
|
|
gl_V4_New eax+GLLight.diffuse, 1.0,1.0,1.0,1.0
|
|
|
|
gl_V4_New eax+GLLight.specular, 1.0,1.0,1.0,1.0
|
|
|
|
gl_V4_New eax+GLLight.position, 0.0,0.0,1.0,0.0
|
|
|
|
gl_V3_New eax+GLLight.norm_position, 0.0,0.0,1.0
|
|
|
|
gl_V3_New eax+GLLight.spot_direction, 0.0,0.0,-1.0
|
|
|
|
gl_V3_New eax+GLLight.norm_spot_direction, 0.0,0.0,-1.0
|
|
|
|
mov dword[eax+GLLight.spot_exponent],0.0
|
|
|
|
mov dword[eax+GLLight.spot_cutoff],180.0
|
|
|
|
gl_V3_New eax+GLLight.attenuation, 1.0,0.0,0.0
|
|
|
|
mov dword[eax+GLLight.enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
add eax,sizeof.GLLight
|
|
|
|
dec ecx
|
|
|
|
cmp ecx,0
|
|
|
|
jg .cycle_0
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.first_light],0 ;NULL
|
|
|
|
gl_V4_New edx+GLContext.ambient_light_model, 0.2,0.2,0.2,1.0
|
|
|
|
mov dword[edx+GLContext.local_light_model],0
|
|
|
|
mov dword[edx+GLContext.lighting_enabled],0
|
|
|
|
mov dword[edx+GLContext.light_model_two_side],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; default materials
|
|
|
|
mov ecx,2 ;for(i=0;i<2;i++)
|
2020-09-16 08:59:01 +02:00
|
|
|
lea eax,[edx+GLContext.materials]
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2020-09-16 08:59:01 +02:00
|
|
|
gl_V4_New eax+GLMaterial.emission, 0.0,0.0,0.0,1.0
|
|
|
|
gl_V4_New eax+GLMaterial.ambient, 0.2,0.2,0.2,1.0
|
|
|
|
gl_V4_New eax+GLMaterial.diffuse, 0.8,0.8,0.8,1.0
|
|
|
|
gl_V4_New eax+GLMaterial.specular, 0.0,0.0,0.0,1.0
|
|
|
|
mov dword[eax+GLMaterial.shininess], 0.0
|
2014-10-31 22:28:24 +01:00
|
|
|
add eax,sizeof.GLMaterial
|
|
|
|
loop @b
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.current_color_material_mode],GL_FRONT_AND_BACK
|
|
|
|
mov dword[edx+GLContext.current_color_material_type],GL_AMBIENT_AND_DIFFUSE
|
|
|
|
mov dword[edx+GLContext.color_material_enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; textures
|
|
|
|
stdcall glInitTextures,edx
|
|
|
|
|
|
|
|
; default state
|
2016-09-16 10:39:28 +02:00
|
|
|
gl_V4_New edx+GLContext.current_color, 1.0,1.0,1.0,1.0
|
|
|
|
gl_V3_New edx+GLContext.longcurrent_color, 65535,65535,65535
|
2014-12-26 22:47:10 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
gl_V4_New edx+GLContext.current_normal, 1.0,0.0,0.0,0.0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.current_edge_flag],1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
gl_V4_New edx+GLContext.current_tex_coord, 0.0,0.0,0.0,1.0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.polygon_mode_front],GL_FILL
|
|
|
|
mov dword[edx+GLContext.polygon_mode_back],GL_FILL
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.current_front_face],0 ;0 = GL_CCW 1 = GL_CW
|
|
|
|
mov dword[edx+GLContext.current_cull_face],GL_BACK
|
|
|
|
mov dword[edx+GLContext.current_shade_model],GL_SMOOTH
|
|
|
|
mov dword[edx+GLContext.cull_face_enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; clear
|
2016-09-16 10:39:28 +02:00
|
|
|
gl_V4_New edx+GLContext.clear_color, 0.0,0.0,0.0,0.0
|
|
|
|
mov dword[edx+GLContext.clear_depth],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; selection
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.render_mode],GL_RENDER
|
|
|
|
mov dword[edx+GLContext.select_buffer],0 ;NULL
|
|
|
|
mov dword[edx+GLContext.name_stack_size],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; matrix
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.matrix_mode],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
gl_V3_New edx+GLContext.matrix_stack_depth_max,\
|
2014-12-26 22:47:10 +01:00
|
|
|
MAX_MODELVIEW_STACK_DEPTH,MAX_PROJECTION_STACK_DEPTH,MAX_TEXTURE_STACK_DEPTH
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
mov ecx,3 ;for(i=0;i<3;i++)
|
|
|
|
mov ebx,edx
|
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
mov edi,[ebx+GLContext.matrix_stack_depth_max]
|
2014-10-31 22:28:24 +01:00
|
|
|
shl edi,6 ;вместо imul edi,sizeof(M4)
|
|
|
|
stdcall gl_zalloc,edi
|
2016-09-16 10:39:28 +02:00
|
|
|
mov [ebx+GLContext.matrix_stack],eax
|
|
|
|
mov [ebx+GLContext.matrix_stack_ptr],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
add ebx,4
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
stdcall glMatrixMode,GL_PROJECTION
|
|
|
|
call glLoadIdentity
|
|
|
|
stdcall glMatrixMode,GL_TEXTURE
|
|
|
|
call glLoadIdentity
|
|
|
|
stdcall glMatrixMode,GL_MODELVIEW
|
|
|
|
call glLoadIdentity
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.matrix_model_projection_updated],1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; opengl 1.1 arrays
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.client_states],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; opengl 1.1 polygon offset
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.offset_states],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; clear the resize callback function pointer
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.gl_resize_viewport],0 ;NULL
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; specular buffer
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.specbuf_first],0 ;NULL
|
|
|
|
mov dword[edx+GLContext.specbuf_used_counter],0
|
|
|
|
mov dword[edx+GLContext.specbuf_num_buffers],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; depth test
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.depth_test],0
|
2020-05-16 16:36:52 +02:00
|
|
|
popad
|
2014-10-31 22:28:24 +01:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc glClose uses eax
|
|
|
|
call gl_get_context
|
|
|
|
stdcall endSharedState,eax
|
|
|
|
stdcall gl_free,eax
|
|
|
|
ret
|
|
|
|
endp
|