mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:30:05 +00:00 
			
		
		
		
	Adding default texture to line, fixing texture coordinates
This commit is contained in:
		
							parent
							
								
									ab50f0b9a2
								
							
						
					
					
						commit
						4b1d63ea62
					
				
					 4 changed files with 17 additions and 9 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								scwx-qt/res/textures/lines/default-1x7.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								scwx-qt/res/textures/lines/default-1x7.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 486 B | 
							
								
								
									
										
											BIN
										
									
								
								scwx-qt/res/textures/lines/test-pattern.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								scwx-qt/res/textures/lines/test-pattern.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 479 B | 
|  | @ -15,5 +15,7 @@ | ||||||
|         <file>res/fonts/din1451alt_g.ttf</file> |         <file>res/fonts/din1451alt_g.ttf</file> | ||||||
|         <file>res/icons/font-awesome-6/square-minus-regular.svg</file> |         <file>res/icons/font-awesome-6/square-minus-regular.svg</file> | ||||||
|         <file>res/icons/font-awesome-6/square-plus-regular.svg</file> |         <file>res/icons/font-awesome-6/square-plus-regular.svg</file> | ||||||
|  |         <file>res/textures/lines/default-1x7.png</file> | ||||||
|  |         <file>res/textures/lines/test-pattern.png</file> | ||||||
|     </qresource> |     </qresource> | ||||||
| </RCC> | </RCC> | ||||||
|  |  | ||||||
|  | @ -32,12 +32,13 @@ public: | ||||||
|        dirty_ {false}, |        dirty_ {false}, | ||||||
|        visible_ {true}, |        visible_ {true}, | ||||||
|        points_ {}, |        points_ {}, | ||||||
|        width_ {1.0f}, |        width_ {7.0f}, | ||||||
|        modulateColor_ {std::nullopt}, |        modulateColor_ {std::nullopt}, | ||||||
|        shaderProgram_ {nullptr}, |        shaderProgram_ {nullptr}, | ||||||
|        uMVPMatrixLocation_(GL_INVALID_INDEX), |        uMVPMatrixLocation_(GL_INVALID_INDEX), | ||||||
|        uMapMatrixLocation_(GL_INVALID_INDEX), |        uMapMatrixLocation_(GL_INVALID_INDEX), | ||||||
|        uMapScreenCoordLocation_(GL_INVALID_INDEX), |        uMapScreenCoordLocation_(GL_INVALID_INDEX), | ||||||
|  |        texture_ {GL_INVALID_INDEX}, | ||||||
|        vao_ {GL_INVALID_INDEX}, |        vao_ {GL_INVALID_INDEX}, | ||||||
|        vbo_ {GL_INVALID_INDEX} |        vbo_ {GL_INVALID_INDEX} | ||||||
|    { |    { | ||||||
|  | @ -55,13 +56,12 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::optional<boost::gil::rgba8_pixel_t> modulateColor_; |    std::optional<boost::gil::rgba8_pixel_t> modulateColor_; | ||||||
| 
 | 
 | ||||||
|    // TODO: Texture
 |  | ||||||
| 
 |  | ||||||
|    std::shared_ptr<ShaderProgram> shaderProgram_; |    std::shared_ptr<ShaderProgram> shaderProgram_; | ||||||
|    GLint                          uMVPMatrixLocation_; |    GLint                          uMVPMatrixLocation_; | ||||||
|    GLint                          uMapMatrixLocation_; |    GLint                          uMapMatrixLocation_; | ||||||
|    GLint                          uMapScreenCoordLocation_; |    GLint                          uMapScreenCoordLocation_; | ||||||
| 
 | 
 | ||||||
|  |    GLuint texture_; | ||||||
|    GLuint vao_; |    GLuint vao_; | ||||||
|    GLuint vbo_; |    GLuint vbo_; | ||||||
| 
 | 
 | ||||||
|  | @ -105,6 +105,9 @@ void GeoLine::Initialize() | ||||||
|       logger_->warn("Could not find uMapScreenCoord"); |       logger_->warn("Could not find uMapScreenCoord"); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    p->texture_ = | ||||||
|  |       p->context_->GetTexture(":/res/textures/lines/default-1x7.png"); | ||||||
|  | 
 | ||||||
|    gl.glGenVertexArrays(1, &p->vao_); |    gl.glGenVertexArrays(1, &p->vao_); | ||||||
|    gl.glGenBuffers(1, &p->vbo_); |    gl.glGenBuffers(1, &p->vbo_); | ||||||
| 
 | 
 | ||||||
|  | @ -167,6 +170,9 @@ void GeoLine::Render(const QMapbox::CustomLayerRenderParameters& params) | ||||||
|       UseMapProjection( |       UseMapProjection( | ||||||
|          params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_); |          params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_); | ||||||
| 
 | 
 | ||||||
|  |       gl.glActiveTexture(GL_TEXTURE0); | ||||||
|  |       gl.glBindTexture(GL_TEXTURE_2D, p->texture_); | ||||||
|  | 
 | ||||||
|       // Draw line
 |       // Draw line
 | ||||||
|       gl.glDrawArrays(GL_TRIANGLES, 0, 6); |       gl.glDrawArrays(GL_TRIANGLES, 0, 6); | ||||||
|    } |    } | ||||||
|  | @ -256,12 +262,12 @@ void GeoLine::Impl::Update() | ||||||
|          {                                   //
 |          {                                   //
 | ||||||
|           // Line
 |           // Line
 | ||||||
|           { |           { | ||||||
|              {lx, by, -ox, -oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3}, // BL
 |              {lx, by, -ox, -oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3}, // BL
 | ||||||
|              {lx, by, +ox, +oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3}, // TL
 |              {lx, by, +ox, +oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3}, // TL
 | ||||||
|              {rx, ty, -ox, -oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // BR
 |              {rx, ty, -ox, -oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // BR
 | ||||||
|              {rx, ty, -ox, -oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // BR
 |              {rx, ty, -ox, -oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // BR
 | ||||||
|              {rx, ty, +ox, +oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // TR
 |              {rx, ty, +ox, +oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // TR
 | ||||||
|              {lx, by, +ox, +oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3}  // TL
 |              {lx, by, +ox, +oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3}  // TL
 | ||||||
|           }}; |           }}; | ||||||
| 
 | 
 | ||||||
|       gl.glBufferData(GL_ARRAY_BUFFER, |       gl.glBufferData(GL_ARRAY_BUFFER, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat