opengl


What am I doing wrong, in regards to multi-texture(OpenGL)?


I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.
This is the texture part of my OpenGL code:
glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);
glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);
Here is the fragment shader:
uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;
void main() {
vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(tex, 1.0);
}
I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?

Related Links

Opengl shader compatibility with opengl es 2.0
How do I convert gl_FragCoord to a world space point in a fragment shader?
Is this diagram for OpenGL data types correct?
3d point behind camera gets projected wrong
GLX double buffering only working after two swaps
How to render to OpenGL from Vulkan?
Can't write to writeonly Shader Storage Block
New to OpenGL Shading Language [closed]
Is there a significant performance difference between using GL_CW in favour of GL_CCW with backface culling?
Setting gl_TessLevel only for one output vertex?
Inner workings of Raspberry Pi userland graphics driver (not firmware or kernel part)
How to correctly set the width and height of a FrameBuffer in libgdx?
Progressbar - Smooth transition between percentages
Assimp loader with a cube of 8 vertices
OpenGl mapping a texture perpendicular to an edge in 2D
Why do I need to make a call to clear before calling glReadPixels?

Categories

HOME
android-studio
generics
bokeh
kendo-dropdown
postgresql-9.4
operating-system
devexpress
compilation
haproxy
hid
ant
whmcs
angular-meteor
mailing-list
stack-overflow
locationmanager
csrf
android-externalstorage
sslhandshakeexception
powermock
corona
orange-api
supervisord
google-tasks-api
closures
varnish-vcl
salt-cloud
significance
libgit2
workday
fusetools
hevc
fusion
objectmapper
windows2012
rust-cargo
series
fotorama
kendo-listview
image-optimization
ms-solver-foundation
aurelia-cli
gitolite
linq.js
task-parallel-library
resampling
grails3.2.0
hdiv
jenkins-slave
qvtkwidget
android-5.0-lollipop
md5-file
amazon-elastic-beanstalk
gmaps.js
http4s
annotatorjs
elastic4s
jsonix
ndk-build
nunit-console
jenkins-workflow
teensy
webgrind
outlook.com
gql
libz
fantom
embeddedwebserver
ocmockito
rfc5545
fat32
jcheckbox
zend-mail
back
object-code
nidaqmx
stripe.net
refit
oxygene
principalcontext
strdup
sql-view
jquery-transit
void-pointers
examine
cgrectmake
xcode4.5
live-wallpaper
kobold2d
hardcode
dropshadow
servercontrol
sql-parametrized-query
suphp
formal-semantics
aptitude
mysqli-multi-query
accumulator
version-control-migration
isapi-redirect
levels
html-generation

Resources

Encrypt Message