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

SSAO Optimization Issue
OpenGL/GLFW: Why is the detected mouse position incorrect when using a TV as the primary display for my laptop?
Bind the same “texture memory” to textures with different dimensionalities
Hardware PCF for Shadow Map using OpenGL
Contents of uniform int[8] area always zero?
What does adding to a GLuint attribute index do?
OpenGL Glut Drawing Points Not Working
For simple rendering: Is OpenCL faster than OpenGL?
Drawing the grid over the texture
slick2d glortho scaling issue with drawtext
OpenGL (core profile) model's triangles wrong rendering
EFL Evas using opengl_x11 engine
Get current fragment color
Shadow mapping with Deferred Rendering (OpenGL)
(OpenGL) CubeMap isn't drawn
How to get current glDebugMessageCallback?

Categories

HOME
list
jms
schema.org
selenium-builder
writefile
scroll
transactions
foaf
message-queue
dafny
ios-simulator
slider
informatica
websocket
jersey-2.0
google-webmaster-tools
lvm
openflow
azure-data-lake
onvif
reportviewer
log4j2
mailgun
vmware-workstation
android-5.1.1-lollipop
nose
renderscript
akka-persistence
android-permissions
sqlplus
intel
pubxml
beego
uri
marquee
ibm-connections
javax.persistence
fatfs
intune
premake
infopath2010
steam-web-api
cucumber-junit
directfb
bootstrap-sass
express-session
rails-postgresql
djcelery
installanywhere
macports
ms-dos
cartopy
jacoco-maven-plugin
newtons-method
robust
music21
icecast
brightscript
head.js
iptv
skip-lists
android-webservice
asp.net-web-api-routing
kendo-treeview
finder
haraka
mifos
java-2d
e
pyaudio
system.net.mail
msbuild-4.0
meld
wicked-pdf
jeditable
distributed-cache
mercurial-extension
univocity
onepage-checkout
ioctl
deeplink
ambiguity
dnx50
gluon-desktop
cache-manifest
darwin
angular-amd
actionpack
ssmtp
mutators
phonegap-facebook-plugin
iodocs
qt5.4
jquery-mobile-flipswitch
lumia-imaging-sdk
box2dweb
git-reset
armv6
smips
mft
jmenubar
acitree
jacob
flv
sly-scroller
axacropdf
significant-digits
msinfo32
word-frequency
prototypal-inheritance
microblogging
mmc3
ognl
servlet-container
aggregator
.net-services
html-components
.net-client-profile
xap
comment-conventions

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