Comments (6)
The main cause should be fixed in ef83211 (why the heck the compiler issued only a warning?!), but the issue shouldn't happen on GL 3.3 in the first place, only on GL < 3.2 (as ARB_explicit_attrib_location
isn't supported there). Also, I couldn't find any issue with textured-triangle example. Is the shader compiler printing similar warning?
from magnum.
I'm not sure why, but I'm still getting black instead of the texture. At first I thought it was my image loading code, but it's not. As you can see below.
But I just keep getting a black triangle when trying to get it to work with magnum.
The image I load uses stb_image, and it is in RGBA8 format.
Here's my image loading code:
auto imageData = util::loadImage("stone.jpg");
Magnum::ImageReference2D image{Magnum::ColorFormat::RGBAInteger,
Magnum::ColorType::UnsignedByte,
{imageData.width, imageData.height},
imageData.pixels.get()};
texture.setWrapping(Magnum::Sampler::Wrapping::ClampToEdge)
.setMagnificationFilter(Magnum::Sampler::Filter::Linear)
.setMinificationFilter(Magnum::Sampler::Filter::Linear)
.setImage(0, Magnum::TextureFormat::RGBA8, image);
Here's my code to set up the buffers/mesh object(s):
struct vertex
{
Vector2 position;
//Color4 colour;
Vector2 textureCoords;
};
const int SIZE = 3;
constexpr static std::array<vertex, SIZE> vertices{{
{ {-300, -300}, /*{},*/ {0, 0} },
{ {300, -300}, /*{},*/ {1, 0} },
{ {0, 300}, /*{},*/ {0.5f, 1} },
}};
buffer.setData(vertices, Magnum::Buffer::Usage::StaticDraw);
mesh.setPrimitive(Mesh::Primitive::TriangleStrip).setVertexCount(SIZE)
.addVertexBuffer(buffer, 0, Shader::Position(), Shader::TextureCoordinates());
Here's my rendering code:
shader.setTransformationProjectionMatrix(Magnum::Matrix3::projection({640, 480}));
texture.bind(Magnum::Shaders::Flat2D::TextureLayer);
shader.use(); // this is a Flat2D shader
mesh.draw();
from magnum.
Magnum::ColorFormat::RGBAInteger
I think one problem might be here. TextureFormat::RGBA8
should match ColorFormat::RGBA
(or, in GL, the glTexImage2D()
function requires GL_RGBA
format for GL_RGBA8
internalFormat).
from magnum.
If that doesn't help, try to trace the application in ApiTrace, if possible, and check for GL errors there, or manually pinpoint the GL error with the following:
Debug() << Renderer::error();
This prints GL error name if any occured since last call to Renderer::error()
(or since the application started). Sadly OSX doesn't support proper OpenGL debug output yet, so there is no better approach to find the error.
from magnum.
When I printed out the error after I uploaded the texture data, I got a:
Renderer::Error::InvalidOperation
And now I fixed this issue, by doing as you suggested and using ColorFormat::RGBA
. Thank you. :)
I think I was just a bit confused, as there are various options you must provide for the format of the image. And I thought RGBAInteger was appropriate for my scenario.
from magnum.
You're welcome, glad it's fixed :-) I should probably update the ColorFormat
, ColorType
and TextureFormat
documentation and list values the user probably wants to use. The GL specification also isn't exactly helpful in this case, as information about the formats and allowed combinations is scattered around the whole document.
from magnum.
Related Issues (20)
- few compile warnings HOT 1
- How to point to a local installation of `corrade` without using the bootstrap project? HOT 3
- undefined symbol: flextGLInit HOT 4
- Image rendered in gray since 1847c72 HOT 18
- Emscripten 3.1.21+ crashes EmscriptenApplication: "AsciiToString is not defined" HOT 4
- How to build from source on MSYS2 MINGW64? HOT 1
- keyReleaseEvent not triggered after printscreen on OSX HOT 6
- Conversion from CubicHermite to Bezier is wrong
- Mixing with raw openGL calls and Context::current().resetState() HOT 3
- C Bindings HOT 5
- WebGPU backend HOT 2
- Parallel rendering with glb files HOT 5
- Conflict with near and far Macros When Including WinSock2.h After Matrix4.h HOT 2
- emsdk compile error: typedef redefinition with different types HOT 4
- Memory leak when destroying GL::Mesh HOT 3
- Linking in Emscripten >= 3.1.52 doesn't work HOT 4
- Some trouble with LineGL3D shader when camera is close HOT 1
- Segmentation fault with nullptr instruction in AbstractShaderProgram at Cross-Compile HOT 21
- Apply MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS for the flextGL globals as well HOT 4
- EmscriptenApplication keyboard handler doesn't send key event corresponding to text input events HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnum.