forgot to bind texture properly
This commit is contained in:
@@ -26,7 +26,7 @@ void FrameBuffer::SetPixel( int x, int y, glm::vec3 p )
|
||||
uint8_t r = (uint8_t)( pow( p.r, gamma ) * 255.0f );
|
||||
uint8_t g = (uint8_t)( pow( p.g, gamma ) * 255.0f );
|
||||
uint8_t b = (uint8_t)( pow( p.b, gamma ) * 255.0f );
|
||||
uint32_t col = 0xFF000000 | r << 16 | g << 8 | b;
|
||||
uint32_t col = r << 24 | g << 16 | b << 8 | 0xFF;
|
||||
Data[i] = col;
|
||||
}
|
||||
|
||||
|
||||
30
src/main.cpp
30
src/main.cpp
@@ -21,14 +21,13 @@ struct Game
|
||||
SDL_GLContext GlContext = nullptr;
|
||||
};
|
||||
|
||||
void GLAPIENTRY
|
||||
MessageCallback( GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam )
|
||||
void GLAPIENTRY MessageCallback( GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam )
|
||||
{
|
||||
std::cout << "GL CALLBACK: type = " << type
|
||||
<< ", severity = " << severity
|
||||
@@ -74,8 +73,9 @@ int main()
|
||||
// Time to actually load OpenGL
|
||||
gladLoadGLLoader( SDL_GL_GetProcAddress );
|
||||
|
||||
glEnable( GL_DEBUG_OUTPUT );
|
||||
glDebugMessageCallback( MessageCallback, 0 );
|
||||
// Doesnt work
|
||||
//glEnable( GL_DEBUG_OUTPUT );
|
||||
//glDebugMessageCallback( MessageCallback, 0 );
|
||||
|
||||
Renderer renderer;
|
||||
renderer.LoadShader();
|
||||
@@ -86,6 +86,16 @@ int main()
|
||||
framebuffer.SetPixel( 3, 1, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 4, 1, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 5, 1, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 1, 2, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 2, 2, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 3, 2, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 4, 2, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 5, 3, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 1, 3, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 2, 3, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 3, 3, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 4, 3, { 1.0, 0.0, 0.0 } );
|
||||
framebuffer.SetPixel( 5, 3, { 1.0, 0.0, 0.0 } );
|
||||
|
||||
renderer.RegisterBuffer( &framebuffer, 0 );
|
||||
|
||||
|
||||
@@ -105,15 +105,16 @@ int8_t Renderer::RegisterBuffer( FrameBuffer* buffer, int layer )
|
||||
// Load buffer as a texture into OpenGL
|
||||
GLuint texture;
|
||||
glGenTextures( 1, &texture );
|
||||
glBindTexture( GL_TEXTURE_2D, texture );
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, buffer->GetWidth(), buffer->GetHeight(), 0, GL_RGB, GL_RGBA32UI, buffer->Data );
|
||||
// Colour stored as uint32_t so 0xRRGGBBAA except no A
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, buffer->GetWidth(), buffer->GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer->Data );
|
||||
|
||||
|
||||
FrameBufferRenderable fb =
|
||||
{
|
||||
buffer,
|
||||
@@ -160,7 +161,7 @@ void Renderer::UpdateBuffer( int8_t id )
|
||||
return;
|
||||
|
||||
FrameBuffer* buffer = mRenderQueue[id].Buffer;
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, buffer->GetWidth(), buffer->GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, buffer->Data );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, buffer->GetWidth(), buffer->GetHeight(), 0, GL_RGBA, GL_RGBA32UI, buffer->Data );
|
||||
}
|
||||
|
||||
void Renderer::Render()
|
||||
@@ -171,8 +172,8 @@ void Renderer::Render()
|
||||
for ( size_t i = 0; i < mRenderQueue.size(); i++ )
|
||||
{
|
||||
FrameBufferRenderable* fb = &mRenderQueue[i];
|
||||
glBindTexture( GL_TEXTURE_2D, fb->TextureID );
|
||||
glBindVertexArray( fb->VAO );
|
||||
glBindTexture( GL_TEXTURE_2D, fb->TextureID );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
7666
src/thirdparty/stb_image.h
vendored
Normal file
7666
src/thirdparty/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user