[Change] Some tweaks to GL rendering. - I should point out, It wasn't me whom broke the textures. :P
This commit is contained in:
		
							parent
							
								
									811fc0b92a
								
							
						
					
					
						commit
						ba4b7239d4
					
				| @ -154,7 +154,7 @@ int main(int argc, char** argv) { | |||||||
|     glClear(GL_COLOR_BUFFER_BIT); |     glClear(GL_COLOR_BUFFER_BIT); | ||||||
|      |      | ||||||
|     fps_control(); // Who doesn't love FPS control?
 |     fps_control(); // Who doesn't love FPS control?
 | ||||||
|     if(!paused) update_space(); // Update the game.
 |     if(!paused && !toolkit) update_space(); // Update the game.
 | ||||||
| 
 | 
 | ||||||
|     render_space(); |     render_space(); | ||||||
|     if(toolkit) toolkit_render(); |     if(toolkit) toolkit_render(); | ||||||
|  | |||||||
							
								
								
									
										86
									
								
								src/opengl.c
									
									
									
									
									
								
							
							
						
						
									
										86
									
								
								src/opengl.c
									
									
									
									
									
								
							| @ -358,65 +358,64 @@ void gl_blitSprite(const glTexture* sprite, const Vec2* pos, const int sx, const | |||||||
|         fabs(VY(*pos) -VY(*gl_camera)+gui_yoff) > gl_screen.h / 2 + sprite->sh / 2) |         fabs(VY(*pos) -VY(*gl_camera)+gui_yoff) > gl_screen.h / 2 + sprite->sh / 2) | ||||||
|     return; |     return; | ||||||
| 
 | 
 | ||||||
|   glEnable(GL_TEXTURE_2D); |   double x, y, tx, ty; | ||||||
|   glMatrixMode(GL_TEXTURE); |  | ||||||
|   glPushMatrix(); |  | ||||||
|   glTranslated(sprite->sw * (double)(sx)/sprite->rw, |  | ||||||
|         sprite->sh*(sprite->sy-(double)sy-1)/sprite->rh, 0.); |  | ||||||
| 
 | 
 | ||||||
|   glMatrixMode(GL_PROJECTION); |   x = VX(*pos) - VX(*gl_camera) - sprite->sw/2. + gui_xoff; | ||||||
|   glPushMatrix(); // Projection translation matrix.
 |   y = VY(*pos) - VY(*gl_camera) - sprite->sh/2. + gui_yoff; | ||||||
|   glTranslated(VX(*pos) - VX(*gl_camera) - sprite->sw/2. + gui_xoff, | 
 | ||||||
|         VY(*pos) -VY(*gl_camera) - sprite->sh/2. + gui_yoff, 0.); |   tx = sprite->sw * (double)(sx)/sprite->rw; | ||||||
|   //glScalef((double)gl_screen.w/SCREEN_W, (double)gl_screen.h/SCREEN_H, 0.);
 |   ty = sprite->sh * (sprite->sy-(double)sy-1)/sprite->rh; | ||||||
| 
 | 
 | ||||||
|   // Actual blitting....
 |   // Actual blitting....
 | ||||||
|   glBindTexture(GL_TEXTURE_2D, sprite->texture); |   glBindTexture(GL_TEXTURE_2D, sprite->texture); | ||||||
|   glBegin(GL_TRIANGLE_STRIP); |   glBegin(GL_QUADS); | ||||||
|     if(c == NULL) glColor4d(1., 1., 1., 1.); |     if(c == NULL) glColor4d(1., 1., 1., 1.); | ||||||
|     else COLOUR(*c); |     else COLOUR(*c); | ||||||
|     glTexCoord2d(0., 0.); | 
 | ||||||
|       glVertex2d(0., 0.); |     glTexCoord2d(tx, ty); | ||||||
|     glTexCoord2d(sprite->sw/sprite->rw, 0.); |       glVertex2d(x, y); | ||||||
|       glVertex2d(sprite->sw, 0.); | 
 | ||||||
|     glTexCoord2d(0., sprite->sh/sprite->rh); |     glTexCoord2d(tx + sprite->sw/sprite->rw, ty); | ||||||
|       glVertex2d(0., sprite->sh); |       glVertex2d(x + sprite->sw, y); | ||||||
|     glTexCoord2d(sprite->sw/sprite->rw, sprite->sh/sprite->rh); | 
 | ||||||
|       glVertex2d(sprite->sw, sprite->sh); |     glTexCoord2d(tx + sprite->sw/sprite->rw, ty + sprite->sh/sprite->rh); | ||||||
|  |       glVertex2d(x + sprite->sw, y + sprite->sh); | ||||||
|  | 
 | ||||||
|  |     glTexCoord2d(tx, ty + sprite->sh/sprite->rh); | ||||||
|  |       glVertex2d(x, y + sprite->sh); | ||||||
|  | 
 | ||||||
|   glEnd(); |   glEnd(); | ||||||
| 
 | 
 | ||||||
|   glPopMatrix(); // Projection translation matrix.
 |  | ||||||
| 
 |  | ||||||
|   glMatrixMode(GL_TEXTURE); |  | ||||||
|   glPopMatrix(); // Sprite translation matrix.
 |  | ||||||
|    |  | ||||||
|   glDisable(GL_TEXTURE_2D); |   glDisable(GL_TEXTURE_2D); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Just straight out blit the thing at position.
 | // Just straight out blit the thing at position.
 | ||||||
| void gl_blitStatic(const glTexture* texture, const Vec2* pos, const glColour* c) { | void gl_blitStatic(const glTexture* texture, const Vec2* pos, const glColour* c) { | ||||||
|  |   double x, y; | ||||||
|   glEnable(GL_TEXTURE_2D); |   glEnable(GL_TEXTURE_2D); | ||||||
|   glMatrixMode(GL_PROJECTION); |    | ||||||
|   glPushMatrix(); // Set up translation matrix.
 |   x = VX(*pos) - (double)gl_screen.w/2.; | ||||||
|   glTranslated(VX(*pos) - (double)gl_screen.w/2., VY(*pos) - (double)gl_screen.h/2., 0); |   y = VY(*pos) - (double)gl_screen.h/2.; | ||||||
|   //glScaled((double)gl_screen.w/SCREEN_W, (double)gl_screen.h/SCREEN_H, 0.);
 |  | ||||||
| 
 | 
 | ||||||
|   // Actual blitting..
 |   // Actual blitting..
 | ||||||
|   glBindTexture(GL_TEXTURE_2D, texture->texture); |   glBindTexture(GL_TEXTURE_2D, texture->texture); | ||||||
|   glBegin(GL_TRIANGLE_STRIP); |   glBegin(GL_QUADS); | ||||||
|     if(c == NULL) glColor4d(1., 1., 1., 1.); |     if(c == NULL) glColor4d(1., 1., 1., 1.); | ||||||
|     else COLOUR(*c); |     else COLOUR(*c); | ||||||
|     glTexCoord2d(0., 0.); |  | ||||||
|       glVertex2d(0., 0.); |  | ||||||
|     glTexCoord2d(texture->sw/texture->rw, 0.); |  | ||||||
|       glVertex2d(texture->sw, 0.); |  | ||||||
|     glTexCoord2d(0., texture->sh/texture->rh); |  | ||||||
|       glVertex2d(0., texture->sh); |  | ||||||
|     glTexCoord2d(texture->sw/texture->rw, texture->sh/texture->rh); |  | ||||||
|       glVertex2d(texture->sw, texture->h); |  | ||||||
|   glEnd(); |  | ||||||
|      |      | ||||||
|   glPopMatrix(); // Pop the translation matrix.
 |     glTexCoord2d(0., 0.); | ||||||
|  |       glVertex2d(x, y); | ||||||
|  | 
 | ||||||
|  |     glTexCoord2d(texture->sw/texture->rw, 0.); | ||||||
|  |       glVertex2d(x + texture->sw, y); | ||||||
|  | 
 | ||||||
|  |     glTexCoord2d(texture->sw/texture->rw, texture->sh/texture->rh); | ||||||
|  |       glVertex2d(x + texture->sw, y + texture->sh); | ||||||
|  | 
 | ||||||
|  |     glTexCoord2d(0., texture->sh/texture->rh); | ||||||
|  |       glVertex2d(x, y + texture->sh); | ||||||
|  | 
 | ||||||
|  |   glEnd(); | ||||||
| 
 | 
 | ||||||
|   glDisable(GL_TEXTURE_2D); |   glDisable(GL_TEXTURE_2D); | ||||||
| } | } | ||||||
| @ -448,8 +447,7 @@ void gl_print(const glFont* ft_font, const double x, const double y, | |||||||
| 
 | 
 | ||||||
|   glListBase(ft_font->list_base); |   glListBase(ft_font->list_base); | ||||||
| 
 | 
 | ||||||
|   glMatrixMode(GL_PROJECTION); |   glMatrixMode(GL_MODELVIEW); | ||||||
| 
 |  | ||||||
|   glPushMatrix(); // Translation matrix.
 |   glPushMatrix(); // Translation matrix.
 | ||||||
|   glTranslated(x - (double)gl_screen.w/2., y - (double)gl_screen.h/2., 0); |   glTranslated(x - (double)gl_screen.w/2., y - (double)gl_screen.h/2., 0); | ||||||
| 
 | 
 | ||||||
| @ -704,7 +702,8 @@ int gl_init(void) { | |||||||
|   glDisable(GL_DEPTH_TEST); // Set for doing 2D shidazles.
 |   glDisable(GL_DEPTH_TEST); // Set for doing 2D shidazles.
 | ||||||
|   //glEnable(GL_TEXTURE_2D); // Don't enable globally, it will break non-texture blits.
 |   //glEnable(GL_TEXTURE_2D); // Don't enable globally, it will break non-texture blits.
 | ||||||
|   glDisable(GL_LIGHTING); // No lighting, it is done when rendered.
 |   glDisable(GL_LIGHTING); // No lighting, it is done when rendered.
 | ||||||
|   glMatrixMode(GL_PROJECTION); |   glEnable(GL_BLEND); | ||||||
|  |   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||||
|   glMatrixMode(GL_PROJECTION); |   glMatrixMode(GL_PROJECTION); | ||||||
|   glLoadIdentity(); |   glLoadIdentity(); | ||||||
|   glOrtho(-SCREEN_W /2,   // Left edge.
 |   glOrtho(-SCREEN_W /2,   // Left edge.
 | ||||||
| @ -713,10 +712,7 @@ int gl_init(void) { | |||||||
|           SCREEN_H  /2,   // Top edge.
 |           SCREEN_H  /2,   // Top edge.
 | ||||||
|           -1.,            // Near.
 |           -1.,            // Near.
 | ||||||
|           1.);            // Far.
 |           1.);            // Far.
 | ||||||
|   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha.
 |  | ||||||
|   glEnable(GL_BLEND); |  | ||||||
|    |    | ||||||
|   glPointSize(1.); // Default is 1.
 |  | ||||||
|   glClear(GL_COLOR_BUFFER_BIT); |   glClear(GL_COLOR_BUFFER_BIT); | ||||||
| 
 | 
 | ||||||
|   return 0; |   return 0; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis