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

Performance difference between geometry shader and vertex shader
openGL createWindow wont execute till end of application code
How to cancel a blocking OpenGL call
glReadPixels() returning non-accurate value
Can I export triangles instead triangle strip in geometry shader?
OpenGL Mapping Textures to a Grid Stored Inside Vertex Array
Show depth equally over frame
What do the OpenGL extensions do? [closed]
How to override texture color in opengl?
Head Pose Estimation with 2 cameras
Why glOrtho() works under Mac but gluOrtho2D() doesn't?
Managing external resources (similar to RAII in C++?)
How to apply texture to a part of a sphere
Why does OpenGL's glDrawArrays() fail with GL_INVALID_OPERATION under Core Profile 3.2, but not 3.3 or 4.2?
What version of OpenGL is closest to OpenGL ES2?
Updating vertex data in a VBO (glBufferSubData vs glMapBuffer)

Categories

HOME
android-espresso
mod-rewrite
ontouchlistener
adfs3.0
postgresql-9.4
selenium-builder
foaf
mousemove
subdomain
biztalk
celery
consul
portable-class-library
implicit-conversion
visualforce
video-streaming
openfoam
kurento
slide
lapack
alljoyn
amazon-emr
trace32
sql-injection
user-defined-types
varnish-vcl
coroutine
cmake-gui
social-tables
unity-container
kaggle
altium-designer
fluent-migrator
cellular-network
multi-dimensional-scaling
pyspark-sql
laravel-4.2
javax.persistence
social-networking
tilemill
shapeless
xmlunit
custom-keyboard
xvfb
ng-repeat
django-smart-selects
extbase
rdp
virtual-memory
swift2.3
.net-micro-framework
roracle
password-hash
jgrapht
punctuation
test-data
dymola
elastic4s
google-identity-toolkit
openseadragon
wicked-pdf
psd
voronoi
wepay
ajax4jsf
gdl
json-spirit
mousehover
place
pythonxy
gluon-desktop
vdm-sl
textscan
findersync
jcheckbox
xhprof
coding-efficiency
maven-central
django-sites
compiler-flags
disjoint-union
virtual-channel
apportable
acceptance-testing
mongo-jackson-mapper
multiscaleimage
story
clearinterval
viewpagerindicator
thejit
nsfont
background-repeat
expression-web
glassfish-esb
qt-mobility
nosetests
fragment-identifier
directshow.net
3des
processors
wmd-editor
community-server
synthesizer

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App