Example #1
0
void RenderInit (void)
{

  HWND              hWnd;
	unsigned		      PixelFormat;
  HFONT	            font;		
	HFONT	            oldfont;

  hWnd = WinHwnd ();
  if (!(hDC = GetDC (hWnd))) 
		YOUFAIL ("Can't Create A GL Device Context.") ;
	if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd)))
		YOUFAIL ("Can't Find A Suitable PixelFormat.") ;
  if(!SetPixelFormat(hDC,PixelFormat,&pfd))
		YOUFAIL ("Can't Set The PixelFormat.");
	if (!(hRC = wglCreateContext (hDC)))	
		YOUFAIL ("Can't Create A GL Rendering Context.");
  if(!wglMakeCurrent(hDC,hRC))	
		YOUFAIL ("Can't Activate The GL Rendering Context.");
  //Load the fonts for printing debug info to the window.
  for (int i = 0; i < FONT_COUNT; i++) {
	  fonts[i].base_char = glGenLists(96); 
	  font = CreateFont (FONT_SIZE,	0, 0,	0,	
				  FW_BOLD, FALSE,	FALSE, FALSE,	DEFAULT_CHARSET,	OUT_TT_PRECIS,		
				  CLIP_DEFAULT_PRECIS,	ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH,
				  fonts[i].name);
	  oldfont = (HFONT)SelectObject(hDC, font);	
	  wglUseFontBitmaps(hDC, 32, 96, fonts[i].base_char);
	  SelectObject(hDC, oldfont);
	  DeleteObject(font);		
  }
  //If the program is running for the first time, set the defaults.
  if (!IniInt ("SetDefaults")) {
    IniIntSet ("SetDefaults", 1);
    IniIntSet ("Effect", EFFECT_BLOOM);
    IniIntSet ("ShowFog", 1);
  }
  //load in our settings
  letterbox = IniInt ("Letterbox") != 0;
  show_wireframe = IniInt ("Wireframe") != 0;
  show_fps = IniInt ("ShowFPS") != 0;
  show_fog = IniInt ("ShowFog") != 0;
  effect = IniInt ("Effect");
  flat = IniInt ("Flat") != 0;
  fog_distance = WORLD_HALF;
  //clear the viewport so the user isn't looking at trash while the program starts
  glViewport (0, 0, WinWidth (), WinHeight ());
  glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  SwapBuffers (hDC);
  RenderResize ();

}
//  \/
//there is an address error somewhere in this routine.				
static void ScrollFromTop(WINDOW *w, HEX_DAT *d)
{
	WIN_RECT wr={ 0, 0, 0, 0 };
	BACKGROUND_DAT *bg=&gBGDAT;
	USHORT result_top;
	USHORT result_bottom;
	USHORT *ptr;
	char buff[150];
	DASM_DAT dasm;

	wr.x1=WinWidth(w);
	wr.y1=ScrollFromBottom_helper+C(6-1,8-1);
	
	if((ULONG)bg->baseaddr && (ULONG)d->top>(ULONG)bg->baseaddr && bg->hOffsetTable)
	{
		ptr=HeapDeref(bg->hOffsetTable);
		result_top=bsearch(ptr, (ULONG)d->top - (ULONG)bg->baseaddr, bg->entries-1);
		result_bottom=bsearch(ptr, (ULONG)bottom_addr - (ULONG)bg->baseaddr, bg->entries-1);
		
		if(result_top==USHRT_MAX || result_bottom==USHRT_MAX)
		{
			d->top-=2;
			WinPaint(w, d);
			
			#ifdef DEBUG
				ST_helpMsg("Address Not In Buffer.");
			#endif
			
			return;
		}			
		
		if(result_top)
		{
			result_top--;	//the previous instruction
			result_bottom--;
		}
		
		d->top=(char*)&bg->baseaddr[ptr[result_top]>>1];
		bottom_addr=(char*)&bg->baseaddr[ptr[result_bottom]>>1];

		WinScrollV(w, &wr, C(-6,-8));
		
		disassemble_one((unsigned short*)d->top, &dasm);
		sprintf(buff, "%lx%s", d->top, dasm.text);
		WinStrXY(w, 1, 1, buff);
	}
Example #3
0
void CPointer::Update()
{
    vec2		p;
    int			viewport[4];
    vec3		pos;
    vec3		angle;
    uint64_t	t;

    t = GetTickCount() % 3600;
    m_pulse = ( float )sin((( float )t / 10.0f ) * DEGREES_TO_RADIANS ) * 1.0f;
    WinMousePosition( p );
    if( m_last_mouse.x == p.x && m_last_mouse.y == p.y )
        return;
    m_last_mouse = p;
    // This Sets The Array <viewport> To The Size And Location Of The Screen Relative To The Window
    glViewport( 0, 0, WinWidth(), WinHeight() );
    glGetIntegerv( GL_VIEWPORT, viewport );
    glMatrixMode( GL_PROJECTION );
    glPushMatrix();
    glLoadIdentity();
    // This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen
    gluPickMatrix(( GLdouble ) p.x, ( GLdouble )( viewport[3] - p.y ), 2.0f, 2.0f, viewport );
    // Apply The Perspective Matrix
    gluPerspective( 45.0f, ( float )( viewport[2] - viewport[0] ) / ( float )( viewport[3] - viewport[1] ), 0.1f, 1024.0f );
    glMatrixMode( GL_MODELVIEW );						// Select The Modelview Matrix
    glLoadIdentity();
    pos = CameraPosition();
    angle = CameraAngle();
    glRotatef( angle.x, 1.0f, 0.0f, 0.0f );
    glRotatef( angle.y, 0.0f, 1.0f, 0.0f );
    glRotatef( angle.z, 0.0f, 0.0f, 1.0f );
    glTranslatef( -pos.x, -pos.y, -pos.z );
    m_last_cell = DrawGrid();
    glMatrixMode( GL_PROJECTION );
    glPopMatrix();
    glMatrixMode( GL_MODELVIEW );
}
Example #4
0
void RenderResize (void)		
{

  float     fovy;

  render_width = WinWidth ();
  render_height = WinHeight ();
  if (letterbox) {
    letterbox_offset = render_height / 6;
    render_height = render_height - letterbox_offset * 2;
  } else 
    letterbox_offset = 0;
  //render_aspect = (float)render_height / (float)render_width;
  glViewport (0, letterbox_offset, render_width, render_height);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  render_aspect = (float)render_width / (float)render_height;
  fovy = 60.0f;
  if (render_aspect > 1.0f) 
    fovy /= render_aspect; 
  gluPerspective (fovy, render_aspect, 0.1f, RENDER_DISTANCE);
	glMatrixMode (GL_MODELVIEW);

}
Example #5
0
void RenderUpdate (void)		
{

  GLvector        pos;
  GLvector        angle;
  GLrgba          color;
  int             elapsed;

  frames++;
  do_fps ();
  glViewport (0, 0, WinWidth (), WinHeight ());
  glDepthMask (true);
  glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
  glEnable(GL_DEPTH_TEST);
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  if (letterbox) 
    glViewport (0, letterbox_offset, render_width, render_height);
  if (LOADING_SCREEN && TextureReady () && !EntityReady ()) {
    do_effects (EFFECT_NONE);
    SwapBuffers (hDC);
    return;
  }
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
  glShadeModel(GL_SMOOTH);
  glFogi (GL_FOG_MODE, GL_LINEAR);
	glDepthFunc(GL_LEQUAL);
  glEnable (GL_CULL_FACE);
  glCullFace (GL_BACK);
  glEnable (GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glMatrixMode (GL_TEXTURE);
  glLoadIdentity();
	glMatrixMode (GL_MODELVIEW);
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
  glLoadIdentity();
  glLineWidth (1.0f);
  pos = CameraPosition ();
  angle = CameraAngle ();
  glRotatef (angle.x, 1.0f, 0.0f, 0.0f);
  glRotatef (angle.y, 0.0f, 1.0f, 0.0f);
  glRotatef (angle.z, 0.0f, 0.0f, 1.0f);
  glTranslatef (-pos.x, -pos.y, -pos.z);
  glEnable (GL_TEXTURE_2D);
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  //Render all the stuff in the whole entire world.
  glDisable (GL_FOG);
  SkyRender ();
  if (show_fog) {
    glEnable (GL_FOG);
    glFogf (GL_FOG_START, fog_distance - 100);
    glFogf (GL_FOG_END, fog_distance);
    color = glRgba (0.0f);
    glFogfv (GL_FOG_COLOR, &color.red);
  }
  WorldRender ();
  if (effect == EFFECT_GLASS_CITY) {
    glDisable (GL_CULL_FACE);
    glEnable (GL_BLEND);
    glBlendFunc (GL_ONE, GL_ONE);
    glDepthFunc (false);
    glDisable(GL_DEPTH_TEST);
    glMatrixMode (GL_TEXTURE);
    glTranslatef ((pos.x + pos.z) / SEGMENTS_PER_TEXTURE, 0, 0);
	  glMatrixMode (GL_MODELVIEW);
  } else {
    glEnable (GL_CULL_FACE);
    glDisable (GL_BLEND);
  }
  EntityRender ();
  if (!LOADING_SCREEN) {
    elapsed = 3000 - WorldSceneElapsed ();
    if (elapsed >= 0 && elapsed <= 3000) {
      RenderFogFX ((float)elapsed / 3000.0f);
      glDisable (GL_TEXTURE_2D);
      glEnable (GL_BLEND);
      glBlendFunc (GL_ONE, GL_ONE);
      EntityRender ();
    }
  } 
  if (EntityReady ())
    LightRender ();
  CarRender ();
  if (show_wireframe) {
    glDisable (GL_TEXTURE_2D);
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    EntityRender ();
  }
  do_effects (effect);
  //Framerate tracker
  if (show_fps) 
    RenderPrint (1, "FPS=%d : Entities=%d : polys=%d", current_fps, EntityCount () + LightCount () + CarCount (), EntityPolyCount () + LightCount () + CarCount ());
  //Show the help overlay
  if (show_help)
    do_help ();
  SwapBuffers (hDC);

}
Example #6
0
void ext_ABOUTRC(void)
{
	Access_AMS_Global_Variables;
	const WIN_RECT wRegion={C(10, 30), C(4, 6), C(MAX_X-10, 215), C(85, 113)};
	WINDOW win;
	WIN_POINT ds_pt={4,1}, post_pt;
	#ifndef NO_EASTER_EGGS
		short leet_user=FALSE;
		short key_code='x';//initialize it with something other than a valid key...
	#endif
	
	if(remaining_element_count(top_estack)) ER_throw(TOO_MANY_ARGS_ERROR);
	
	if(!WinOpen(&win, &wRegion, WF_SAVE_SCR|WF_TTY|WF_TITLE|WF_ROUNDEDBORDER, XR_stringPtr(XR_ABOUT)))
		ER_throw(ER_MEMORY);
	
	WinBeginPaint(&win);
	
	#ifdef _89
		WinFont(&win, F_4x6);
	#endif
	
	post_pt.x0=WinWidth(&win)-4-((BITMAP*)AppIcon)->NumCols;
	post_pt.y0=1;
	
	WinClr(&win);
	WinBitmapPut(&win, ds_pt.x0, ds_pt.y0, (BITMAP*)DSIcon, A_XOR);
	WinBitmapPut(&win, post_pt.x0, post_pt.y0, (BITMAP*)AppIcon, A_XOR);
	
	WinMoveTo(&win,33,7);
	WinStr(&win, (char*)OO_AbsoluteGet(OO_FIRST_APP_STRING + XR_About_Me));//About());
	DrawStaticButton(&win, PDB_OK, 5);
	
	#ifdef NO_EASTER_EGGS
		while(KeyYesOrNo(GKeyIn(NULL, GKF_MODAL | GKF_SYS))==-1);
	#else
		while(KeyYesOrNo(key_code)==-1)
		{
			key_code=GKeyIn(NULL, GKF_MODAL | GKF_SYS);
			if(key_code==(0x31337-(0x12F0|0x30000)) && !leet_user)	//$r3 j00 1 31337 H4X0R G
			{
				short dx=1, dy=1, steps;
				
				leet_user=TRUE;
				
				for(steps=0;steps<C(105,210);steps++)
				{
					#ifdef _92
					if(steps<155)
					{
					#endif
						WinBitmapPut(&win, post_pt.x0, post_pt.y0, (BITMAP*)AppIcon, A_XOR);
						post_pt.x0--;
						WinBitmapPut(&win, post_pt.x0, post_pt.y0, (BITMAP*)AppIcon, A_XOR);
					#ifdef _92
					}
					else
					{
						short delay;
						for(delay=0;delay<5000;delay++);
					}
					#endif
					
					WinBitmapPut(&win, ds_pt.x0, ds_pt.y0, (BITMAP*)DSIcon, A_XOR);
					if(ds_pt.x0>WinWidth(&win)-16  || ds_pt.x0<0)dx=-dx;
					if(ds_pt.y0>WinHeight(&win)-16 || ds_pt.y0<0)dy=-dy;
					ds_pt.x0+=dx;	ds_pt.y0+=dy;
					WinBitmapPut(&win, ds_pt.x0, ds_pt.y0, (BITMAP*)DSIcon, A_XOR);
				}
			}
		}
		#endif
	

	WinEndPaint(&win);
	WinClose(&win);
}